Skip to content

Commit

Permalink
Sync in the latests changes from the bold repo
Browse files Browse the repository at this point in the history
This includes wiring the HeaderProvider through to the challenge stack and a
slightly clunky backend wrapper around the ethereum client instances.
  • Loading branch information
eljobe committed Nov 22, 2024
1 parent 72ba88d commit eed7b12
Show file tree
Hide file tree
Showing 6 changed files with 30 additions and 18 deletions.
2 changes: 1 addition & 1 deletion bold
Submodule bold updated 50 files
+1 −1 assertions/BUILD.bazel
+4 −3 assertions/manager.go
+2 −1 assertions/manager_test.go
+3 −6 assertions/poster.go
+3 −14 assertions/sync.go
+1 −0 chain-abstraction/BUILD.bazel
+24 −11 chain-abstraction/interfaces.go
+1 −0 chain-abstraction/sol-implementation/BUILD.bazel
+14 −23 chain-abstraction/sol-implementation/assertion_chain.go
+4 −4 chain-abstraction/sol-implementation/assertion_chain_test.go
+57 −21 chain-abstraction/sol-implementation/edge_challenge_manager.go
+11 −11 chain-abstraction/sol-implementation/edge_challenge_manager_test.go
+7 −0 chain-abstraction/sol-implementation/metrics_contract_backend.go
+15 −0 chain-abstraction/sol-implementation/tracked_contract_backend_test.go
+9 −10 chain-abstraction/sol-implementation/transact.go
+2 −1 chain-abstraction/sol-implementation/types.go
+1 −0 challenge-manager/chain-watcher/BUILD.bazel
+72 −49 challenge-manager/chain-watcher/watcher.go
+18 −2 challenge-manager/chain-watcher/watcher_test.go
+1 −0 challenge-manager/challenge-tree/BUILD.bazel
+18 −16 challenge-manager/challenge-tree/add_edge.go
+1 −1 challenge-manager/challenge-tree/ancestors.go
+1 −1 challenge-manager/challenge-tree/inherited_timer.go
+10 −1 challenge-manager/challenge-tree/local_timer.go
+32 −1 challenge-manager/challenge-tree/mock/edge.go
+77 −125 challenge-manager/challenge-tree/paths.go
+191 −0 challenge-manager/challenge-tree/paths_edge_cases_test.go
+28 −42 challenge-manager/challenge-tree/paths_test.go
+17 −15 challenge-manager/challenge-tree/tree.go
+17 −21 challenge-manager/challenge-tree/tree_test.go
+1 −0 challenge-manager/edge-tracker/BUILD.bazel
+39 −46 challenge-manager/edge-tracker/challenge_confirmation.go
+155 −87 challenge-manager/edge-tracker/tracker.go
+18 −19 challenge-manager/manager.go
+16 −5 challenge-manager/manager_test.go
+19 −22 challenge-manager/stack.go
+10 −3 testing/endtoend/BUILD.bazel
+1 −4 testing/endtoend/backend/BUILD.bazel
+5 −6 testing/endtoend/backend/anvil_local.go
+0 −34 testing/endtoend/backend/anvil_local_test.go
+23 −31 testing/endtoend/e2e_test.go
+59 −6 testing/endtoend/expectations.go
+53 −0 testing/endtoend/headers.go
+24 −14 testing/endtoend/helpers_test.go
+16 −4 testing/mocks/mocks.go
+1 −0 testing/setup/BUILD.bazel
+6 −10 testing/setup/rollup_stack.go
+59 −18 testing/setup/simulated_backend_wrapper.go
+13 −0 util/BUILD.bazel
+39 −0 util/backend.go
19 changes: 13 additions & 6 deletions staker/bold/bold_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,21 @@ import (
"github.com/ethereum/go-ethereum"
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/rpc"

protocol "github.com/offchainlabs/bold/chain-abstraction"
solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation"
challengemanager "github.com/offchainlabs/bold/challenge-manager"
boldtypes "github.com/offchainlabs/bold/challenge-manager/types"
l2stateprovider "github.com/offchainlabs/bold/layer2-state-provider"
boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen"
"github.com/offchainlabs/bold/util"
"github.com/offchainlabs/nitro/arbnode/dataposter"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/staker"
legacystaker "github.com/offchainlabs/nitro/staker/legacy"
"github.com/offchainlabs/nitro/util/headerreader"
"github.com/offchainlabs/nitro/util/stopwaiter"
"github.com/offchainlabs/nitro/validator"
)
Expand Down Expand Up @@ -144,8 +146,9 @@ type BOLDStaker struct {
blockValidator *staker.BlockValidator
statelessBlockValidator *staker.StatelessBlockValidator
rollupAddress common.Address
client bind.ContractBackend
l1Reader *headerreader.HeaderReader
lastWasmModuleRoot common.Hash
client protocol.ChainBackend
callOpts bind.CallOpts
wallet legacystaker.ValidatorWalletInterface
stakedNotifiers []legacystaker.LatestStakedNotifier
Expand All @@ -157,7 +160,7 @@ func NewBOLDStaker(
rollupAddress common.Address,
callOpts bind.CallOpts,
txOpts *bind.TransactOpts,
client *ethclient.Client,
l1Reader *headerreader.HeaderReader,
blockValidator *staker.BlockValidator,
statelessBlockValidator *staker.StatelessBlockValidator,
config *BoldConfig,
Expand All @@ -166,7 +169,8 @@ func NewBOLDStaker(
stakedNotifiers []legacystaker.LatestStakedNotifier,
confirmedNotifiers []legacystaker.LatestConfirmedNotifier,
) (*BOLDStaker, error) {
manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, client, blockValidator, statelessBlockValidator, config, dataPoster)
wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber)
manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster)
if err != nil {
return nil, err
}
Expand All @@ -176,7 +180,8 @@ func NewBOLDStaker(
blockValidator: blockValidator,
statelessBlockValidator: statelessBlockValidator,
rollupAddress: rollupAddress,
client: client,
l1Reader: l1Reader,
client: wrappedClient,
callOpts: callOpts,
wallet: wallet,
stakedNotifiers: stakedNotifiers,
Expand Down Expand Up @@ -340,7 +345,8 @@ func newBOLDChallengeManager(
ctx context.Context,
rollupAddress common.Address,
txOpts *bind.TransactOpts,
client *ethclient.Client,
l1Reader *headerreader.HeaderReader,
client protocol.ChainBackend,
blockValidator *staker.BlockValidator,
statelessBlockValidator *staker.StatelessBlockValidator,
config *BoldConfig,
Expand Down Expand Up @@ -403,6 +409,7 @@ func newBOLDChallengeManager(
challengemanager.StackWithPostingInterval(postingInterval),
challengemanager.StackWithConfirmationInterval(confirmingInterval),
challengemanager.StackWithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes),
challengemanager.StackWithHeaderProvider(l1Reader),
}
if config.API {
apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort)
Expand Down
9 changes: 4 additions & 5 deletions staker/multi_protocol/multi_protocol_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@ import (

"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/ethclient"
"github.com/ethereum/go-ethereum/log"

"github.com/offchainlabs/bold/solgen/go/bridgegen"
Expand All @@ -29,7 +28,7 @@ type MultiProtocolStaker struct {
confirmedNotifiers []legacystaker.LatestConfirmedNotifier
statelessBlockValidator *staker.StatelessBlockValidator
wallet legacystaker.ValidatorWalletInterface
client *ethclient.Client
l1Reader *headerreader.HeaderReader
blockValidator *staker.BlockValidator
callOpts bind.CallOpts
boldConfig *boldstaker.BoldConfig
Expand Down Expand Up @@ -83,7 +82,7 @@ func NewMultiProtocolStaker(
confirmedNotifiers: confirmedNotifiers,
statelessBlockValidator: statelessBlockValidator,
wallet: wallet,
client: l1Reader.Client(),
l1Reader: l1Reader,
blockValidator: blockValidator,
callOpts: callOpts,
boldConfig: boldConfig,
Expand Down Expand Up @@ -157,7 +156,7 @@ func (m *MultiProtocolStaker) isBoldActive(ctx context.Context) (bool, common.Ad
if err != nil {
return false, addr, err
}
userLogic, err := boldrollup.NewRollupUserLogic(rollupAddress, m.client)
userLogic, err := boldrollup.NewRollupUserLogic(rollupAddress, m.l1Reader.Client())
if err != nil {
return false, addr, err
}
Expand Down Expand Up @@ -213,7 +212,7 @@ func (m *MultiProtocolStaker) setupBoldStaker(
rollupAddress,
*m.getCallOpts(ctx),
auth,
m.client,
m.l1Reader,
m.blockValidator,
m.statelessBlockValidator,
m.boldConfig,
Expand Down
10 changes: 6 additions & 4 deletions system_tests/bold_challenge_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rlp"
"github.com/ethereum/go-ethereum/rpc"
protocol "github.com/offchainlabs/bold/chain-abstraction"
solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation"
challengemanager "github.com/offchainlabs/bold/challenge-manager"
Expand All @@ -40,6 +41,7 @@ import (
"github.com/offchainlabs/bold/solgen/go/rollupgen"
challengetesting "github.com/offchainlabs/bold/testing"
"github.com/offchainlabs/bold/testing/setup"
butil "github.com/offchainlabs/bold/util"
"github.com/offchainlabs/nitro/arbcompress"
"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/arbnode/dataposter/storage"
Expand Down Expand Up @@ -230,7 +232,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp
assertionChain.RollupAddress(),
chalManagerAddr.Address(),
&evilOpts,
l1client,
butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber),
solimpl.NewDataPosterTransactor(dp),
)
Require(t, err)
Expand Down Expand Up @@ -616,7 +618,7 @@ func createTestNodeOnL1ForBoldProtocol(
addresses.Rollup,
chalManagerAddr,
&opts,
l1client,
butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber),
solimpl.NewDataPosterTransactor(dp),
)
Require(t, err)
Expand Down Expand Up @@ -671,7 +673,7 @@ func deployContractsOnly(
cfg.ChainConfig = string(config)
addresses, err := setup.DeployFullRollupStack(
ctx,
backend,
butil.NewBackendWrapper(backend, rpc.LatestBlockNumber),
&l1TransactionOpts,
l1info.GetAddress("Sequencer"),
cfg,
Expand Down Expand Up @@ -824,7 +826,7 @@ func create2ndNodeWithConfigForBoldProtocol(
addresses.Rollup,
chalManagerAddr,
&evilOpts,
l1client,
butil.NewBackendWrapper(l1client, rpc.LatestBlockNumber),
solimpl.NewDataPosterTransactor(dp),
)
Require(t, err)
Expand Down
4 changes: 3 additions & 1 deletion system_tests/bold_new_challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
protocol "github.com/offchainlabs/bold/chain-abstraction"
solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation"
challengemanager "github.com/offchainlabs/bold/challenge-manager"
Expand All @@ -27,6 +28,7 @@ import (
"github.com/offchainlabs/bold/solgen/go/mocksgen"
"github.com/offchainlabs/bold/solgen/go/rollupgen"
"github.com/offchainlabs/bold/state-commitments/history"
"github.com/offchainlabs/bold/util"
"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/arbnode/dataposter/storage"
"github.com/offchainlabs/nitro/staker/bold"
Expand Down Expand Up @@ -329,7 +331,7 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB
builder.addresses.Rollup,
chalManagerAddr,
&txOpts,
builder.L1.Client,
util.NewBackendWrapper(builder.L1.Client, rpc.LatestBlockNumber),
solimpl.NewDataPosterTransactor(dp),
)
Require(t, err)
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 @@ -54,6 +54,7 @@ import (
boldMocksgen "github.com/offchainlabs/bold/solgen/go/mocksgen"
"github.com/offchainlabs/bold/solgen/go/rollupgen"
"github.com/offchainlabs/bold/testing/setup"
butil "github.com/offchainlabs/bold/util"
"github.com/offchainlabs/nitro/arbnode"
"github.com/offchainlabs/nitro/arbos"
"github.com/offchainlabs/nitro/arbos/arbostypes"
Expand Down Expand Up @@ -1342,9 +1343,10 @@ func deployOnParentChain(
NumBigStepLevel: 3,
ChallengeGracePeriodBlocks: 3,
}
wrappedClient := butil.NewBackendWrapper(parentChainReader.Client(), rpc.LatestBlockNumber)
boldAddresses, err := setup.DeployFullRollupStack(
ctx,
parentChainReader.Client(),
wrappedClient,
&parentChainTransactionOpts,
parentChainInfo.GetAddress("Sequencer"),
cfg,
Expand Down

0 comments on commit eed7b12

Please sign in to comment.