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
|
lumtis
left a comment
There was a problem hiding this comment.
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 <lucas.bertrand.22@gmail.com>
…n-flags' into refactor-lightclient-verification-flags
skosito
left a comment
There was a problem hiding this comment.
lgtm, just couple small comments
Description
MsgUpdateVerificationFlagsintoMsgEnableHeaderVerificationandMsgDisableHeaderVerification.BlockHeaderVerificationwhich 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: