Skip to content

Commit

Permalink
Fix the wiring after the giant refactoring in bold repo
Browse files Browse the repository at this point in the history
  • Loading branch information
eljobe committed Nov 14, 2024
1 parent 2f0bc89 commit 0abf704
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 109 deletions.
2 changes: 1 addition & 1 deletion bold
Submodule bold updated 37 files
+12 −8 api/backend/backend.go
+5 −1 api/server/server.go
+1 −0 assertions/BUILD.bazel
+9 −1 assertions/confirmation.go
+13 −20 assertions/manager.go
+40 −65 assertions/manager_test.go
+14 −2 assertions/poster.go
+5 −9 assertions/poster_test.go
+4 −3 assertions/sync.go
+1 −1 assertions/sync_test.go
+7 −5 chain-abstraction/interfaces.go
+19 −20 chain-abstraction/sol-implementation/assertion_chain.go
+3 −7 chain-abstraction/sol-implementation/assertion_chain_test.go
+3 −7 chain-abstraction/sol-implementation/edge_challenge_manager.go
+14 −23 chain-abstraction/sol-implementation/edge_challenge_manager_test.go
+2 −7 challenge-manager/BUILD.bazel
+1 −0 challenge-manager/chain-watcher/BUILD.bazel
+111 −98 challenge-manager/chain-watcher/watcher.go
+0 −2 challenge-manager/chain-watcher/watcher_test.go
+1 −1 challenge-manager/challenge-tree/tree.go
+8 −8 challenge-manager/challenge-tree/tree_test.go
+2 −17 challenge-manager/challenges.go
+8 −9 challenge-manager/edge-tracker/challenge_confirmation.go
+10 −26 challenge-manager/edge-tracker/tracker.go
+60 −194 challenge-manager/manager.go
+46 −92 challenge-manager/manager_test.go
+229 −0 challenge-manager/stack.go
+2 −0 layer2-state-provider/provider.go
+9 −0 logs/ephemeral/BUILD.bazel
+67 −0 logs/ephemeral/log.go
+70 −0 logs/ephemeral/log_test.go
+0 −2 testing/endtoend/BUILD.bazel
+21 −54 testing/endtoend/e2e_test.go
+0 −24 testing/endtoend/helpers_test.go
+1 −0 testing/mocks/BUILD.bazel
+57 −8 testing/mocks/mocks.go
+23 −26 testing/setup/rollup_stack.go
47 changes: 12 additions & 35 deletions staker/bold/bold_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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
}

Expand Down
62 changes: 14 additions & 48 deletions system_tests/bold_challenge_protocol_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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)

Expand Down
35 changes: 10 additions & 25 deletions system_tests/bold_new_challenge_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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)

Expand Down Expand Up @@ -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)

Expand Down

0 comments on commit 0abf704

Please sign in to comment.