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

validation spawner only recieves one validation binary #2505

Merged
merged 12 commits into from
Jul 29, 2024
Merged

Conversation

tsahee
Copy link
Contributor

@tsahee tsahee commented Jul 18, 2024

This prepares some work towards multi-arch support, but mostly reduces validation entry size

  • Adding a StylusArch field to validation input. Supported values are GOARCH for jit validation and "wavm" for arbitrator-validation
  • userWasms contain either Asm or Module, not both
  • add field "stylusArch" to spawners, indicating which arch they require
  • also - compress the module before sending it over rpc to reduce it's size

@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 Jul 18, 2024
@tsahee tsahee requested review from magicxyyz and PlasmaPower July 18, 2024 23:56
@PlasmaPower
Copy link
Collaborator

PlasmaPower commented Jul 19, 2024

Are we sure we want to go this route? I thought we'd previously talked about potentially running nitro-val instances on mixed architectures. Perhaps we could allow configuring multiple architectures for the validator, and the default would be sending all of them?

@tsahee
Copy link
Contributor Author

tsahee commented Jul 19, 2024

Perhaps we could allow configuring multiple architectures for the validator, and the default would be sending all of them?

Good idea.
I implemented the options to have multiple architectures in the Input. Default for redis is still only wavm. After @magicxyyz work to implement cross-compiling we might change that (at that stage, we'll also use better architecture defintions, GOARCH is just a siple placeholder)

Copy link
Contributor

@magicxyyz magicxyyz left a comment

Choose a reason for hiding this comment

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

looks good, just one metric name fix needed

validatorValidationWaitToRecordHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRecord", nil, metrics.NewBoundedHistogramSample())
validatorValidationRecordingHist = metrics.NewRegisteredHistogram("arb/validator/validations/recording", nil, metrics.NewBoundedHistogramSample())
validatorValidationWaitToLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRun", nil, metrics.NewBoundedHistogramSample())
validatorValidationLaunchHist = metrics.NewRegisteredHistogram("arb/validator/validations/waitToRun", nil, metrics.NewBoundedHistogramSample())
Copy link
Contributor

@magicxyyz magicxyyz Jul 23, 2024

Choose a reason for hiding this comment

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

here the metric name needs to be fixed
How about naming it .../validations/launch and previous one .../validations/waitToLaunch to match the variable names?
Alternatively, we could rename the metrics variables to match the names

magicxyyz
magicxyyz previously approved these changes Jul 23, 2024
if err != nil {
return nil, err
}
uncompressed, err := arbcompress.Decompress(decoded, 30000000)
Copy link
Contributor

@magicxyyz magicxyyz Jul 23, 2024

Choose a reason for hiding this comment

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

do we have a guarantee that the wasm won't exceed the 30000000 bytes? currently the uncompressed data size is not checked before compression in ValidationInputToJson -- should we also check the limit there?

nit: we might want to use some named constant for the max size 30000000 (?)

magicxyyz
magicxyyz previously approved these changes Jul 24, 2024
Copy link
Contributor

@magicxyyz magicxyyz left a comment

Choose a reason for hiding this comment

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

LGTM

PlasmaPower
PlasmaPower previously approved these changes Jul 25, 2024
Copy link
Collaborator

@PlasmaPower PlasmaPower left a comment

Choose a reason for hiding this comment

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

LGTM, but I have some ideas for potential improvements, maybe in a follow-up PR

staker/block_validator.go Outdated Show resolved Hide resolved
staker/block_validator.go Outdated Show resolved Hide resolved
staker/block_validator.go Outdated Show resolved Hide resolved
staker/block_validator.go Outdated Show resolved Hide resolved
staker/block_validator.go Show resolved Hide resolved
validator/client/validation_client.go Show resolved Hide resolved
if err != nil {
continue
}
archWasms[moduleHash] = base64.StdEncoding.EncodeToString(compressed)
Copy link
Collaborator

Choose a reason for hiding this comment

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

At some point it might be worth doing something like *jsonapi.PreimagesMapJson to optimize this and avoid extra copying but that probably belongs in a separate PR. As-is it's still more efficient than what we previously had.

maxSize := 2_000_000
var uncompressed []byte
for {
uncompressed, err = arbcompress.Decompress(decoded, maxSize)
Copy link
Collaborator

Choose a reason for hiding this comment

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

Perhaps we should use a go brotli library for this instead, since it's not in consensus and would have a nicer API? Or alternatively we could add a new decompression stream API to this.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

forgot to address this:
I think we will lose more from having multiple implementations of brotli than we'll gain from a better API in this specific case.
Also, I hope API will improve after wasmer answer and provide a reasonable upper-bound.

@tsahee tsahee dismissed stale reviews from PlasmaPower and magicxyyz via a8284d5 July 26, 2024 18:34
@tsahee tsahee requested review from PlasmaPower and magicxyyz July 29, 2024 15:53
Copy link
Collaborator

@PlasmaPower PlasmaPower left a comment

Choose a reason for hiding this comment

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

LGTM

@tsahee tsahee enabled auto-merge July 29, 2024 21:23
@tsahee tsahee merged commit 1b9f7ab into master Jul 29, 2024
13 checks passed
@tsahee tsahee deleted the redis_val_fixes branch July 29, 2024 22:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
design-approved 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.

3 participants