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

Integrate Redis streams in to Nitro's validation #2241

Merged
merged 17 commits into from
Apr 23, 2024
Merged

Integrate Redis streams in to Nitro's validation #2241

merged 17 commits into from
Apr 23, 2024

Conversation

anodar
Copy link
Contributor

@anodar anodar commented Apr 19, 2024

No description provided.

@cla-bot cla-bot bot added the s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA. label Apr 19, 2024
@anodar anodar changed the title Second draft of pubsub in nitro Integrate Redis streams in to Nitro's validation Apr 19, 2024
@anodar anodar marked this pull request as ready for review April 19, 2024 21:32
@anodar anodar requested a review from tsahee April 19, 2024 21:32
staker/block_validator.go Outdated Show resolved Hide resolved
@anodar anodar requested a review from tsahee April 19, 2024 23:50
pubsub/producer.go Outdated Show resolved Hide resolved
staker/stateless_block_validator.go Outdated Show resolved Hide resolved
staker/stateless_block_validator.go Show resolved Hide resolved
system_tests/common_test.go Outdated Show resolved Hide resolved
validator/server_api/redisconsumer.go Outdated Show resolved Hide resolved
conf.Arbitrator.RedisValidationServerConfig.RedisURL = redisURL
t.Cleanup(func() { destroyGroup(ctx, t, redisStream, redisClient) })
conf.Arbitrator.RedisValidationServerConfig.ModuleRoots = []string{currentRootModule(t).Hex()}
}
_, valStack := createTestValidationNode(t, ctx, &conf)
configByValidationNode(t, nodeConfig, valStack)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Problem here that it'll create both an rpc-validation and a redis-validation.
Need to figure how to configure to use rpc for execution only (like other comments mention),
It's fine to assume here if redisURL != "" that you do want rpc for execution and not for validation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Changed ValidationServerConfigs to set to nil so that there's no rpc-validation, now that we have ExecutionServerConfig separately, this can be nil.

@@ -54,49 +55,48 @@ func (e *disableReproduce) apply(_ *ConsumerConfig, prodCfg *ProducerConfig) {

func producerCfg() *ProducerConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

cant you just return &TestProducerConfig?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We run tests in parallel and some of them change property on it, e.g. set EnableReproduce to false. If you use same instance for concurrently running tests, tests will become flaky.

EnableReproduce: TestProducerConfig.EnableReproduce,
CheckPendingInterval: TestProducerConfig.CheckPendingInterval,
KeepAliveTimeout: TestProducerConfig.KeepAliveTimeout,
CheckResultInterval: TestProducerConfig.CheckResultInterval,
}
}

func consumerCfg() *ConsumerConfig {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(same as producerCfg)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same as above (technically we don't change consumer config, but just to follow the pattern).

@anodar anodar requested a review from tsahee April 20, 2024 09:58
Copy link
Contributor

@tsahee tsahee left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

got as far as redisproducer. will continue soon

staker/stateless_block_validator.go Outdated Show resolved Hide resolved
@@ -173,6 +179,7 @@ var TestBlockValidatorConfig = BlockValidatorConfig{
Enable: false,
ValidationServer: rpcclient.TestClientConfig,
ValidationServerConfigs: []rpcclient.ClientConfig{rpcclient.TestClientConfig},
ExecutionServerConfig: rpcclient.TestClientConfig,
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

need to also add ExecutionServerConfig to DefaultBlockValidatorConfig with same value as ValidationServer

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

staker/block_validator.go Show resolved Hide resolved
staker/stateless_block_validator.go Show resolved Hide resolved
validator/client/redisproducer.go Outdated Show resolved Hide resolved
validator/client/redisproducer.go Outdated Show resolved Hide resolved
@anodar anodar requested a review from tsahee April 22, 2024 19:15
DataB64 string
}

type RedisValidationServerConfig struct {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the config , defaults and addoptions belongs in valnode/redisconsumer.go

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can't just move them there though, it will introduce cyclic dependency valnode->server_arb ->valnode.

validator_spawner.go (server_arb) initializes redis validation server config (calls ValidationServerConfigAddOptions, that would be in valnode if I moved).
valnode.go itself spawns validator spawners so has dependency on server_arb.

I have moved out redis consumer (and also producer for consistency) into separate packages to accomodate your comment.

@@ -1060,6 +1065,9 @@ func (v *BlockValidator) Initialize(ctx context.Context) error {
}
}
log.Info("BlockValidator initialized", "current", v.currentWasmModuleRoot, "pending", v.pendingWasmModuleRoot)
if err := v.StatelessBlockValidator.Initialize([]common.Hash{v.currentWasmModuleRoot, v.pendingWasmModuleRoot}); err != nil {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

check if they are identical, and if so only send one - this is common and we don't want a warning on boot

Copy link
Contributor Author

@anodar anodar Apr 23, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@anodar anodar requested a review from tsahee April 23, 2024 10:03
c.StopWaiter.StopAndWait()
}

func (c *ValidationClient) Name() string {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

here we can just return name as it's not from cfg

if err != nil {
log.Warn("closing execution client run got error", "err", err, "client", r.client.Name(), "id", r.id)
}
})
}

func ValidationInputToJson(entry *validator.ValidationInput) *server_api.InputJSON {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can that move to be with InputJSON?

@@ -182,3 +182,34 @@ func (a *ExecServerAPI) CloseExec(execid uint64) {
run.run.Close()
delete(a.runs, execid)
}

func ValidationInputFromJson(entry *server_api.InputJSON) (*validator.ValidationInput, error) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can this move to be near InputJSON?

@tsahee tsahee enabled auto-merge April 23, 2024 23:00
@tsahee tsahee merged commit 9aff6dc into master Apr 23, 2024
8 checks passed
@tsahee tsahee deleted the nitro-pubsub branch April 23, 2024 23:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
s Automatically added by the CLA bot if the creator of a PR is registered as having signed the CLA.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants