From 87e65002234939f71144c5458ef604f5737f6264 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Wed, 14 Feb 2024 22:43:42 -0600 Subject: [PATCH 1/5] Require beacon client RPC --- arbnode/blob_reader.go | 52 +++++++++++++++++------------------------- arbnode/node.go | 25 +++++++++++++++++++- arbstate/inbox.go | 1 + cmd/replay/main.go | 4 ++++ 4 files changed, 50 insertions(+), 32 deletions(-) diff --git a/arbnode/blob_reader.go b/arbnode/blob_reader.go index 1424285832..9383a78b1e 100644 --- a/arbnode/blob_reader.go +++ b/arbnode/blob_reader.go @@ -6,6 +6,7 @@ package arbnode import ( "context" "encoding/json" + "errors" "fmt" "io" "net/http" @@ -28,9 +29,9 @@ type BlobClient struct { beaconUrl *url.URL httpClient *http.Client - // The genesis time time and seconds per slot won't change so only request them once. - cachedGenesisTime uint64 - cachedSecondsPerSlot uint64 + // Filled in in Initialize() + genesisTime uint64 + secondsPerSlot uint64 } type BlobClientConfig struct { @@ -42,7 +43,7 @@ var DefaultBlobClientConfig = BlobClientConfig{ } func BlobClientAddOptions(prefix string, f *pflag.FlagSet) { - f.String(prefix+".beacon-chain-url", DefaultBlobClientConfig.BeaconChainUrl, "Beacon Chain url to use for fetching blobs") + f.String(prefix+".beacon-chain-url", DefaultBlobClientConfig.BeaconChainUrl, "Beacon Chain url to use for fetching blobs (normally on port 3500)") } func NewBlobClient(config BlobClientConfig, ec arbutil.L1Interface) (*BlobClient, error) { @@ -100,15 +101,10 @@ func (b *BlobClient) GetBlobs(ctx context.Context, blockHash common.Hash, versio if err != nil { return nil, err } - genesisTime, err := b.genesisTime(ctx) - if err != nil { - return nil, err + if b.secondsPerSlot == 0 { + return nil, errors.New("BlobClient hasn't been initialized") } - secondsPerSlot, err := b.secondsPerSlot(ctx) - if err != nil { - return nil, err - } - slot := (header.Time - genesisTime) / secondsPerSlot + slot := (header.Time - b.genesisTime) / b.secondsPerSlot return b.blobSidecars(ctx, slot, versionedHashes) } @@ -186,31 +182,25 @@ type genesisResponse struct { // don't currently care about other fields, add if needed } -func (b *BlobClient) genesisTime(ctx context.Context) (uint64, error) { - if b.cachedGenesisTime > 0 { - return b.cachedGenesisTime, nil - } - gr, err := beaconRequest[genesisResponse](b, ctx, "/eth/v1/beacon/genesis") - if err != nil { - return 0, fmt.Errorf("error calling beacon client in genesisTime: %w", err) - } - b.cachedGenesisTime = uint64(gr.GenesisTime) - return b.cachedGenesisTime, nil -} - type getSpecResponse struct { SecondsPerSlot jsonapi.Uint64String `json:"SECONDS_PER_SLOT"` } -func (b *BlobClient) secondsPerSlot(ctx context.Context) (uint64, error) { - if b.cachedSecondsPerSlot > 0 { - return b.cachedSecondsPerSlot, nil +func (b *BlobClient) Initialize(ctx context.Context) error { + genesis, err := beaconRequest[genesisResponse](b, ctx, "/eth/v1/beacon/genesis") + if err != nil { + return fmt.Errorf("error calling beacon client in genesisTime: %w", err) } - gr, err := beaconRequest[getSpecResponse](b, ctx, "/eth/v1/config/spec") + b.genesisTime = uint64(genesis.GenesisTime) + + spec, err := beaconRequest[getSpecResponse](b, ctx, "/eth/v1/config/spec") if err != nil { - return 0, fmt.Errorf("error calling beacon client in secondsPerSlot: %w", err) + return fmt.Errorf("error calling beacon client in secondsPerSlot: %w", err) + } + if spec.SecondsPerSlot == 0 { + return errors.New("Got SECONDS_PER_SLOT of zero from beacon client") } - b.cachedSecondsPerSlot = uint64(gr.SecondsPerSlot) - return b.cachedSecondsPerSlot, nil + b.secondsPerSlot = uint64(spec.SecondsPerSlot) + return nil } diff --git a/arbnode/node.go b/arbnode/node.go index df7236f0fd..8182055045 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -191,6 +191,7 @@ func ConfigDefaultL1Test() *Config { func ConfigDefaultL1NonSequencerTest() *Config { config := ConfigDefault + config.Dangerous = TestDangerousConfig config.ParentChainReader = headerreader.TestConfig config.InboxReader = TestInboxReaderConfig config.DelayedSequencer.Enable = false @@ -206,6 +207,7 @@ func ConfigDefaultL1NonSequencerTest() *Config { func ConfigDefaultL2Test() *Config { config := ConfigDefault + config.Dangerous = TestDangerousConfig config.ParentChainReader.Enable = false config.SeqCoordinator = TestSeqCoordinatorConfig config.Feed.Input.Verify.Dangerous.AcceptMissing = true @@ -223,16 +225,25 @@ func ConfigDefaultL2Test() *Config { type DangerousConfig struct { NoL1Listener bool `koanf:"no-l1-listener"` NoSequencerCoordinator bool `koanf:"no-sequencer-coordinator"` + DisableBlobReader bool `koanf:"disable-blob-reader"` } var DefaultDangerousConfig = DangerousConfig{ NoL1Listener: false, NoSequencerCoordinator: false, + DisableBlobReader: false, +} + +var TestDangerousConfig = DangerousConfig{ + NoL1Listener: false, + NoSequencerCoordinator: false, + DisableBlobReader: true, } func DangerousConfigAddOptions(prefix string, f *flag.FlagSet) { f.Bool(prefix+".no-l1-listener", DefaultDangerousConfig.NoL1Listener, "DANGEROUS! disables listening to L1. To be used in test nodes only") f.Bool(prefix+".no-sequencer-coordinator", DefaultDangerousConfig.NoSequencerCoordinator, "DANGEROUS! allows sequencing without sequencer-coordinator") + f.Bool(prefix+".disable-blob-reader", DefaultDangerousConfig.DisableBlobReader, "DANGEROUS! disables the EIP-4844 blob reader, which is necessary to read batches") } type Node struct { @@ -242,6 +253,7 @@ type Node struct { L1Reader *headerreader.HeaderReader TxStreamer *TransactionStreamer DeployInfo *chaininfo.RollupAddresses + BlobReader arbstate.BlobReader InboxReader *InboxReader InboxTracker *InboxTracker DelayedSequencer *DelayedSequencer @@ -463,6 +475,7 @@ func createNodeImpl( L1Reader: nil, TxStreamer: txStreamer, DeployInfo: nil, + BlobReader: nil, InboxReader: nil, InboxTracker: nil, DelayedSequencer: nil, @@ -524,7 +537,10 @@ func createNodeImpl( } var blobReader arbstate.BlobReader - if config.BlobClient.BeaconChainUrl != "" { + if !l1Reader.IsParentChainArbitrum() && !config.Dangerous.DisableBlobReader { + if config.BlobClient.BeaconChainUrl == "" { + return nil, errors.New("a beacon chain RPC URL is required to read batches, but it was not configured (CLI argument: --node.blob-client.beacon-chain-url [URL])") + } blobReader, err = NewBlobClient(config.BlobClient, l1client) if err != nil { return nil, err @@ -688,6 +704,7 @@ func createNodeImpl( L1Reader: l1Reader, TxStreamer: txStreamer, DeployInfo: deployInfo, + BlobReader: blobReader, InboxReader: inboxReader, InboxTracker: inboxTracker, DelayedSequencer: delayedSequencer, @@ -777,6 +794,12 @@ func (n *Node) Start(ctx context.Context) error { if err != nil { return fmt.Errorf("error starting exec client: %w", err) } + if n.BlobReader != nil { + err = n.BlobReader.Initialize(ctx) + if err != nil { + return fmt.Errorf("error initializing blob reader: %w", err) + } + } if n.InboxTracker != nil { err = n.InboxTracker.Initialize() if err != nil { diff --git a/arbstate/inbox.go b/arbstate/inbox.go index fcb1c1ebcb..a6fc7f008d 100644 --- a/arbstate/inbox.go +++ b/arbstate/inbox.go @@ -45,6 +45,7 @@ type BlobReader interface { batchBlockHash common.Hash, versionedHashes []common.Hash, ) ([]kzg4844.Blob, error) + Initialize(ctx context.Context) error } type sequencerMessage struct { diff --git a/cmd/replay/main.go b/cmd/replay/main.go index dd8a0fd1f7..afbd308e91 100644 --- a/cmd/replay/main.go +++ b/cmd/replay/main.go @@ -143,6 +143,10 @@ func (r *BlobPreimageReader) GetBlobs( return blobs, nil } +func (r *BlobPreimageReader) Initialize(ctx context.Context) error { + return nil +} + // To generate: // key, _ := crypto.HexToECDSA("0000000000000000000000000000000000000000000000000000000000000001") // sig, _ := crypto.Sign(make([]byte, 32), key) From 50e9045742801bb745df6f427fdc768b5c25d4e4 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 15 Feb 2024 01:17:53 -0600 Subject: [PATCH 2/5] Move blob client config from node to parent chain section --- arbnode/node.go | 19 +++--------- cmd/conf/chain.go | 18 ++++++----- cmd/nitro/nitro.go | 30 +++++++++++++++---- system_tests/blocks_reexecutor_test.go | 2 +- system_tests/common_test.go | 6 ++-- system_tests/das_test.go | 6 ++-- system_tests/full_challenge_impl_test.go | 4 +-- system_tests/recreatestate_rpc_test.go | 4 +-- .../headerreader/blob_client.go | 16 +++++----- 9 files changed, 58 insertions(+), 47 deletions(-) rename arbnode/blob_reader.go => util/headerreader/blob_client.go (91%) diff --git a/arbnode/node.go b/arbnode/node.go index 8182055045..9f66710623 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -87,7 +87,6 @@ type Config struct { Staker staker.L1ValidatorConfig `koanf:"staker" reload:"hot"` SeqCoordinator SeqCoordinatorConfig `koanf:"seq-coordinator"` DataAvailability das.DataAvailabilityConfig `koanf:"data-availability"` - BlobClient BlobClientConfig `koanf:"blob-client"` SyncMonitor SyncMonitorConfig `koanf:"sync-monitor"` Dangerous DangerousConfig `koanf:"dangerous"` TransactionStreamer TransactionStreamerConfig `koanf:"transaction-streamer" reload:"hot"` @@ -152,7 +151,6 @@ func ConfigAddOptions(prefix string, f *flag.FlagSet, feedInputEnable bool, feed staker.L1ValidatorConfigAddOptions(prefix+".staker", f) SeqCoordinatorConfigAddOptions(prefix+".seq-coordinator", f) das.DataAvailabilityConfigAddNodeOptions(prefix+".data-availability", f) - BlobClientAddOptions(prefix+".blob-client", f) SyncMonitorConfigAddOptions(prefix+".sync-monitor", f) DangerousConfigAddOptions(prefix+".dangerous", f) TransactionStreamerConfigAddOptions(prefix+".transaction-streamer", f) @@ -372,6 +370,7 @@ func createNodeImpl( dataSigner signature.DataSignerFunc, fatalErrChan chan error, parentChainID *big.Int, + blobReader arbstate.BlobReader, ) (*Node, error) { config := configFetcher.Get() @@ -475,7 +474,7 @@ func createNodeImpl( L1Reader: nil, TxStreamer: txStreamer, DeployInfo: nil, - BlobReader: nil, + BlobReader: blobReader, InboxReader: nil, InboxTracker: nil, DelayedSequencer: nil, @@ -536,17 +535,6 @@ func createNodeImpl( return nil, errors.New("a data availability service is required for this chain, but it was not configured") } - var blobReader arbstate.BlobReader - if !l1Reader.IsParentChainArbitrum() && !config.Dangerous.DisableBlobReader { - if config.BlobClient.BeaconChainUrl == "" { - return nil, errors.New("a beacon chain RPC URL is required to read batches, but it was not configured (CLI argument: --node.blob-client.beacon-chain-url [URL])") - } - blobReader, err = NewBlobClient(config.BlobClient, l1client) - if err != nil { - return nil, err - } - } - inboxTracker, err := NewInboxTracker(arbDb, txStreamer, daReader, blobReader) if err != nil { return nil, err @@ -744,8 +732,9 @@ func CreateNode( dataSigner signature.DataSignerFunc, fatalErrChan chan error, parentChainID *big.Int, + blobReader arbstate.BlobReader, ) (*Node, error) { - currentNode, err := createNodeImpl(ctx, stack, exec, arbDb, configFetcher, l2Config, l1client, deployInfo, txOptsValidator, txOptsBatchPoster, dataSigner, fatalErrChan, parentChainID) + currentNode, err := createNodeImpl(ctx, stack, exec, arbDb, configFetcher, l2Config, l1client, deployInfo, txOptsValidator, txOptsBatchPoster, dataSigner, fatalErrChan, parentChainID, blobReader) if err != nil { return nil, err } diff --git a/cmd/conf/chain.go b/cmd/conf/chain.go index e9ec2af0c1..531945b4d6 100644 --- a/cmd/conf/chain.go +++ b/cmd/conf/chain.go @@ -7,14 +7,16 @@ import ( "time" "github.com/offchainlabs/nitro/cmd/genericconf" + "github.com/offchainlabs/nitro/util/headerreader" "github.com/offchainlabs/nitro/util/rpcclient" flag "github.com/spf13/pflag" ) -type L1Config struct { - ID uint64 `koanf:"id"` - Connection rpcclient.ClientConfig `koanf:"connection" reload:"hot"` - Wallet genericconf.WalletConfig `koanf:"wallet"` +type ParentChainConfig struct { + ID uint64 `koanf:"id"` + Connection rpcclient.ClientConfig `koanf:"connection" reload:"hot"` + Wallet genericconf.WalletConfig `koanf:"wallet"` + BlobClient headerreader.BlobClientConfig `koanf:"blob-client"` } var L1ConnectionConfigDefault = rpcclient.ClientConfig{ @@ -25,10 +27,11 @@ var L1ConnectionConfigDefault = rpcclient.ClientConfig{ ArgLogLimit: 2048, } -var L1ConfigDefault = L1Config{ +var L1ConfigDefault = ParentChainConfig{ ID: 0, Connection: L1ConnectionConfigDefault, Wallet: DefaultL1WalletConfig, + BlobClient: headerreader.DefaultBlobClientConfig, } var DefaultL1WalletConfig = genericconf.WalletConfig{ @@ -43,13 +46,14 @@ func L1ConfigAddOptions(prefix string, f *flag.FlagSet) { f.Uint64(prefix+".id", L1ConfigDefault.ID, "if set other than 0, will be used to validate database and L1 connection") rpcclient.RPCClientAddOptions(prefix+".connection", f, &L1ConfigDefault.Connection) genericconf.WalletConfigAddOptions(prefix+".wallet", f, L1ConfigDefault.Wallet.Pathname) + headerreader.BlobClientAddOptions(prefix+".blob-client", f) } -func (c *L1Config) ResolveDirectoryNames(chain string) { +func (c *ParentChainConfig) ResolveDirectoryNames(chain string) { c.Wallet.ResolveDirectoryNames(chain) } -func (c *L1Config) Validate() error { +func (c *ParentChainConfig) Validate() error { return c.Connection.Validate() } diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 6cb9a89b70..9a8119eea0 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -42,6 +42,7 @@ import ( "github.com/offchainlabs/nitro/arbnode" "github.com/offchainlabs/nitro/arbnode/resourcemanager" + "github.com/offchainlabs/nitro/arbstate" "github.com/offchainlabs/nitro/arbutil" blocksreexecutor "github.com/offchainlabs/nitro/blocks_reexecutor" "github.com/offchainlabs/nitro/cmd/chaininfo" @@ -329,6 +330,8 @@ func mainImpl() int { var rollupAddrs chaininfo.RollupAddresses var l1Client *ethclient.Client + var l1Reader *headerreader.HeaderReader + var blobReader arbstate.BlobReader if nodeConfig.Node.ParentChainReader.Enable { confFetcher := func() *rpcclient.ClientConfig { return &liveNodeConfig.Get().ParentChain.Connection } rpcClient := rpcclient.NewRpcClient(confFetcher, nil) @@ -351,6 +354,22 @@ func mainImpl() int { if err != nil { log.Crit("error getting rollup addresses", "err", err) } + arbSys, _ := precompilesgen.NewArbSys(types.ArbSysAddress, l1Client) + l1Reader, err = headerreader.New(ctx, l1Client, func() *headerreader.Config { return &liveNodeConfig.Get().Node.ParentChainReader }, arbSys) + if err != nil { + log.Crit("failed to get L1 headerreader", "err", err) + } + if !l1Reader.IsParentChainArbitrum() && !nodeConfig.Node.Dangerous.DisableBlobReader { + if nodeConfig.ParentChain.BlobClient.BeaconUrl == "" { + flag.Usage() + log.Crit("a beacon chain RPC URL is required to read batches, but it was not configured (CLI argument: --node.parent-chain.blob-client.beacon-url [URL])") + } + blobClient, err := headerreader.NewBlobClient(nodeConfig.ParentChain.BlobClient, l1Client) + if err != nil { + log.Crit("failed to initialize blob client", "err", err) + } + blobReader = blobClient + } } if nodeConfig.Node.Staker.OnlyCreateWalletContract { @@ -358,12 +377,10 @@ func mainImpl() int { flag.Usage() log.Crit("--node.validator.only-create-wallet-contract requires --node.validator.use-smart-contract-wallet") } - arbSys, _ := precompilesgen.NewArbSys(types.ArbSysAddress, l1Client) - l1Reader, err := headerreader.New(ctx, l1Client, func() *headerreader.Config { return &liveNodeConfig.Get().Node.ParentChainReader }, arbSys) - if err != nil { - log.Crit("failed to get L1 headerreader", "error", err) + if l1Reader == nil { + flag.Usage() + log.Crit("--node.validator.only-create-wallet-contract conflicts with --node.dangerous.no-l1-listener") } - // Just create validator smart wallet if needed then exit deployInfo, err := chaininfo.GetRollupAddressesConfig(nodeConfig.Chain.ID, nodeConfig.Chain.Name, combinedL2ChainInfoFile, nodeConfig.Chain.InfoJson) if err != nil { @@ -536,6 +553,7 @@ func mainImpl() int { dataSigner, fatalErrChan, big.NewInt(int64(nodeConfig.ParentChain.ID)), + blobReader, ) if err != nil { log.Error("failed to create node", "err", err) @@ -667,7 +685,7 @@ type NodeConfig struct { Node arbnode.Config `koanf:"node" reload:"hot"` Execution gethexec.Config `koanf:"execution" reload:"hot"` Validation valnode.Config `koanf:"validation" reload:"hot"` - ParentChain conf.L1Config `koanf:"parent-chain" reload:"hot"` + ParentChain conf.ParentChainConfig `koanf:"parent-chain" reload:"hot"` Chain conf.L2Config `koanf:"chain"` LogLevel int `koanf:"log-level" reload:"hot"` LogType string `koanf:"log-type" reload:"hot"` diff --git a/system_tests/blocks_reexecutor_test.go b/system_tests/blocks_reexecutor_test.go index 76034570b2..c2941ddcc4 100644 --- a/system_tests/blocks_reexecutor_test.go +++ b/system_tests/blocks_reexecutor_test.go @@ -26,7 +26,7 @@ func TestBlocksReExecutorModes(t *testing.T) { parentChainID := big.NewInt(1234) feedErrChan := make(chan error, 10) - node, err := arbnode.CreateNode(ctx, stack, execNode, arbDb, NewFetcherFromConfig(arbnode.ConfigDefaultL2Test()), blockchain.Config(), nil, nil, nil, nil, nil, feedErrChan, parentChainID) + node, err := arbnode.CreateNode(ctx, stack, execNode, arbDb, NewFetcherFromConfig(arbnode.ConfigDefaultL2Test()), blockchain.Config(), nil, nil, nil, nil, nil, feedErrChan, parentChainID, nil) Require(t, err) err = node.TxStreamer.AddFakeInitMessage() Require(t, err) diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 52f8a56bca..1dbd0d81b3 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -789,7 +789,7 @@ func createTestNodeWithL1( Require(t, err) currentNode, err = arbnode.CreateNode( ctx, l2stack, execNode, l2arbDb, NewFetcherFromConfig(nodeConfig), l2blockchain.Config(), l1client, - addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, dataSigner, fatalErrChan, big.NewInt(1337), + addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, dataSigner, fatalErrChan, big.NewInt(1337), nil, ) Require(t, err) @@ -825,7 +825,7 @@ func createTestNode( execNode, err := gethexec.CreateExecutionNode(ctx, stack, chainDb, blockchain, nil, execConfigFetcher) Require(t, err) - currentNode, err := arbnode.CreateNode(ctx, stack, execNode, arbDb, NewFetcherFromConfig(nodeConfig), blockchain.Config(), nil, nil, nil, nil, nil, feedErrChan, big.NewInt(1337)) + currentNode, err := arbnode.CreateNode(ctx, stack, execNode, arbDb, NewFetcherFromConfig(nodeConfig), blockchain.Config(), nil, nil, nil, nil, nil, feedErrChan, big.NewInt(1337), nil) Require(t, err) // Give the node an init message @@ -930,7 +930,7 @@ func Create2ndNodeWithConfig( currentExec, err := gethexec.CreateExecutionNode(ctx, l2stack, l2chainDb, l2blockchain, l1client, configFetcher) Require(t, err) - currentNode, err := arbnode.CreateNode(ctx, l2stack, currentExec, l2arbDb, NewFetcherFromConfig(nodeConfig), l2blockchain.Config(), l1client, first.DeployInfo, &txOpts, &txOpts, dataSigner, feedErrChan, big.NewInt(1337)) + currentNode, err := arbnode.CreateNode(ctx, l2stack, currentExec, l2arbDb, NewFetcherFromConfig(nodeConfig), l2blockchain.Config(), l1client, first.DeployInfo, &txOpts, &txOpts, dataSigner, feedErrChan, big.NewInt(1337), nil) Require(t, err) err = currentNode.Start(ctx) diff --git a/system_tests/das_test.go b/system_tests/das_test.go index 96de52e197..8edd91e1ec 100644 --- a/system_tests/das_test.go +++ b/system_tests/das_test.go @@ -141,7 +141,7 @@ func TestDASRekey(t *testing.T) { l1NodeConfigA.DataAvailability.ParentChainNodeURL = "none" execA, err := gethexec.CreateExecutionNode(ctx, l2stackA, l2chainDb, l2blockchain, l1client, gethexec.ConfigDefaultTest) Require(t, err) - nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2blockchain.Config(), l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, nil, feedErrChan, parentChainID) + nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2blockchain.Config(), l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, nil, feedErrChan, parentChainID, nil) Require(t, err) Require(t, nodeA.Start(ctx)) l2clientA := ClientForStack(t, l2stackA) @@ -188,7 +188,7 @@ func TestDASRekey(t *testing.T) { Require(t, err) l1NodeConfigA.DataAvailability.RPCAggregator = aggConfigForBackend(t, backendConfigB) - nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2blockchain.Config(), l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, nil, feedErrChan, parentChainID) + nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2blockchain.Config(), l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, nil, feedErrChan, parentChainID, nil) Require(t, err) Require(t, nodeA.Start(ctx)) l2clientA := ClientForStack(t, l2stackA) @@ -321,7 +321,7 @@ func TestDASComplexConfigAndRestMirror(t *testing.T) { sequencerTxOpts := l1info.GetDefaultTransactOpts("Sequencer", ctx) sequencerTxOptsPtr := &sequencerTxOpts - nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2blockchain.Config(), l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, dataSigner, feedErrChan, big.NewInt(1337)) + nodeA, err := arbnode.CreateNode(ctx, l2stackA, execA, l2arbDb, NewFetcherFromConfig(l1NodeConfigA), l2blockchain.Config(), l1client, addresses, sequencerTxOptsPtr, sequencerTxOptsPtr, dataSigner, feedErrChan, big.NewInt(1337), nil) Require(t, err) Require(t, nodeA.Start(ctx)) l2clientA := ClientForStack(t, l2stackA) diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index b8f891e3e7..362b134806 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -285,7 +285,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall asserterExec, err := gethexec.CreateExecutionNode(ctx, asserterL2Stack, asserterL2ChainDb, asserterL2Blockchain, l1Backend, gethexec.ConfigDefaultTest) Require(t, err) parentChainID := big.NewInt(1337) - asserterL2, err := arbnode.CreateNode(ctx, asserterL2Stack, asserterExec, asserterL2ArbDb, NewFetcherFromConfig(conf), chainConfig, l1Backend, asserterRollupAddresses, nil, nil, nil, fatalErrChan, parentChainID) + asserterL2, err := arbnode.CreateNode(ctx, asserterL2Stack, asserterExec, asserterL2ArbDb, NewFetcherFromConfig(conf), chainConfig, l1Backend, asserterRollupAddresses, nil, nil, nil, fatalErrChan, parentChainID, nil) Require(t, err) err = asserterL2.Start(ctx) Require(t, err) @@ -296,7 +296,7 @@ func RunChallengeTest(t *testing.T, asserterIsCorrect bool, useStubs bool, chall challengerRollupAddresses.SequencerInbox = challengerSeqInboxAddr challengerExec, err := gethexec.CreateExecutionNode(ctx, challengerL2Stack, challengerL2ChainDb, challengerL2Blockchain, l1Backend, gethexec.ConfigDefaultTest) Require(t, err) - challengerL2, err := arbnode.CreateNode(ctx, challengerL2Stack, challengerExec, challengerL2ArbDb, NewFetcherFromConfig(conf), chainConfig, l1Backend, &challengerRollupAddresses, nil, nil, nil, fatalErrChan, parentChainID) + challengerL2, err := arbnode.CreateNode(ctx, challengerL2Stack, challengerExec, challengerL2ArbDb, NewFetcherFromConfig(conf), chainConfig, l1Backend, &challengerRollupAddresses, nil, nil, nil, fatalErrChan, parentChainID, nil) Require(t, err) err = challengerL2.Start(ctx) Require(t, err) diff --git a/system_tests/recreatestate_rpc_test.go b/system_tests/recreatestate_rpc_test.go index f5bdca0970..1973587ecb 100644 --- a/system_tests/recreatestate_rpc_test.go +++ b/system_tests/recreatestate_rpc_test.go @@ -335,7 +335,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig Require(t, err) parentChainID := big.NewInt(1337) - node, err := arbnode.CreateNode(ctx1, stack, execNode, arbDb, NewFetcherFromConfig(arbnode.ConfigDefaultL2Test()), blockchain.Config(), nil, nil, nil, nil, nil, feedErrChan, parentChainID) + node, err := arbnode.CreateNode(ctx1, stack, execNode, arbDb, NewFetcherFromConfig(arbnode.ConfigDefaultL2Test()), blockchain.Config(), nil, nil, nil, nil, nil, feedErrChan, parentChainID, nil) Require(t, err) err = node.TxStreamer.AddFakeInitMessage() Require(t, err) @@ -376,7 +376,7 @@ func testSkippingSavingStateAndRecreatingAfterRestart(t *testing.T, cacheConfig execNode, err = gethexec.CreateExecutionNode(ctx1, stack, chainDb, blockchain, nil, execConfigFetcher) Require(t, err) - node, err = arbnode.CreateNode(ctx, stack, execNode, arbDb, NewFetcherFromConfig(arbnode.ConfigDefaultL2Test()), blockchain.Config(), nil, node.DeployInfo, nil, nil, nil, feedErrChan, parentChainID) + node, err = arbnode.CreateNode(ctx, stack, execNode, arbDb, NewFetcherFromConfig(arbnode.ConfigDefaultL2Test()), blockchain.Config(), nil, node.DeployInfo, nil, nil, nil, feedErrChan, parentChainID, nil) Require(t, err) Require(t, node.Start(ctx)) client = ClientForStack(t, stack) diff --git a/arbnode/blob_reader.go b/util/headerreader/blob_client.go similarity index 91% rename from arbnode/blob_reader.go rename to util/headerreader/blob_client.go index 9383a78b1e..32a264ca93 100644 --- a/arbnode/blob_reader.go +++ b/util/headerreader/blob_client.go @@ -1,7 +1,7 @@ // Copyright 2023, Offchain Labs, Inc. // For license information, see https://github.com/nitro/blob/master/LICENSE -package arbnode +package headerreader import ( "context" @@ -35,19 +35,19 @@ type BlobClient struct { } type BlobClientConfig struct { - BeaconChainUrl string `koanf:"beacon-chain-url"` + BeaconUrl string `koanf:"beacon-url"` } var DefaultBlobClientConfig = BlobClientConfig{ - BeaconChainUrl: "", + BeaconUrl: "", } func BlobClientAddOptions(prefix string, f *pflag.FlagSet) { - f.String(prefix+".beacon-chain-url", DefaultBlobClientConfig.BeaconChainUrl, "Beacon Chain url to use for fetching blobs (normally on port 3500)") + f.String(prefix+".beacon-url", DefaultBlobClientConfig.BeaconUrl, "Beacon Chain RPC URL to use for fetching blobs (normally on port 3500)") } func NewBlobClient(config BlobClientConfig, ec arbutil.L1Interface) (*BlobClient, error) { - beaconUrl, err := url.Parse(config.BeaconChainUrl) + beaconUrl, err := url.Parse(config.BeaconUrl) if err != nil { return nil, fmt.Errorf("failed to parse beacon chain URL: %w", err) } @@ -189,16 +189,16 @@ type getSpecResponse struct { func (b *BlobClient) Initialize(ctx context.Context) error { genesis, err := beaconRequest[genesisResponse](b, ctx, "/eth/v1/beacon/genesis") if err != nil { - return fmt.Errorf("error calling beacon client in genesisTime: %w", err) + return fmt.Errorf("error calling beacon client to get genesisTime: %w", err) } b.genesisTime = uint64(genesis.GenesisTime) spec, err := beaconRequest[getSpecResponse](b, ctx, "/eth/v1/config/spec") if err != nil { - return fmt.Errorf("error calling beacon client in secondsPerSlot: %w", err) + return fmt.Errorf("error calling beacon client to get secondsPerSlot: %w", err) } if spec.SecondsPerSlot == 0 { - return errors.New("Got SECONDS_PER_SLOT of zero from beacon client") + return errors.New("got SECONDS_PER_SLOT of zero from beacon client") } b.secondsPerSlot = uint64(spec.SecondsPerSlot) From 5d11850fea7ee77b2f476a8b18f2740232cbaafd Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 15 Feb 2024 02:58:14 -0600 Subject: [PATCH 3/5] Fix argument name in error message --- cmd/nitro/nitro.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/cmd/nitro/nitro.go b/cmd/nitro/nitro.go index 9a8119eea0..c32d2e6c80 100644 --- a/cmd/nitro/nitro.go +++ b/cmd/nitro/nitro.go @@ -362,7 +362,7 @@ func mainImpl() int { if !l1Reader.IsParentChainArbitrum() && !nodeConfig.Node.Dangerous.DisableBlobReader { if nodeConfig.ParentChain.BlobClient.BeaconUrl == "" { flag.Usage() - log.Crit("a beacon chain RPC URL is required to read batches, but it was not configured (CLI argument: --node.parent-chain.blob-client.beacon-url [URL])") + log.Crit("a beacon chain RPC URL is required to read batches, but it was not configured (CLI argument: --parent-chain.blob-client.beacon-url [URL])") } blobClient, err := headerreader.NewBlobClient(nodeConfig.ParentChain.BlobClient, l1Client) if err != nil { From a069bf1aaf000143fc94c0a08f45f322dafbe5fa Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 15 Feb 2024 11:50:44 -0600 Subject: [PATCH 4/5] Update nitro-testnode to add beacon client URL --- nitro-testnode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitro-testnode b/nitro-testnode index aee6ceff9c..d62114ce0a 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit aee6ceff9c9d3fb2749da55a7d7842f23d1bfc8e +Subproject commit d62114ce0aec72982c744ee7d0167302d581a083 From 58f83c52964068ce01b2cc9d09cd5457388d9bf1 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Thu, 15 Feb 2024 16:20:10 -0600 Subject: [PATCH 5/5] Bump testnode pin to disable blob reader there --- nitro-testnode | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nitro-testnode b/nitro-testnode index d62114ce0a..a22f63a4f0 160000 --- a/nitro-testnode +++ b/nitro-testnode @@ -1 +1 @@ -Subproject commit d62114ce0aec72982c744ee7d0167302d581a083 +Subproject commit a22f63a4f03687f708696f6250cfc1ef5d2d914d