Skip to content

Commit

Permalink
Fix two batch posters being enabled in staker tests
Browse files Browse the repository at this point in the history
  • Loading branch information
PlasmaPower committed Aug 3, 2023
1 parent f5e7c28 commit 978eaeb
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 29 deletions.
1 change: 0 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -113,7 +113,6 @@ require (
github.com/hannahhoward/go-pubsub v0.0.0-20200423002714-8d62886cc36e // indirect
github.com/hashicorp/errwrap v1.1.0 // indirect
github.com/hashicorp/go-multierror v1.1.1 // indirect
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e // indirect
github.com/ipfs/bbloom v0.0.4 // indirect
github.com/ipfs/go-bitfield v1.1.0 // indirect
github.com/ipfs/go-block-format v0.1.1 // indirect
Expand Down
2 changes: 0 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -600,8 +600,6 @@ github.com/hashicorp/vault/api v1.0.4/go.mod h1:gDcqh3WGcR1cpF5AJz/B1UFheUEneMoI
github.com/hashicorp/vault/sdk v0.1.13/go.mod h1:B+hVj7TpuQY1Y/GPbCpffmgd+tSEwvhkWnjtSYCaS2M=
github.com/hashicorp/yamux v0.0.0-20180604194846-3520598351bb/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/hashicorp/yamux v0.0.0-20181012175058-2f1d1f20f75d/go.mod h1:+NfK9FKeTrX5uv1uIXGdwYDTeHna2qgaIlx54MXqjAM=
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e h1:pIYdhNkDh+YENVNi3gto8n9hAmRxKxoar0iE6BLucjw=
github.com/holiman/big v0.0.0-20221017200358-a027dc42d04e/go.mod h1:j9cQbcqHQujT0oKJ38PylVfqohClLr3CvDC+Qcg+lhU=
github.com/holiman/bloomfilter/v2 v2.0.3 h1:73e0e/V0tCydx14a0SCYS/EWCxgwLZ18CZcZKVu0fao=
github.com/holiman/bloomfilter/v2 v2.0.3/go.mod h1:zpoh+gs7qcpqrHr3dB55AMiJwo0iURXE7ZOP9L9hSkA=
github.com/holiman/uint256 v1.2.0 h1:gpSYcPLWGv4sG43I2mVLiDZCNDh/EpGjSk8tmtxitHM=
Expand Down
44 changes: 18 additions & 26 deletions system_tests/staker_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ import (
"github.com/offchainlabs/nitro/validator/valnode"
)

func makeBackgroundTxs(ctx context.Context, l2info *BlockchainTestInfo, l2clientA arbutil.L1Interface, l2clientB arbutil.L1Interface, faultyStaker bool) error {
func makeBackgroundTxs(ctx context.Context, l2info *BlockchainTestInfo, l2clientA arbutil.L1Interface) error {
for i := uint64(0); ctx.Err() == nil; i++ {
l2info.Accounts["BackgroundUser"].Nonce = i
tx := l2info.PrepareTx("BackgroundUser", "BackgroundUser", l2info.TransferGas, common.Big0, nil)
Expand All @@ -47,19 +47,6 @@ func makeBackgroundTxs(ctx context.Context, l2info *BlockchainTestInfo, l2client
if err != nil {
return err
}
if faultyStaker {
// Create a different transaction for the second node
l2info.Accounts["BackgroundUser"].Nonce = i
tx = l2info.PrepareTx("BackgroundUser", "BackgroundUser", l2info.TransferGas, common.Big1, nil)
err = l2clientB.SendTransaction(ctx, tx)
if err != nil {
return err
}
_, err = EnsureTxSucceeded(ctx, l2clientB, tx)
if err != nil {
return err
}
}
}
return nil
}
Expand All @@ -82,7 +69,11 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
if faultyStaker {
l2info.GenerateGenesisAccount("FaultyAddr", common.Big1)
}
l2clientB, l2nodeB := Create2ndNodeWithConfig(t, ctx, l2nodeA, l1stack, l1info, &l2info.ArbInitData, arbnode.ConfigDefaultL1Test(), nil)
config := arbnode.ConfigDefaultL1Test()
config.Sequencer.Enable = false
config.DelayedSequencer.Enable = false
config.BatchPoster.Enable = false
_, l2nodeB := Create2ndNodeWithConfig(t, ctx, l2nodeA, l1stack, l1info, &l2info.ArbInitData, config, nil)
defer l2nodeB.StopAndWait()

nodeAGenesis := l2nodeA.Execution.Backend.APIBackend().CurrentHeader().Hash()
Expand Down Expand Up @@ -132,6 +123,9 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
_, err = EnsureTxSucceeded(ctx, l1client, tx)
Require(t, err)

validatorUtils, err := rollupgen.NewValidatorUtils(l2nodeA.DeployInfo.ValidatorUtils, l1client)
Require(t, err)

valConfig := staker.L1ValidatorConfig{}

valWalletA, err := staker.NewContractValidatorWallet(nil, l2nodeA.DeployInfo.ValidatorWalletCreator, l2nodeA.DeployInfo.Rollup, l2nodeA.L1Reader, &l1authA, 0, func(common.Address) {})
Expand Down Expand Up @@ -243,12 +237,6 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
Require(t, err)
_, err = EnsureTxSucceeded(ctx, l2clientA, tx)
Require(t, err)
if faultyStaker {
err = l2clientB.SendTransaction(ctx, tx)
Require(t, err)
_, err = EnsureTxSucceeded(ctx, l2clientB, tx)
Require(t, err)
}

// Continually make L2 transactions in a background thread
backgroundTxsCtx, cancelBackgroundTxs := context.WithCancel(ctx)
Expand All @@ -259,7 +247,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
})()
go (func() {
defer close(backgroundTxsShutdownChan)
err := makeBackgroundTxs(backgroundTxsCtx, l2info, l2clientA, l2clientB, faultyStaker)
err := makeBackgroundTxs(backgroundTxsCtx, l2info, l2clientA)
if !errors.Is(err, context.Canceled) {
log.Warn("error making background txs", "err", err)
}
Expand Down Expand Up @@ -302,8 +290,11 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
if !challengeMangerTimedOut {
// Upgrade the ChallengeManager contract to an implementation which says challenges are always timed out

mockImpl, _, _, err := mocksgen.DeployTimedOutChallengeManager(&deployAuth, l1client)
mockImpl, tx, _, err := mocksgen.DeployTimedOutChallengeManager(&deployAuth, l1client)
Require(t, err)
_, err = EnsureTxSucceeded(ctx, l1client, tx)
Require(t, err)

managerAddr := valWalletA.ChallengeManagerAddress()
// 0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103
proxyAdminSlot := common.BigToHash(arbmath.BigSub(crypto.Keccak256Hash([]byte("eip1967.proxy.admin")).Big(), common.Big1))
Expand All @@ -316,7 +307,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)

proxyAdmin, err := mocksgen.NewProxyAdminForBinding(proxyAdminAddr, l1client)
Require(t, err)
tx, err := proxyAdmin.Upgrade(&deployAuth, managerAddr, mockImpl)
tx, err = proxyAdmin.Upgrade(&deployAuth, managerAddr, mockImpl)
Require(t, err)
_, err = EnsureTxSucceeded(ctx, l1client, tx)
Require(t, err)
Expand All @@ -342,9 +333,9 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
Require(t, err, "EnsureTxSucceeded failed for staker", stakerName, "tx")
}
if faultyStaker {
challengeAddr, err := rollup.CurrentChallenge(&bind.CallOpts{}, valWalletAddrA)
conflictInfo, err := validatorUtils.FindStakerConflict(&bind.CallOpts{}, l2nodeA.DeployInfo.Rollup, l1authA.From, l1authB.From, big.NewInt(1024))
Require(t, err)
if challengeAddr != 0 {
if staker.ConflictType(conflictInfo.Ty) == staker.CONFLICT_TYPE_FOUND {
cancelBackgroundTxs()
}
}
Expand All @@ -357,6 +348,7 @@ func stakerTestImpl(t *testing.T, faultyStaker bool, honestStakerInactive bool)
if isHonestZombie {
Fatal(t, "staker A became a zombie")
}
fmt.Printf("watchtower staker acting:\n")
watchTx, err := stakerC.Act(ctx)
if err != nil && !strings.Contains(err.Error(), "catch up") {
Require(t, err, "watchtower staker failed to act")
Expand Down

0 comments on commit 978eaeb

Please sign in to comment.