Skip to content

Commit

Permalink
Merge pull request #2811 from OffchainLabs/bold-overflow-test
Browse files Browse the repository at this point in the history
Test an overflow assertion
  • Loading branch information
eljobe authored Nov 28, 2024
2 parents 0e6e2a8 + 1ad24f2 commit c63db41
Show file tree
Hide file tree
Showing 5 changed files with 375 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bold
39 changes: 33 additions & 6 deletions system_tests/bold_challenge_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,22 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp
ownerBal := big.NewInt(params.Ether)
ownerBal.Mul(ownerBal, big.NewInt(1_000_000))
l2info.GenerateGenesisAccount("Owner", ownerBal)
sconf := setup.RollupStackConfig{
UseMockBridge: false,
UseMockOneStepProver: false,
MinimumAssertionPeriod: 0,
}

_, l2nodeA, _, _, l1info, _, l1client, l1stack, assertionChain, stakeTokenAddr := createTestNodeOnL1ForBoldProtocol(t, ctx, true, nil, l2chainConfig, nil, l2info)
_, l2nodeA, _, _, l1info, _, l1client, l1stack, assertionChain, stakeTokenAddr := createTestNodeOnL1ForBoldProtocol(
t,
ctx,
true,
nil,
l2chainConfig,
nil,
sconf,
l2info,
)
defer requireClose(t, l1stack)
defer l2nodeA.StopAndWait()

Expand All @@ -109,7 +123,18 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp
go keepChainMoving(t, ctx, l1info, l1client)

l2nodeConfig := arbnode.ConfigDefaultL1Test()
_, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol(t, ctx, l2nodeA, l1stack, l1info, &l2info.ArbInitData, l2nodeConfig, nil, stakeTokenAddr)
_, l2nodeB, _ := create2ndNodeWithConfigForBoldProtocol(
t,
ctx,
l2nodeA,
l1stack,
l1info,
&l2info.ArbInitData,
l2nodeConfig,
nil,
sconf,
stakeTokenAddr,
)
defer l2nodeB.StopAndWait()

genesisA, err := l2nodeA.Execution.ResultAtPos(0)
Expand Down Expand Up @@ -494,6 +519,7 @@ func createTestNodeOnL1ForBoldProtocol(
nodeConfig *arbnode.Config,
chainConfig *params.ChainConfig,
_ *node.Config,
rollupStackConf setup.RollupStackConfig,
l2infoIn info,
) (
l2info info, currentNode *arbnode.Node, l2client *ethclient.Client, l2stack *node.Node,
Expand Down Expand Up @@ -554,7 +580,7 @@ func createTestNodeOnL1ForBoldProtocol(
Require(t, err)
l1TransactionOpts.Value = nil

addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, stakeToken)
addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, rollupStackConf, stakeToken)
rollupUser, err := rollupgen.NewRollupUserLogic(addresses.Rollup, l1client)
Require(t, err)
chalManagerAddr, err := rollupUser.ChallengeManager(&bind.CallOpts{})
Expand Down Expand Up @@ -635,6 +661,7 @@ func deployContractsOnly(
l1info info,
backend *ethclient.Client,
chainId *big.Int,
rollupStackConf setup.RollupStackConfig,
stakeToken common.Address,
) *chaininfo.RollupAddresses {
l1TransactionOpts := l1info.GetDefaultTransactOpts("RollupOwner", ctx)
Expand Down Expand Up @@ -679,8 +706,7 @@ func deployContractsOnly(
&l1TransactionOpts,
l1info.GetAddress("Sequencer"),
cfg,
false, // do not use mock bridge.
false, // do not use a mock one-step prover
rollupStackConf,
)
Require(t, err)

Expand Down Expand Up @@ -747,6 +773,7 @@ func create2ndNodeWithConfigForBoldProtocol(
l2InitData *statetransfer.ArbosInitializationInfo,
nodeConfig *arbnode.Config,
stackConfig *node.Config,
rollupStackConf setup.RollupStackConfig,
stakeTokenAddr common.Address,
) (*ethclient.Client, *arbnode.Node, *solimpl.AssertionChain) {
fatalErrChan := make(chan error, 10)
Expand All @@ -757,7 +784,7 @@ func create2ndNodeWithConfigForBoldProtocol(
Fatal(t, "not geth execution node")
}
chainConfig := firstExec.ArbInterface.BlockChain().Config()
addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, stakeTokenAddr)
addresses := deployContractsOnly(t, ctx, l1info, l1client, chainConfig.ChainID, rollupStackConf, stakeTokenAddr)

l1info.SetContract("EvilBridge", addresses.Bridge)
l1info.SetContract("EvilSequencerInbox", addresses.SequencerInbox)
Expand Down
17 changes: 16 additions & 1 deletion system_tests/bold_state_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ import (
"github.com/offchainlabs/bold/solgen/go/mocksgen"
prefixproofs "github.com/offchainlabs/bold/state-commitments/prefix-proofs"
mockmanager "github.com/offchainlabs/bold/testing/mocks/state-provider"
"github.com/offchainlabs/bold/testing/setup"
)

func TestChallengeProtocolBOLD_Bisections(t *testing.T) {
Expand Down Expand Up @@ -354,8 +355,22 @@ func setupBoldStateProvider(t *testing.T, ctx context.Context, blockChallengeHei
ownerBal := big.NewInt(params.Ether)
ownerBal.Mul(ownerBal, big.NewInt(1_000_000))
l2info.GenerateGenesisAccount("Owner", ownerBal)
sconf := setup.RollupStackConfig{
UseMockBridge: false,
UseMockOneStepProver: false,
MinimumAssertionPeriod: 0,
}

_, l2node, _, _, l1info, _, l1client, l1stack, _, _ := createTestNodeOnL1ForBoldProtocol(t, ctx, false, nil, l2chainConfig, nil, l2info)
_, l2node, _, _, l1info, _, l1client, l1stack, _, _ := createTestNodeOnL1ForBoldProtocol(
t,
ctx,
false,
nil,
l2chainConfig,
nil,
sconf,
l2info,
)

valnode.TestValidationConfig.UseJit = false
_, valStack := createTestValidationNode(t, ctx, &valnode.TestValidationConfig)
Expand Down
7 changes: 5 additions & 2 deletions system_tests/common_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1350,8 +1350,11 @@ func deployOnParentChain(
&parentChainTransactionOpts,
parentChainInfo.GetAddress("Sequencer"),
cfg,
false, // do not use mock bridge.
false, // do not use a mock one-step prover
setup.RollupStackConfig{
UseMockBridge: false,
UseMockOneStepProver: false,
MinimumAssertionPeriod: 0,
},
)
Require(t, err)
addresses = &chaininfo.RollupAddresses{
Expand Down
Loading

0 comments on commit c63db41

Please sign in to comment.