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

persist identity events, published proposals and calculated eligibilities #6577

Open
wants to merge 7 commits into
base: node-split-poc
Choose a base branch
from

Conversation

poszu
Copy link
Contributor

@poszu poszu commented Dec 30, 2024

Closes #6544

Persist identity events, published proposals and eligibilities in a local database.

The StateStorage was much simplified and is a simple proxy to the local DB.

The events are persisted in a form of JSON. A tag is used to identify the right event type to deserialize to.

The proposal is serialized using scale to maintain as much information as possible but we could also just store:

  • proposal ID
  • layer
  • smesher ID

Copy link

codecov bot commented Dec 30, 2024

Codecov Report

Attention: Patch coverage is 63.00940% with 118 lines in your changes missing coverage. Please review.

Project coverage is 76.8%. Comparing base (49bbb0b) to head (2240acb).
Report is 21 commits behind head on node-split-poc.

Files with missing lines Patch % Lines
identity/identity.go 19.6% 46 Missing and 3 partials ⚠️
miner/remote_proposals.go 15.7% 16 Missing ⚠️
api/grpcserver/v2alpha1/smeshing_identities.go 0.0% 15 Missing ⚠️
sql/localsql/events/proposals.go 68.5% 7 Missing and 4 partials ⚠️
identity/serialization.go 90.4% 8 Missing and 1 partial ⚠️
sql/localsql/events/events.go 79.5% 6 Missing and 3 partials ⚠️
sql/localsql/events/eligibilities.go 82.3% 4 Missing and 2 partials ⚠️
identity/state.go 0.0% 3 Missing ⚠️
Additional details and impacted files
@@               Coverage Diff                @@
##           node-split-poc   #6577     +/-   ##
================================================
- Coverage            77.2%   76.8%   -0.4%     
================================================
  Files                 342     346      +4     
  Lines               45839   46317    +478     
================================================
+ Hits                35391   35607    +216     
- Misses               8330    8585    +255     
- Partials             2118    2125      +7     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

@poszu poszu changed the title persist identity states persist identity events, published proposals and calculated eligibilities Dec 31, 2024
@poszu poszu force-pushed the node-split-persist-states branch 2 times, most recently from 0d3cc9c to 2e4734b Compare December 31, 2024 11:23
@poszu poszu force-pushed the node-split-persist-states branch from 352e103 to 338ce11 Compare December 31, 2024 12:10
@poszu poszu marked this pull request as ready for review December 31, 2024 14:22
@@ -101,7 +101,7 @@ func NewNIPostBuilder(
layerClock: layerClock,
postStates: NewPostStates(lg),
validator: validator,
identityStates: identity.NewIdentityStateStorage(),
identityStates: identity.NewIdentityStateStorage(db),
Copy link
Member

Choose a reason for hiding this comment

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

Every time I stumble upon this line I question why instead of a newly initialized repository/service we do not pass the one created in the activation.Builder or even node.go. And then I realise it's because we pass a mandatory dependency using a functional option 😅 Maybe that's worth changing?

@@ -201,7 +201,7 @@ func NewBuilder(
logger: log,
poetRetryInterval: defaultPoetRetryInterval,
postStates: NewPostStates(log),
identitiesStates: identity.NewIdentityStateStorage(),
identitiesStates: identity.NewIdentityStateStorage(localDB),
Copy link
Member

Choose a reason for hiding this comment

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

same here - I don't think defaulting to this and passing the real identity service as functional parameter is correct 🤔

Comment on lines +17 to +20
// NOTE: The `require` doesn't support comparing time.Time after marhsaling
// (the monotonic counter is dropped in the process of serialization).
// We need to compare the values manually for some types.
// See: https://github.com/stretchr/testify/issues/502
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
// NOTE: The `require` doesn't support comparing time.Time after marhsaling
// (the monotonic counter is dropped in the process of serialization).
// We need to compare the values manually for some types.
// See: https://github.com/stretchr/testify/issues/502
// NOTE: The `require` doesn't support comparing time.Time after marshaling
// (the monotonic counter is dropped in the process of serialization).
// We need to compare the values manually for some types.
// See: https://github.com/stretchr/testify/issues/502

s.identities[id] = append(s.identities[id], info)
stateBytes, err := marshalState(&info)
if err != nil {
panic(fmt.Sprintf("marhsaling state: %v", err))
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
panic(fmt.Sprintf("marhsaling state: %v", err))
panic(fmt.Sprintf("marshaling state: %v", err))

I'm not a big fan of just panicing here. How about adding a logger to StateStorage and at least log.Fatal or log.Panic instead? 🙂

return nil
}

func InterateAllProposals(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func InterateAllProposals(
func IterateAllProposals(

return nil
}

func InterateAllEligibilities(
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
func InterateAllEligibilities(
func IterateAllEligibilities(

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants