diff --git a/arbnode/node.go b/arbnode/node.go index 9f66710623..580dea25ca 100644 --- a/arbnode/node.go +++ b/arbnode/node.go @@ -67,10 +67,10 @@ func GenerateRollupConfig(prod bool, wasmModuleRoot common.Hash, rollupOwner com // TODO could the ChainConfig be just []byte? ChainConfig: string(serializedChainConfig), SequencerInboxMaxTimeVariation: rollupgen.ISequencerInboxMaxTimeVariation{ - DelayBlocks: 60 * 60 * 24 / 15, - FutureBlocks: 12, - DelaySeconds: 60 * 60 * 24, - FutureSeconds: 60 * 60, + DelayBlocks: big.NewInt(60 * 60 * 24 / 15), + FutureBlocks: big.NewInt(12), + DelaySeconds: big.NewInt(60 * 60 * 24), + FutureSeconds: big.NewInt(60 * 60), }, } } diff --git a/arbnode/sequencer_inbox.go b/arbnode/sequencer_inbox.go index b743bf0ef9..edda4e5512 100644 --- a/arbnode/sequencer_inbox.go +++ b/arbnode/sequencer_inbox.go @@ -45,7 +45,7 @@ func init() { } batchDeliveredID = sequencerBridgeABI.Events["SequencerBatchDelivered"].ID sequencerBatchDataABI = sequencerBridgeABI.Events[sequencerBatchDataEvent] - addSequencerL2BatchFromOriginCallABI = sequencerBridgeABI.Methods["addSequencerL2BatchFromOrigin"] + addSequencerL2BatchFromOriginCallABI = sequencerBridgeABI.Methods["addSequencerL2BatchFromOrigin0"] } type SequencerInbox struct { diff --git a/cmd/deploy/deploy.go b/cmd/deploy/deploy.go index afbcddec62..1c8b858106 100644 --- a/cmd/deploy/deploy.go +++ b/cmd/deploy/deploy.go @@ -10,6 +10,7 @@ import ( "fmt" "math/big" "os" + "strings" "time" "github.com/offchainlabs/nitro/cmd/chaininfo" @@ -41,6 +42,8 @@ func main() { deployAccount := flag.String("l1DeployAccount", "", "l1 seq account to use (default is first account in keystore)") ownerAddressString := flag.String("ownerAddress", "", "the rollup owner's address") sequencerAddressString := flag.String("sequencerAddress", "", "the sequencer's address") + batchPostersString := flag.String("batchPosters", "", "the comma separated array of addresses of batch posters. Defaults to sequencer address") + batchPosterManagerAddressString := flag.String("batchPosterManger", "", "the batch poster manger's address. Defaults to owner address") nativeTokenAddressString := flag.String("nativeTokenAddress", "0x0000000000000000000000000000000000000000", "address of the ERC20 token which is used as native L2 currency") maxDataSizeUint := flag.Uint64("maxDataSize", 117964, "maximum data size of a batch or a cross-chain message (default = 90% of Geth's 128KB tx size limit)") loserEscrowAddressString := flag.String("loserEscrowAddress", "", "the address which half of challenge loser's funds accumulate at") @@ -56,6 +59,7 @@ func main() { authorizevalidators := flag.Uint64("authorizevalidators", 0, "Number of validators to preemptively authorize") txTimeout := flag.Duration("txtimeout", 10*time.Minute, "Timeout when waiting for a transaction to be included in a block") prod := flag.Bool("prod", false, "Whether to configure the rollup for production or testing") + isUsingFeeToken := flag.Bool("isUsingFeeToken", false, "true if the chain uses custom fee token") flag.Parse() l1ChainId := new(big.Int).SetUint64(*l1ChainIdUint) maxDataSize := new(big.Int).SetUint64(*maxDataSizeUint) @@ -92,15 +96,47 @@ func main() { if !common.IsHexAddress(*sequencerAddressString) && len(*sequencerAddressString) > 0 { panic("specified sequencer address is invalid") } + sequencerAddress := common.HexToAddress(*sequencerAddressString) + if !common.IsHexAddress(*ownerAddressString) { panic("please specify a valid rollup owner address") } + ownerAddress := common.HexToAddress(*ownerAddressString) + if *prod && !common.IsHexAddress(*loserEscrowAddressString) { panic("please specify a valid loser escrow address") } - sequencerAddress := common.HexToAddress(*sequencerAddressString) - ownerAddress := common.HexToAddress(*ownerAddressString) + var batchPosters []common.Address + if len(*batchPostersString) > 0 { + batchPostersArr := strings.Split(*batchPostersString, ",") + for _, address := range batchPostersArr { + if !common.IsHexAddress(address) { + log.Error("invalid address in batch posters array", "address", address) + continue + } + batchPosters = append(batchPosters, common.HexToAddress(address)) + } + if len(batchPosters) != len(batchPostersArr) { + panic("found at least one invalid address in batch posters array") + } + } + if len(batchPosters) == 0 { + log.Info("batch posters array was empty, defaulting to sequencer address") + batchPosters = append(batchPosters, sequencerAddress) + } + + var batchPosterManagerAddress common.Address + if common.IsHexAddress(*batchPosterManagerAddressString) { + batchPosterManagerAddress = common.HexToAddress(*batchPosterManagerAddressString) + } else { + if len(*batchPosterManagerAddressString) > 0 { + panic("please specify a valid batch poster manager address") + } + log.Info("batch poster manager address was empty, defaulting to owner address") + batchPosterManagerAddress = ownerAddress + } + loserEscrowAddress := common.HexToAddress(*loserEscrowAddressString) if sequencerAddress != (common.Address{}) && ownerAddress != l1TransactionOpts.From { panic("cannot specify sequencer address if owner is not deployer") @@ -146,11 +182,13 @@ func main() { ctx, l1Reader, l1TransactionOpts, - sequencerAddress, + batchPosters, + batchPosterManagerAddress, *authorizevalidators, arbnode.GenerateRollupConfig(*prod, moduleRoot, ownerAddress, &chainConfig, chainConfigJson, loserEscrowAddress), nativeToken, maxDataSize, + *isUsingFeeToken, ) if err != nil { flag.Usage() diff --git a/contracts b/contracts index 9a6bfad236..7c46876077 160000 --- a/contracts +++ b/contracts @@ -1 +1 @@ -Subproject commit 9a6bfad2363322099d399698751551ff044c7a72 +Subproject commit 7c46876077c6353c7ebdf9cd364710d357fa3914 diff --git a/das/syncing_fallback_storage.go b/das/syncing_fallback_storage.go index 91f2e522a7..c79cd80400 100644 --- a/das/syncing_fallback_storage.go +++ b/das/syncing_fallback_storage.go @@ -53,7 +53,7 @@ func init() { } BatchDeliveredID = sequencerInboxABI.Events[sequencerBatchDeliveredEvent].ID sequencerBatchDataABI = sequencerInboxABI.Events[sequencerBatchDataEvent] - addSequencerL2BatchFromOriginCallABI = sequencerInboxABI.Methods["addSequencerL2BatchFromOrigin"] + addSequencerL2BatchFromOriginCallABI = sequencerInboxABI.Methods["addSequencerL2BatchFromOrigin0"] } type SyncToStorageConfig struct { diff --git a/deploy/deploy.go b/deploy/deploy.go index 59760e2c21..5e7755cae3 100644 --- a/deploy/deploy.go +++ b/deploy/deploy.go @@ -31,7 +31,7 @@ func andTxSucceeded(ctx context.Context, l1Reader *headerreader.HeaderReader, tx return nil } -func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int) (common.Address, error) { +func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int, isUsingFeeToken bool) (common.Address, error) { client := l1Reader.Client() /// deploy eth based templates @@ -46,7 +46,7 @@ func deployBridgeCreator(ctx context.Context, l1Reader *headerreader.HeaderReade if err != nil { return common.Address{}, fmt.Errorf("blob basefee reader deploy error: %w", err) } - seqInboxTemplate, tx, _, err := bridgegen.DeploySequencerInbox(auth, client, maxDataSize, reader4844) + seqInboxTemplate, tx, _, err := bridgegen.DeploySequencerInbox(auth, client, maxDataSize, reader4844, isUsingFeeToken) err = andTxSucceeded(ctx, l1Reader, tx, err) if err != nil { return common.Address{}, fmt.Errorf("sequencer inbox deploy error: %w", err) @@ -161,8 +161,8 @@ func deployChallengeFactory(ctx context.Context, l1Reader *headerreader.HeaderRe return ospEntryAddr, challengeManagerAddr, nil } -func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) { - bridgeCreator, err := deployBridgeCreator(ctx, l1Reader, auth, maxDataSize) +func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReader, auth *bind.TransactOpts, maxDataSize *big.Int, isUsingFeeToken bool) (*rollupgen.RollupCreator, common.Address, common.Address, common.Address, error) { + bridgeCreator, err := deployBridgeCreator(ctx, l1Reader, auth, maxDataSize, isUsingFeeToken) if err != nil { return nil, common.Address{}, common.Address{}, common.Address{}, fmt.Errorf("bridge creator deploy error: %w", err) } @@ -234,12 +234,12 @@ func deployRollupCreator(ctx context.Context, l1Reader *headerreader.HeaderReade return rollupCreator, rollupCreatorAddress, validatorUtils, validatorWalletCreator, nil } -func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPoster common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address, maxDataSize *big.Int) (*chaininfo.RollupAddresses, error) { +func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReader, deployAuth *bind.TransactOpts, batchPosters []common.Address, batchPosterManager common.Address, authorizeValidators uint64, config rollupgen.Config, nativeToken common.Address, maxDataSize *big.Int, isUsingFeeToken bool) (*chaininfo.RollupAddresses, error) { if config.WasmModuleRoot == (common.Hash{}) { return nil, errors.New("no machine specified") } - rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize) + rollupCreator, _, validatorUtils, validatorWalletCreator, err := deployRollupCreator(ctx, parentChainReader, deployAuth, maxDataSize, isUsingFeeToken) if err != nil { return nil, fmt.Errorf("error deploying rollup creator: %w", err) } @@ -251,12 +251,13 @@ func DeployOnL1(ctx context.Context, parentChainReader *headerreader.HeaderReade deployParams := rollupgen.RollupCreatorRollupDeploymentParams{ Config: config, - BatchPoster: batchPoster, Validators: validatorAddrs, MaxDataSize: maxDataSize, NativeToken: nativeToken, DeployFactoriesToL2: false, MaxFeePerGasForRetryables: big.NewInt(0), // needed when utility factories are deployed + BatchPosters: batchPosters, + BatchPosterManager: batchPosterManager, } tx, err := rollupCreator.CreateRollup( diff --git a/system_tests/common_test.go b/system_tests/common_test.go index 1dbd0d81b3..0dda408aaa 100644 --- a/system_tests/common_test.go +++ b/system_tests/common_test.go @@ -666,11 +666,13 @@ func DeployOnTestL1( ctx, l1Reader, &l1TransactionOpts, - l1info.GetAddress("Sequencer"), + []common.Address{l1info.GetAddress("Sequencer")}, + l1info.GetAddress("RollupOwner"), 0, arbnode.GenerateRollupConfig(false, locator.LatestWasmModuleRoot(), l1info.GetAddress("RollupOwner"), chainConfig, serializedChainConfig, common.Address{}), nativeToken, maxDataSize, + false, ) Require(t, err) l1info.SetContract("Bridge", addresses.Bridge) diff --git a/system_tests/full_challenge_impl_test.go b/system_tests/full_challenge_impl_test.go index 362b134806..97deb199b1 100644 --- a/system_tests/full_challenge_impl_test.go +++ b/system_tests/full_challenge_impl_test.go @@ -205,10 +205,10 @@ func setupSequencerInboxStub(ctx context.Context, t *testing.T, l1Info *Blockcha _, err = EnsureTxSucceeded(ctx, l1Client, tx) Require(t, err) timeBounds := mocksgen.ISequencerInboxMaxTimeVariation{ - DelayBlocks: 10000, - FutureBlocks: 10000, - DelaySeconds: 10000, - FutureSeconds: 10000, + DelayBlocks: big.NewInt(10000), + FutureBlocks: big.NewInt(10000), + DelaySeconds: big.NewInt(10000), + FutureSeconds: big.NewInt(10000), } seqInboxAddr, tx, seqInbox, err := mocksgen.DeploySequencerInboxStub( &txOpts, @@ -218,6 +218,7 @@ func setupSequencerInboxStub(ctx context.Context, t *testing.T, l1Info *Blockcha timeBounds, big.NewInt(117964), reader4844, + false, ) Require(t, err) _, err = EnsureTxSucceeded(ctx, l1Client, tx) diff --git a/system_tests/meaningless_reorg_test.go b/system_tests/meaningless_reorg_test.go index e1715dc635..11b68b558b 100644 --- a/system_tests/meaningless_reorg_test.go +++ b/system_tests/meaningless_reorg_test.go @@ -27,7 +27,7 @@ func TestMeaninglessBatchReorg(t *testing.T) { Require(t, err) seqOpts := builder.L1Info.GetDefaultTransactOpts("Sequencer", ctx) - tx, err := seqInbox.AddSequencerL2BatchFromOrigin(&seqOpts, big.NewInt(1), nil, big.NewInt(1), common.Address{}) + tx, err := seqInbox.AddSequencerL2BatchFromOrigin0(&seqOpts, big.NewInt(1), nil, big.NewInt(1), common.Address{}, common.Big0, common.Big0) Require(t, err) batchReceipt, err := builder.L1.EnsureTxSucceeded(tx) Require(t, err) @@ -69,7 +69,7 @@ func TestMeaninglessBatchReorg(t *testing.T) { // Produce a new l1Block so that the batch ends up in a different l1Block than before builder.L1.TransferBalance(t, "User", "User", common.Big1, builder.L1Info) - tx, err = seqInbox.AddSequencerL2BatchFromOrigin(&seqOpts, big.NewInt(1), nil, big.NewInt(1), common.Address{}) + tx, err = seqInbox.AddSequencerL2BatchFromOrigin0(&seqOpts, big.NewInt(1), nil, big.NewInt(1), common.Address{}, common.Big0, common.Big0) Require(t, err) newBatchReceipt, err := builder.L1.EnsureTxSucceeded(tx) Require(t, err) diff --git a/system_tests/ipc_test.go b/system_tests/rpc_test.go similarity index 50% rename from system_tests/ipc_test.go rename to system_tests/rpc_test.go index 511a608e67..357cb8e4c1 100644 --- a/system_tests/ipc_test.go +++ b/system_tests/rpc_test.go @@ -7,8 +7,10 @@ import ( "context" "path/filepath" "testing" + "time" "github.com/ethereum/go-ethereum/ethclient" + "github.com/offchainlabs/nitro/solgen/go/mocksgen" ) func TestIpcRpc(t *testing.T) { @@ -25,3 +27,23 @@ func TestIpcRpc(t *testing.T) { _, err := ethclient.Dial(ipcPath) Require(t, err) } + +func TestPendingBlockTimeAndNumberAdvance(t *testing.T) { + t.Parallel() + ctx, cancel := context.WithCancel(context.Background()) + defer cancel() + + builder := NewNodeBuilder(ctx).DefaultConfig(t, true) + cleanup := builder.Build(t) + defer cleanup() + + auth := builder.L2Info.GetDefaultTransactOpts("Faucet", ctx) + + _, _, testTimeAndNr, err := mocksgen.DeployPendingBlkTimeAndNrAdvanceCheck(&auth, builder.L2.Client) + Require(t, err) + + time.Sleep(1 * time.Second) + + _, err = testTimeAndNr.IsAdvancing(&auth) + Require(t, err) +} diff --git a/system_tests/seqinbox_test.go b/system_tests/seqinbox_test.go index c4dd17ef53..e00bda8e84 100644 --- a/system_tests/seqinbox_test.go +++ b/system_tests/seqinbox_test.go @@ -355,7 +355,7 @@ func testSequencerInboxReaderImpl(t *testing.T, validator bool) { if i%5 == 0 { tx, err = seqInbox.AddSequencerL2Batch(&seqOpts, big.NewInt(int64(len(blockStates))), batchData, big.NewInt(1), gasRefunderAddr, big.NewInt(0), big.NewInt(0)) } else { - tx, err = seqInbox.AddSequencerL2BatchFromOrigin(&seqOpts, big.NewInt(int64(len(blockStates))), batchData, big.NewInt(1), gasRefunderAddr) + tx, err = seqInbox.AddSequencerL2BatchFromOrigin0(&seqOpts, big.NewInt(int64(len(blockStates))), batchData, big.NewInt(1), gasRefunderAddr, common.Big0, common.Big0) } Require(t, err) txRes, err := builder.L1.EnsureTxSucceeded(tx)