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

Add missing methods to transaction interface #5732

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
e3752c8
added missing methods to transaction interface, created new AccessLis…
daniellehrner Jul 30, 2023
d4cdcc3
CHANGELOG.md entry
daniellehrner Jul 30, 2023
e1e93dc
added missing javadoc entry
daniellehrner Jul 30, 2023
547133b
Update datatypes/src/main/java/org/hyperledger/besu/datatypes/Transac…
daniellehrner Aug 4, 2023
3ebafb3
Update datatypes/src/main/java/org/hyperledger/besu/datatypes/Transac…
daniellehrner Aug 4, 2023
8221324
Make smart contract permissioning features work with london fork (#5727)
siladu Jul 31, 2023
ff7c669
Correctly cache the TransactionValidator instance on creation (#5726)
fab-10 Jul 31, 2023
d7c6ef3
Reference tests 12.3 (#5733)
shemnon Jul 31, 2023
349649e
Return all not selected transactions, not only invalid ones. (#5711)
fab-10 Aug 1, 2023
bf99643
Address import performance issues (#5734)
shemnon Aug 2, 2023
4f0fe20
Add type to PendingTransactionDetail (#5729)
gtebrean Aug 2, 2023
675bd30
Migrate to blobGas in execution-spec-tests (#5745)
shemnon Aug 2, 2023
4e08e53
remove AccessListEntry interface and move its class to the datatypes …
daniellehrner Aug 4, 2023
312769b
add missing cost methods to interface, add method to get RLP of trans…
daniellehrner Aug 4, 2023
8bf7073
Merge branch 'main' into feat/issue-5731/update-transaction-interface
daniellehrner Aug 4, 2023
5f6666d
updating hash with updated reference tests
daniellehrner Aug 4, 2023
6855b76
added missing javadocs
daniellehrner Aug 4, 2023
5ca6a64
fixed compiler errors in integration tests
daniellehrner Aug 4, 2023
180135a
Merge branch 'main' into feat/issue-5731/update-transaction-interface
daniellehrner Aug 9, 2023
876c4e4
Merge branch 'main' into feat/issue-5731/update-transaction-interface
garyschulte Aug 21, 2023
3d7c991
retro blobGas name change into Transaction interface
garyschulte Aug 21, 2023
b71032f
removed methods from transaction interface which values can be derive…
daniellehrner Aug 22, 2023
12b88e1
Merge branch 'main' into feat/issue-5731/update-transaction-interface
daniellehrner Aug 22, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- Add ABI-decoded revert reason to `eth_call` and `eth_estimateGas` responses [#5705](https://github.com/hyperledger/besu/issues/5705)

### Additions and Improvements
- Add missing methods to the `Transaction` interface [#5732](https://github.com/hyperledger/besu/pull/5732)
- Added `benchmark` subcommand to `evmtool` [#5754](https://github.com/hyperledger/besu/issues/5754)
- JSON output is now compact by default. This can be overridden by the new `--json-pretty-print-enabled` CLI option. [#5766](https://github.com/hyperledger/besu/pull/5766)

Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright ConsenSys AG.
* Copyright Hyperledger Besu Contributors.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
Expand All @@ -12,35 +12,18 @@
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.evm;

import org.hyperledger.besu.datatypes.Address;
package org.hyperledger.besu.datatypes;

import java.util.List;
import java.util.stream.Collectors;

import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;

/** The Access list entry. */
public class AccessListEntry {
private final Address address;
private final List<Bytes32> storageKeys;

/**
* Instantiates a new Access list entry.
*
* @param address the address
* @param storageKeys the storage keys
*/
public AccessListEntry(final Address address, final List<Bytes32> storageKeys) {
this.address = address;
this.storageKeys = storageKeys;
}

/** An access list entry as defined in EIP-2930 */
public record AccessListEntry(Address address, List<Bytes32> storageKeys) {
daniellehrner marked this conversation as resolved.
Show resolved Hide resolved
/**
* Create access list entry.
*
Expand All @@ -56,26 +39,6 @@ public static AccessListEntry createAccessListEntry(
address, storageKeys.stream().map(Bytes32::fromHexString).collect(Collectors.toList()));
}

/**
* Gets address.
*
* @return the address
*/
@JsonIgnore
public Address getAddress() {
return address;
}

/**
* Gets storage keys.
*
* @return the storage keys
*/
@JsonIgnore
public List<Bytes32> getStorageKeys() {
return storageKeys;
}

/**
* Gets address string.
*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.datatypes;

import java.math.BigInteger;
import java.util.List;
import java.util.Optional;

import org.apache.tuweni.bytes.Bytes;
Expand Down Expand Up @@ -183,4 +184,39 @@ default Optional<? extends Quantity> getMaxFeePerBlobGas() {
* @return the type of the transaction
*/
TransactionType getType();

/**
* Return the versioned hashes for this transaction.
*
* @return optional list of versioned hashes
*/
Optional<List<VersionedHash>> getVersionedHashes();

/**
* Return the blobs with commitments for this transaction.
*
* @return optional blobs with commitments
*/
Optional<BlobsWithCommitments> getBlobsWithCommitments();

/**
* Return the address of the contract, if the transaction creates one
*
* @return address of new contract or empty otherwise
*/
Optional<Address> contractAddress();

/**
* Return the access list in case of EIP-2930 transaction
*
* @return optional access list
*/
Optional<List<AccessListEntry>> getAccessList();

/**
* Returns the transaction with the proper encoding
*
* @return the encoded transaction as Bytes
*/
Bytes encoded();
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter;
Expand All @@ -27,7 +28,6 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.CreateAccessListResult;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.testutil.BlockTestUtil;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@

import static org.assertj.core.api.Assertions.assertThat;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter;
Expand All @@ -26,7 +27,6 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.testutil.BlockTestUtil;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.ethereum.api.graphql.internal.pojoadapter;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.evm.AccessListEntry;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -32,11 +32,11 @@ public AccessListEntryAdapter(final AccessListEntry accessListEntry) {
}

public List<Bytes32> getStorageKeys() {
final var storage = accessListEntry.getStorageKeys();
final var storage = accessListEntry.storageKeys();
return new ArrayList<>(storage);
}

public Optional<Address> getAddress() {
return Optional.of(accessListEntry.getAddress());
return Optional.of(accessListEntry.address());
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.RpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
Expand All @@ -29,7 +30,6 @@
import org.hyperledger.besu.ethereum.transaction.CallParameter;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.tracing.AccessListOperationTracer;

import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.json.HexLongDeserializer;
import org.hyperledger.besu.ethereum.core.json.HexStringDeserializer;
import org.hyperledger.besu.ethereum.transaction.CallParameter;
import org.hyperledger.besu.evm.AccessListEntry;

import java.util.List;
import java.util.Optional;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;

import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.datatypes.AccessListEntry;

import java.util.Collection;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.evm.AccessListEntry;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,13 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder;
import org.hyperledger.besu.evm.AccessListEntry;

import java.util.List;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import static org.mockito.Mockito.verify;
import static org.mockito.Mockito.when;

import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
Expand All @@ -43,7 +44,6 @@
import org.hyperledger.besu.ethereum.transaction.TransactionSimulator;
import org.hyperledger.besu.ethereum.transaction.TransactionSimulatorResult;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.tracing.AccessListOperationTracer;

import java.util.ArrayList;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,13 +18,13 @@

import org.hyperledger.besu.crypto.SECPSignature;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.evm.AccessListEntry;

import java.math.BigInteger;
import java.util.List;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,13 @@
import org.hyperledger.besu.crypto.SECPSignature;
import org.hyperledger.besu.crypto.SignatureAlgorithm;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Blob;
import org.hyperledger.besu.datatypes.BlobsWithCommitments;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.KZGCommitment;
import org.hyperledger.besu.datatypes.KZGProof;
import org.hyperledger.besu.datatypes.Quantity;
import org.hyperledger.besu.datatypes.Sha256Hash;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.VersionedHash;
Expand All @@ -42,10 +42,8 @@
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.evm.AccessListEntry;

import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collection;
import java.util.List;
import java.util.Objects;
Expand Down Expand Up @@ -432,20 +430,11 @@ public Optional<Wei> getMaxFeePerBlobGas() {
}

/**
* Boolean which indicates the transaction has associated cost data, whether gas price or 1559 fee
* market parameters.
* Return the effective priority fee per gas for this transaction.
*
* @return whether cost params are present
* @param maybeBaseFee base fee in case of EIP-1559 transaction
* @return priority fee per gas in wei
*/
public boolean hasCostParams() {
return Arrays.asList(
getGasPrice(), getMaxFeePerGas(), getMaxPriorityFeePerGas(), getMaxFeePerBlobGas())
.stream()
.flatMap(Optional::stream)
.map(Quantity::getAsBigInteger)
.anyMatch(q -> q.longValue() > 0L);
}

public Wei getEffectivePriorityFeePerGas(final Optional<Wei> maybeBaseFee) {
return maybeBaseFee
.map(
Expand Down Expand Up @@ -547,6 +536,7 @@ public Optional<Bytes> getData() {
return getTo().isPresent() ? Optional.of(payload) : Optional.empty();
}

@Override
public Optional<List<AccessListEntry>> getAccessList() {
return maybeAccessList;
}
Expand Down Expand Up @@ -625,6 +615,13 @@ public void writeTo(final RLPOutput out) {
TransactionEncoder.encodeForWire(this, out);
}

@Override
public Bytes encoded() {
final BytesValueRLPOutput rplOutput = new BytesValueRLPOutput();
writeTo(rplOutput);
return rplOutput.encoded();
}

@Override
public BigInteger getR() {
return signature.getR();
Expand Down Expand Up @@ -780,6 +777,7 @@ public Wei getMaxGasPrice() {
new IllegalStateException(
"Transaction requires either gasPrice or maxFeePerGas")));
}

/**
* Calculates the effectiveGasPrice of a transaction on the basis of an {@code Optional<Long>}
* baseFee and handles unwrapping Optional fee parameters. If baseFee is present, effective gas is
Expand All @@ -801,10 +799,12 @@ public TransactionType getType() {
return this.transactionType;
}

@Override
public Optional<List<VersionedHash>> getVersionedHashes() {
return versionedHashes;
}

@Override
public Optional<BlobsWithCommitments> getBlobsWithCommitments() {
return blobsWithCommitments;
}
Expand Down Expand Up @@ -1127,6 +1127,7 @@ public String toTraceLog() {
return sb.append("}").toString();
}

@Override
public Optional<Address> contractAddress() {
if (isContractCreation()) {
return Optional.of(Address.contractAddress(getSender(), getNonce()));
Expand Down