-
Notifications
You must be signed in to change notification settings - Fork 215
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Serve API to return poet registrations state #6266
Conversation
- fixed review issues
- removed unused params
- removed unused params2
# Conflicts: # api/grpcserver/admin_service.go # api/grpcserver/grpcserver_test.go # api/grpcserver/node_service_test.go
# Conflicts: # activation/nipost.go # activation/nipost_test.go # sql/localsql/nipost/poet_registration.go
# Conflicts: # activation/nipost.go
Some quite minor nits, otherwise looks good |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm wondering whether it would make sense to combine the existing "post states" (PROVING/IDLE) with this (extend the existing API)?
tab := newTestBuilder(t, 1, WithPoetConfig(PoetConfig{PhaseShift: layerDuration})) | ||
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), | ||
WithIdentityStates(idStates)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the point of adding the "identitystates` in these tests? It doesn't verify anything additionally (compared to the original test) but it complicates the tests.
ctrl := gomock.NewController(t) | ||
idStates := NewMockIdentityStates(ctrl) | ||
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | ||
|
||
tab := newTestBuilder(t, 1, | ||
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), | ||
WithIdentityStates(idStates), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto
ctrl := gomock.NewController(t) | |
idStates := NewMockIdentityStates(ctrl) | |
idStates.EXPECT().Set(gomock.Any(), gomock.Any()).Return(nil).AnyTimes() | |
tab := newTestBuilder(t, 1, | |
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), | |
WithIdentityStates(idStates), | |
tab := newTestBuilder(t, 1, | |
WithPoetConfig(PoetConfig{PhaseShift: layerDuration}), |
func (b *Builder) IdentityStates() map[types.IdentityDescriptor]IdentityState { | ||
states := b.identitiesStates.All() | ||
res := make(map[types.IdentityDescriptor]IdentityState, len(states)) | ||
b.smeshingMutex.Lock() | ||
defer b.smeshingMutex.Unlock() | ||
for id, state := range states { | ||
if sig, exists := b.signers[id]; exists { | ||
res[sig] = state | ||
} | ||
} | ||
return res | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How about not adding this to the ATX Builder? The builder doesn't need this at all. AFAIR, it's only used in the grpc service, which could do read directly from the "identities state", wdyt?
We don't support unregistering, so the GRPC service could just return all the state of all IDs.
if len(r.RoundID) == 0 { | ||
continue // skip failed registrations | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's incorrect as the first poet round has ID 0. IMHO, it's better not to give existing fields "extra meaning" but to have a dedicated field.
Note: this PR depends on spacemeshos/api#369 |
This PR was used as part of the work to create #6452. |
Motivation
Smesher needs to understand situation with poet registrations (success, failed, residual, no registrations and etc.)
Easiest way is providing API for that.
Description
Closes #6174
Connected PR:
spacemeshos/api#369
Test Plan
Unit tests
TODO