Skip to content

Commit

Permalink
Move migrated data existence check into backend and add a new conditi…
Browse files Browse the repository at this point in the history
…on for full sync node
  • Loading branch information
Kourin1996 committed Jan 29, 2025
1 parent 67a7b52 commit 5c3e2be
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 6 deletions.
6 changes: 0 additions & 6 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -347,12 +347,6 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, genesis *Genesis
// Make sure the state associated with the block is available, or log out
// if there is no available state, waiting for state sync.
head := bc.CurrentBlock()
// Make sure Cel2 chain has migrated data from Celo1
if chainConfig.Cel2Time != nil && !chainConfig.IsCel2(head.Time) {
log.Error("Migrated data for Cel2 is missing, please ensure the migrated data from Celo1 can be properly loaded before starting the blockchain",
"current number", head.Number, "current hash", head.Hash())
return nil, fmt.Errorf("missing migrated data")
}
if !bc.HasState(head.Root) {
if head.Number.Uint64() == 0 {
// The genesis state is missing, which is only possible in the path-based
Expand Down
7 changes: 7 additions & 0 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,13 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
if err != nil {
return nil, err
}
// Make sure Cel2 full sync node has migrated data from Celo1
currentBlock := eth.blockchain.CurrentBlock()
if config.SyncMode == downloader.FullSync && chainConfig.Cel2Time != nil && !chainConfig.IsCel2(currentBlock.Number.Uint64()) {
log.Error("Migrated data for Cel2 is missing, please ensure the migrated data from Celo1 can be properly loaded before starting the blockchain",
"current number", currentBlock.Number.Uint64(), "current hash", currentBlock.Hash())
return nil, fmt.Errorf("missing migrated data")
}
if chainConfig := eth.blockchain.Config(); chainConfig.Optimism != nil { // config.Genesis.Config.ChainID cannot be used because it's based on CLI flags only, thus default to mainnet L1
config.NetworkId = chainConfig.ChainID.Uint64() // optimism defaults eth network ID to chain ID
eth.networkID = config.NetworkId
Expand Down

0 comments on commit 5c3e2be

Please sign in to comment.