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

fix: check versioned hash version for EIP-4844 transactions #6601

Merged
merged 7 commits into from
Feb 15, 2024

Conversation

jtraglia
Copy link
Contributor

I didn't see where the versioned hash's version was checked for EIP-4844 transactions. This PR adds this check. I don't believe this is a big deal though because the CL should also check this.

Here's the spec for this:

This part in particular:

# all versioned blob hashes must start with VERSIONED_HASH_VERSION_KZG
for h in tx.blob_versioned_hashes:
    assert h[0] == VERSIONED_HASH_VERSION_KZG

@jtraglia jtraglia requested a review from mattsse as a code owner February 14, 2024 01:42
@Rjected
Copy link
Member

Rjected commented Feb 14, 2024

it should be checked here, although implicitly by recalculating the versioned hash

let calculated_versioned_hash = kzg_to_versioned_hash(commitment);
if *versioned_hash != calculated_versioned_hash {
return Err(BlobTransactionValidationError::InvalidProof)
}

the error type is useful though, see the TODO in the above snippet

@jtraglia
Copy link
Contributor Author

Oh I see, thanks! Would it be worth keeping both checks? How should I proceed?

You're welcome to modify this PR how you see fit btw.

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

I think the way forward would be to create a new BlobTransactionValidationError variant that describes a mismatched versioned hash, and change this to return that variant

return Err(BlobTransactionValidationError::InvalidProof)

@Rjected
Copy link
Member

Rjected commented Feb 14, 2024

adding a link to the spec, or even quoting the spec code verbatim around those lines would be useful as an artifact of this

@jtraglia
Copy link
Contributor Author

Sounds good. I'll make this change tomorrow.

@jtraglia jtraglia requested a review from gakonst as a code owner February 15, 2024 14:54
@jtraglia
Copy link
Contributor Author

Should be ready now!

Copy link
Member

@Rjected Rjected left a comment

Choose a reason for hiding this comment

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

awesome, this looks good to me, thanks!

@Rjected Rjected added this pull request to the merge queue Feb 15, 2024
Merged via the queue into paradigmxyz:main with commit 9450319 Feb 15, 2024
29 checks passed
@jtraglia jtraglia deleted the eip4844-hash-version-check branch February 15, 2024 18:42
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.

2 participants