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

Datahash opcode #4933

Merged
merged 32 commits into from
Jan 20, 2023
Merged

Datahash opcode #4933

merged 32 commits into from
Jan 20, 2023

Conversation

jflo
Copy link
Contributor

@jflo jflo commented Jan 15, 2023

Don't merge till https://github.com/hyperledger/besu/pull/4931/files has been merged.

@jflo jflo requested review from gezero and fab-10 January 15, 2023 21:34
Copy link
Contributor

@fab-10 fab-10 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, please check my comments/questions

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -753,6 +768,7 @@ private static Bytes32 computeSenderRecoveryHash(
preimage = frontierPreimage(nonce, gasPrice, gasLimit, to, value, payload, chainId);
break;
case EIP1559:
case EIP4844:
Copy link
Contributor

Choose a reason for hiding this comment

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

idk too much about the recovery hash, so just asking if the versionedHashes should be ignored or taken in consideration here

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I'm also unclear, but i think this will make more sense when we merge in the SSZ serialization

@@ -979,6 +995,7 @@ public static class Builder {
protected Optional<BigInteger> chainId = Optional.empty();

protected Optional<BigInteger> v = Optional.empty();
protected Optional<List<Hash>> versionedHashes;
Copy link
Contributor

Choose a reason for hiding this comment

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

it seems simpler and more efficient to treat this likewise maxPriorityFeePerGas and similar optional field, keeping it null by default and using Optional.ofNullable in the build method

Copy link
Contributor

@shemnon shemnon left a comment

Choose a reason for hiding this comment

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

One thing is unclear to me, if the chain is post-cancun, and they pass in a legacy or 1559 transaction should the datahash opcode be available? i.e. should it act as though there were zero hashes and always return zero or should it throw an invalid opcode if a 1559 tx calls a contract with the opcode?

Currently it looks like we are coded for the latter. This doesn't seem like the valid set of opcodes should be a function of the transaction format.

@jflo
Copy link
Contributor Author

jflo commented Jan 17, 2023

One thing is unclear to me, if the chain is post-cancun, and they pass in a legacy or 1559 transaction should the datahash opcode be available? i.e. should it act as though there were zero hashes and always return zero or should it throw an invalid opcode if a 1559 tx calls a contract with the opcode?

Currently it looks like we are coded for the latter. This doesn't seem like the valid set of opcodes should be a function of the transaction format.

Yes! I struggled with this as well while implementing it, and in hindsight i think I like returning zero instead. That way at least contract authors using DATAHASH can choose to accept or not pre-4844 transactions without a halt. I will change this and bring it up for discussion and see if test cases to cover this are planned.

@jflo jflo marked this pull request as ready for review January 17, 2023 19:18
@jflo jflo requested review from shemnon and fab-10 January 17, 2023 19:18
jflo added 20 commits January 18, 2023 13:37
…ventsImplTest

Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…s, wtf

Signed-off-by: Justin Florentine <justin+github@florentine.us>
… dns

Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…blic constructor.

Signed-off-by: Justin Florentine <justin+github@florentine.us>
jflo added 2 commits January 18, 2023 13:37
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
@jflo jflo requested a review from fab-10 January 18, 2023 20:55
}

@Test
public void failsOnVersionIndexOutOFBounds() {
Copy link
Contributor

Choose a reason for hiding this comment

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

fail in tests indicates to me an exception raised, rather than a zero push.

  public void pushesZeroOnVersionInexOutOfBounds() {

Copy link
Contributor

@shemnon shemnon left a comment

Choose a reason for hiding this comment

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

Return need to be null exceptional halt reason, and some minor test changes (perhaps we should add the null exceptional halt to the last two unit tests for the data hash)

jflo and others added 3 commits January 19, 2023 09:28
…peration.java

Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…OperationTest.java

Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
…OperationTest.java

Co-authored-by: Danno Ferrin <danno.ferrin@shemnon.com>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Copy link
Contributor

@diega diega left a comment

Choose a reason for hiding this comment

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

Doesn't o.h.b.e.m.MainnetProtocolSpecs#cancunDefinition need to set the transactionValidatorBuilder to add support for the new BLOB tx?

For the future, maybe we could came up with a different design for the Transaction/MessageFrame that doesn't carry so many Optionals all around.

Signed-off-by: Justin Florentine <justin+github@florentine.us>
@jflo jflo enabled auto-merge (squash) January 19, 2023 16:42
jflo added 3 commits January 19, 2023 14:10
Signed-off-by: Justin Florentine <justin+github@florentine.us>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
@jflo jflo merged commit 42d67de into hyperledger:main Jan 20, 2023
elenduuche pushed a commit to elenduuche/besu that referenced this pull request Aug 16, 2023
Implements new DATAHASH opcode in EVM

Signed-off-by: Justin Florentine <justin+github@florentine.us>
eum602 pushed a commit to lacchain/besu that referenced this pull request Nov 3, 2023
Implements new DATAHASH opcode in EVM

Signed-off-by: Justin Florentine <justin+github@florentine.us>
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.

4 participants