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

[Dynamic Protocol State] InstanceParams refactoring #5113

Merged

Conversation

durkmurder
Copy link
Member

Context

This PR updates design and implementation of InstanceParams to be more modular, remove circular dependency of State -> InstanceParams -> State and improves overall bootstrapping process.

Previously our bootstrapping process was creating a state, then bootstraping it and then populating internal cache. I've updated the process to be more clear, now we bootstrap everything only after that we try to open boostrapped state.

@codecov-commenter
Copy link

codecov-commenter commented Dec 6, 2023

Codecov Report

All modified and coverable lines are covered by tests ✅

Comparison is base (7384d70) 56.46% compared to head (6cf2e9f) 54.68%.

Additional details and impacted files
@@                        Coverage Diff                         @@
##           feature/dynamic-protocol-state    #5113      +/-   ##
==================================================================
- Coverage                           56.46%   54.68%   -1.78%     
==================================================================
  Files                                 987      236     -751     
  Lines                               92546    23048   -69498     
==================================================================
- Hits                                52252    12603   -39649     
+ Misses                              36449     9391   -27058     
+ Partials                             3845     1054    -2791     
Flag Coverage Δ
unittests 54.68% <100.00%> (-1.78%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@durkmurder
Copy link
Member Author

This PR has some overlap with #5089, I would prefer if it gets merged first so I can resolve conflicts in bootstrapping process

engine/execution/ingestion/loader/loader.go Outdated Show resolved Hide resolved
engine/execution/ingestion/loader/loader.go Outdated Show resolved Hide resolved
state/protocol/badger/params.go Outdated Show resolved Hide resolved
state/protocol/badger/params.go Outdated Show resolved Hide resolved
state/protocol/badger/params.go Outdated Show resolved Hide resolved
state/protocol/badger/params.go Outdated Show resolved Hide resolved
state/protocol/badger/state_test.go Outdated Show resolved Hide resolved
state/protocol/badger/state.go Outdated Show resolved Hide resolved
durkmurder and others added 2 commits December 8, 2023 22:23
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
Alexander Hentschel added 2 commits December 9, 2023 14:48
… in the `GlobalParams` interface (` state/protocol/params.go`)
… to uniformly return functors `func(*transaction.Tx) error`
state/protocol/badger/state.go Outdated Show resolved Hide resolved
state/protocol/badger/state.go Outdated Show resolved Hide resolved
state/protocol/badger/state.go Outdated Show resolved Hide resolved
Copy link
Member

@AlexHentschel AlexHentschel left a comment

Choose a reason for hiding this comment

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

Very nice. This is a great cleanup.
There are a few places, where I think our goDoc should be revised, which I implemented in PR #5132 (targeting your branch), alongside a few other revisions. Most (but not all) of my comments should be addressed by my PR

Comment on lines +174 to 179
metrics.BlockSealed(lastSealed)
metrics.SealedHeight(lastSealed.Header.Height)
metrics.FinalizedHeight(lastFinalized.Header.Height)
for _, block := range segment.Blocks {
state.metrics.BlockFinalized(block)
metrics.BlockFinalized(block)
}
Copy link
Member

Choose a reason for hiding this comment

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

what do you think about moving these lines into this function

func updateEpochMetrics(metrics module.ComplianceMetrics, snap protocol.Snapshot, epochFallbackTriggered bool) error {

? It would declutter the high-level code a bit.

Copy link
Member Author

Choose a reason for hiding this comment

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

Reporting those metrics relies on SealingSegment and to my understanding we want to report them once, only when we bootstrap. updateEpochMetrics on other side is called every time we open a state(on each node startup) we probably don't want to report again those metrics. Additionally I would suggest to think if we actually need those metrics at that place, maybe it's safe to remove them?

state/protocol/badger/state.go Outdated Show resolved Hide resolved
state/protocol/badger/params.go Outdated Show resolved Hide resolved
engine/consensus/sealing/engine_test.go Show resolved Hide resolved
engine/access/ingestion/engine.go Outdated Show resolved Hide resolved
cmd/scaffold.go Outdated Show resolved Hide resolved
cmd/scaffold.go Outdated Show resolved Hide resolved
cmd/util/cmd/reindex/cmd/results.go Outdated Show resolved Hide resolved
engine/consensus/sealing/core.go Outdated Show resolved Hide resolved
state/protocol/badger/snapshot_test.go Outdated Show resolved Hide resolved
@durkmurder durkmurder merged commit 1668c30 into feature/dynamic-protocol-state Dec 13, 2023
53 checks passed
@durkmurder durkmurder deleted the yurii/instance-params-refactoring branch December 13, 2023 08:32
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.

4 participants