Skip to content

Commit

Permalink
multiple batches at the same time
Browse files Browse the repository at this point in the history
  • Loading branch information
amsanghi committed Sep 21, 2023
1 parent d57c770 commit 00e0a18
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 40 deletions.
2 changes: 1 addition & 1 deletion contracts
70 changes: 31 additions & 39 deletions system_tests/assertion_on_large_number_of_blocks_test.go
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
// Copyright 2023, Offchain Labs, Inc.
// For license information, see https://github.com/offchainlabs/bold/blob/main/LICENSE

//go:build assertion_on_large_number_of_batch_test
// +build assertion_on_large_number_of_batch_test

package arbtest

import (
"context"
"encoding/json"
"github.com/ethereum/go-ethereum/rlp"
"github.com/offchainlabs/nitro/arbcompress"
"github.com/offchainlabs/nitro/arbstate"
"math/big"
"os"
"testing"
Expand All @@ -28,11 +28,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"

"github.com/offchainlabs/nitro/arbcompress"
"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/arbstate"
"github.com/offchainlabs/nitro/cmd/chaininfo"
"github.com/offchainlabs/nitro/staker"
"github.com/offchainlabs/nitro/validator/server_common"
Expand Down Expand Up @@ -97,7 +93,7 @@ func setupAndPostBatches(t *testing.T, ctx context.Context) (*arbnode.Node, prot
glogger.Verbosity(log.LvlInfo)
log.Root().SetHandler(glogger)

initialBalance := new(big.Int).Lsh(big.NewInt(1), 200)
initialBalance := new(big.Int).Lsh(big.NewInt(1), 250)
l1Info := NewL1TestInfo(t)
l1Info.GenerateGenesisAccount("deployer", initialBalance)
l1Info.GenerateGenesisAccount("asserter", initialBalance)
Expand Down Expand Up @@ -141,9 +137,7 @@ func setupAndPostBatches(t *testing.T, ctx context.Context) (*arbnode.Node, prot
l1Info.SetContract("Inbox", rollupAddresses.Inbox)
initMessage := getInitMessage(ctx, t, l1Backend, rollupAddresses)

sequencerTxOpts := l1Info.GetDefaultTransactOpts("sequencer", ctx)

bridgeAddr, seqInbox, seqInboxAddr := setupSequencerInboxStub(ctx, t, l1Info, l1Backend, chainConfig)
bridgeAddr, _, seqInboxAddr := setupSequencerInboxStub(ctx, t, l1Info, l1Backend, chainConfig)

l2Info, l2Stack, l2ChainDb, l2ArbDb, l2Blockchain := createL2BlockChainWithStackConfig(t, nil, "", chainConfig, initMessage, nil, nil)
rollupAddresses.Bridge = bridgeAddr
Expand All @@ -163,37 +157,35 @@ func setupAndPostBatches(t *testing.T, ctx context.Context) (*arbnode.Node, prot
_, err = rollup.SetMinimumAssertionPeriod(&deployAuth, big.NewInt(1))
Require(t, err)

for i := 0; i < 1024; i++ {
emptyArray, err := rlp.EncodeToBytes([]uint8{0})
Require(t, err)
var out []byte
for i := 0; i < arbstate.MaxSegmentsPerSequencerMessage-1; i++ {
out = append(out, emptyArray...)
}
batch := []uint8{0}
compressed, err := arbcompress.CompressWell(out)
Require(t, err)
batch = append(batch, compressed...)
emptyArray, err := rlp.EncodeToBytes([]uint8{0})
Require(t, err)
var out []byte
for i := 0; i < arbstate.MaxSegmentsPerSequencerMessage-1; i++ {
out = append(out, emptyArray...)
}
batch := []uint8{0}
compressed, err := arbcompress.CompressWell(out)
Require(t, err)
batch = append(batch, compressed...)

seqNum := new(big.Int).Lsh(common.Big1, 256)
seqNum.Sub(seqNum, common.Big1)
tx, err := seqInbox.AddSequencerL2BatchFromOrigin0(&sequencerTxOpts, seqNum, batch, big.NewInt(1), common.Address{}, big.NewInt(0), big.NewInt(0))
Require(t, err)
receipt, err := EnsureTxSucceeded(ctx, l1Backend, tx)
Require(t, err)
txOpts := l1Info.GetDefaultTransactOpts("deployer", ctx)
_, simple := deploySimple(t, ctx, txOpts, l1Backend)
tx, err = simple.PostManyBatches(&txOpts, seqInboxAddr, batch, big.NewInt(1024))

Check failure on line 173 in system_tests/assertion_on_large_number_of_blocks_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

simple.PostManyBatches undefined (type *"github.com/offchainlabs/nitro/solgen/go/mocksgen".Simple has no field or method PostManyBatches) (typecheck)

Check failure on line 173 in system_tests/assertion_on_large_number_of_blocks_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

simple.PostManyBatches undefined (type *"github.com/offchainlabs/nitro/solgen/go/mocksgen".Simple has no field or method PostManyBatches) (typecheck)

Check failure on line 173 in system_tests/assertion_on_large_number_of_blocks_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

simple.PostManyBatches undefined (type *"github.com/offchainlabs/nitro/solgen/go/mocksgen".Simple has no field or method PostManyBatches) (typecheck)
Require(t, err)
receipt, err := EnsureTxSucceeded(ctx, l1Backend, tx)
Require(t, err)

nodeSeqInbox, err := arbnode.NewSequencerInbox(l1Backend, seqInboxAddr, 0)
Require(t, err)
batches, err := nodeSeqInbox.LookupBatchesInRange(ctx, receipt.BlockNumber, receipt.BlockNumber)
Require(t, err)
if len(batches) == 0 {
Fatal(t, "batch not found after AddSequencerL2BatchFromOrigin")
}
err = l2Node.InboxTracker.AddSequencerBatches(ctx, l1Backend, batches)
Require(t, err)
_, err = l2Node.InboxTracker.GetBatchMetadata(0)
Require(t, err, "failed to get batch metadata after adding batch:")
nodeSeqInbox, err := arbnode.NewSequencerInbox(l1Backend, seqInboxAddr, 0)
Require(t, err)
batches, err := nodeSeqInbox.LookupBatchesInRange(ctx, receipt.BlockNumber, receipt.BlockNumber)
Require(t, err)
if len(batches) == 0 {
Fatal(t, "batch not found after AddSequencerL2BatchFromOrigin")
}
err = l2Node.InboxTracker.AddSequencerBatches(ctx, l1Backend, batches)
Require(t, err)
_, err = l2Node.InboxTracker.GetBatchMetadata(0)
Require(t, err, "failed to get batch metadata after adding batch:")
return l2Node, assertionChain
}

Expand Down

0 comments on commit 00e0a18

Please sign in to comment.