From 0abf704f24f61d6fc50e57c4c188d9987e3ebadc Mon Sep 17 00:00:00 2001 From: Pepper Lebeck-Jobe Date: Thu, 14 Nov 2024 23:23:19 +0100 Subject: [PATCH] Fix the wiring after the giant refactoring in bold repo --- bold | 2 +- staker/bold/bold_staker.go | 47 ++++----------- system_tests/bold_challenge_protocol_test.go | 62 +++++--------------- system_tests/bold_new_challenge_test.go | 35 ++++------- 4 files changed, 37 insertions(+), 109 deletions(-) diff --git a/bold b/bold index 06de67750e..ece8f7a0cf 160000 --- a/bold +++ b/bold @@ -1 +1 @@ -Subproject commit 06de67750eac6ea40ba6359df605ce02a7997d5f +Subproject commit ece8f7a0cf26caa6525f32aa409df48b5f572fbd diff --git a/staker/bold/bold_staker.go b/staker/bold/bold_staker.go index d57d95ee2c..bb9b5dde47 100644 --- a/staker/bold/bold_staker.go +++ b/staker/bold/bold_staker.go @@ -9,7 +9,6 @@ import ( "math/big" "time" - "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -396,49 +395,27 @@ func newBOLDChallengeManager( // The interval at which the manager will attempt to confirm assertions. confirmingInterval := config.AssertionConfirmingInterval - amOpts := []assertions.Opt{ - assertions.WithPostingInterval(postingInterval), - assertions.WithPollingInterval(scanningInterval), - assertions.WithConfirmationInterval(confirmingInterval), - } - assertionManager, err := assertions.NewManager( - assertionChain, - provider, - assertionChain.Backend(), - assertionChain.RollupAddress(), - config.StateProviderConfig.ValidatorName, - nil, // TODO: This is not going to cut it. - BoldModes[config.Mode], - amOpts..., - ) - if err != nil { - return nil, fmt.Errorf("could not create assertion manager: %w", err) - } - - cmOpts := []challengemanager.Opt{ - challengemanager.WithName(config.StateProviderConfig.ValidatorName), - challengemanager.WithMode(BoldModes[config.Mode]), - challengemanager.WithAssertionConfirmingInterval(confirmingInterval), - challengemanager.WithAddress(txOpts.From), - // Configure the validator to track only certain challenges if configured to do so. - challengemanager.WithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes), + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName(config.StateProviderConfig.ValidatorName), + challengemanager.StackWithMode(BoldModes[config.Mode]), + challengemanager.StackWithPollingInterval(scanningInterval), + challengemanager.StackWithPostingInterval(postingInterval), + challengemanager.StackWithConfirmationInterval(confirmingInterval), + challengemanager.StackWithTrackChallengeParentAssertionHashes(config.TrackChallengeParentAssertionHashes), } if config.API { - // Conditionally enables the BOLD API if configured. - cmOpts = append(cmOpts, challengemanager.WithAPIEnabled(fmt.Sprintf("%s:%d", config.APIHost, config.APIPort), config.APIDBPath)) + apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort) + stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, config.APIDBPath)) } - manager, err := challengemanager.New( - ctx, + + manager, err := challengemanager.NewChallengeStack( assertionChain, provider, - assertionManager, - assertionChain.RollupAddress(), - cmOpts..., + stackOpts..., ) if err != nil { return nil, fmt.Errorf("could not create challenge manager: %w", err) } - provider.UpdateAPIDatabase(manager.Database()) return manager, nil } diff --git a/system_tests/bold_challenge_protocol_test.go b/system_tests/bold_challenge_protocol_test.go index 55fb2790b0..5c1e4f7369 100644 --- a/system_tests/bold_challenge_protocol_test.go +++ b/system_tests/bold_challenge_protocol_test.go @@ -29,7 +29,6 @@ import ( "github.com/ethereum/go-ethereum/node" "github.com/ethereum/go-ethereum/params" "github.com/ethereum/go-ethereum/rlp" - "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -212,8 +211,7 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp Require(t, l2nodeA.Start(ctx)) Require(t, l2nodeB.Start(ctx)) - chalManagerAddr, err := assertionChain.SpecChallengeManager(ctx) - Require(t, err) + chalManagerAddr := assertionChain.SpecChallengeManager() evilOpts := l1info.GetDefaultTransactOpts("EvilAsserter", ctx) l1ChainId, err := l1client.ChainID(ctx) Require(t, err) @@ -388,66 +386,34 @@ func testChallengeProtocolBOLD(t *testing.T, spawnerOpts ...server_arb.SpawnerOp nil, // Api db ) - assertionManager, err := assertions.NewManager( - assertionChain, - provider, - assertionChain.Backend(), - assertionChain.RollupAddress(), - "honest", - nil, - modes.MakeMode, - assertions.WithPostingInterval(time.Second*3), - assertions.WithPollingInterval(time.Second), - assertions.WithAverageBlockCreationTime(time.Second), - ) - Require(t, err) + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName("honest"), + challengemanager.StackWithMode(modes.MakeMode), + challengemanager.StackWithPostingInterval(time.Second * 3), + challengemanager.StackWithPollingInterval(time.Second), + challengemanager.StackWithAverageBlockCreationTime(time.Second), + } - manager, err := challengemanager.New( - ctx, + manager, err := challengemanager.NewChallengeStack( assertionChain, provider, - assertionManager, - assertionChain.RollupAddress(), - challengemanager.WithName("honest"), - challengemanager.WithMode(modes.MakeMode), - challengemanager.WithAddress(l1info.GetDefaultTransactOpts("Asserter", ctx).From), - challengemanager.WithAvgBlockCreationTime(time.Second), + stackOpts..., ) Require(t, err) - assertionManagerB, err := assertions.NewManager( - chainB, - evilProvider, - chainB.Backend(), - chainB.RollupAddress(), - "evil", - nil, - modes.MakeMode, - assertions.WithPostingInterval(time.Second*3), - assertions.WithPollingInterval(time.Second), - assertions.WithAverageBlockCreationTime(time.Second), - ) - Require(t, err) + evilStackOpts := append(stackOpts, challengemanager.StackWithName("evil")) - managerB, err := challengemanager.New( - ctx, + managerB, err := challengemanager.NewChallengeStack( chainB, evilProvider, - assertionManagerB, - assertionChain.RollupAddress(), - challengemanager.WithName("evil"), - challengemanager.WithMode(modes.MakeMode), - challengemanager.WithAddress(l1info.GetDefaultTransactOpts("EvilAsserter", ctx).From), - challengemanager.WithAvgBlockCreationTime(time.Second), + evilStackOpts..., ) Require(t, err) manager.Start(ctx) managerB.Start(ctx) - chalManager, err := assertionChain.SpecChallengeManager(ctx) - Require(t, err) - + chalManager := assertionChain.SpecChallengeManager() filterer, err := challengeV2gen.NewEdgeChallengeManagerFilterer(chalManager.Address(), l1client) Require(t, err) diff --git a/system_tests/bold_new_challenge_test.go b/system_tests/bold_new_challenge_test.go index 0d4090dccb..fab6e7eabf 100644 --- a/system_tests/bold_new_challenge_test.go +++ b/system_tests/bold_new_challenge_test.go @@ -17,7 +17,6 @@ import ( "github.com/ethereum/go-ethereum/core/rawdb" "github.com/ethereum/go-ethereum/core/types" "github.com/ethereum/go-ethereum/params" - "github.com/offchainlabs/bold/assertions" protocol "github.com/offchainlabs/bold/chain-abstraction" solimpl "github.com/offchainlabs/bold/chain-abstraction/sol-implementation" challengemanager "github.com/offchainlabs/bold/challenge-manager" @@ -174,9 +173,7 @@ func testChallengeProtocolBOLDVirtualBlocks(t *testing.T, wrongAtFirstVirtual bo // Everything's setup, now just wait for the challenge to complete and ensure the honest party won - chalManager, err := assertionChain.SpecChallengeManager(ctx) - Require(t, err) - + chalManager := assertionChain.SpecChallengeManager() filterer, err := challengeV2gen.NewEdgeChallengeManagerFilterer(chalManager.Address(), builder.L1.Client) Require(t, err) @@ -335,30 +332,18 @@ func startBoldChallengeManager(t *testing.T, ctx context.Context, builder *NodeB ) Require(t, err) - assertionManager, err := assertions.NewManager( - assertionChain, - provider, - assertionChain.Backend(), - assertionChain.RollupAddress(), - addressName, - nil, - modes.MakeMode, - assertions.WithPostingInterval(time.Second*3), - assertions.WithPollingInterval(time.Second), - assertions.WithAverageBlockCreationTime(time.Second), - ) - Require(t, err) + stackOpts := []challengemanager.StackOpt{ + challengemanager.StackWithName(addressName), + challengemanager.StackWithMode(modes.MakeMode), + challengemanager.StackWithPostingInterval(time.Second * 3), + challengemanager.StackWithPollingInterval(time.Second), + challengemanager.StackWithAverageBlockCreationTime(time.Second), + } - challengeManager, err := challengemanager.New( - ctx, + challengeManager, err := challengemanager.NewChallengeStack( assertionChain, provider, - assertionManager, - assertionChain.RollupAddress(), - challengemanager.WithName(addressName), - challengemanager.WithMode(modes.MakeMode), - challengemanager.WithAddress(txOpts.From), - challengemanager.WithAvgBlockCreationTime(time.Second), + stackOpts..., ) Require(t, err)