Skip to content

Commit

Permalink
Merge branch 'update-gethpin-v1.14.6' into update-gethpin-v1.14.7
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi authored Dec 12, 2024
2 parents 67a8375 + d9301a4 commit 72b893f
Show file tree
Hide file tree
Showing 9 changed files with 382 additions and 74 deletions.
2 changes: 1 addition & 1 deletion arbnode/seq_coordinator.go
Original file line number Diff line number Diff line change
Expand Up @@ -662,7 +662,7 @@ func (c *SeqCoordinator) update(ctx context.Context) time.Duration {
for msgToRead < readUntil && localMsgCount >= remoteFinalizedMsgCount {
var resString string
resString, msgReadErr = client.Get(ctx, redisutil.MessageKeyFor(msgToRead)).Result()
if msgReadErr != nil {
if msgReadErr != nil && c.sequencer.Synced() {
log.Warn("coordinator failed reading message", "pos", msgToRead, "err", msgReadErr)
break
}
Expand Down
3 changes: 3 additions & 0 deletions cmd/conf/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ type InitConfig struct {
ImportWasm bool `koanf:"import-wasm"`
AccountsPerSync uint `koanf:"accounts-per-sync"`
ImportFile string `koanf:"import-file"`
GenesisJsonFile string `koanf:"genesis-json-file"`
ThenQuit bool `koanf:"then-quit"`
Prune string `koanf:"prune"`
PruneBloomSize uint64 `koanf:"prune-bloom-size"`
Expand Down Expand Up @@ -54,6 +55,7 @@ var InitConfigDefault = InitConfig{
Empty: false,
ImportWasm: false,
ImportFile: "",
GenesisJsonFile: "",
AccountsPerSync: 100000,
ThenQuit: false,
Prune: "",
Expand Down Expand Up @@ -83,6 +85,7 @@ func InitConfigAddOptions(prefix string, f *pflag.FlagSet) {
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")
f.String(prefix+".import-file", InitConfigDefault.ImportFile, "path for json data to import")
f.String(prefix+".genesis-json-file", InitConfigDefault.GenesisJsonFile, "path for genesis json file")
f.Uint(prefix+".accounts-per-sync", InitConfigDefault.AccountsPerSync, "during init - sync database every X accounts. Lower value for low-memory systems. 0 disables.")
f.String(prefix+".prune", InitConfigDefault.Prune, "pruning for a given use: \"full\" for full nodes serving RPC requests, or \"validator\" for validators")
f.Uint64(prefix+".prune-bloom-size", InitConfigDefault.PruneBloomSize, "the amount of memory in megabytes to use for the pruning bloom filter (higher values prune better)")
Expand Down
38 changes: 35 additions & 3 deletions cmd/nitro/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -689,6 +689,36 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo

var chainConfig *params.ChainConfig

if config.Init.GenesisJsonFile != "" {
if initDataReader != nil {
return chainDb, nil, errors.New("multiple init methods supplied")
}
genesisJson, err := os.ReadFile(config.Init.GenesisJsonFile)
if err != nil {
return chainDb, nil, err
}
var gen core.Genesis
if err := json.Unmarshal(genesisJson, &gen); err != nil {
return chainDb, nil, err
}
var accounts []statetransfer.AccountInitializationInfo
for address, account := range gen.Alloc {
accounts = append(accounts, statetransfer.AccountInitializationInfo{
Addr: address,
EthBalance: account.Balance,
Nonce: account.Nonce,
ContractInfo: &statetransfer.AccountInitContractInfo{
Code: account.Code,
ContractStorage: account.Storage,
},
})
}
initDataReader = statetransfer.NewMemoryInitDataReader(&statetransfer.ArbosInitializationInfo{
Accounts: accounts,
})
chainConfig = gen.Config
}

var l2BlockChain *core.BlockChain
txIndexWg := sync.WaitGroup{}
if initDataReader == nil {
Expand All @@ -714,9 +744,11 @@ func openInitializeChainDb(ctx context.Context, stack *node.Node, config *NodeCo
if err != nil {
return chainDb, nil, err
}
chainConfig, err = chaininfo.GetChainConfig(new(big.Int).SetUint64(config.Chain.ID), config.Chain.Name, genesisBlockNr, config.Chain.InfoFiles, config.Chain.InfoJson)
if err != nil {
return chainDb, nil, err
if chainConfig == nil {
chainConfig, err = chaininfo.GetChainConfig(new(big.Int).SetUint64(config.Chain.ID), config.Chain.Name, genesisBlockNr, config.Chain.InfoFiles, config.Chain.InfoJson)
if err != nil {
return chainDb, nil, err
}
}
if config.Init.DevInit && config.Init.DevMaxCodeSize != 0 {
chainConfig.ArbitrumChainParams.MaxCodeSize = config.Init.DevMaxCodeSize
Expand Down
131 changes: 87 additions & 44 deletions cmd/nitro/nitro.go
Original file line number Diff line number Diff line change
Expand Up @@ -616,6 +616,46 @@ func mainImpl() int {
}
}
}

// Before starting the node, wait until the transaction that deployed rollup is finalized
if nodeConfig.EnsureRollupDeployment &&
nodeConfig.Node.ParentChainReader.Enable &&
rollupAddrs.DeployedAt > 0 {
currentFinalized, err := l1Reader.LatestFinalizedBlockNr(ctx)
if err != nil && errors.Is(err, headerreader.ErrBlockNumberNotSupported) {
log.Info("Finality not supported by parent chain, disabling the check to verify if rollup deployment tx was finalized", "err", err)
} else {
newHeaders, unsubscribe := l1Reader.Subscribe(false)
retriesOnError := 10
sigint := make(chan os.Signal, 1)
signal.Notify(sigint, os.Interrupt, syscall.SIGTERM)
for currentFinalized < rollupAddrs.DeployedAt && retriesOnError > 0 {
select {
case <-newHeaders:
if finalized, err := l1Reader.LatestFinalizedBlockNr(ctx); err != nil {
if errors.Is(err, headerreader.ErrBlockNumberNotSupported) {
log.Error("Finality support was removed from parent chain mid way, disabling the check to verify if the rollup deployment tx was finalized", "err", err)
retriesOnError = 0 // Break out of for loop as well
break
}
log.Error("Error getting latestFinalizedBlockNr from l1Reader", "err", err)
retriesOnError--
} else {
currentFinalized = finalized
log.Debug("Finalized block number updated", "finalized", finalized)
}
case <-ctx.Done():
log.Error("Context done while checking if the rollup deployment tx was finalized")
return 1
case <-sigint:
log.Info("shutting down because of sigint")
return 0
}
}
unsubscribe()
}
}

gqlConf := nodeConfig.GraphQL
if gqlConf.Enable {
if err := graphql.New(stack, execNode.Backend.APIBackend(), execNode.FilterSystem, gqlConf.CORSDomain, gqlConf.VHosts); err != nil {
Expand Down Expand Up @@ -675,53 +715,55 @@ func mainImpl() int {
}

type NodeConfig struct {
Conf genericconf.ConfConfig `koanf:"conf" reload:"hot"`
Node arbnode.Config `koanf:"node" reload:"hot"`
Execution gethexec.Config `koanf:"execution" reload:"hot"`
Validation valnode.Config `koanf:"validation" reload:"hot"`
ParentChain conf.ParentChainConfig `koanf:"parent-chain" reload:"hot"`
Chain conf.L2Config `koanf:"chain"`
LogLevel string `koanf:"log-level" reload:"hot"`
LogType string `koanf:"log-type" reload:"hot"`
FileLogging genericconf.FileLoggingConfig `koanf:"file-logging" reload:"hot"`
Persistent conf.PersistentConfig `koanf:"persistent"`
HTTP genericconf.HTTPConfig `koanf:"http"`
WS genericconf.WSConfig `koanf:"ws"`
IPC genericconf.IPCConfig `koanf:"ipc"`
Auth genericconf.AuthRPCConfig `koanf:"auth"`
GraphQL genericconf.GraphQLConfig `koanf:"graphql"`
Metrics bool `koanf:"metrics"`
MetricsServer genericconf.MetricsServerConfig `koanf:"metrics-server"`
PProf bool `koanf:"pprof"`
PprofCfg genericconf.PProf `koanf:"pprof-cfg"`
Init conf.InitConfig `koanf:"init"`
Rpc genericconf.RpcConfig `koanf:"rpc"`
BlocksReExecutor blocksreexecutor.Config `koanf:"blocks-reexecutor"`
Conf genericconf.ConfConfig `koanf:"conf" reload:"hot"`
Node arbnode.Config `koanf:"node" reload:"hot"`
Execution gethexec.Config `koanf:"execution" reload:"hot"`
Validation valnode.Config `koanf:"validation" reload:"hot"`
ParentChain conf.ParentChainConfig `koanf:"parent-chain" reload:"hot"`
Chain conf.L2Config `koanf:"chain"`
LogLevel string `koanf:"log-level" reload:"hot"`
LogType string `koanf:"log-type" reload:"hot"`
FileLogging genericconf.FileLoggingConfig `koanf:"file-logging" reload:"hot"`
Persistent conf.PersistentConfig `koanf:"persistent"`
HTTP genericconf.HTTPConfig `koanf:"http"`
WS genericconf.WSConfig `koanf:"ws"`
IPC genericconf.IPCConfig `koanf:"ipc"`
Auth genericconf.AuthRPCConfig `koanf:"auth"`
GraphQL genericconf.GraphQLConfig `koanf:"graphql"`
Metrics bool `koanf:"metrics"`
MetricsServer genericconf.MetricsServerConfig `koanf:"metrics-server"`
PProf bool `koanf:"pprof"`
PprofCfg genericconf.PProf `koanf:"pprof-cfg"`
Init conf.InitConfig `koanf:"init"`
Rpc genericconf.RpcConfig `koanf:"rpc"`
BlocksReExecutor blocksreexecutor.Config `koanf:"blocks-reexecutor"`
EnsureRollupDeployment bool `koanf:"ensure-rollup-deployment" reload:"hot"`
}

var NodeConfigDefault = NodeConfig{
Conf: genericconf.ConfConfigDefault,
Node: arbnode.ConfigDefault,
Execution: gethexec.ConfigDefault,
Validation: valnode.DefaultValidationConfig,
ParentChain: conf.L1ConfigDefault,
Chain: conf.L2ConfigDefault,
LogLevel: "INFO",
LogType: "plaintext",
FileLogging: genericconf.DefaultFileLoggingConfig,
Persistent: conf.PersistentConfigDefault,
HTTP: genericconf.HTTPConfigDefault,
WS: genericconf.WSConfigDefault,
IPC: genericconf.IPCConfigDefault,
Auth: genericconf.AuthRPCConfigDefault,
GraphQL: genericconf.GraphQLConfigDefault,
Metrics: false,
MetricsServer: genericconf.MetricsServerConfigDefault,
Init: conf.InitConfigDefault,
Rpc: genericconf.DefaultRpcConfig,
PProf: false,
PprofCfg: genericconf.PProfDefault,
BlocksReExecutor: blocksreexecutor.DefaultConfig,
Conf: genericconf.ConfConfigDefault,
Node: arbnode.ConfigDefault,
Execution: gethexec.ConfigDefault,
Validation: valnode.DefaultValidationConfig,
ParentChain: conf.L1ConfigDefault,
Chain: conf.L2ConfigDefault,
LogLevel: "INFO",
LogType: "plaintext",
FileLogging: genericconf.DefaultFileLoggingConfig,
Persistent: conf.PersistentConfigDefault,
HTTP: genericconf.HTTPConfigDefault,
WS: genericconf.WSConfigDefault,
IPC: genericconf.IPCConfigDefault,
Auth: genericconf.AuthRPCConfigDefault,
GraphQL: genericconf.GraphQLConfigDefault,
Metrics: false,
MetricsServer: genericconf.MetricsServerConfigDefault,
Init: conf.InitConfigDefault,
Rpc: genericconf.DefaultRpcConfig,
PProf: false,
PprofCfg: genericconf.PProfDefault,
BlocksReExecutor: blocksreexecutor.DefaultConfig,
EnsureRollupDeployment: true,
}

func NodeConfigAddOptions(f *flag.FlagSet) {
Expand All @@ -748,6 +790,7 @@ func NodeConfigAddOptions(f *flag.FlagSet) {
conf.InitConfigAddOptions("init", f)
genericconf.RpcConfigAddOptions("rpc", f)
blocksreexecutor.ConfigAddOptions("blocks-reexecutor", f)
f.Bool("ensure-rollup-deployment", NodeConfigDefault.EnsureRollupDeployment, "before starting the node, wait until the transaction that deployed rollup is finalized")
}

func (c *NodeConfig) ResolveDirectoryNames() error {
Expand Down
18 changes: 9 additions & 9 deletions das/aggregator.go
Original file line number Diff line number Diff line change
Expand Up @@ -254,7 +254,7 @@ func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64)
var sigs []blsSignatures.Signature
var aggSignersMask uint64
var successfullyStoredCount int
var returned bool
var returned int // 0-no status, 1-succeeded, 2-failed
for i := 0; i < len(a.services); i++ {
select {
case <-ctx.Done():
Expand All @@ -276,26 +276,26 @@ func (a *Aggregator) Store(ctx context.Context, message []byte, timeout uint64)
// certDetailsChan, so the Store function can return, but also continue
// running until all responses are received (or the context is canceled)
// in order to produce accurate logs/metrics.
if !returned {
if returned == 0 {
if successfullyStoredCount >= a.requiredServicesForStore {
cd := certDetails{}
cd.pubKeys = append(cd.pubKeys, pubKeys...)
cd.sigs = append(cd.sigs, sigs...)
cd.aggSignersMask = aggSignersMask
certDetailsChan <- cd
returned = true
if a.maxAllowedServiceStoreFailures > 0 && // Ignore the case where AssumedHonest = 1, probably a testnet
int(storeFailures.Load())+1 > a.maxAllowedServiceStoreFailures {
log.Error("das.Aggregator: storing the batch data succeeded to enough DAS commitee members to generate the Data Availability Cert, but if one more had failed then the cert would not have been able to be generated. Look for preceding logs with \"Error from backend\"")
}
returned = 1
} else if int(storeFailures.Load()) > a.maxAllowedServiceStoreFailures {
cd := certDetails{}
cd.err = fmt.Errorf("aggregator failed to store message to at least %d out of %d DASes (assuming %d are honest). %w", a.requiredServicesForStore, len(a.services), a.config.AssumedHonest, daprovider.ErrBatchToDasFailed)
certDetailsChan <- cd
returned = true
returned = 2
}
}

}
if returned == 1 &&
a.maxAllowedServiceStoreFailures > 0 && // Ignore the case where AssumedHonest = 1, probably a testnet
int(storeFailures.Load())+1 > a.maxAllowedServiceStoreFailures {
log.Error("das.Aggregator: storing the batch data succeeded to enough DAS commitee members to generate the Data Availability Cert, but if one more had failed then the cert would not have been able to be generated. Look for preceding logs with \"Error from backend\"")
}
}()

Expand Down
6 changes: 2 additions & 4 deletions das/reader_aggregator_strategies.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ package das

import (
"errors"
"maps"
"math/rand"
"sort"
"sync"
Expand Down Expand Up @@ -33,10 +34,7 @@ func (s *abstractAggregatorStrategy) update(readers []daprovider.DASReader, stat
s.readers = make([]daprovider.DASReader, len(readers))
copy(s.readers, readers)

s.stats = make(map[daprovider.DASReader]readerStats)
for k, v := range stats {
s.stats[k] = v
}
s.stats = maps.Clone(stats)
}

// Exponentially growing Explore Exploit Strategy
Expand Down
Loading

0 comments on commit 72b893f

Please sign in to comment.