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] badger.Snapshot uses dynamic protocol state #4625

Merged
merged 16 commits into from
Sep 13, 2023

Conversation

durkmurder
Copy link
Member

https://github.com/dapperlabs/flow-go/issues/6803

Context

This PR updates Snapshot implementation to use dynamic protocol state to query identities and epochs.
badger.Snapshot no more determines identity table using epoch setup events it just relies on protocol state, same happens for epoch queries.
Updated inmem.EncodableSnapshot to carry only needed information without redundancies, removed identities and epoch phase since they can be derived from dynamic protocol state. Finally removed EpochStatuses as it's no more needed, updated related badger util to work with protocol state instead.
Making those changes allowed to simplify our code base, tests became simpler.

Comment on lines -98 to -101
// TODO: CAUTION SHORTCUT
// we retrieve identities based on the initial identity table from the EpochSetup
// event here -- this will need revision to support mid-epoch identity changes
// once slashing is implemented
Copy link
Member

Choose a reason for hiding this comment

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

🥳

@@ -64,7 +64,6 @@ const (
codePayloadSeals = 53 // index mapping block ID to payload seals
codeCollectionBlock = 54 // index mapping collection ID to block ID
codeOwnBlockReceipt = 55 // index mapping block ID to execution receipt ID for execution nodes
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
codeOwnBlockReceipt = 55 // index mapping block ID to execution receipt ID for execution nodes
codeOwnBlockReceipt = 55 // index mapping block ID to execution receipt ID for execution nodes
// code 56 previously used for epoch status index, now deprecated

may be useful to leave a tombstone explaining the missing code

Copy link
Member

@AlexHentschel AlexHentschel Sep 7, 2023

Choose a reason for hiding this comment

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

What is the rational behind leaving a tombstone? Just out of curiosity.

My default would have been to decrement the values of the following prefixes each by 1:

codePayloadReceipts = 57 // index mapping block ID to payload receipts
codePayloadResults = 58 // index mapping block ID to payload results
codeAllBlockReceipts = 59 // index mapping of blockID to multiple receipts

Thereby, we close the gap. We have extended, shortened or replaced prefix conventions previously, with prefix.go only representing the latest version (and changes being incompatible). I wonder why we would do it differently now? I don't think it is tractable for us to keep a useful documentation of past usages for certain numerical values in this file.

Copy link
Member

Choose a reason for hiding this comment

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

decrement the values of the following prefixes each by 1

That works too -- mainly just didn't want to leave a gap with no explanation. I was hesitant to change the key prefixes, but you're right we've done that before, and don't have backward-compatibility anyway.

Copy link
Member Author

Choose a reason for hiding this comment

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

I've updated it to be a continuous range

Base automatically changed from yurii/5514-extend-updates-protocol-state to feature/dynamic-protocol-state September 13, 2023 14:50
@codecov-commenter
Copy link

Codecov Report

Patch coverage has no change and project coverage change: +12.63% 🎉

Comparison is base (9c9bd9d) 52.07% compared to head (5db8f87) 64.71%.

Additional details and impacted files
@@                         Coverage Diff                         @@
##           feature/dynamic-protocol-state    #4625       +/-   ##
===================================================================
+ Coverage                           52.07%   64.71%   +12.63%     
===================================================================
  Files                                 740      184      -556     
  Lines                               66757    19496    -47261     
===================================================================
- Hits                                34765    12617    -22148     
+ Misses                              29342     5913    -23429     
+ Partials                             2650      966     -1684     
Flag Coverage Δ
unittests 64.71% <ø> (+12.63%) ⬆️

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

see 923 files with indirect coverage changes

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

@durkmurder durkmurder merged commit 5b58dcf into feature/dynamic-protocol-state Sep 13, 2023
65 checks passed
@durkmurder durkmurder deleted the yurii/6803-snapshot-updates branch September 13, 2023 15:31
This pull request was closed.
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