diff --git a/cmd/utils/flags.go b/cmd/utils/flags.go index 2e070815b9..8f480b9c17 100644 --- a/cmd/utils/flags.go +++ b/cmd/utils/flags.go @@ -2441,7 +2441,7 @@ func ParseStateScheme(ctx *cli.Context, disk ethdb.Database) (string, error) { // If state scheme is specified, ensure it's compatible with // persistent state. scheme := ctx.String(StateSchemeFlag.Name) - if stored != "" || scheme == stored { + if stored == "" || scheme == stored { log.Info("State scheme set by user", "scheme", scheme) return scheme, nil } diff --git a/consensus/consortium/v1/consortium.go b/consensus/consortium/v1/consortium.go index f208275857..dee4b9c326 100644 --- a/consensus/consortium/v1/consortium.go +++ b/consensus/consortium/v1/consortium.go @@ -308,9 +308,13 @@ func (c *Consortium) verifyCascadingFields(chain consensus.ChainHeaderReader, he func (c *Consortium) snapshot(chain consensus.ChainHeaderReader, number uint64, hash common.Hash, parents []*types.Header) (*Snapshot, error) { // Search for a snapshot in memory or on disk for checkpoints var ( - headers []*types.Header - snap *Snapshot + headers []*types.Header + snap *Snapshot + cpyParents = make([]*types.Header, len(parents)) ) + // We must copy parents before going to the loop because parents are modified. + // If not, the FindAncientHeader function can not find its block ancestor + copy(cpyParents, parents) for snap == nil { // If an in-memory snapshot was found, use that if s, ok := c.recents.Get(hash); ok { @@ -370,7 +374,7 @@ func (c *Consortium) snapshot(chain consensus.ChainHeaderReader, number uint64, for i := 0; i < len(headers)/2; i++ { headers[i], headers[len(headers)-1-i] = headers[len(headers)-1-i], headers[i] } - snap, err := snap.apply(chain, c, headers, parents) + snap, err := snap.apply(chain, c, headers, cpyParents) if err != nil { return nil, err } diff --git a/core/rawdb/ancient_scheme.go b/core/rawdb/ancient_scheme.go index 2773d3611a..0e6d4bea5a 100644 --- a/core/rawdb/ancient_scheme.go +++ b/core/rawdb/ancient_scheme.go @@ -78,7 +78,7 @@ var ( ) // freezers the collections of all builtin freezers. -var freezers = []string{chainFreezerName} +var freezers = []string{chainFreezerName, stateFreezerName} // NewStateFreezer initializes the freezer for state history. func NewStateFreezer(ancientDir string, readOnly bool) (*ResettableFreezer, error) { diff --git a/docker/chainnode/entrypoint.sh b/docker/chainnode/entrypoint.sh index b1825f88fd..095cfdc37f 100755 --- a/docker/chainnode/entrypoint.sh +++ b/docker/chainnode/entrypoint.sh @@ -29,6 +29,7 @@ params="" syncmode="snap" mine="true" blsParams="" +state_scheme="hash" set -e @@ -48,6 +49,11 @@ if [[ ! -z $WS_PORT ]]; then ws_port="$WS_PORT" fi +if [[ ! -z $STATE_SCHEME ]]; then + state_scheme="$STATE_SCHEME" +fi + + # networkid if [[ ! -z $NETWORK_ID ]]; then case $NETWORK_ID in @@ -78,15 +84,14 @@ fi # data dir if [[ ! -d $datadir/ronin ]]; then - echo "No blockchain data, creating genesis block." - ronin init $dbEngine --datadir $datadir $genesisPath 2> /dev/null + echo "No blockchain data, creating genesis block with $genesisPath, state_scheme $state_scheme ..." + ronin init $dbEngine --datadir $datadir --state.scheme $state_scheme $genesisPath $genesisPath elif [[ "$FORCE_INIT" = "true" && "$INIT_FORCE_OVERRIDE_CHAIN_CONFIG" = "true" ]]; then - echo "Forcing update chain config with force overriding chain config." - ronin init $dbEngine --overrideChainConfig --datadir $datadir $genesisPath 2> /dev/null + echo "Forcing update chain config with force overriding chain config with $genesisPath, state_scheme $state_scheme ..." + ronin init $dbEngine --overrideChainConfig --datadir $datadir --state.scheme $state_scheme $genesisPath elif [ "$FORCE_INIT" = "true" ]; then - echo "Forcing update chain config." - ronin init $dbEngine --datadir $datadir $genesisPath 2> /dev/null -fi + echo "Forcing update chain config with $genesisPath, state_scheme $state_scheme ..." + ronin init $dbEngine --datadir $datadir --state.scheme $state_scheme $genesisPath # password file if [[ ! -f $PASSWORD_FILE ]]; then @@ -333,6 +338,9 @@ if [[ "$BLS_SHOW_PRIVATE_KEY" = "true" ]]; then --finality.blswalletpath $BLS_PRIVATE_KEY_DIR \ --secret fi +echo "---------------------------------" +echo "Starting the Ronin Node" +echo "---------------------------------" exec ronin $params \ --syncmode $syncmode \ diff --git a/eth/backend.go b/eth/backend.go index 12cdafeb3d..6345ad8097 100644 --- a/eth/backend.go +++ b/eth/backend.go @@ -207,11 +207,12 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) { } ) eth.blockchain, err = core.NewBlockChain(chainDb, cacheConfig, config.Genesis, config.OverrideArrowGlacier, eth.engine, vmConfig, eth.shouldPreserve, &config.TransactionHistory) - chainConfig := eth.blockchain.Config() - genesisHash := eth.blockchain.Genesis().Hash() if err != nil { return nil, err } + chainConfig := eth.blockchain.Config() + genesisHash := eth.blockchain.Genesis().Hash() + if config.EnableMonitorDoubleSign { go eth.blockchain.StartDoubleSignMonitor() }