Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[NIT-2740] Horizontal Scaling of Validation Node #2354

Open
wants to merge 25 commits into
base: bold-review
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
6f0bade
Use redis streams in bold
anodar May 30, 2024
2851ef3
Use different streams for bold
anodar May 31, 2024
d15ef6a
Initialize bold execution runner
anodar Jun 5, 2024
9100a8d
Merge branch 'master' into sepolia-tooling-merge-redis
anodar Jun 5, 2024
e2c20ce
Add stream connection and timeout logic
anodar Jun 5, 2024
40b6483
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Jul 1, 2024
5d30cc9
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Aug 27, 2024
301ea72
fix config
amsanghi Aug 27, 2024
0bbc41e
clean up
amsanghi Aug 27, 2024
3cb9241
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Aug 27, 2024
b9c8900
remove redudtant changes
amsanghi Aug 27, 2024
8fcd8b7
fix config setup
amsanghi Aug 28, 2024
f3fc6f3
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Aug 28, 2024
ca909c8
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Aug 28, 2024
f0bc4d4
Update validator/server_arb/redis/consumer.go
amsanghi Aug 28, 2024
b421fb0
Update validator/server_arb/redis/consumer.go
amsanghi Aug 28, 2024
aeb0e24
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Aug 28, 2024
596ff81
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Aug 29, 2024
4fbd706
Add tests and fix some bugs
amsanghi Aug 29, 2024
5170a79
Update validator/client/redis/boldproducer.go
rauljordan Aug 29, 2024
545f9d2
add metrics
amsanghi Aug 30, 2024
e9e0224
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Oct 9, 2024
9be8a33
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Oct 9, 2024
161fcca
Merge branch 'bold-review' into sepolia-tooling-merge-redis
amsanghi Oct 28, 2024
d895bc4
fix lint
amsanghi Oct 29, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 44 additions & 41 deletions staker/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,21 +91,22 @@ type BlockValidator struct {
}

type BlockValidatorConfig struct {
Enable bool `koanf:"enable"`
Evil bool `koanf:"evil"`
EvilInterceptDepositGwei uint64 `koanf:"evil-intercept-deposit-gwei"`
RedisValidationClientConfig redis.ValidationClientConfig `koanf:"redis-validation-client-config"`
ValidationServer rpcclient.ClientConfig `koanf:"validation-server" reload:"hot"`
ValidationServerConfigs []rpcclient.ClientConfig `koanf:"validation-server-configs"`
ValidationPoll time.Duration `koanf:"validation-poll" reload:"hot"`
PrerecordedBlocks uint64 `koanf:"prerecorded-blocks" reload:"hot"`
ForwardBlocks uint64 `koanf:"forward-blocks" reload:"hot"`
CurrentModuleRoot string `koanf:"current-module-root"` // TODO(magic) requires reinitialization on hot reload
PendingUpgradeModuleRoot string `koanf:"pending-upgrade-module-root"` // TODO(magic) requires StatelessBlockValidator recreation on hot reload
FailureIsFatal bool `koanf:"failure-is-fatal" reload:"hot"`
Dangerous BlockValidatorDangerousConfig `koanf:"dangerous"`
MemoryFreeLimit string `koanf:"memory-free-limit" reload:"hot"`
ValidationServerConfigsList string `koanf:"validation-server-configs-list"`
Enable bool `koanf:"enable"`
Evil bool `koanf:"evil"`
EvilInterceptDepositGwei uint64 `koanf:"evil-intercept-deposit-gwei"`
RedisValidationClientConfig redis.ValidationClientConfig `koanf:"redis-validation-client-config"`
RedisBoldValidationClientConfig redis.BoldValidationClientConfig `koanf:"redis-bold-validation-client-config"`
ValidationServer rpcclient.ClientConfig `koanf:"validation-server" reload:"hot"`
ValidationServerConfigs []rpcclient.ClientConfig `koanf:"validation-server-configs"`
ValidationPoll time.Duration `koanf:"validation-poll" reload:"hot"`
PrerecordedBlocks uint64 `koanf:"prerecorded-blocks" reload:"hot"`
ForwardBlocks uint64 `koanf:"forward-blocks" reload:"hot"`
CurrentModuleRoot string `koanf:"current-module-root"` // TODO(magic) requires reinitialization on hot reload
PendingUpgradeModuleRoot string `koanf:"pending-upgrade-module-root"` // TODO(magic) requires StatelessBlockValidator recreation on hot reload
FailureIsFatal bool `koanf:"failure-is-fatal" reload:"hot"`
Dangerous BlockValidatorDangerousConfig `koanf:"dangerous"`
MemoryFreeLimit string `koanf:"memory-free-limit" reload:"hot"`
ValidationServerConfigsList string `koanf:"validation-server-configs-list"`

memoryFreeLimit int
}
Expand Down Expand Up @@ -167,35 +168,37 @@ func BlockValidatorDangerousConfigAddOptions(prefix string, f *pflag.FlagSet) {
}

var DefaultBlockValidatorConfig = BlockValidatorConfig{
Enable: false,
ValidationServerConfigsList: "default",
ValidationServer: rpcclient.DefaultClientConfig,
RedisValidationClientConfig: redis.DefaultValidationClientConfig,
ValidationPoll: time.Second,
ForwardBlocks: 1024,
PrerecordedBlocks: uint64(2 * runtime.NumCPU()),
CurrentModuleRoot: "current",
PendingUpgradeModuleRoot: "latest",
FailureIsFatal: true,
Dangerous: DefaultBlockValidatorDangerousConfig,
MemoryFreeLimit: "default",
EvilInterceptDepositGwei: 1_000_000, // 1M gwei or 0.001 ETH
Enable: false,
ValidationServerConfigsList: "default",
ValidationServer: rpcclient.DefaultClientConfig,
RedisValidationClientConfig: redis.DefaultValidationClientConfig,
RedisBoldValidationClientConfig: redis.DefaultBoldValidationClientConfig,
ValidationPoll: time.Second,
ForwardBlocks: 1024,
PrerecordedBlocks: uint64(2 * runtime.NumCPU()),
CurrentModuleRoot: "current",
PendingUpgradeModuleRoot: "latest",
FailureIsFatal: true,
Dangerous: DefaultBlockValidatorDangerousConfig,
MemoryFreeLimit: "default",
EvilInterceptDepositGwei: 1_000_000, // 1M gwei or 0.001 ETH
}

var TestBlockValidatorConfig = BlockValidatorConfig{
Enable: false,
EvilInterceptDepositGwei: 1_000_000, // 1M gwei or 0.001 ETH
ValidationServer: rpcclient.TestClientConfig,
ValidationServerConfigs: []rpcclient.ClientConfig{rpcclient.TestClientConfig},
RedisValidationClientConfig: redis.TestValidationClientConfig,
ValidationPoll: 100 * time.Millisecond,
ForwardBlocks: 128,
PrerecordedBlocks: uint64(2 * runtime.NumCPU()),
CurrentModuleRoot: "latest",
PendingUpgradeModuleRoot: "latest",
FailureIsFatal: true,
Dangerous: DefaultBlockValidatorDangerousConfig,
MemoryFreeLimit: "default",
Enable: false,
EvilInterceptDepositGwei: 1_000_000, // 1M gwei or 0.001 ETH
ValidationServer: rpcclient.TestClientConfig,
ValidationServerConfigs: []rpcclient.ClientConfig{rpcclient.TestClientConfig},
RedisValidationClientConfig: redis.TestValidationClientConfig,
RedisBoldValidationClientConfig: redis.TestBoldValidationClientConfig,
ValidationPoll: 100 * time.Millisecond,
ForwardBlocks: 128,
PrerecordedBlocks: uint64(2 * runtime.NumCPU()),
CurrentModuleRoot: "latest",
PendingUpgradeModuleRoot: "latest",
FailureIsFatal: true,
Dangerous: DefaultBlockValidatorDangerousConfig,
MemoryFreeLimit: "default",
}

var DefaultBlockValidatorDangerousConfig = BlockValidatorDangerousConfig{
Expand Down
14 changes: 12 additions & 2 deletions staker/stateless_block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,11 @@
config func() *BlockValidatorConfig,
stack *node.Node,
) (*StatelessBlockValidator, error) {
var executionSpawners []validator.ExecutionSpawner
var redisValClient *redis.ValidationClient
var (
executionSpawners []validator.ExecutionSpawner
redisValClient *redis.ValidationClient
redisBoldValClient *redis.BoldValidationClient

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

redisBoldValClient declared and not used

Check failure on line 237 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

redisBoldValClient declared and not used
)

if config().RedisValidationClientConfig.Enabled() {
var err error
Expand All @@ -241,11 +244,18 @@
return nil, fmt.Errorf("creating new redis validation client: %w", err)
}
}
if config().RedisBoldValidationClientConfig.Enabled() {
var err error
redisBoldValClient, err = redis.NewBoldValidationClient(&config().RedisBoldValidationClientConfig)
if err != nil {
return nil, fmt.Errorf("creating new redis bold validation client: %w", err)
}
}
configs := config().ValidationServerConfigs
for i := range configs {
i := i
confFetcher := func() *rpcclient.ClientConfig { return &config().ValidationServerConfigs[i] }
executionSpawners = append(executionSpawners, validatorclient.NewExecutionClient(confFetcher, stack))

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (stylus)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (race)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (defaults)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (long)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

not enough arguments in call to validatorclient.NewExecutionClient

Check failure on line 258 in staker/stateless_block_validator.go

View workflow job for this annotation

GitHub Actions / Go Tests (challenge)

not enough arguments in call to validatorclient.NewExecutionClient
}

if len(executionSpawners) == 0 {
Expand Down
2 changes: 1 addition & 1 deletion system_tests/validation_mock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@
}
configFetcher := func() *server_arb.ArbitratorSpawnerConfig { return config }
spawner := &mockSpawner{}
serverAPI := valnode.NewExecutionServerAPI(spawner, spawner, configFetcher)
serverAPI := valnode.NewExecutionServerAPI(spawner, spawner, nil, configFetcher)

valAPIs := []rpc.API{{
Namespace: server_api.Namespace,
Expand Down Expand Up @@ -205,7 +205,7 @@
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
_, validationDefault := createMockValidationNode(t, ctx, nil)
client := validatorclient.NewExecutionClient(StaticFetcherFrom(t, &rpcclient.TestClientConfig), validationDefault)

Check failure on line 208 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to validatorclient.NewExecutionClient
err := client.Start(ctx)
Require(t, err)

Expand Down Expand Up @@ -282,7 +282,7 @@
ctx, cancel := context.WithCancel(context.Background())
defer cancel()
mockSpawner, spawnerStack := createMockValidationNode(t, ctx, nil)
client := validatorclient.NewExecutionClient(StaticFetcherFrom(t, &rpcclient.TestClientConfig), spawnerStack)

Check failure on line 285 in system_tests/validation_mock_test.go

View workflow job for this annotation

GitHub Actions / Analyze (go)

not enough arguments in call to validatorclient.NewExecutionClient
err := client.Start(ctx)
Require(t, err)

Expand Down
106 changes: 106 additions & 0 deletions validator/client/redis/boldproducer.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
package redis

import (
"context"
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/log"
"github.com/go-redis/redis/v8"
"github.com/offchainlabs/nitro/pubsub"
"github.com/offchainlabs/nitro/util/containers"
"github.com/offchainlabs/nitro/util/redisutil"
"github.com/offchainlabs/nitro/util/stopwaiter"
"github.com/offchainlabs/nitro/validator/server_api"
"github.com/spf13/pflag"
)

type BoldValidationClientConfig struct {
RedisURL string `koanf:"redis-url"`
}

func (c BoldValidationClientConfig) Enabled() bool {
return c.RedisURL != ""
}

var DefaultBoldValidationClientConfig = BoldValidationClientConfig{
RedisURL: "",
}

var TestBoldValidationClientConfig = BoldValidationClientConfig{
RedisURL: "",
}

func BoldValidationClientConfigAddOptions(prefix string, f *pflag.FlagSet) {
pubsub.ProducerAddConfigAddOptions(prefix+".producer-config", f)
}

// BoldValidationClient implements bold validation client through redis streams.
type BoldValidationClient struct {
stopwaiter.StopWaiter
// producers stores moduleRoot to producer mapping.
producers map[common.Hash]*pubsub.Producer[*server_api.GetLeavesWithStepSizeInput, []common.Hash]
producerConfig pubsub.ProducerConfig
redisClient redis.UniversalClient
moduleRoots []common.Hash
}

func NewBoldValidationClient(cfg *BoldValidationClientConfig) (*BoldValidationClient, error) {
if cfg.RedisURL == "" {
return nil, fmt.Errorf("redis url cannot be empty")
}
redisClient, err := redisutil.RedisClientFromURL(cfg.RedisURL)
if err != nil {
return nil, err
}
return &BoldValidationClient{
producers: make(map[common.Hash]*pubsub.Producer[*server_api.GetLeavesWithStepSizeInput, []common.Hash]),
redisClient: redisClient,
}, nil
}

func (c *BoldValidationClient) Initialize(moduleRoots []common.Hash) error {
for _, mr := range moduleRoots {
if _, exists := c.producers[mr]; exists {
log.Warn("Producer already existsw for module root", "hash", mr)
rauljordan marked this conversation as resolved.
Show resolved Hide resolved
continue
}
p, err := pubsub.NewProducer[*server_api.GetLeavesWithStepSizeInput, []common.Hash](
c.redisClient, server_api.RedisStreamForRoot(mr), &c.producerConfig)
if err != nil {
log.Warn("failed init redis for %v: %w", mr, err)
continue
}
p.Start(c.GetContext())
c.producers[mr] = p
c.moduleRoots = append(c.moduleRoots, mr)
}
return nil
}

func (c *BoldValidationClient) GetLeavesWithStepSize(req *server_api.GetLeavesWithStepSizeInput) containers.PromiseInterface[[]common.Hash] {
producer, found := c.producers[req.ModuleRoot]
if !found {
return containers.NewReadyPromise([]common.Hash{}, fmt.Errorf("no validation is configured for wasm root %v", req.ModuleRoot))
}
promise, err := producer.Produce(c.GetContext(), req)
if err != nil {
return containers.NewReadyPromise([]common.Hash{}, fmt.Errorf("error producing input: %w", err))
}
return promise
}

func (c *BoldValidationClient) Start(ctx_in context.Context) error {
for _, p := range c.producers {
p.Start(ctx_in)
}
c.StopWaiter.Start(ctx_in, c)
return nil
}

func (c *BoldValidationClient) Stop() {
for _, p := range c.producers {
p.StopAndWait()
}
c.StopWaiter.StopAndWait()
}
35 changes: 30 additions & 5 deletions validator/client/validation_client.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ import (
"github.com/offchainlabs/nitro/util/rpcclient"
"github.com/offchainlabs/nitro/util/stopwaiter"

"github.com/offchainlabs/nitro/validator/client/redis"
"github.com/offchainlabs/nitro/validator/server_api"
"github.com/offchainlabs/nitro/validator/server_common"

Expand Down Expand Up @@ -115,11 +116,21 @@ func (c *ValidationClient) Room() int {

type ExecutionClient struct {
ValidationClient
boldValClient *redis.BoldValidationClient
}

func NewExecutionClient(config rpcclient.ClientConfigFetcher, stack *node.Node) *ExecutionClient {
func NewExecutionClient(config rpcclient.ClientConfigFetcher, redisBoldValidationClientConfig redis.BoldValidationClientConfig, stack *node.Node) *ExecutionClient {
var boldClient *redis.BoldValidationClient
if redisBoldValidationClientConfig.Enabled() {
var err error
boldClient, err = redis.NewBoldValidationClient(&redisBoldValidationClientConfig)
if err != nil {
log.Error("Creating new redis bold validation client", "error", err)
}
}
return &ExecutionClient{
ValidationClient: *NewValidationClient(config, stack),
boldValClient: boldClient,
}
}

Expand All @@ -131,8 +142,10 @@ func (c *ExecutionClient) CreateBoldExecutionRun(wasmModuleRoot common.Hash, ste
return nil, err
}
run := &ExecutionClientRun{
client: c,
id: res,
client: c,
id: res,
wasmModuleRoot: wasmModuleRoot,
input: input,
}
run.Start(c.GetContext()) // note: not this temporary thread's context!
return run, nil
Expand All @@ -157,8 +170,10 @@ func (c *ExecutionClient) CreateExecutionRun(wasmModuleRoot common.Hash, input *

type ExecutionClientRun struct {
stopwaiter.StopWaiter
client *ExecutionClient
id uint64
client *ExecutionClient
id uint64
wasmModuleRoot common.Hash
input *validator.ValidationInput
}

func (c *ExecutionClient) LatestWasmModuleRoot() containers.PromiseInterface[common.Hash] {
Expand Down Expand Up @@ -213,6 +228,16 @@ func (r *ExecutionClientRun) GetStepAt(pos uint64) containers.PromiseInterface[*
}

func (r *ExecutionClientRun) GetLeavesWithStepSize(fromBatch, machineStartIndex, stepSize, numDesiredLeaves uint64) containers.PromiseInterface[[]common.Hash] {
if r.client.boldValClient != nil {
return r.client.boldValClient.GetLeavesWithStepSize(&server_api.GetLeavesWithStepSizeInput{
anodar marked this conversation as resolved.
Show resolved Hide resolved
ModuleRoot: r.wasmModuleRoot,
FromBatch: fromBatch,
MachineStartIndex: machineStartIndex,
StepSize: stepSize,
NumDesiredLeaves: numDesiredLeaves,
ValidationInput: r.input,
})
}
return stopwaiter.LaunchPromiseThread[[]common.Hash](r, func(ctx context.Context) ([]common.Hash, error) {
var resJson []common.Hash
err := r.client.client.CallContext(ctx, &resJson, server_api.Namespace+"_getLeavesWithStepSize", r.id, fromBatch, machineStartIndex, stepSize, numDesiredLeaves)
Expand Down
9 changes: 9 additions & 0 deletions validator/server_api/json.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,12 @@ func ValidationInputFromJson(entry *InputJSON) (*validator.ValidationInput, erro
}
return valInput, nil
}

type GetLeavesWithStepSizeInput struct {
ModuleRoot common.Hash
FromBatch uint64
MachineStartIndex uint64
StepSize uint64
NumDesiredLeaves uint64
ValidationInput *validator.ValidationInput
}
Loading
Loading