Skip to content

Commit

Permalink
Merge pull request #2127 from OffchainLabs/bump-contracts-pin
Browse files Browse the repository at this point in the history
  • Loading branch information
ganeshvanahalli committed Feb 27, 2024
2 parents 58e4b50 + 7f1678f commit 8683407
Show file tree
Hide file tree
Showing 11 changed files with 89 additions and 25 deletions.
8 changes: 4 additions & 4 deletions arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -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),
},
}
}
Expand Down
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
44 changes: 41 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,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")
Expand Down Expand Up @@ -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()
Expand Down
2 changes: 1 addition & 1 deletion contracts
Submodule contracts updated 53 files
+48 −0 .github/workflows/audit-ci.yml
+3 −0 .github/workflows/contract-tests.yml
+1 −0 .gitignore
+1 −1 .solhint.json
+13 −11 LICENSE.md
+14 −0 README.md
+56 −0 audit-ci.jsonc
+4 −1 deploy/SequencerInboxStubCreator.js
+14 −11 package.json
+1 −154 scripts/deployment.ts
+191 −0 scripts/deploymentUtils.ts
+107 −0 scripts/upgrade/deploy4844.ts
+2 −0 src/bridge/GasRefunder.sol
+34 −6 src/bridge/ISequencerInbox.sol
+122 −99 src/bridge/SequencerInbox.sol
+12 −9 src/libraries/Error.sol
+1 −1 src/libraries/GasRefundEnabled.sol
+4 −0 src/libraries/IReader4844.sol
+2 −2 src/mocks/InboxStub.sol
+22 −0 src/mocks/PendingBlkTimeAndNrAdvanceCheck.sol
+7 −6 src/mocks/SequencerInboxStub.sol
+4 −0 src/mocks/Simple.sol
+10 −4 src/rollup/RollupCreator.sol
+101 −9 test/contract/arbRollup.spec.ts
+4 −59 test/contract/sequencerInbox.spec.4844.ts
+53 −8 test/contract/sequencerInboxForceInclude.spec.ts
+2 −2 test/contract/toolkit4844.ts
+12 −8 test/contract/validatorWallet.spec.ts
+28 −8 test/foundry/AbsInbox.t.sol
+4 −7 test/foundry/BridgeCreator.t.sol
+20 −14 test/foundry/ChallengeManager.t.sol
+24 −9 test/foundry/ERC20Bridge.t.sol
+2 −1 test/foundry/ERC20Inbox.t.sol
+108 −54 test/foundry/RollupCreator.t.sol
+382 −84 test/foundry/SequencerInbox.t.sol
+5 −5 test/foundry/util/TestUtil.sol
+25 −0 test/signatures/Bridge
+10 −0 test/signatures/BridgeCreator
+19 −0 test/signatures/ChallengeManager
+16 −0 test/signatures/DeployHelper
+26 −0 test/signatures/ERC20Bridge
+22 −0 test/signatures/ERC20Inbox
+23 −0 test/signatures/ERC20Outbox
+30 −0 test/signatures/Inbox
+22 −0 test/signatures/Outbox
+73 −0 test/signatures/RollupAdminLogic
+44 −0 test/signatures/RollupCore
+16 −0 test/signatures/RollupCreator
+71 −0 test/signatures/RollupUserLogic
+39 −0 test/signatures/SequencerInbox
+17 −0 test/signatures/test-sigs.bash
+2 −1 test/storage/SequencerInbox
+1,088 −5,172 yarn.lock
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
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
9 changes: 5 additions & 4 deletions system_tests/full_challenge_impl_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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
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
22 changes: 22 additions & 0 deletions system_tests/ipc_test.go → system_tests/rpc_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,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)
}
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 8683407

Please sign in to comment.