Commit bccd8ae9 authored by Mark Tyneway's avatar Mark Tyneway Committed by GitHub

op-chain-ops: defensive storage config (#3643)

Check for nil values coming from the block when creating
a new `StorageConfig`. This will prevent cryptic errors
that happen deeper in serialization, when trying to
deal with `nil` values. Instead the error should be caught
earlier with a better error message.
Co-authored-by: default avatarmergify[bot] <37929162+mergify[bot]@users.noreply.github.com>
parent d9316206
......@@ -2,6 +2,7 @@ package genesis
import (
"encoding/json"
"errors"
"os"
"path/filepath"
......@@ -120,6 +121,13 @@ func NewL2ImmutableConfig(config *DeployConfig, block *types.Block, proxyL1Stand
func NewL2StorageConfig(config *DeployConfig, block *types.Block, proxyL1StandardBridge common.Address, proxyL1CrossDomainMessenger common.Address) (state.StorageConfig, error) {
storage := make(state.StorageConfig)
if block.Number() == nil {
return storage, errors.New("block number not set")
}
if block.BaseFee() == nil {
return storage, errors.New("block base fee not set")
}
storage["L2ToL1MessagePasser"] = state.StorageValues{
"nonce": 0,
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment