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

core: 4844 opcode and precompile #27356

Merged
merged 3 commits into from
Jun 5, 2023

Conversation

MariusVanDerWijden
Copy link
Member

@MariusVanDerWijden MariusVanDerWijden commented May 25, 2023

This PR implements the pointEvaluation precompile and the DATAHASH opcode both are needed for 4844
Spec: https://eips.ethereum.org/EIPS/eip-4844#point-evaluation-precompile

crypto/kzg4844/kzg4844.go Outdated Show resolved Hide resolved
crypto/kzg4844/kzg4844.go Outdated Show resolved Hide resolved
core/vm/contracts.go Outdated Show resolved Hide resolved
params/protocol_params.go Outdated Show resolved Hide resolved
core/vm/contracts.go Outdated Show resolved Hide resolved
common.BytesToAddress([]byte{7}): &bn256ScalarMulIstanbul{},
common.BytesToAddress([]byte{8}): &bn256PairingIstanbul{},
common.BytesToAddress([]byte{9}): &blake2F{},
common.BytesToAddress([]byte{20}): &pointEvaluation{},
Copy link
Contributor

Choose a reason for hiding this comment

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

Whaaa.. -- it's at 20? 👀

Copy link
Member Author

Choose a reason for hiding this comment

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

Yep, because of the BLS precompiles

return nil, errors.Join(errBlobVerifyKZGProof, err)
}

return common.CopyBytes(kzg4844.PrecompileReturnValue[:]), nil
Copy link
Contributor

Choose a reason for hiding this comment

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

Wait -- is this using a public global variable in the kzg8444 package to return the response?
Wow, that's dirtier than ..

Copy link
Contributor

@holiman holiman May 31, 2023

Choose a reason for hiding this comment

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

I mean... what if an rpc call happens to invoke the precompile too, for example?
Or the miner, building a block?

Copy link
Contributor

Choose a reason for hiding this comment

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

Ahh.. wait.. the return value of this op is not input-dependent??

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes the precompile returns a constant

@MariusVanDerWijden MariusVanDerWijden changed the title WIP: 4844 opcode precompile core: 4844 opcode precompile May 31, 2023
@MariusVanDerWijden MariusVanDerWijden changed the title core: 4844 opcode precompile core: 4844 opcode and precompile May 31, 2023
core/vm/contracts_test.go Outdated Show resolved Hide resolved
core/vm/contracts.go Outdated Show resolved Hide resolved
core/vm/contracts.go Outdated Show resolved Hide resolved
core/vm/contracts.go Outdated Show resolved Hide resolved
core/vm/contracts.go Outdated Show resolved Hide resolved
@MariusVanDerWijden MariusVanDerWijden marked this pull request as ready for review June 5, 2023 07:09
@@ -1081,7 +1082,7 @@ func (b *kzgPointEvaluation) RequiredGas(input []byte) uint64 {

const (
blobVerifyInputLength = 192 // Max input length for the point evaluation precompile.
blobVerifyKZGVersion uint8 = 0x01 // Version byte for the point evaluation precompile.
blobCommitmentVersionKZG uint8 = 0x01 // Version byte for the point evaluation precompile.
Copy link
Member

Choose a reason for hiding this comment

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

This is part of the params package, shouldn't we use that?

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

Copy link
Member

@karalabe karalabe left a comment

Choose a reason for hiding this comment

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

SGTM

@karalabe karalabe added this to the 1.12.1 milestone Jun 5, 2023
@karalabe karalabe merged commit c537ace into ethereum:master Jun 5, 2023
devopsbo3 pushed a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
* core: crypto: implement BLOBHASH and pointEval precompile

* core: crypto: fixed nitpicks, moved precompile return value

* core/vm: fix review comments
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
devopsbo3 added a commit to HorizenOfficial/go-ethereum that referenced this pull request Nov 10, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants