Skip to content

Commit

Permalink
Bump contracts pin and add test to verify pending block's time and nu…
Browse files Browse the repository at this point in the history
…mber advance
  • Loading branch information
ganeshvanahalli committed Feb 2, 2024
1 parent 4128f24 commit bd73a56
Show file tree
Hide file tree
Showing 11 changed files with 75 additions and 18 deletions.
2 changes: 1 addition & 1 deletion arbnode/sequencer_inbox.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
38 changes: 35 additions & 3 deletions cmd/deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
"fmt"
"math/big"
"os"
"strings"
"time"

"github.com/offchainlabs/nitro/cmd/chaininfo"
Expand Down Expand Up @@ -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")
Expand All @@ -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)
Expand Down Expand Up @@ -92,15 +96,41 @@ 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.Warn("invalid address in batch posters array", "address", address)
continue
}
batchPosters = append(batchPosters, common.HexToAddress(address))
}
}
if len(batchPosters) == 0 {
log.Info("batch posters array was empty or invalid, defaulting to sequencer address")
batchPosters = append(batchPosters, sequencerAddress)
}

var batchPosterManagerAddress common.Address
if common.IsHexAddress(*batchPosterManagerAddressString) {
batchPosterManagerAddress = common.HexToAddress(*batchPosterManagerAddressString)
} else {
log.Info("batch poster manager address was empty or invalid, 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")
Expand Down Expand Up @@ -146,11 +176,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()
Expand Down
2 changes: 1 addition & 1 deletion das/syncing_fallback_storage.go
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down
15 changes: 8 additions & 7 deletions deploy/deploy.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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)
Expand Down Expand Up @@ -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)
}
Expand Down Expand Up @@ -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)
}
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion go-ethereum
4 changes: 3 additions & 1 deletion system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions system_tests/full_challenge_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
21 changes: 21 additions & 0 deletions system_tests/ipc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -25,3 +27,22 @@ func TestIpcRpc(t *testing.T) {
_, err := ethclient.Dial(ipcPath)
Require(t, err)
}

func TestPendingBlockTimeAndNumberAdvance(t *testing.T) {
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)
}
4 changes: 2 additions & 2 deletions system_tests/meaningless_reorg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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)
Expand Down
2 changes: 1 addition & 1 deletion system_tests/seqinbox_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit bd73a56

Please sign in to comment.