From 8518e3d0c249f62b03a6d86a75d9d97f14b8c749 Mon Sep 17 00:00:00 2001 From: Lee Bousfield Date: Fri, 6 Dec 2024 08:41:17 -0700 Subject: [PATCH] Less useBoldMachine pointers --- staker/bold/bold_state_provider.go | 6 ++---- staker/legacy/challenge_manager.go | 3 +-- system_tests/validation_mock_test.go | 10 ++++------ validator/client/validation_client.go | 4 ++-- validator/interface.go | 2 +- validator/server_arb/validator_spawner.go | 4 ++-- validator/valnode/validation_api.go | 6 +++++- 7 files changed, 17 insertions(+), 18 deletions(-) diff --git a/staker/bold/bold_state_provider.go b/staker/bold/bold_state_provider.go index 13e08f7d3f..48b7cbd91e 100644 --- a/staker/bold/bold_state_provider.go +++ b/staker/bold/bold_state_provider.go @@ -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 } @@ -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 } diff --git a/staker/legacy/challenge_manager.go b/staker/legacy/challenge_manager.go index 20bfff6b80..1aa13a9e05 100644 --- a/staker/legacy/challenge_manager.go +++ b/staker/legacy/challenge_manager.go @@ -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) } diff --git a/system_tests/validation_mock_test.go b/system_tests/validation_mock_test.go index e0475daae8..98dab7ad39 100644 --- a/system_tests/validation_mock_test.go +++ b/system_tests/validation_mock_test.go @@ -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, @@ -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) @@ -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) diff --git a/validator/client/validation_client.go b/validator/client/validation_client.go index 9ac2271963..c04817d654 100644 --- a/validator/client/validation_client.go +++ b/validator/client/validation_client.go @@ -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 } diff --git a/validator/interface.go b/validator/interface.go index 5c5052d8eb..249cf1b1c3 100644 --- a/validator/interface.go +++ b/validator/interface.go @@ -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] } diff --git a/validator/server_arb/validator_spawner.go b/validator/server_arb/validator_spawner.go index 5eb69ff60b..76c19dc8f2 100644 --- a/validator/server_arb/validator_spawner.go +++ b/validator/server_arb/validator_spawner.go @@ -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 { @@ -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) diff --git a/validator/valnode/validation_api.go b/validator/valnode/validation_api.go index b5644adc21..dab74f6e29 100644 --- a/validator/valnode/validation_api.go +++ b/validator/valnode/validation_api.go @@ -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