Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIT-2852] Add flags and other info for nitro --dev #2751

Merged
merged 8 commits into from
Nov 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions arbos/arbosState/initialize.go
Original file line number Diff line number Diff line change
Expand Up @@ -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{}) {
amsanghi marked this conversation as resolved.
Show resolved Hide resolved
err = arbosState.ChainOwners().Add(chainOwner)
if err != nil {
return common.Hash{}, err
}
}
addrTable := arbosState.AddressTable()
addrTableSize, err := addrTable.Size()
if err != nil {
Expand Down
3 changes: 3 additions & 0 deletions cmd/conf/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"`
Expand Down Expand Up @@ -47,6 +48,7 @@ var InitConfigDefault = InitConfig{
DownloadPoll: time.Minute,
DevInit: false,
DevInitAddress: "",
DevMaxCodeSize: 0,
DevInitBlockNum: 0,
Empty: false,
ImportWasm: false,
Expand Down Expand Up @@ -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")
Expand Down
4 changes: 4 additions & 0 deletions cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -681,6 +681,7 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo
Nonce: 0,
},
},
ChainOwner: common.HexToAddress(config.Init.DevInitAddress),
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nice solution!

}
initDataReader = statetransfer.NewMemoryInitDataReader(&initData)
}
Expand Down Expand Up @@ -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 {
Expand Down
1 change: 1 addition & 0 deletions cmd/util/confighelpers/configuration.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
1 change: 1 addition & 0 deletions statetransfer/data.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ type ArbosInitializationInfo struct {
AddressTableContents []common.Address
RetryableData []InitializationDataForRetryable
Accounts []AccountInitializationInfo
ChainOwner common.Address
}

type InitializationDataForRetryable struct {
Expand Down
1 change: 1 addition & 0 deletions statetransfer/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ type InitDataReader interface {
GetNextBlockNumber() (uint64, error)
GetRetryableDataReader() (RetryableDataReader, error)
GetAccountDataReader() (AccountDataReader, error)
GetChainOwner() (common.Address, error)
}

type ListReader interface {
Expand Down
4 changes: 4 additions & 0 deletions statetransfer/jsondatareader.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,3 +210,7 @@ func (r *JsonInitDataReader) GetAccountDataReader() (AccountDataReader, error) {
JsonListReader: listreader,
}, nil
}

func (r *JsonInitDataReader) GetChainOwner() (common.Address, error) {
return common.Address{}, nil
}
4 changes: 4 additions & 0 deletions statetransfer/memdatareader.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Loading