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
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
32 commits
Select commit Hold shift + click to select a range
aadd8e7
replace iteration over tx type enums with explicit lists, fixes BesuE…
jflo Jan 13, 2023
f62cc77
fixes more tests
jflo Jan 14, 2023
aae68e4
fixes BlockchainQueriesTest by changing the ORDER of transaction type…
jflo Jan 14, 2023
8a6ef6d
fixes test that won't pass if local hostname unresolvable via reverse…
jflo Jan 15, 2023
997596d
removed commented code
jflo Jan 15, 2023
9bc7bfa
removed commented code
jflo Jan 15, 2023
8157269
changelog blurb
jflo Jan 4, 2023
60adb09
naive impl, passes a happy path test
jflo Jan 10, 2023
6e07e73
adds error condition coverage
jflo Jan 10, 2023
f331684
updating TX construction signatures
jflo Jan 10, 2023
fb76b2f
updates plugin api hash since we've got a new TX type.
jflo Jan 10, 2023
2f23a2f
changelog blurb
jflo Jan 4, 2023
753d975
naive impl, passes a happy path test
jflo Jan 10, 2023
448ce9e
adds error condition coverage
jflo Jan 10, 2023
27c0fe5
unit tests passing
jflo Jan 11, 2023
b364cda
rebased off of 4844_tx_type
jflo Jan 15, 2023
dc5bd41
adopts pr suggestions
jflo Jan 16, 2023
6c1ae0c
never throw an invalid operation
jflo Jan 17, 2023
bd14bb6
more memory
jflo Jan 17, 2023
f03af6f
fix broken integration test that doesn't use the builder, uses the pu…
jflo Jan 17, 2023
9e90c0a
adopts pr suggestions
jflo Jan 18, 2023
70beaef
adopts pr suggestions
jflo Jan 18, 2023
aaa9290
Merge branch 'main' into DATAHASH_opcode
jflo Jan 19, 2023
429588b
Update evm/src/main/java/org/hyperledger/besu/evm/operation/DataHashO…
jflo Jan 19, 2023
b7d5380
Update evm/src/test/java/org/hyperledger/besu/evm/operations/DataHash…
jflo Jan 19, 2023
79d9d26
Update evm/src/test/java/org/hyperledger/besu/evm/operations/DataHash…
jflo Jan 19, 2023
534c1a0
adds test coverage to ensure halt reason is null
jflo Jan 19, 2023
1aaf58c
Merge branch 'main' into DATAHASH_opcode
jflo Jan 19, 2023
d16cee5
minimized new param impact to legacy Transaction constructors
jflo Jan 19, 2023
081edaa
Merge branch 'main' into DATAHASH_opcode
jflo Jan 19, 2023
742a111
Merge branch 'main' into DATAHASH_opcode
jflo Jan 20, 2023
bb448be
fixes conflict
jflo Jan 20, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
rebased off of 4844_tx_type
Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
jflo committed Jan 18, 2023
commit b364cda62be1a7a293077b16544b33c9af1d8641
Original file line number Diff line number Diff line change
Expand Up @@ -303,7 +303,7 @@ public Transaction(
final Bytes payload,
final Address sender,
final Optional<BigInteger> chainId,
final Optional<List<Hash>> versionedHashes ) {
final Optional<List<Hash>> versionedHashes) {
this(
nonce,
Optional.of(gasPrice),
Expand Down Expand Up @@ -768,7 +768,7 @@ private static Bytes32 computeSenderRecoveryHash(
preimage = frontierPreimage(nonce, gasPrice, gasLimit, to, value, payload, chainId);
break;
case EIP1559:
case BLOB_TX_TYPE:
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

preimage =
eip1559Preimage(
nonce,
Expand Down Expand Up @@ -1074,7 +1074,7 @@ public Builder versionedHashes(final Optional<List<Hash>> versionedHashes) {

public Builder guessType() {
if (versionedHashes != null && versionedHashes.isPresent()) {
transactionType = TransactionType.BLOB_TX_TYPE;
transactionType = TransactionType.EIP4844;
} else if (maxPriorityFeePerGas != null || maxFeePerGas != null) {
transactionType = TransactionType.EIP1559;
} else if (accessList.isPresent()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,9 +55,7 @@ interface Decoder {
TransactionType.ACCESS_LIST,
TransactionDecoder::decodeAccessList,
TransactionType.EIP1559,
TransactionDecoder::decodeEIP1559,
TransactionType.BLOB_TX_TYPE,
TransactionDecoder::decodeEIP4844);
TransactionDecoder::decodeEIP1559);

private static final Supplier<SignatureAlgorithm> SIGNATURE_ALGORITHM =
Suppliers.memoize(SignatureAlgorithmFactory::getInstance);
Expand Down Expand Up @@ -217,45 +215,4 @@ static Transaction decodeEIP1559(final RLPInput input) {
input.leaveList();
return transaction;
}

// TODO: copypasta till SSZ decoder available
static Transaction decodeEIP4844(final RLPInput input) {
input.enterList();
final BigInteger chainId = input.readBigIntegerScalar();
final Transaction.Builder builder =
Transaction.builder()
.type(TransactionType.BLOB_TX_TYPE)
.chainId(chainId)
.nonce(input.readLongScalar())
.maxPriorityFeePerGas(Wei.of(input.readUInt256Scalar()))
.maxFeePerGas(Wei.of(input.readUInt256Scalar()))
.gasLimit(input.readLongScalar())
.to(input.readBytes(v -> v.size() == 0 ? null : Address.wrap(v)))
.value(Wei.of(input.readUInt256Scalar()))
.payload(input.readBytes())
.accessList(
input.readList(
accessListEntryRLPInput -> {
accessListEntryRLPInput.enterList();
final AccessListEntry accessListEntry =
new AccessListEntry(
Address.wrap(accessListEntryRLPInput.readBytes()),
accessListEntryRLPInput.readList(RLPInput::readBytes32));
accessListEntryRLPInput.leaveList();
return accessListEntry;
}));
final byte recId = (byte) input.readIntScalar();
final Transaction transaction =
builder
.signature(
SIGNATURE_ALGORITHM
.get()
.createSignature(
input.readUInt256Scalar().toUnsignedBigInteger(),
input.readUInt256Scalar().toUnsignedBigInteger(),
recId))
.build();
input.leaveList();
return transaction;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -43,8 +43,6 @@ interface Encoder {
TransactionType.ACCESS_LIST,
TransactionEncoder::encodeAccessList,
TransactionType.EIP1559,
TransactionEncoder::encodeEIP1559,
TransactionType.BLOB_TX_TYPE,
TransactionEncoder::encodeEIP1559);

public static void encodeForWire(final Transaction transaction, final RLPOutput rlpOutput) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ public TransactionProcessingResult processTransaction(
.contract(contractAddress)
.inputData(Bytes.EMPTY)
.versionedHashes(
transaction.getType() == TransactionType.BLOB_TX_TYPE
transaction.getType() == TransactionType.EIP4844
? transaction.getVersionedHashes()
: Optional.empty())
.code(
Expand All @@ -398,7 +398,7 @@ public TransactionProcessingResult processTransaction(
.contract(to)
.inputData(transaction.getPayload())
.versionedHashes(
transaction.getType() == TransactionType.BLOB_TX_TYPE
transaction.getType() == TransactionType.EIP4844
? transaction.getVersionedHashes()
: Optional.empty())
.code(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -373,8 +373,6 @@ public Transaction transaction(
return eip1559Transaction(payload, to);
case ACCESS_LIST:
return accessListTransaction(payload, to);
case BLOB_TX_TYPE:
return eip4844Transaction(payload, to);
default:
throw new RuntimeException(
String.format(
Expand All @@ -397,22 +395,6 @@ private Transaction accessListTransaction(final Bytes payload, final Address to)
.signAndBuild(generateKeyPair());
}

private Transaction eip4844Transaction(final Bytes payload, final Address to) {
return Transaction.builder()
.type(TransactionType.BLOB_TX_TYPE)
.nonce(random.nextLong())
.maxPriorityFeePerGas(Wei.wrap(bytesValue(4)))
.maxFeePerGas(Wei.wrap(bytesValue(4)))
.gasLimit(positiveLong())
.to(to)
.value(Wei.wrap(bytes32()))
.payload(payload)
.chainId(BigInteger.ONE)
.versionedHashes(
Optional.of(Arrays.asList(Hash.fromHexStringLenient("0xdeadbeefb0b0facecafebabe"))))
.signAndBuild(generateKeyPair());
}

private List<AccessListEntry> accessList() {
final List<Address> accessedAddresses =
Stream.generate(this::address).limit(1L + random.nextInt(3)).collect(toUnmodifiableList());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,11 @@
import static java.util.stream.Collectors.toUnmodifiableSet;
import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.plugin.data.TransactionType;

import java.util.Arrays;
import java.util.List;
import java.util.Optional;
import java.util.Set;
import java.util.stream.Stream;

Expand All @@ -41,11 +38,9 @@ public void guessTypeCanGuessAllTypes() {
final Transaction.Builder accessListBuilder =
Transaction.builder()
.accessList(List.of(new AccessListEntry(gen.address(), List.of(gen.bytes32()))));
final Transaction.Builder eip4844Builder =
Transaction.builder().versionedHashes(Optional.of(Arrays.asList(Hash.ZERO)));

final Set<TransactionType> guessedTypes =
Stream.of(frontierBuilder, eip1559Builder, accessListBuilder, eip4844Builder)
Stream.of(frontierBuilder, eip1559Builder, accessListBuilder)
.map(transactionBuilder -> transactionBuilder.guessType().getTransactionType())
.collect(toUnmodifiableSet());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import org.hyperledger.besu.evm.operation.DataHashOperation;
import org.hyperledger.besu.evm.operation.Operation;

import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Optional;
Expand Down