Commit 9fb2b72d authored by Roberto Bayardo's avatar Roberto Bayardo

make extradata configurable for the genesis block generator

parent 9576bed0
......@@ -72,6 +72,9 @@ type DeployConfig struct {
// Seconds after genesis block that Regolith hard fork activates. 0 to activate at genesis. Nil to disable regolith
L2GenesisRegolithTimeOffset *hexutil.Uint64 `json:"l2GenesisRegolithTimeOffset,omitempty"`
// Configurable extradata. Will default to []byte("BEDROCK") if left unspecified.
L2GenesisBlockExtraData []byte `json:"l2GenesisBlockExtraData"`
// Owner of the ProxyAdmin predeploy
ProxyAdminOwner common.Address `json:"proxyAdminOwner"`
// Owner of the system on L1
......
......@@ -14,14 +14,16 @@ import (
"github.com/stretchr/testify/require"
)
func TestConfigMarshalUnmarshal(t *testing.T) {
func TestConfigDataMarshalUnmarshal(t *testing.T) {
b, err := os.ReadFile("testdata/test-deploy-config-full.json")
require.NoError(t, err)
dec := json.NewDecoder(bytes.NewReader(b))
decoded := new(DeployConfig)
require.NoError(t, dec.Decode(decoded))
encoded, err := json.MarshalIndent(decoded, "", " ")
require.EqualValues(t, "non-default value", string(decoded.L2GenesisBlockExtraData))
encoded, err := json.MarshalIndent(decoded, "", " ")
require.NoError(t, err)
require.JSONEq(t, string(b), string(encoded))
}
......
......@@ -74,8 +74,13 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro
difficulty = newHexBig(0)
}
extraData := config.L2GenesisBlockExtraData
if extraData == nil {
// L2GenesisBlockExtraData is optional, so use a default value when nil
extraData = BedrockTransitionBlockExtraData
}
// Ensure that the extradata is valid
if size := len(BedrockTransitionBlockExtraData); size > 32 {
if size := len(extraData); size > 32 {
return nil, fmt.Errorf("transition block extradata too long: %d", size)
}
......@@ -83,7 +88,7 @@ func NewL2Genesis(config *DeployConfig, block *types.Block) (*core.Genesis, erro
Config: &optimismChainConfig,
Nonce: uint64(config.L2GenesisBlockNonce),
Timestamp: block.Time(),
ExtraData: BedrockTransitionBlockExtraData,
ExtraData: extraData,
GasLimit: uint64(gasLimit),
Difficulty: difficulty.ToInt(),
Mixhash: config.L2GenesisBlockMixHash,
......
......@@ -36,6 +36,7 @@
"l2GenesisBlockGasUsed": "0x0",
"l2GenesisBlockParentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"l2GenesisBlockBaseFeePerGas": "0x3b9aca00",
"l2GenesisBlockExtraData": "bm9uLWRlZmF1bHQgdmFsdWU=",
"baseFeeVaultRecipient": "0x42000000000000000000000000000000000000f5",
"l1FeeVaultRecipient": "0x42000000000000000000000000000000000000f6",
"sequencerFeeVaultRecipient": "0x42000000000000000000000000000000000000f7",
......
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