Skip to content

Commit

Permalink
build
Browse files Browse the repository at this point in the history
  • Loading branch information
rauljordan committed Dec 5, 2024
1 parent dc36a3f commit d706059
Show file tree
Hide file tree
Showing 7 changed files with 31 additions and 21 deletions.
2 changes: 1 addition & 1 deletion arbnode/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -693,7 +693,7 @@ func createNodeImpl(
confirmedNotifiers = append(confirmedNotifiers, messagePruner)
}

stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, deployInfo.StakeToken, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan)
stakerObj, err = multiprotocolstaker.NewMultiProtocolStaker(stack, l1Reader, wallet, bind.CallOpts{}, func() *legacystaker.L1ValidatorConfig { return &configFetcher.Get().Staker }, &configFetcher.Get().Bold, blockValidator, statelessBlockValidator, nil, deployInfo.StakeToken, confirmedNotifiers, deployInfo.ValidatorUtils, deployInfo.Bridge, fatalErrChan)
if err != nil {
return nil, err
}
Expand Down
30 changes: 17 additions & 13 deletions staker/bold/bold_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ import (
"errors"
"fmt"
"math/big"
"os"
"path/filepath"
"time"

flag "github.com/spf13/pflag"
Expand All @@ -17,6 +15,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"
"github.com/ethereum/go-ethereum/rpc"

protocol "github.com/offchainlabs/bold/chain-abstraction"
Expand All @@ -29,7 +28,6 @@ import (
"github.com/offchainlabs/bold/util"
"github.com/offchainlabs/nitro/arbnode/dataposter"
"github.com/offchainlabs/nitro/arbutil"
"github.com/offchainlabs/nitro/cmd/conf"
"github.com/offchainlabs/nitro/staker"
legacystaker "github.com/offchainlabs/nitro/staker/legacy"
"github.com/offchainlabs/nitro/util/headerreader"
Expand All @@ -38,7 +36,6 @@ import (
)

var assertionCreatedId common.Hash
var homeDir string

func init() {
rollupAbi, err := boldrollup.RollupCoreMetaData.GetAbi()
Expand All @@ -50,11 +47,6 @@ func init() {
panic("RollupCore ABI missing AssertionCreated event")
}
assertionCreatedId = assertionCreatedEvent.ID
homeDirPath, err := os.UserHomeDir()
if err != nil {
panic(err)
}
homeDir = homeDirPath
}

type BoldConfig struct {
Expand Down Expand Up @@ -97,7 +89,7 @@ type StateProviderConfig struct {
var DefaultStateProviderConfig = StateProviderConfig{
ValidatorName: "default-validator",
CheckBatchFinality: true,
MachineLeavesCachePath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "machine-hashes-cache"),
MachineLeavesCachePath: "machine-hashes-cache",
}

var DefaultBoldConfig = BoldConfig{
Expand All @@ -109,7 +101,7 @@ var DefaultBoldConfig = BoldConfig{
API: false,
APIHost: "127.0.0.1",
APIPort: 9393,
APIDBPath: filepath.Join(homeDir, conf.PersistentConfigDefault.GlobalConfig, "bold-api-db"),
APIDBPath: "bold-api-db",
TrackChallengeParentAssertionHashes: []string{},
CheckStakerSwitchInterval: time.Minute, // Every minute, check if the Nitro node staker should switch to using BOLD.
StateProviderConfig: DefaultStateProviderConfig,
Expand Down Expand Up @@ -162,6 +154,7 @@ type BOLDStaker struct {

func NewBOLDStaker(
ctx context.Context,
stack *node.Node,
rollupAddress common.Address,
callOpts bind.CallOpts,
txOpts *bind.TransactOpts,
Expand All @@ -178,7 +171,7 @@ func NewBOLDStaker(
return nil, err
}
wrappedClient := util.NewBackendWrapper(l1Reader.Client(), rpc.LatestBlockNumber)
manager, err := newBOLDChallengeManager(ctx, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster)
manager, err := newBOLDChallengeManager(ctx, stack, rollupAddress, txOpts, l1Reader, wrappedClient, blockValidator, statelessBlockValidator, config, dataPoster)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -349,6 +342,7 @@ func (b *BOLDStaker) getCallOpts(ctx context.Context) *bind.CallOpts {
// implements the StopWaiter pattern as part of the Nitro validator.
func newBOLDChallengeManager(
ctx context.Context,
stack *node.Node,
rollupAddress common.Address,
txOpts *bind.TransactOpts,
l1Reader *headerreader.HeaderReader,
Expand Down Expand Up @@ -405,6 +399,15 @@ func newBOLDChallengeManager(
bigStepHeight := l2stateprovider.Height(bigStepHeightBig.Uint64())
smallStepHeight := l2stateprovider.Height(smallStepHeightBig.Uint64())

apiDBPath := config.APIDBPath
if apiDBPath != "" {
apiDBPath = stack.ResolvePath(apiDBPath)
}
machineHashesPath := config.StateProviderConfig.MachineLeavesCachePath
if machineHashesPath != "" {
machineHashesPath = stack.ResolvePath(machineHashesPath)
}

// Sets up the state provider interface that BOLD will use to request data such as
// execution states for assertions, history commitments for machine execution, and one step proofs.
stateProvider, err := NewBOLDStateProvider(
Expand All @@ -414,6 +417,7 @@ func newBOLDChallengeManager(
// TODO: Fetch these from the smart contract instead.
blockChallengeLeafHeight,
&config.StateProviderConfig,
machineHashesPath,
)
if err != nil {
return nil, fmt.Errorf("could not create state manager: %w", err)
Expand Down Expand Up @@ -449,7 +453,7 @@ func newBOLDChallengeManager(
}
if config.API {
apiAddr := fmt.Sprintf("%s:%d", config.APIHost, config.APIPort)
stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, config.APIDBPath))
stackOpts = append(stackOpts, challengemanager.StackWithAPIEnabled(apiAddr, apiDBPath))
}

manager, err := challengemanager.NewChallengeStack(
Expand Down
3 changes: 2 additions & 1 deletion staker/bold/bold_state_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,8 +56,9 @@ func NewBOLDStateProvider(
statelessValidator *staker.StatelessBlockValidator,
blockChallengeLeafHeight l2stateprovider.Height,
stateProviderConfig *StateProviderConfig,
machineHashesCachePath string,
) (*BOLDStateProvider, error) {
historyCache, err := challengecache.New(stateProviderConfig.MachineLeavesCachePath)
historyCache, err := challengecache.New(machineHashesCachePath)
if err != nil {
return nil, err
}
Expand Down
5 changes: 5 additions & 0 deletions staker/multi_protocol/multi_protocol_staker.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (
"github.com/ethereum/go-ethereum/accounts/abi/bind"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/node"

"github.com/offchainlabs/bold/solgen/go/bridgegen"
boldrollup "github.com/offchainlabs/bold/solgen/go/rollupgen"
Expand Down Expand Up @@ -46,9 +47,11 @@ type MultiProtocolStaker struct {
callOpts bind.CallOpts
boldConfig *boldstaker.BoldConfig
stakeTokenAddress common.Address
stack *node.Node
}

func NewMultiProtocolStaker(
stack *node.Node,
l1Reader *headerreader.HeaderReader,
wallet legacystaker.ValidatorWalletInterface,
callOpts bind.CallOpts,
Expand Down Expand Up @@ -102,6 +105,7 @@ func NewMultiProtocolStaker(
callOpts: callOpts,
boldConfig: boldConfig,
stakeTokenAddress: stakeTokenAddress,
stack: stack,
}, nil
}

Expand Down Expand Up @@ -224,6 +228,7 @@ func (m *MultiProtocolStaker) setupBoldStaker(
}
boldStaker, err := boldstaker.NewBOLDStaker(
ctx,
m.stack,
rollupAddress,
m.callOpts,
txBuilder.SingleTxAuth(),
Expand Down
8 changes: 4 additions & 4 deletions system_tests/validation_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (s *mockSpawner) Stop() {}
func (s *mockSpawner) Name() string { return "mock" }
func (s *mockSpawner) Room() int { return 4 }

func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine *bool) containers.PromiseInterface[validator.ExecutionRun] {
func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine bool) containers.PromiseInterface[validator.ExecutionRun] {
s.ExecSpawned = append(s.ExecSpawned, input.Id)
return containers.NewReadyPromise[validator.ExecutionRun](&mockExecRun{
startState: input.StartState,
Expand Down Expand Up @@ -261,7 +261,7 @@ func TestValidationServerAPI(t *testing.T) {
t.Error("unexpected mock validation run")
}
useBoldMachine := false
execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx)
execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx)

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun

Check failure on line 264 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to client.CreateExecutionRun
Require(t, err)
step0 := execRun.GetStepAt(0)
step0Res, err := step0.Await(ctx)
Expand Down Expand Up @@ -387,9 +387,9 @@ func TestExecutionKeepAlive(t *testing.T) {

valInput := validator.ValidationInput{}
useBoldMachine := false
runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx)
runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx)

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun

Check failure on line 390 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientDefault.CreateExecutionRun
Require(t, err)
runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx)
runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, useBoldMachine).Await(ctx)

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun (typecheck)

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun (typecheck)

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun (typecheck)

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun (typecheck)

Check failure on line 392 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

cannot use useBoldMachine (variable of type bool) as *bool value in argument to clientShortTO.CreateExecutionRun (typecheck)
Require(t, err)
<-time.After(time.Second * 10)
stepDefault := runDefault.GetStepAt(0)
Expand Down
2 changes: 1 addition & 1 deletion validator/client/validation_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -160,7 +160,7 @@ func (c *ExecutionClient) CreateExecutionRun(
) containers.PromiseInterface[validator.ExecutionRun] {
return stopwaiter.LaunchPromiseThread(c, func(ctx context.Context) (validator.ExecutionRun, error) {
var res uint64
err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), useBoldMachine)
err := c.client.CallContext(ctx, &res, server_api.Namespace+"_createExecutionRun", wasmModuleRoot, server_api.ValidationInputToJson(input), *useBoldMachine)
if err != nil {
return nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion validator/server_arb/validator_spawner.go
Original file line number Diff line number Diff line change
Expand Up @@ -245,7 +245,7 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input
return nil, err
}
var wrapped MachineInterface
if *useBoldMachine {
if useBoldMachine != nil && *useBoldMachine {
wrapped = BoldMachineWrapper(machine)
} else {
wrapped = MachineInterface(machine)
Expand Down

0 comments on commit d706059

Please sign in to comment.