Skip to content
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

Closed
wants to merge 68 commits into from
Closed

Conversation

ConvallariaMaj
Copy link
Contributor

@ConvallariaMaj ConvallariaMaj commented Aug 19, 2024

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

  • created smesher identity states
  • created new grpc service (SmeshingIdentitiesService) to serve new API
  • implemented logic to save failed registrations, retry to register in case if deadline for submit challenge is not passed, and update recording into db in case, if registrations were successful after another try
  • fixed tests
  • made some small refactoring

Connected PR:
spacemeshos/api#369

Test Plan

Unit tests

TODO

  • Explain motivation or link existing issue(s)
  • Test changes and document test plan
  • Update documentation as needed
  • Update changelog as needed

@ivan4th
Copy link
Contributor

ivan4th commented Oct 2, 2024

Some quite minor nits, otherwise looks good

@fasmat fasmat requested a review from jellonek as a code owner October 9, 2024 08:26
Copy link
Contributor

@poszu poszu left a 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)?

Comment on lines -352 to +362
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))

Copy link
Contributor

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.

Comment on lines +21 to +27
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),
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ditto

Suggested change
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}),

Comment on lines +267 to +278
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
}
Copy link
Contributor

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.

Comment on lines +576 to +578
if len(r.RoundID) == 0 {
continue // skip failed registrations
}
Copy link
Contributor

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.

@jellonek
Copy link
Contributor

jellonek commented Nov 5, 2024

Note: this PR depends on spacemeshos/api#369

@kacpersaw
Copy link
Contributor

This PR was used as part of the work to create #6452.

@kacpersaw kacpersaw closed this Nov 18, 2024
@fasmat fasmat deleted the issue-332 branch November 18, 2024 14:40
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Serve API per each NodeID configured / known poets
6 participants