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

ethrpc: strictness validation level when unmarshalling blocks and txns #143

Merged
merged 9 commits into from
Oct 23, 2024

Conversation

pkieltyka
Copy link
Member

@pkieltyka pkieltyka commented Oct 23, 2024

This PR introduces StrictnessLevel on a ethrpc.Provider which effects how the provider will validate block and transaction data from nodes at the time of unmarshalling the json into a runtime type. Options >= 1 will perform rpc client-side checksum validation of the data coming from the nodes. Option 0, disables client-side validation.

The strictness levels:

  • 0: disabled, no validation on blocks or transactions (default)
  • 1: semi-strict transactions – validates only transaction V, R, S values
  • 2: strict block and transactions – validates block hash, sender address, and transaction signatures

Usage

// default, no validation – we trust values from the node
provider, err := ethrpc.NewProvider(nodeURL)

// semi validation
provider, err := ethrpc.NewProvider(nodeURL, ethrpc.WithSemiValidation())

// strict validation
provider, err := ethrpc.NewProvider(nodeURL, ethrpc.WithStrictValidation())

// we also have ethrpc.WithStrictness(x) where you can pass the specific value, the above is sugar

@pkieltyka pkieltyka merged commit 0525c78 into master Oct 23, 2024
8 checks passed
@pkieltyka pkieltyka deleted the strict-block-hash branch October 23, 2024 14:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant