diff --git a/arbos/arbosState/initialize.go b/arbos/arbosState/initialize.go index 374eff2cea..7ea2938c74 100644 --- a/arbos/arbosState/initialize.go +++ b/arbos/arbosState/initialize.go @@ -97,6 +97,16 @@ func InitializeArbosInDatabase(db ethdb.Database, cacheConfig *core.CacheConfig, log.Crit("failed to open the ArbOS state", "error", err) } + chainOwner, err := initData.GetChainOwner() + if err != nil { + return common.Hash{}, err + } + if chainOwner != (common.Address{}) { + err = arbosState.ChainOwners().Add(chainOwner) + if err != nil { + return common.Hash{}, err + } + } addrTable := arbosState.AddressTable() addrTableSize, err := addrTable.Size() if err != nil { diff --git a/cmd/conf/init.go b/cmd/conf/init.go index f01d99f8b7..8e4e9a8892 100644 --- a/cmd/conf/init.go +++ b/cmd/conf/init.go @@ -20,6 +20,7 @@ type InitConfig struct { DownloadPoll time.Duration `koanf:"download-poll"` DevInit bool `koanf:"dev-init"` DevInitAddress string `koanf:"dev-init-address"` + DevMaxCodeSize uint64 `koanf:"dev-max-code-size"` DevInitBlockNum uint64 `koanf:"dev-init-blocknum"` Empty bool `koanf:"empty"` ImportWasm bool `koanf:"import-wasm"` @@ -47,6 +48,7 @@ var InitConfigDefault = InitConfig{ DownloadPoll: time.Minute, DevInit: false, DevInitAddress: "", + DevMaxCodeSize: 0, DevInitBlockNum: 0, Empty: false, ImportWasm: false, @@ -75,6 +77,7 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) { f.Bool(prefix+".dev-init", InitConfigDefault.DevInit, "init with dev data (1 account with balance) instead of file import") f.String(prefix+".dev-init-address", InitConfigDefault.DevInitAddress, "Address of dev-account. Leave empty to use the dev-wallet.") f.Uint64(prefix+".dev-init-blocknum", InitConfigDefault.DevInitBlockNum, "Number of preinit blocks. Must exist in ancient database.") + f.Uint64(prefix+".dev-max-code-size", InitConfigDefault.DevMaxCodeSize, "Max code size for dev accounts") f.Bool(prefix+".empty", InitConfigDefault.Empty, "init with empty state") f.Bool(prefix+".import-wasm", InitConfigDefault.ImportWasm, "if set, import the wasm directory when downloading a database (contains executable code - only use with highly trusted source)") f.Bool(prefix+".then-quit", InitConfigDefault.ThenQuit, "quit after init is done") diff --git a/cmd/nitro/init.go b/cmd/nitro/init.go index f0b303817c..d4794f9fee 100644 --- a/cmd/nitro/init.go +++ b/cmd/nitro/init.go @@ -681,6 +681,7 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo Nonce: 0, }, }, + ChainOwner: common.HexToAddress(config.Init.DevInitAddress), } initDataReader = statetransfer.NewMemoryInitDataReader(&initData) } @@ -716,6 +717,9 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo if err != nil { return chainDb, nil, err } + if config.Init.DevInit && config.Init.DevMaxCodeSize != 0 { + chainConfig.ArbitrumChainParams.MaxCodeSize = config.Init.DevMaxCodeSize + } testUpdateTxIndex(chainDb, chainConfig, &txIndexWg) ancients, err := chainDb.Ancients() if err != nil { diff --git a/cmd/util/confighelpers/configuration.go b/cmd/util/confighelpers/configuration.go index 19b5b1a24c..8c4ef2a70b 100644 --- a/cmd/util/confighelpers/configuration.go +++ b/cmd/util/confighelpers/configuration.go @@ -209,6 +209,7 @@ func devFlagArgs() []string { "--init.empty=false", "--http.port", "8547", "--http.addr", "127.0.0.1", + "--http.api=net,web3,eth,arb,arbdebug,debug", } return args } diff --git a/statetransfer/data.go b/statetransfer/data.go index df4694aa17..21268a443a 100644 --- a/statetransfer/data.go +++ b/statetransfer/data.go @@ -14,6 +14,7 @@ type ArbosInitializationInfo struct { AddressTableContents []common.Address RetryableData []InitializationDataForRetryable Accounts []AccountInitializationInfo + ChainOwner common.Address } type InitializationDataForRetryable struct { diff --git a/statetransfer/interface.go b/statetransfer/interface.go index 7d592b4430..cb70fdd14d 100644 --- a/statetransfer/interface.go +++ b/statetransfer/interface.go @@ -17,6 +17,7 @@ type InitDataReader interface { GetNextBlockNumber() (uint64, error) GetRetryableDataReader() (RetryableDataReader, error) GetAccountDataReader() (AccountDataReader, error) + GetChainOwner() (common.Address, error) } type ListReader interface { diff --git a/statetransfer/jsondatareader.go b/statetransfer/jsondatareader.go index c36061c0b0..5e992df3f0 100644 --- a/statetransfer/jsondatareader.go +++ b/statetransfer/jsondatareader.go @@ -210,3 +210,7 @@ func (r *JsonInitDataReader) GetAccountDataReader() (AccountDataReader, error) { JsonListReader: listreader, }, nil } + +func (r *JsonInitDataReader) GetChainOwner() (common.Address, error) { + return common.Address{}, nil +} diff --git a/statetransfer/memdatareader.go b/statetransfer/memdatareader.go index 1d60888937..3d6b68343c 100644 --- a/statetransfer/memdatareader.go +++ b/statetransfer/memdatareader.go @@ -99,6 +99,10 @@ func (r *MemoryInitDataReader) GetAccountDataReader() (AccountDataReader, error) }, nil } +func (r *MemoryInitDataReader) GetChainOwner() (common.Address, error) { + return r.d.ChainOwner, nil +} + func (r *MemoryInitDataReader) Close() error { return nil }