-
Notifications
You must be signed in to change notification settings - Fork 106
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
refactor: lightclient verification flags #2097
Conversation
Codecov ReportAttention: Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #2097 +/- ##
===========================================
+ Coverage 72.30% 72.33% +0.03%
===========================================
Files 247 250 +3
Lines 13921 14041 +120
===========================================
+ Hits 10066 10157 +91
- Misses 3394 3423 +29
Partials 461 461
|
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.
Refactor storage for Verification flags to use chain-id as index
Why adding this indexation instead of simply keep an array of chain IDs in a singleton?
VerificationFlags {
ChainIDs []int64
}
It's easier to maintain, we can put most of the logic in types
in pure function and easier to migrate
In general we should avoid adding indexation when necessary since this complexify the state. Here it would not be necessary, the rollout of chain header supported would be slow so the array would not continously grow unlike cctxs and it wouldn't be a performance issue to iterate the array to detect enabled chains
(the variable should also be renamed from flags since we don't have a a predifined list of values to set/unset but can be considered for another PR)
Having an index makes the update much easier, especially when we consider that the input is a list of chain IDs. I agree regarding the names |
Using a singleton simplifies the interaction and representation of the store with a single entrypoint. This structure is like parameters of a module, it's not a ever-growing array of data where indexing is critical, I see it as a simpler model to use a self-containing structure like we do for similar structures.
The algo would be:
Finally the query would be simplified, the ZetaClient would directly get a list of chainIDs that are enabled instead of a list of VerificationFlag object that can contains false |
x/lightclient/keeper/msg_server_disable_block_header_verification.go
Outdated
Show resolved
Hide resolved
Co-authored-by: Lucas Bertrand <[email protected]>
…n-flags' into refactor-lightclient-verification-flags
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.
lgtm, just couple small comments
Description
MsgUpdateVerificationFlags
intoMsgEnableHeaderVerification
andMsgDisableHeaderVerification
.BlockHeaderVerification
which stores a list of chainsIt does not add a migration script , as the flags can be enable once the upgrade rolls out
Closes: #2083
Type of change
How Has This Been Tested?
Please describe the tests that you ran to verify your changes. Include instructions and any relevant details so others can reproduce.
Checklist: