Skip to content

Commit

Permalink
Merge branch 'bold-review' of github.com:OffchainLabs/nitro into bold…
Browse files Browse the repository at this point in the history
…-review
  • Loading branch information
rauljordan committed Dec 6, 2024
2 parents 1e635e4 + 8518e3d commit d372f30
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 18 deletions.
6 changes: 2 additions & 4 deletions staker/bold/bold_state_provider.go
Original file line number Diff line number Diff line change
Expand Up @@ -371,8 +371,7 @@ func (s *BOLDStateProvider) CollectMachineHashes(
}
// TODO: Enable Redis streams.
wasmModRoot := cfg.AssertionMetadata.WasmModuleRoot
useBoldMachine := true
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx)
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, true).Await(ctx)
if err != nil {
return nil, err
}
Expand Down Expand Up @@ -531,8 +530,7 @@ func (s *BOLDStateProvider) CollectProof(
"startState", fmt.Sprintf("%+v", input.StartState),
)
wasmModRoot := assertionMetadata.WasmModuleRoot
useBoldMachine := true
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, &useBoldMachine).Await(ctx)
execRun, err := s.statelessValidator.ExecutionSpawners()[0].CreateExecutionRun(wasmModRoot, input, true).Await(ctx)
if err != nil {
return nil, err
}
Expand Down
3 changes: 1 addition & 2 deletions staker/legacy/challenge_manager.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,8 +485,7 @@ func (m *ChallengeManager) createExecutionBackend(ctx context.Context, step uint
var execRun validator.ExecutionRun
for _, spawner := range m.validator.ExecutionSpawners() {
if validator.SpawnerSupportsModule(spawner, m.wasmModuleRoot) {
useBold := false
execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input, &useBold).Await(ctx)
execRun, err = spawner.CreateExecutionRun(m.wasmModuleRoot, input, false).Await(ctx)
if err != nil {
return fmt.Errorf("error creating execution backend for msg %v: %w", initialCount, err)
}
Expand Down
10 changes: 4 additions & 6 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, _ *bool) containers.PromiseInterface[validator.ExecutionRun] {
func (s *mockSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, _ 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 @@ -260,8 +260,7 @@ func TestValidationServerAPI(t *testing.T) {
if res != endState {
t.Error("unexpected mock validation run")
}
useBoldMachine := false
execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx)
execRun, err := client.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx)
Require(t, err)
step0 := execRun.GetStepAt(0)
step0Res, err := step0.Await(ctx)
Expand Down Expand Up @@ -386,10 +385,9 @@ func TestExecutionKeepAlive(t *testing.T) {
Require(t, err)

valInput := validator.ValidationInput{}
useBoldMachine := false
runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx)
runDefault, err := clientDefault.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx)
Require(t, err)
runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, &useBoldMachine).Await(ctx)
runShortTO, err := clientShortTO.CreateExecutionRun(wasmRoot, &valInput, false).Await(ctx)
Require(t, err)
<-time.After(time.Second * 10)
stepDefault := runDefault.GetStepAt(0)
Expand Down
4 changes: 2 additions & 2 deletions validator/client/validation_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,11 +156,11 @@ func NewExecutionClient(config rpcclient.ClientConfigFetcher, stack *node.Node)
func (c *ExecutionClient) CreateExecutionRun(
wasmModuleRoot common.Hash,
input *validator.ValidationInput,
useBoldMachine *bool,
useBoldMachine bool,
) 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/interface.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ValidationRun interface {

type ExecutionSpawner interface {
ValidationSpawner
CreateExecutionRun(wasmModuleRoot common.Hash, input *ValidationInput, useBoldMachine *bool) containers.PromiseInterface[ExecutionRun]
CreateExecutionRun(wasmModuleRoot common.Hash, input *ValidationInput, useBoldMachine bool) containers.PromiseInterface[ExecutionRun]
LatestWasmModuleRoot() containers.PromiseInterface[common.Hash]
}

Expand Down
4 changes: 2 additions & 2 deletions validator/server_arb/validator_spawner.go
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ func (v *ArbitratorSpawner) Room() int {
return avail
}

func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine *bool) containers.PromiseInterface[validator.ExecutionRun] {
func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input *validator.ValidationInput, useBoldMachine bool) containers.PromiseInterface[validator.ExecutionRun] {
getMachine := func(ctx context.Context) (MachineInterface, error) {
initialFrozenMachine, err := v.machineLoader.GetZeroStepMachine(ctx, wasmModuleRoot)
if err != nil {
Expand All @@ -245,7 +245,7 @@ func (v *ArbitratorSpawner) CreateExecutionRun(wasmModuleRoot common.Hash, input
return nil, err
}
var wrapped MachineInterface
if useBoldMachine != nil && *useBoldMachine {
if useBoldMachine {
wrapped = BoldMachineWrapper(machine)
} else {
wrapped = MachineInterface(machine)
Expand Down
6 changes: 5 additions & 1 deletion validator/valnode/validation_api.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,11 +80,15 @@ func NewExecutionServerAPI(valSpawner validator.ValidationSpawner, execution val
}
}

func (a *ExecServerAPI) CreateExecutionRun(ctx context.Context, wasmModuleRoot common.Hash, jsonInput *server_api.InputJSON, useBoldMachine *bool) (uint64, error) {
func (a *ExecServerAPI) CreateExecutionRun(ctx context.Context, wasmModuleRoot common.Hash, jsonInput *server_api.InputJSON, useBoldMachineOptional *bool) (uint64, error) {
input, err := server_api.ValidationInputFromJson(jsonInput)
if err != nil {
return 0, err
}
useBoldMachine := false
if useBoldMachineOptional != nil {
useBoldMachine = *useBoldMachineOptional
}
execRun, err := a.execSpawner.CreateExecutionRun(wasmModuleRoot, input, useBoldMachine).Await(ctx)
if err != nil {
return 0, err
Expand Down

0 comments on commit d372f30

Please sign in to comment.