fix: sync Account.Extra with GovCouncil contract slots on genesis init#73
Merged
fix: sync Account.Extra with GovCouncil contract slots on genesis init#73
Conversation
Add Extra field to prealloc format to preserve Account.Extra during genesis serialization. Declared as rlp:"optional" to maintain backward compatibility with existing prealloc data.
…nsition Nil map was passed to GetSystemContractsTransition when genesis.Alloc was not pre-allocated, causing a potential panic on write inside system contract initialization. Move the nil check before the call to ensure a valid map is always passed.
Introduce AccountExtraValidMask as the union of all defined bit masks, and ValidateExtra to reject any account extra value with undefined bits set.
Reconcile blacklist and authorized account addresses from Account.Extra and chain config params, ensuring both alloc and GovCouncil contract storage slots reflect the same state at genesis.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Ensure consistency between
Account.Extrabits and GovCouncil contract storage slots (blacklist / authorized accounts) at genesis initialization.Previously, the two sources could diverge — addresses set via chain config params were not reflected in
alloc.Extra, and vice versa.Changes
Bug Fixes
Alloc ↔ contract slot sync (
systemcontracts/gov_council.go,systemcontracts/systemcontracts.go)Pass
genesis.AlloctoinitializeGovCounciland reconcile blacklist/authorized addresses from bothAccount.Extrabits and chain config params into a unified set (union).Both
alloc.Extraand contract storage slots are updated to reflect the final state.Nil map panic (
core/genesis.go)Initialize
genesis.Allocbefore passing toGetSystemContractsTransitionto prevent a nil map write panic whenAllocis unset at the timeInjectContractsis called.Additions
Prealloc encoding (
core/mkalloc.go,core/genesis.go)Include
Account.Extrain prealloc RLP encoding/decoding (rlp:"optional"for backward compatibility).Extra bit validation (
core/types/state_account_extra.go,core/genesis.go)Add
AccountExtraValidMaskconstant andValidateExtrafunction.Reject undefined Extra bits early in
initializeAnzeonGenesisbefore any initialization runs.