Add missing methods to transaction interface (#5732)

* added missing methods to transaction interface, created new AccessListEntry interface to add it to the transaction interface

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* CHANGELOG.md entry

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* added missing javadoc entry

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Update datatypes/src/main/java/org/hyperledger/besu/datatypes/Transaction.java

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Update datatypes/src/main/java/org/hyperledger/besu/datatypes/Transaction.java

Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Make smart contract permissioning features work with london fork (#5727)

* Make smart contract permissioning features work with london fork

Override the transactionSimulator's default TransactionValidationParams with one that allows for exceeding the account balance (which effectively zeros the baseFee).
This mimics the way that eth_estimateGas and eth_call are implemented.
Similar change to #5277

Update ATs to use londonBlock (existing genesis allocs necessitate zeroBaseFee as well)

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>

* changelog
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>

---------

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Correctly cache the TransactionValidator instance on creation (#5726)

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Reference tests 12.3 (#5733)

Update Reference Tests to 12.3
* fix decoding error
* add ignored field
* update module

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Return all not selected transactions, not only invalid ones. (#5711)

This way it is possible for the caller to have more data about the selection
process.

Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Address import performance issues (#5734)

* ensure we are on a single tuweni version
* factor out an unneeded concatenate

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Add type to PendingTransactionDetail (#5729)

* add type

* update changelog

---------

Signed-off-by: George Tebrean <george@web3labs.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* Migrate to blobGas in execution-spec-tests (#5745)

Execution-spec-tests migrated from DataGas to BlobGas and checks for its
inclusion in tests now. Add needed support.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* remove AccessListEntry interface and move its class to the datatypes module

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* add missing cost methods to interface, add method to get RLP of transaction

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* updating hash with updated reference tests

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* added missing javadocs

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* fixed compiler errors in integration tests

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

* retro blobGas name change into Transaction interface

Signed-off-by: garyschulte <garyschulte@gmail.com>

* removed methods from transaction interface which values can be derived through other means. Added new method encoded to return the encoded tx in Bytes instead of RLPOutput

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>

---------

Signed-off-by: Daniel Lehrner <daniel.lehrner@consensys.net>
Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Signed-off-by: George Tebrean <george@web3labs.com>
Signed-off-by: garyschulte <garyschulte@gmail.com>
Co-authored-by: Sally MacFarlane <macfarla.github@gmail.com>
Co-authored-by: Simon Dudley <simon.dudley@consensys.net>
Co-authored-by: Fabio Di Fabio <fabio.difabio@consensys.net>
Co-authored-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
Co-authored-by: George Tebrean <99179176+gtebrean@users.noreply.github.com>
Co-authored-by: garyschulte <garyschulte@gmail.com>
pull/5789/head
Daniel Lehrner 1 year ago committed by GitHub
parent 47285a48f6
commit 19c989a6d9
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 45
      datatypes/src/main/java/org/hyperledger/besu/datatypes/AccessListEntry.java
  3. 36
      datatypes/src/main/java/org/hyperledger/besu/datatypes/Transaction.java
  4. 2
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCreateAccessListIntegrationTest.java
  5. 2
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthEstimateGasIntegrationTest.java
  6. 6
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/AccessListEntryAdapter.java
  7. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCreateAccessList.java
  8. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java
  9. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/CreateAccessListResult.java
  10. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionCompleteResult.java
  11. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java
  12. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCreateAccessListTest.java
  13. 2
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java
  14. 31
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java
  15. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionDecoder.java
  16. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java
  17. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java
  18. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionProcessor.java
  19. 2
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/CallParameter.java
  20. 2
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/BlockDataGenerator.java
  21. 2
      ethereum/core/src/test-support/java/org/hyperledger/besu/ethereum/core/TransactionTestFixture.java
  22. 2
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java
  23. 9
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java
  24. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransaction.java
  25. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java
  26. 2
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  27. 2
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestAccessListDeserializer.java
  28. 2
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/StateTestVersionedTransaction.java
  29. 4
      evm/src/main/java/org/hyperledger/besu/evm/gascalculator/GasCalculator.java
  30. 2
      evm/src/main/java/org/hyperledger/besu/evm/tracing/AccessListOperationTracer.java

@ -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)

@ -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
@ -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) {
/**
* Create access list entry.
*
@ -56,26 +39,6 @@ public class AccessListEntry {
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.
*

@ -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;
@ -183,4 +184,39 @@ public interface Transaction {
* @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();
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods.fork.frontier;
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;
@ -27,7 +28,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallPar
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;

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.methods.fork.london;
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;
@ -26,7 +27,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
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;

@ -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;
@ -32,11 +32,11 @@ public class AccessListEntryAdapter extends AdapterBase {
}
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());
}
}

@ -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;
@ -29,7 +30,6 @@ import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
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;

@ -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;

@ -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;

@ -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;

@ -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;

@ -23,6 +23,7 @@ import static org.mockito.Mockito.times;
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;
@ -43,7 +44,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.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.tracing.AccessListOperationTracer;
import java.util.ArrayList;

@ -18,13 +18,13 @@ package org.hyperledger.besu.ethereum.api.util;
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;

@ -24,13 +24,13 @@ import org.hyperledger.besu.crypto.SECPPublicKey;
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;
@ -42,10 +42,8 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
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;
@ -432,20 +430,11 @@ public class Transaction
}
/**
* 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(
@ -547,6 +536,7 @@ public class Transaction
return getTo().isPresent() ? Optional.of(payload) : Optional.empty();
}
@Override
public Optional<List<AccessListEntry>> getAccessList() {
return maybeAccessList;
}
@ -625,6 +615,13 @@ public class Transaction
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();
@ -780,6 +777,7 @@ public class Transaction
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
@ -801,10 +799,12 @@ public class Transaction
return this.transactionType;
}
@Override
public Optional<List<VersionedHash>> getVersionedHashes() {
return versionedHashes;
}
@Override
public Optional<BlobsWithCommitments> getBlobsWithCommitments() {
return blobsWithCommitments;
}
@ -1127,6 +1127,7 @@ public class Transaction
return sb.append("}").toString();
}
@Override
public Optional<Address> contractAddress() {
if (isContractCreation()) {
return Optional.of(Address.contractAddress(getSender(), getNonce()));

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.core.encoding;
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.KZGCommitment;
@ -25,7 +26,6 @@ import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.evm.AccessListEntry;
import java.util.List;
import java.util.function.Supplier;

@ -24,13 +24,13 @@ import static org.hyperledger.besu.ethereum.core.Transaction.TWO;
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.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.evm.AccessListEntry;
import java.math.BigInteger;
import java.util.Optional;

@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.core.encoding;
import static com.google.common.base.Preconditions.checkNotNull;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
@ -23,7 +24,6 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.hyperledger.besu.evm.AccessListEntry;
import java.math.BigInteger;
import java.util.List;
@ -178,9 +178,9 @@ public class TransactionEncoder {
accessListEntries.get(),
(accessListEntry, accessListEntryRLPOutput) -> {
accessListEntryRLPOutput.startList();
out.writeBytes(accessListEntry.getAddress());
out.writeBytes(accessListEntry.address());
out.writeList(
accessListEntry.getStorageKeys(),
accessListEntry.storageKeys(),
(storageKeyBytes, storageKeyBytesRLPOutput) ->
storageKeyBytesRLPOutput.writeBytes(storageKeyBytes));
accessListEntryRLPOutput.endList();

@ -19,6 +19,7 @@ import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_PRIVAT
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION;
import static org.hyperledger.besu.ethereum.mainnet.PrivateStateUtils.KEY_TRANSACTION_HASH;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.chain.Blockchain;
@ -31,7 +32,6 @@ import org.hyperledger.besu.ethereum.processing.TransactionProcessingResult;
import org.hyperledger.besu.ethereum.transaction.TransactionInvalidReason;
import org.hyperledger.besu.ethereum.trie.MerkleTrieException;
import org.hyperledger.besu.ethereum.vm.BlockHashLookup;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.EvmAccount;
import org.hyperledger.besu.evm.account.MutableAccount;
@ -324,9 +324,9 @@ public class MainnetTransactionProcessor {
final Multimap<Address, Bytes32> storageList = HashMultimap.create();
int accessListStorageCount = 0;
for (final var entry : accessListEntries) {
final Address address = entry.getAddress();
final Address address = entry.address();
addressList.add(address);
final List<Bytes32> storageKeys = entry.getStorageKeys();
final List<Bytes32> storageKeys = entry.storageKeys();
storageList.putAll(address, storageKeys);
accessListStorageCount += storageKeys.size();
}

@ -14,10 +14,10 @@
*/
package org.hyperledger.besu.ethereum.transaction;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.evm.AccessListEntry;
import java.util.List;
import java.util.Objects;

@ -23,6 +23,7 @@ import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.SecureRandomProvider;
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.Hash;
import org.hyperledger.besu.datatypes.TransactionType;
@ -31,7 +32,6 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.worldstate.WorldStateArchive;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.MutableAccount;
import org.hyperledger.besu.evm.log.Log;

@ -15,12 +15,12 @@
package org.hyperledger.besu.ethereum.core;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.BlobsWithCommitments;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.AccessListEntry;
import java.math.BigInteger;
import java.util.List;

@ -22,9 +22,9 @@ import static org.junit.jupiter.api.Assertions.fail;
import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.crypto.SignatureAlgorithm;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.AccessListEntry;
import java.math.BigInteger;
import java.util.List;

@ -31,6 +31,7 @@ import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.MethodSource;
import org.junit.jupiter.params.provider.ValueSource;
class TransactionRLPDecoderTest {
@ -97,4 +98,12 @@ class TransactionRLPDecoderTest {
// Bytes size should be equal to transaction size
assertThat(transaction.getSize()).isEqualTo(bytes.size());
}
@ParameterizedTest
@ValueSource(strings = {FRONTIER_TX_RLP, EIP1559_TX_RLP, NONCE_64_BIT_MAX_MINUS_2_TX_RLP})
void shouldReturnCorrectEncodedBytes(final String txRlp) {
final Transaction transaction =
TransactionDecoder.decodeForWire(RLP.input(Bytes.fromHexString(txRlp)));
assertThat(transaction.encoded()).isEqualTo(Bytes.fromHexString(txRlp));
}
}

@ -14,11 +14,11 @@
*/
package org.hyperledger.besu.ethereum.eth.transactions;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.evm.AccessListEntry;
import java.util.Collection;
import java.util.List;
@ -141,7 +141,7 @@ public abstract class PendingTransaction {
int totalSize = OPTIONAL_ACCESS_LIST_MEMORY_SIZE;
totalSize += al.size() * ACCESS_LIST_ENTRY_BASE_MEMORY_SIZE;
totalSize +=
al.stream().map(AccessListEntry::getStorageKeys).mapToInt(List::size).sum()
al.stream().map(AccessListEntry::storageKeys).mapToInt(List::size).sum()
* ACCESS_LIST_STORAGE_KEY_MEMORY_SIZE;
return totalSize;
})

@ -17,6 +17,7 @@ package org.hyperledger.besu.ethereum.eth.transactions;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.crypto.SignatureAlgorithm;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
@ -25,7 +26,6 @@ import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.eth.transactions.layered.BaseTransactionPoolTest;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.evm.AccessListEntry;
import java.util.HashSet;
import java.util.List;
@ -250,7 +250,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
assertThat(size.sum()).isEqualTo(PendingTransaction.ACCESS_LIST_ENTRY_BASE_MEMORY_SIZE);
final Bytes32 storageKey = ale.getStorageKeys().get(0);
final Bytes32 storageKey = ale.storageKeys().get(0);
final ClassLayout cl4 = ClassLayout.parseInstance(storageKey);
System.out.println(cl4.toPrintable());
System.out.println("Single storage key size: " + cl4.instanceSize());

@ -24,6 +24,7 @@ import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.crypto.KeyPair;
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.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
@ -48,7 +49,6 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.worldstate.DefaultMutableWorldState;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountStorageEntry;
import org.hyperledger.besu.evm.log.Log;

@ -15,7 +15,7 @@
*/
package org.hyperledger.besu.ethereum.referencetests;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.datatypes.AccessListEntry;
import java.io.IOException;
import java.util.ArrayList;

@ -18,11 +18,11 @@ package org.hyperledger.besu.ethereum.referencetests;
import org.hyperledger.besu.crypto.KeyPair;
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.VersionedHash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.evm.AccessListEntry;
import java.math.BigInteger;
import java.util.ArrayList;

@ -14,9 +14,9 @@
*/
package org.hyperledger.besu.evm.gascalculator;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.operation.BalanceOperation;
@ -456,7 +456,7 @@ public interface GasCalculator {
default long accessListGasCost(final List<AccessListEntry> accessListEntries) {
return accessListGasCost(
accessListEntries.size(),
accessListEntries.stream().mapToInt(e -> e.getStorageKeys().size()).sum());
accessListEntries.stream().mapToInt(e -> e.storageKeys().size()).sum());
}
/**

@ -14,8 +14,8 @@
*/
package org.hyperledger.besu.evm.tracing;
import org.hyperledger.besu.datatypes.AccessListEntry;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.evm.frame.MessageFrame;
import org.hyperledger.besu.evm.operation.Operation.OperationResult;

Loading…
Cancel
Save