merge providers

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/7871/head
Gabriel-Trintinalia 3 weeks ago
parent 1135dcf6f0
commit abc1827325
  1. 4
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/TxParseSubCommand.java
  2. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java
  3. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java
  4. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java
  5. 10
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java
  6. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadBodiesResultV1.java
  7. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java
  8. 4
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java
  9. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHashTest.java
  10. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java
  11. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java
  12. 6
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java
  13. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java
  14. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java
  15. 9
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java
  16. 54
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpPooledTransactionProvider.java
  17. 96
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpProvider.java
  18. 53
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpTransactionProvider.java
  19. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java
  20. 8
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionIntegrationTest.java
  21. 11
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java
  22. 9
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java
  23. 6
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPEncoderTest.java
  24. 4
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java
  25. 10
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/FixedKeySigningPrivateMarkerTransactionFactoryTest.java
  26. 10
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/RandomSigningPrivateMarkerTransactionFactoryTest.java
  27. 4
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthServer.java
  28. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/PooledTransactionsMessage.java
  29. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/TransactionsMessage.java
  30. 6
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java
  31. 4
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthServerTest.java
  32. 33
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java
  33. 6
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java
  34. 10
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java
  35. 4
      ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java
  36. 7
      ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java

@ -19,7 +19,7 @@ import static org.hyperledger.besu.cli.subcommands.TxParseSubCommand.COMMAND_NAM
import org.hyperledger.besu.cli.util.VersionProvider; import org.hyperledger.besu.cli.util.VersionProvider;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import java.io.BufferedReader; import java.io.BufferedReader;
import java.io.InputStreamReader; import java.io.InputStreamReader;
@ -104,7 +104,7 @@ public class TxParseSubCommand implements Runnable {
void dump(final Bytes tx) { void dump(final Bytes tx) {
try { try {
var transaction = RlpTransactionProvider.decodeOpaqueBytes(tx); var transaction = RlpProvider.transaction().decodeOpaqueBytes(tx);
// https://github.com/hyperledger/besu/blob/5fe49c60b30fe2954c7967e8475c3b3e9afecf35/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java#L252 // https://github.com/hyperledger/besu/blob/5fe49c60b30fe2954c7967e8475c3b3e9afecf35/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/MainnetTransactionValidator.java#L252
if (transaction.getChainId().isPresent() && !transaction.getChainId().get().equals(chainId)) { if (transaction.getChainId().isPresent() && !transaction.getChainId().get().equals(chainId)) {

@ -34,7 +34,7 @@ import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
import org.hyperledger.besu.ethereum.core.LogWithMetadata; import org.hyperledger.besu.ethereum.core.LogWithMetadata;
import org.hyperledger.besu.ethereum.core.Synchronizer; import org.hyperledger.besu.ethereum.core.Synchronizer;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.EthProtocol; import org.hyperledger.besu.ethereum.eth.EthProtocol;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -130,7 +130,7 @@ public class GraphQLDataFetchers {
dataFetchingEnvironment.getGraphQlContext().get(GraphQLContextType.TRANSACTION_POOL); dataFetchingEnvironment.getGraphQlContext().get(GraphQLContextType.TRANSACTION_POOL);
final Bytes rawTran = dataFetchingEnvironment.getArgument("data"); final Bytes rawTran = dataFetchingEnvironment.getArgument("data");
final Transaction transaction = RlpTransactionProvider.readFrom(RLP.input(rawTran)); final Transaction transaction = RlpProvider.transaction().readFrom(RLP.input(rawTran));
final ValidationResult<TransactionInvalidReason> validationResult = final ValidationResult<TransactionInvalidReason> validationResult =
transactionPool.addTransactionViaApi(transaction); transactionPool.addTransactionViaApi(transaction);
if (validationResult.isValid()) { if (validationResult.isValid()) {

@ -51,7 +51,7 @@ import org.hyperledger.besu.ethereum.core.Difficulty;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.manager.EthPeers; import org.hyperledger.besu.ethereum.eth.manager.EthPeers;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
@ -220,7 +220,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
transactions = transactions =
blockParam.getTransactions().stream() blockParam.getTransactions().stream()
.map(Bytes::fromHexString) .map(Bytes::fromHexString)
.map(RlpTransactionProvider::decodeOpaqueBytes) .map(RlpProvider.transaction()::decodeOpaqueBytes)
.collect(Collectors.toList()); .collect(Collectors.toList());
transactions.forEach( transactions.forEach(
transaction -> transaction ->

@ -32,7 +32,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcRespon
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
@ -156,7 +156,7 @@ public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod {
final Bytes rlpBytes = final Bytes rlpBytes =
privateMarkerTransactionFactory.create( privateMarkerTransactionFactory.create(
unsignedPrivateMarkerTransaction, privateTransaction, privacyUserId); unsignedPrivateMarkerTransaction, privateTransaction, privacyUserId);
return RlpTransactionProvider.readFrom(rlpBytes); return RlpProvider.transaction().readFrom(rlpBytes);
} }
protected abstract long getGasLimit(PrivateTransaction privateTransaction, String pmtPayload); protected abstract long getGasLimit(PrivateTransaction privateTransaction, String pmtPayload);

@ -23,7 +23,7 @@ import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@ -95,7 +95,7 @@ public class BlockResultFactory {
public EngineGetPayloadResultV1 payloadTransactionCompleteV1(final Block block) { public EngineGetPayloadResultV1 payloadTransactionCompleteV1(final Block block) {
final List<String> txs = final List<String> txs =
block.getBody().getTransactions().stream() block.getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes) .map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString) .map(Bytes::toHexString)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -106,7 +106,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts(); final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs = final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream() blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes) .map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString) .map(Bytes::toHexString)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -130,7 +130,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts(); final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs = final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream() blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes) .map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString) .map(Bytes::toHexString)
.collect(Collectors.toList()); .collect(Collectors.toList());
@ -148,7 +148,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts(); final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs = final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream() blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes) .map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString) .map(Bytes::toHexString)
.collect(Collectors.toList()); .collect(Collectors.toList());
final Optional<List<String>> requestsWithoutRequestId = final Optional<List<String>> requestsWithoutRequestId =

@ -16,7 +16,7 @@ package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.WithdrawalParameter;
import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
@ -52,7 +52,7 @@ public class EngineGetPayloadBodiesResultV1 {
public PayloadBody(final BlockBody blockBody) { public PayloadBody(final BlockBody blockBody) {
this.transactions = this.transactions =
blockBody.getTransactions().stream() blockBody.getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes) .map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString) .map(Bytes::toHexString)
.collect(Collectors.toList()); .collect(Collectors.toList());
this.withdrawals = this.withdrawals =

@ -20,7 +20,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.VersionedHash; import org.hyperledger.besu.datatypes.VersionedHash;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import java.util.List; import java.util.List;
@ -101,7 +101,7 @@ public class TransactionPendingResult implements TransactionResult {
this.input = transaction.getPayload().toString(); this.input = transaction.getPayload().toString();
this.nonce = Quantity.create(transaction.getNonce()); this.nonce = Quantity.create(transaction.getNonce());
this.publicKey = transaction.getPublicKey().orElse(null); this.publicKey = transaction.getPublicKey().orElse(null);
this.raw = RlpPooledTransactionProvider.encodeOpaqueBytes(transaction).toString(); this.raw = RlpProvider.pooledTransaction().encodeOpaqueBytes(transaction).toString();
this.to = transaction.getTo().map(Address::toHexString).orElse(null); this.to = transaction.getTo().map(Address::toHexString).orElse(null);
if (transactionType == TransactionType.FRONTIER) { if (transactionType == TransactionType.FRONTIER) {
this.type = Quantity.create(0); this.type = Quantity.create(0);

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.api.util;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.exception.InvalidJsonRpcRequestException;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType; import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes;
@ -28,7 +28,7 @@ public class DomainObjectDecodeUtils {
throws InvalidJsonRpcRequestException { throws InvalidJsonRpcRequestException {
try { try {
Bytes txnBytes = Bytes.fromHexString(rawTransaction); Bytes txnBytes = Bytes.fromHexString(rawTransaction);
return RlpPooledTransactionProvider.decodeOpaqueBytes(txnBytes); return RlpProvider.pooledTransaction().decodeOpaqueBytes(txnBytes);
} catch (final IllegalArgumentException e) { } catch (final IllegalArgumentException e) {
throw new InvalidJsonRpcRequestException( throw new InvalidJsonRpcRequestException(
"Invalid raw transaction hex", RpcErrorType.INVALID_TRANSACTION_PARAMS, e); "Invalid raw transaction hex", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);

@ -33,7 +33,7 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.TransactionPen
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries; import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata; import org.hyperledger.besu.ethereum.api.query.TransactionWithMetadata;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction; import org.hyperledger.besu.ethereum.eth.transactions.PendingTransaction;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool; import org.hyperledger.besu.ethereum.eth.transactions.TransactionPool;
@ -109,7 +109,7 @@ class EthGetTransactionByHashTest {
@Test @Test
void shouldReturnPendingTransactionWhenTransactionExistsAndIsPending() { void shouldReturnPendingTransactionWhenTransactionExistsAndIsPending() {
final org.hyperledger.besu.ethereum.core.Transaction transaction = final org.hyperledger.besu.ethereum.core.Transaction transaction =
RlpTransactionProvider.readFrom(Bytes.fromHexString(VALID_TRANSACTION)); RlpProvider.transaction().readFrom(Bytes.fromHexString(VALID_TRANSACTION));
when(transactionPool.getTransactionByHash(transaction.getHash())) when(transactionPool.getTransactionByHash(transaction.getHash()))
.thenReturn(Optional.of(transaction)); .thenReturn(Optional.of(transaction));
@ -131,7 +131,7 @@ class EthGetTransactionByHashTest {
@Test @Test
void shouldReturnCompleteTransactionWhenTransactionExistsInBlockchain() { void shouldReturnCompleteTransactionWhenTransactionExistsInBlockchain() {
final org.hyperledger.besu.ethereum.core.Transaction transaction = final org.hyperledger.besu.ethereum.core.Transaction transaction =
RlpTransactionProvider.readFrom(Bytes.fromHexString(VALID_TRANSACTION)); RlpProvider.transaction().readFrom(Bytes.fromHexString(VALID_TRANSACTION));
final TransactionWithMetadata transactionWithMetadata = final TransactionWithMetadata transactionWithMetadata =
new TransactionWithMetadata(transaction, 1, Optional.empty(), Hash.ZERO, 0); new TransactionWithMetadata(transaction, 1, Optional.empty(), Hash.ZERO, 0);

@ -48,7 +48,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.CancunTargetingGasLimitCalculator; import org.hyperledger.besu.ethereum.mainnet.CancunTargetingGasLimitCalculator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -225,7 +225,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
public void shouldRejectTransactionsWithFullBlobs() { public void shouldRejectTransactionsWithFullBlobs() {
Bytes transactionWithBlobsBytes = Bytes transactionWithBlobsBytes =
RlpPooledTransactionProvider.encodeOpaqueBytes(createTransactionWithBlobs()); RlpProvider.pooledTransaction().encodeOpaqueBytes(createTransactionWithBlobs());
List<String> transactions = List.of(transactionWithBlobsBytes.toString()); List<String> transactions = List.of(transactionWithBlobsBytes.toString());

@ -21,7 +21,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import java.math.BigInteger; import java.math.BigInteger;
@ -57,7 +57,7 @@ public class DomainObjectDecodeUtilsTest {
@Test @Test
public void testAccessListRLPSerDes() { public void testAccessListRLPSerDes() {
final BytesValueRLPOutput encoded = new BytesValueRLPOutput(); final BytesValueRLPOutput encoded = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(accessListTxn, encoded); RlpProvider.pooledTransaction().writeTo(accessListTxn, encoded);
Transaction decoded = Transaction decoded =
DomainObjectDecodeUtils.decodeRawTransaction(encoded.encoded().toHexString()); DomainObjectDecodeUtils.decodeRawTransaction(encoded.encoded().toHexString());
Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue(); Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue();
@ -66,7 +66,7 @@ public class DomainObjectDecodeUtilsTest {
@Test @Test
public void testAccessList2718OpaqueSerDes() { public void testAccessList2718OpaqueSerDes() {
final Bytes encoded = RlpPooledTransactionProvider.encodeOpaqueBytes(accessListTxn); final Bytes encoded = RlpProvider.pooledTransaction().encodeOpaqueBytes(accessListTxn);
Transaction decoded = DomainObjectDecodeUtils.decodeRawTransaction(encoded.toString()); Transaction decoded = DomainObjectDecodeUtils.decodeRawTransaction(encoded.toString());
Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue(); Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue();
Assertions.assertThat(decoded.getAccessList().map(List::size).get()).isEqualTo(1); Assertions.assertThat(decoded.getAccessList().map(List::size).get()).isEqualTo(1);

@ -30,7 +30,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture; import org.hyperledger.besu.ethereum.core.ExecutionContextTestFixture;
import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.debug.TraceFrame;
import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.debug.TraceOptions;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
@ -171,8 +171,8 @@ public class TraceTransactionIntegrationTest {
final DebugOperationTracer tracer = final DebugOperationTracer tracer =
new DebugOperationTracer(new TraceOptions(true, true, true), false); new DebugOperationTracer(new TraceOptions(true, true, true), false);
final Transaction transaction = final Transaction transaction =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false)); .readFrom(new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false));
final BlockHeader genesisBlockHeader = genesisBlock.getHeader(); final BlockHeader genesisBlockHeader = genesisBlock.getHeader();
transactionProcessor.processTransaction( transactionProcessor.processTransaction(
worldStateArchive worldStateArchive

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.core; package org.hyperledger.besu.ethereum.core;
import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.rlp.RLPOutput;
@ -60,7 +60,7 @@ public class Block {
out.startList(); out.startList();
header.writeTo(out); header.writeTo(out);
out.writeList(body.getTransactions(), RlpTransactionProvider::writeTo); out.writeList(body.getTransactions(), RlpProvider.transaction()::writeTo);
out.writeList(body.getOmmers(), BlockHeader::writeTo); out.writeList(body.getOmmers(), BlockHeader::writeTo);
body.getWithdrawals().ifPresent(withdrawals -> out.writeList(withdrawals, Withdrawal::writeTo)); body.getWithdrawals().ifPresent(withdrawals -> out.writeList(withdrawals, Withdrawal::writeTo));
@ -70,7 +70,7 @@ public class Block {
public static Block readFrom(final RLPInput in, final BlockHeaderFunctions hashFunction) { public static Block readFrom(final RLPInput in, final BlockHeaderFunctions hashFunction) {
in.enterList(); in.enterList();
final BlockHeader header = BlockHeader.readFrom(in, hashFunction); final BlockHeader header = BlockHeader.readFrom(in, hashFunction);
final List<Transaction> transactions = in.readList(RlpTransactionProvider::readFrom); final List<Transaction> transactions = in.readList(RlpProvider.transaction()::readFrom);
final List<BlockHeader> ommers = in.readList(rlp -> BlockHeader.readFrom(rlp, hashFunction)); final List<BlockHeader> ommers = in.readList(rlp -> BlockHeader.readFrom(rlp, hashFunction));
final Optional<List<Withdrawal>> withdrawals = final Optional<List<Withdrawal>> withdrawals =
in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Withdrawal::readFrom)); in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Withdrawal::readFrom));

@ -14,7 +14,7 @@
*/ */
package org.hyperledger.besu.ethereum.core; package org.hyperledger.besu.ethereum.core;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.rlp.RLPOutput;
@ -96,7 +96,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody {
} }
public void writeTo(final RLPOutput output) { public void writeTo(final RLPOutput output) {
output.writeList(getTransactions(), RlpTransactionProvider::writeTo); output.writeList(getTransactions(), RlpProvider.transaction()::writeTo);
output.writeList(getOmmers(), BlockHeader::writeTo); output.writeList(getOmmers(), BlockHeader::writeTo);
withdrawals.ifPresent(withdrawals -> output.writeList(withdrawals, Withdrawal::writeTo)); withdrawals.ifPresent(withdrawals -> output.writeList(withdrawals, Withdrawal::writeTo));
} }
@ -143,7 +143,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody {
public static BlockBody readFrom( public static BlockBody readFrom(
final RLPInput input, final BlockHeaderFunctions blockHeaderFunctions) { final RLPInput input, final BlockHeaderFunctions blockHeaderFunctions) {
return new BlockBody( return new BlockBody(
input.readList(RlpTransactionProvider::readFrom), input.readList(RlpProvider.transaction()::readFrom),
input.readList(rlp -> BlockHeader.readFrom(rlp, blockHeaderFunctions)), input.readList(rlp -> BlockHeader.readFrom(rlp, blockHeaderFunctions)),
input.isEndOfCurrentList() input.isEndOfCurrentList()
? Optional.empty() ? Optional.empty()

@ -39,8 +39,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder; import org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder;
import org.hyperledger.besu.ethereum.core.encoding.BlobTransactionEncoder; import org.hyperledger.besu.ethereum.core.encoding.BlobTransactionEncoder;
import org.hyperledger.besu.ethereum.core.encoding.CodeDelegationEncoder; import org.hyperledger.besu.ethereum.core.encoding.CodeDelegationEncoder;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.ethereum.rlp.RLPOutput;
@ -472,7 +471,7 @@ public class Transaction
@Override @Override
public Bytes encoded() { public Bytes encoded() {
final BytesValueRLPOutput rplOutput = new BytesValueRLPOutput(); final BytesValueRLPOutput rplOutput = new BytesValueRLPOutput();
RlpTransactionProvider.writeTo(this, rplOutput); RlpProvider.transaction().writeTo(this, rplOutput);
return rplOutput.encoded(); return rplOutput.encoded();
} }
@ -537,10 +536,10 @@ public class Transaction
} }
private void memoizeHashAndSize() { private void memoizeHashAndSize() {
final Bytes bytes = RlpTransactionProvider.encodeOpaqueBytes(this); final Bytes bytes = RlpProvider.transaction().encodeOpaqueBytes(this);
hash = Hash.hash(bytes); hash = Hash.hash(bytes);
if (transactionType.supportsBlob() && getBlobsWithCommitments().isPresent()) { if (transactionType.supportsBlob() && getBlobsWithCommitments().isPresent()) {
final Bytes pooledBytes = RlpPooledTransactionProvider.encodeOpaqueBytes(this); final Bytes pooledBytes = RlpProvider.pooledTransaction().encodeOpaqueBytes(this);
size = pooledBytes.size(); size = pooledBytes.size();
return; return;
} }

@ -1,54 +0,0 @@
/*
* Copyright contributors to Besu.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.apache.tuweni.bytes.Bytes;
public class RlpPooledTransactionProvider {
private RlpPooledTransactionProvider() {}
public static Transaction readFrom(final RLPInput rlpInput) {
return getDecoder().readFrom(rlpInput);
}
public static Transaction readFrom(final Bytes bytes) {
return getDecoder().readFrom(bytes);
}
public static Transaction decodeOpaqueBytes(final Bytes bytes) {
return getDecoder().decodeOpaqueBytes(bytes);
}
public static void writeTo(final Transaction transaction, final RLPOutput output) {
getEncoder().writeTo(transaction, output);
}
public static Bytes encodeOpaqueBytes(final Transaction transaction) {
return getEncoder().encodeOpaqueBytes(transaction);
}
private static TransactionEncoder getEncoder() {
return RlpRegistry.getInstance().getPooledTransactionEncoder();
}
private static TransactionDecoder getDecoder() {
return RlpRegistry.getInstance().getPooledTransactionDecoder();
}
}

@ -0,0 +1,96 @@
/*
* Copyright contributors to Besu.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.apache.tuweni.bytes.Bytes;
public class RlpProvider {
private RlpProvider() {}
public static TransactionHandler transaction() {
return new TransactionHandler();
}
public static PooledTransactionHandler pooledTransaction() {
return new PooledTransactionHandler();
}
public static class TransactionHandler {
public Transaction readFrom(final RLPInput rlpInput) {
return getDecoder().readFrom(rlpInput);
}
public Transaction readFrom(final Bytes bytes) {
return getDecoder().readFrom(bytes);
}
public Transaction decodeOpaqueBytes(final Bytes bytes) {
return getDecoder().decodeOpaqueBytes(bytes);
}
public void writeTo(final Transaction transaction, final RLPOutput output) {
getEncoder().writeTo(transaction, output);
}
public Bytes encodeOpaqueBytes(final Transaction transaction) {
return getEncoder().encodeOpaqueBytes(transaction);
}
private TransactionDecoder getDecoder() {
return RlpRegistry.getInstance().getTransactionDecoder();
}
private TransactionEncoder getEncoder() {
return RlpRegistry.getInstance().getTransactionEncoder();
}
}
public static class PooledTransactionHandler {
public Transaction readFrom(final RLPInput rlpInput) {
return getDecoder().readFrom(rlpInput);
}
public Transaction readFrom(final Bytes bytes) {
return getDecoder().readFrom(bytes);
}
public Transaction decodeOpaqueBytes(final Bytes bytes) {
return getDecoder().decodeOpaqueBytes(bytes);
}
public void writeTo(final Transaction transaction, final RLPOutput output) {
getEncoder().writeTo(transaction, output);
}
public Bytes encodeOpaqueBytes(final Transaction transaction) {
return getEncoder().encodeOpaqueBytes(transaction);
}
private TransactionDecoder getDecoder() {
return RlpRegistry.getInstance().getPooledTransactionDecoder();
}
private TransactionEncoder getEncoder() {
return RlpRegistry.getInstance().getPooledTransactionEncoder();
}
}
}

@ -1,53 +0,0 @@
/*
* Copyright contributors to Besu.
*
* 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
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import org.apache.tuweni.bytes.Bytes;
public class RlpTransactionProvider {
private RlpTransactionProvider() {}
public static Transaction readFrom(final RLPInput rlpInput) {
return getDecoder().readFrom(rlpInput);
}
public static Transaction readFrom(final Bytes bytes) {
return getDecoder().readFrom(bytes);
}
public static Transaction decodeOpaqueBytes(final Bytes bytes) {
return getDecoder().decodeOpaqueBytes(bytes);
}
public static void writeTo(final Transaction transaction, final RLPOutput output) {
getEncoder().writeTo(transaction, output);
}
public static Bytes encodeOpaqueBytes(final Transaction transaction) {
return getEncoder().encodeOpaqueBytes(transaction);
}
private static TransactionDecoder getDecoder() {
return RlpRegistry.getInstance().getTransactionDecoder();
}
private static TransactionEncoder getEncoder() {
return RlpRegistry.getInstance().getTransactionEncoder();
}
}

@ -24,7 +24,7 @@ import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.encoding.WithdrawalEncoder; import org.hyperledger.besu.ethereum.core.encoding.WithdrawalEncoder;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrie; import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie; import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie;
@ -65,7 +65,7 @@ public final class BodyValidation {
.forEach( .forEach(
i -> i ->
trie.put( trie.put(
indexKey(i), RlpTransactionProvider.encodeOpaqueBytes(transactions.get(i)))); indexKey(i), RlpProvider.transaction().encodeOpaqueBytes(transactions.get(i))));
return Hash.wrap(trie.getRootHash()); return Hash.wrap(trie.getRootHash());
} }

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.core;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput;
@ -35,7 +35,7 @@ public class TransactionIntegrationTest {
"0xf902560c843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000007b820fe8a009e7b69af4c318e7fb915f53649bd9f99e5423d41c2cd6a01ab69bb34a951b2fa01b5d39b7c9041ec022d13e6e89eec2cddbe27572eda7956ada5de1032cd5da15"; "0xf902560c843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000007b820fe8a009e7b69af4c318e7fb915f53649bd9f99e5423d41c2cd6a01ab69bb34a951b2fa01b5d39b7c9041ec022d13e6e89eec2cddbe27572eda7956ada5de1032cd5da15";
final Bytes encoded = Bytes.fromHexString(encodedString); final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded); final RLPInput input = RLP.input(encoded);
final Transaction transaction = RlpTransactionProvider.readFrom(input); final Transaction transaction = RlpProvider.transaction().readFrom(input);
assertThat(transaction).isNotNull(); assertThat(transaction).isNotNull();
assertThat(transaction.isContractCreation()).isTrue(); assertThat(transaction.isContractCreation()).isTrue();
assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2018)); assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2018));
@ -49,7 +49,7 @@ public class TransactionIntegrationTest {
"0xf9025780843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000000c830628cba0482ba9b1136cd9337408938eea6b991fd153900a014867da2f4bb113d4003888a00c5a2f8f279fe2c86831afb5c9578dd1c3be457e3aca3abe439b1a5dd122e676"; "0xf9025780843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000000c830628cba0482ba9b1136cd9337408938eea6b991fd153900a014867da2f4bb113d4003888a00c5a2f8f279fe2c86831afb5c9578dd1c3be457e3aca3abe439b1a5dd122e676";
final Bytes encoded = Bytes.fromHexString(encodedString); final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded); final RLPInput input = RLP.input(encoded);
final Transaction transaction = RlpTransactionProvider.readFrom(input); final Transaction transaction = RlpProvider.transaction().readFrom(input);
assertThat(transaction.encoded().toString()).isEqualTo(encodedString); assertThat(transaction.encoded().toString()).isEqualTo(encodedString);
} }
@ -59,7 +59,7 @@ public class TransactionIntegrationTest {
"0xf86a018609184e72a0008276c094d30c3d13b07029deba00de1da369cd69a02c20560180850100000021a07d344f26d7329e8932d2878b99f07b12752bbd13a0b3b822644dbf9600fe718da01d6e6b6c66e1aadf4e33e318a7eef03d3bd3602de52662f0cb5af5b372d44dcd"; "0xf86a018609184e72a0008276c094d30c3d13b07029deba00de1da369cd69a02c20560180850100000021a07d344f26d7329e8932d2878b99f07b12752bbd13a0b3b822644dbf9600fe718da01d6e6b6c66e1aadf4e33e318a7eef03d3bd3602de52662f0cb5af5b372d44dcd";
final Bytes encoded = Bytes.fromHexString(encodedString); final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded); final RLPInput input = RLP.input(encoded);
final Transaction transaction = RlpTransactionProvider.readFrom(input); final Transaction transaction = RlpProvider.transaction().readFrom(input);
assertThat(transaction).isNotNull(); assertThat(transaction).isNotNull();
assertThat(transaction.isContractCreation()).isFalse(); assertThat(transaction.isContractCreation()).isFalse();
assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2147483647)); assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2147483647));

@ -17,8 +17,7 @@ package org.hyperledger.besu.ethereum.core.encoding;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import java.io.BufferedReader; import java.io.BufferedReader;
@ -59,13 +58,13 @@ public class BlobTransactionEncodingTest {
final TypedTransactionBytesArgument argument) { final TypedTransactionBytesArgument argument) {
Bytes bytes = argument.bytes; Bytes bytes = argument.bytes;
// Decode the transaction from the wire using the TransactionDecoder. // Decode the transaction from the wire using the TransactionDecoder.
final Transaction transaction = RlpPooledTransactionProvider.decodeOpaqueBytes(bytes); final Transaction transaction = RlpProvider.pooledTransaction().decodeOpaqueBytes(bytes);
final BytesValueRLPOutput output = new BytesValueRLPOutput(); final BytesValueRLPOutput output = new BytesValueRLPOutput();
new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, output); new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, output);
final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput(); final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(transaction, bytesValueRLPOutput); RlpProvider.pooledTransaction().writeTo(transaction, bytesValueRLPOutput);
assertThat(transaction.getSize()).isEqualTo(bytes.size()); assertThat(transaction.getSize()).isEqualTo(bytes.size());
} }
@ -74,10 +73,10 @@ public class BlobTransactionEncodingTest {
public void blobTransactionEncodingDecodingTest(final TypedTransactionBytesArgument argument) { public void blobTransactionEncodingDecodingTest(final TypedTransactionBytesArgument argument) {
Bytes bytes = argument.bytes; Bytes bytes = argument.bytes;
// Decode the transaction from the wire using the TransactionDecoder. // Decode the transaction from the wire using the TransactionDecoder.
final Transaction transaction = RlpTransactionProvider.decodeOpaqueBytes(bytes); final Transaction transaction = RlpProvider.transaction().decodeOpaqueBytes(bytes);
// Encode the transaction for wire using the TransactionEncoder. // Encode the transaction for wire using the TransactionEncoder.
Bytes encoded = RlpTransactionProvider.encodeOpaqueBytes(transaction); Bytes encoded = RlpProvider.transaction().encodeOpaqueBytes(transaction);
// Assert that the encoded transaction matches the original bytes. // Assert that the encoded transaction matches the original bytes.
assertThat(encoded.toHexString()).isEqualTo(bytes.toHexString()); assertThat(encoded.toHexString()).isEqualTo(bytes.toHexString());

@ -23,8 +23,7 @@ import static org.junit.jupiter.api.Assumptions.assumeTrue;
import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput;
@ -70,7 +69,7 @@ class TransactionRLPDecoderTest {
final String txWithBigFees = final String txWithBigFees =
"0x02f84e0101a1648a5f8b2dcad5ea5ba6b720ff069c1d87c21a4a6a5b3766b39e2c2792367bb066a1ffa5ffaf5b0560d3a9fb186c2ede2ae6751bc0b4fef9107cf36389630b6196a38805800180c0010203"; "0x02f84e0101a1648a5f8b2dcad5ea5ba6b720ff069c1d87c21a4a6a5b3766b39e2c2792367bb066a1ffa5ffaf5b0560d3a9fb186c2ede2ae6751bc0b4fef9107cf36389630b6196a38805800180c0010203";
assertThatThrownBy( assertThatThrownBy(
() -> RlpTransactionProvider.decodeOpaqueBytes(Bytes.fromHexString(txWithBigFees))) () -> RlpProvider.transaction().decodeOpaqueBytes(Bytes.fromHexString(txWithBigFees)))
.isInstanceOf(RLPException.class); .isInstanceOf(RLPException.class);
} }
@ -115,7 +114,7 @@ class TransactionRLPDecoderTest {
final Bytes bytes = Bytes.fromHexString(rlp_tx); final Bytes bytes = Bytes.fromHexString(rlp_tx);
// Decode bytes into a transaction // Decode bytes into a transaction
final Transaction transaction = decodeRLP(RLP.input(bytes)); final Transaction transaction = decodeRLP(RLP.input(bytes));
Bytes transactionBytes = RlpPooledTransactionProvider.encodeOpaqueBytes(transaction); Bytes transactionBytes = RlpProvider.pooledTransaction().encodeOpaqueBytes(transaction);
// Bytes size should be equal to transaction size // Bytes size should be equal to transaction size
assertThat(transaction.getSize()).isEqualTo(transactionBytes.size()); assertThat(transaction.getSize()).isEqualTo(transactionBytes.size());
} }
@ -156,6 +155,6 @@ class TransactionRLPDecoderTest {
} }
private Transaction decodeRLP(final RLPInput input) { private Transaction decodeRLP(final RLPInput input) {
return RlpPooledTransactionProvider.readFrom(input); return RlpProvider.pooledTransaction().readFrom(input);
} }
} }

@ -21,7 +21,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
@ -94,10 +94,10 @@ class TransactionRLPEncoderTest {
} }
private Transaction decodeRLP(final RLPInput input) { private Transaction decodeRLP(final RLPInput input) {
return RlpTransactionProvider.readFrom(input); return RlpProvider.transaction().readFrom(input);
} }
private void encodeRLP(final Transaction transaction, final BytesValueRLPOutput output) { private void encodeRLP(final Transaction transaction, final BytesValueRLPOutput output) {
RlpTransactionProvider.writeTo(transaction, output); RlpProvider.transaction().writeTo(transaction, output);
} }
} }

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.mainnet;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator; import org.hyperledger.besu.evm.gascalculator.FrontierGasCalculator;
import org.hyperledger.besu.evm.gascalculator.GasCalculator; import org.hyperledger.besu.evm.gascalculator.GasCalculator;
@ -89,7 +89,7 @@ public class IntrinsicGasTest {
@MethodSource("data") @MethodSource("data")
public void validateGasCost( public void validateGasCost(
final GasCalculator gasCalculator, final long expectedGas, final String txRlp) { final GasCalculator gasCalculator, final long expectedGas, final String txRlp) {
Transaction t = RlpTransactionProvider.readFrom(RLP.input(Bytes.fromHexString(txRlp))); Transaction t = RlpProvider.transaction().readFrom(RLP.input(Bytes.fromHexString(txRlp)));
Assertions.assertThat( Assertions.assertThat(
gasCalculator.transactionIntrinsicGasCost(t.getPayload(), t.isContractCreation())) gasCalculator.transactionIntrinsicGasCost(t.getPayload(), t.isContractCreation()))
.isEqualTo(expectedGas); .isEqualTo(expectedGas);

@ -24,7 +24,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.Util; import org.hyperledger.besu.ethereum.core.Util;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import java.util.Optional; import java.util.Optional;
@ -65,8 +65,8 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest {
.build(); .build();
final Transaction transaction = final Transaction transaction =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); .readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(transaction.getNonce()).isEqualTo(providedNonce); assertThat(transaction.getNonce()).isEqualTo(providedNonce);
assertThat(transaction.getGasLimit()).isEqualTo(gasLimit); assertThat(transaction.getGasLimit()).isEqualTo(gasLimit);
@ -78,8 +78,8 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest {
assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey)); assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey));
final Transaction nextTransaction = final Transaction nextTransaction =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); .readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(nextTransaction.getSender()).isEqualTo(transaction.getSender()); assertThat(nextTransaction.getSender()).isEqualTo(transaction.getSender());
} }
} }

@ -21,7 +21,7 @@ import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
import java.util.Optional; import java.util.Optional;
@ -61,8 +61,8 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest {
new RandomSigningPrivateMarkerTransactionFactory(); new RandomSigningPrivateMarkerTransactionFactory();
final Transaction transaction = final Transaction transaction =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); .readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(transaction.getNonce()).isEqualTo(0); assertThat(transaction.getNonce()).isEqualTo(0);
assertThat(transaction.getGasLimit()).isEqualTo(gasLimit); assertThat(transaction.getGasLimit()).isEqualTo(gasLimit);
@ -72,8 +72,8 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest {
assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey)); assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey));
final Transaction nextTransaction = final Transaction nextTransaction =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); .readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(nextTransaction.getSender()).isNotEqualTo(transaction.getSender()); assertThat(nextTransaction.getSender()).isNotEqualTo(transaction.getSender());
} }
} }

@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage; import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage;
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage; import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;
@ -272,7 +272,7 @@ class EthServer {
} }
final BytesValueRLPOutput txRlp = new BytesValueRLPOutput(); final BytesValueRLPOutput txRlp = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(maybeTx.get(), txRlp); RlpProvider.pooledTransaction().writeTo(maybeTx.get(), txRlp);
final int encodedSize = txRlp.encodedSize(); final int encodedSize = txRlp.encodedSize();
if (responseSizeEstimate + encodedSize > maxMessageSize) { if (responseSizeEstimate + encodedSize > maxMessageSize) {
break; break;

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.eth.messages; package org.hyperledger.besu.ethereum.eth.messages;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.AbstractMessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.AbstractMessageData;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
@ -41,7 +41,7 @@ public final class PooledTransactionsMessage extends AbstractMessageData {
public static PooledTransactionsMessage create(final List<Transaction> transactions) { public static PooledTransactionsMessage create(final List<Transaction> transactions) {
final BytesValueRLPOutput out = new BytesValueRLPOutput(); final BytesValueRLPOutput out = new BytesValueRLPOutput();
out.writeList(transactions, RlpPooledTransactionProvider::writeTo); out.writeList(transactions, RlpProvider.pooledTransaction()::writeTo);
return new PooledTransactionsMessage(out.encoded()); return new PooledTransactionsMessage(out.encoded());
} }
@ -72,7 +72,7 @@ public final class PooledTransactionsMessage extends AbstractMessageData {
public List<Transaction> transactions() { public List<Transaction> transactions() {
if (pooledTransactions == null) { if (pooledTransactions == null) {
final BytesValueRLPInput in = new BytesValueRLPInput(getData(), false); final BytesValueRLPInput in = new BytesValueRLPInput(getData(), false);
pooledTransactions = in.readList(RlpPooledTransactionProvider::readFrom); pooledTransactions = in.readList(RlpProvider.pooledTransaction()::readFrom);
} }
return pooledTransactions; return pooledTransactions;
} }

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.eth.messages; package org.hyperledger.besu.ethereum.eth.messages;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.AbstractMessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.AbstractMessageData;
import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData; import org.hyperledger.besu.ethereum.p2p.rlpx.wire.MessageData;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
@ -43,7 +43,7 @@ public class TransactionsMessage extends AbstractMessageData {
final BytesValueRLPOutput tmp = new BytesValueRLPOutput(); final BytesValueRLPOutput tmp = new BytesValueRLPOutput();
tmp.startList(); tmp.startList();
for (final Transaction transaction : transactions) { for (final Transaction transaction : transactions) {
RlpTransactionProvider.writeTo(transaction, tmp); RlpProvider.transaction().writeTo(transaction, tmp);
} }
tmp.endList(); tmp.endList();
return new TransactionsMessage(tmp.encoded()); return new TransactionsMessage(tmp.encoded());
@ -59,6 +59,6 @@ public class TransactionsMessage extends AbstractMessageData {
} }
public List<Transaction> transactions() { public List<Transaction> transactions() {
return new BytesValueRLPInput(data, false).readList(RlpTransactionProvider::readFrom); return new BytesValueRLPInput(data, false).readList(RlpProvider.transaction()::readFrom);
} }
} }

@ -31,7 +31,7 @@ import org.hyperledger.besu.ethereum.chain.BlockAddedObserver;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain; import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthContext;
import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import org.hyperledger.besu.ethereum.eth.manager.EthPeer;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@ -842,8 +842,8 @@ public class TransactionPool implements BlockAddedObserver {
line -> { line -> {
final boolean isLocal = line.charAt(0) == 'l'; final boolean isLocal = line.charAt(0) == 'l';
final Transaction tx = final Transaction tx =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
Bytes.fromBase64String(line.substring(1))); .readFrom(Bytes.fromBase64String(line.substring(1)));
final ValidationResult<TransactionInvalidReason> result = final ValidationResult<TransactionInvalidReason> result =
addTransaction(tx, isLocal); addTransaction(tx, isLocal);

@ -28,7 +28,7 @@ import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage; import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage;
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage; import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;
@ -388,7 +388,7 @@ public class EthServerTest {
} }
private int calculateRlpEncodedSize(final Transaction tx) { private int calculateRlpEncodedSize(final Transaction tx) {
return RLP.encode(output -> RlpTransactionProvider.writeTo(tx, output)).size(); return RLP.encode(output -> RlpProvider.transaction().writeTo(tx, output)).size();
} }
private int calculateRlpEncodedSize(final Bytes data) { private int calculateRlpEncodedSize(final Bytes data) {

@ -24,8 +24,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.eth.transactions.layered.BaseTransactionPoolTest; import org.hyperledger.besu.ethereum.eth.transactions.layered.BaseTransactionPoolTest;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
@ -72,10 +71,11 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txTo = Transaction txTo =
preparedTx.to(Optional.of(Address.extract(Bytes32.random()))).createTransaction(KEYS1); preparedTx.to(Optional.of(Address.extract(Bytes32.random()))).createTransaction(KEYS1);
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpTransactionProvider.writeTo(txTo, rlpOut); RlpProvider.transaction().writeTo(txTo, rlpOut);
txTo = txTo =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)) RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txTo.getSender()); System.out.println(txTo.getSender());
System.out.println(txTo.getHash()); System.out.println(txTo.getHash());
@ -120,7 +120,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txPayload = preparedTx.createTransaction(KEYS1); Transaction txPayload = preparedTx.createTransaction(KEYS1);
txPayload = txPayload =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)) RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txPayload.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txPayload.getSender()); System.out.println(txPayload.getSender());
System.out.println(txPayload.getHash()); System.out.println(txPayload.getHash());
@ -210,10 +211,11 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
prepareTransaction(TransactionType.BLOB, 10, Wei.of(500), Wei.of(50), 10, 1); prepareTransaction(TransactionType.BLOB, 10, Wei.of(500), Wei.of(50), 10, 1);
Transaction txBlob = preparedTx.createTransaction(KEYS1); Transaction txBlob = preparedTx.createTransaction(KEYS1);
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(txBlob, rlpOut); RlpProvider.pooledTransaction().writeTo(txBlob, rlpOut);
txBlob = txBlob =
RlpPooledTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)) RlpProvider.pooledTransaction()
.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txBlob.getSender()); System.out.println(txBlob.getSender());
System.out.println(txBlob.getHash()); System.out.println(txBlob.getHash());
@ -241,10 +243,11 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
prepareTransaction(TransactionType.BLOB, 10, Wei.of(500), Wei.of(50), 10, 1); prepareTransaction(TransactionType.BLOB, 10, Wei.of(500), Wei.of(50), 10, 1);
Transaction txBlob = preparedTx.createTransaction(KEYS1); Transaction txBlob = preparedTx.createTransaction(KEYS1);
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(txBlob, rlpOut); RlpProvider.pooledTransaction().writeTo(txBlob, rlpOut);
txBlob = txBlob =
RlpPooledTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)) RlpProvider.pooledTransaction()
.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txBlob.getSender()); System.out.println(txBlob.getSender());
System.out.println(txBlob.getHash()); System.out.println(txBlob.getHash());
@ -270,7 +273,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txPayload = preparedTx.createTransaction(KEYS1); Transaction txPayload = preparedTx.createTransaction(KEYS1);
txPayload = txPayload =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)) RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txPayload.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txPayload.getSender()); System.out.println(txPayload.getSender());
System.out.println(txPayload.getHash()); System.out.println(txPayload.getHash());
@ -301,7 +305,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1); Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1);
txAccessList = txAccessList =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false)) RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txAccessList.getSender()); System.out.println(txAccessList.getSender());
System.out.println(txAccessList.getHash()); System.out.println(txAccessList.getHash());
@ -342,7 +347,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txEip1559 = createEIP1559Transaction(1, KEYS1, 10); Transaction txEip1559 = createEIP1559Transaction(1, KEYS1, 10);
txEip1559 = txEip1559 =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false)) RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txEip1559.getSender()); System.out.println(txEip1559.getSender());
System.out.println(txEip1559.getHash()); System.out.println(txEip1559.getHash());
@ -385,7 +391,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txFrontier = createTransaction(TransactionType.FRONTIER, 1, Wei.of(500), 0, KEYS1); Transaction txFrontier = createTransaction(TransactionType.FRONTIER, 1, Wei.of(500), 0, KEYS1);
txFrontier = txFrontier =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false)) RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false))
.detachedCopy(); .detachedCopy();
System.out.println(txFrontier.getSender()); System.out.println(txFrontier.getSender());
System.out.println(txFrontier.getHash()); System.out.println(txFrontier.getHash());

@ -27,7 +27,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.MiningConfiguration; import org.hyperledger.besu.ethereum.core.MiningConfiguration;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
import org.hyperledger.besu.ethereum.eth.transactions.BlobCache; import org.hyperledger.besu.ethereum.eth.transactions.BlobCache;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration; import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
@ -295,7 +295,7 @@ public class ReplayTest {
final LayeredPendingTransactions pendingTransactions, final LayeredPendingTransactions pendingTransactions,
final AbstractPrioritizedTransactions prioritizedTransactions) { final AbstractPrioritizedTransactions prioritizedTransactions) {
final Bytes rlp = Bytes.fromHexString(commaSplit[commaSplit.length - 1]); final Bytes rlp = Bytes.fromHexString(commaSplit[commaSplit.length - 1]);
final Transaction tx = RlpTransactionProvider.readFrom(rlp); final Transaction tx = RlpProvider.transaction().readFrom(rlp);
final Account mockAccount = mock(Account.class); final Account mockAccount = mock(Account.class);
final long nonce = Long.parseLong(commaSplit[4]); final long nonce = Long.parseLong(commaSplit[4]);
when(mockAccount.getNonce()).thenReturn(nonce); when(mockAccount.getNonce()).thenReturn(nonce);
@ -319,7 +319,7 @@ public class ReplayTest {
private void processInvalid( private void processInvalid(
final String[] commaSplit, final AbstractPrioritizedTransactions prioritizedTransactions) { final String[] commaSplit, final AbstractPrioritizedTransactions prioritizedTransactions) {
final Bytes rlp = Bytes.fromHexString(commaSplit[commaSplit.length - 1]); final Bytes rlp = Bytes.fromHexString(commaSplit[commaSplit.length - 1]);
final Transaction tx = RlpTransactionProvider.readFrom(rlp); final Transaction tx = RlpProvider.transaction().readFrom(rlp);
if (tx.getSender().equals(senderToLog)) { if (tx.getSender().equals(senderToLog)) {
LOG.warn("D {}, Before {}", tx.getNonce(), prioritizedTransactions.logSender(senderToLog)); LOG.warn("D {}, Before {}", tx.getNonce(), prioritizedTransactions.logSender(senderToLog));
} }

@ -37,7 +37,7 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Request; import org.hyperledger.besu.ethereum.core.Request;
import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt; import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -141,14 +141,14 @@ public class T8nExecutor {
new BytesValueRLPInput(Bytes.fromHexString(txNode.asText()), false); new BytesValueRLPInput(Bytes.fromHexString(txNode.asText()), false);
rlpInput.enterList(); rlpInput.enterList();
while (!rlpInput.isEndOfCurrentList()) { while (!rlpInput.isEndOfCurrentList()) {
Transaction tx = RlpTransactionProvider.readFrom(rlpInput); Transaction tx = RlpProvider.transaction().readFrom(rlpInput);
transactions.add(tx); transactions.add(tx);
} }
} else if (txNode.isObject()) { } else if (txNode.isObject()) {
if (txNode.has("txBytes")) { if (txNode.has("txBytes")) {
Transaction tx = Transaction tx =
RlpTransactionProvider.readFrom( RlpProvider.transaction()
Bytes.fromHexString(txNode.get("txbytes").asText())); .readFrom(Bytes.fromHexString(txNode.get("txbytes").asText()));
transactions.add(tx); transactions.add(tx);
} else { } else {
Transaction.Builder builder = Transaction.builder(); Transaction.Builder builder = Transaction.builder();
@ -617,7 +617,7 @@ public class T8nExecutor {
}); });
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
rlpOut.writeList(transactions, RlpTransactionProvider::writeTo); rlpOut.writeList(transactions, RlpProvider.transaction()::writeTo);
TextNode bodyBytes = TextNode.valueOf(rlpOut.encoded().toHexString()); TextNode bodyBytes = TextNode.valueOf(rlpOut.encoded().toHexString());
return new T8nResult(allocObject, bodyBytes, resultObject); return new T8nResult(allocObject, bodyBytes, resultObject);
} }

@ -32,7 +32,7 @@ import org.hyperledger.besu.ethereum.core.InMemoryKeyValueStorageProvider;
import org.hyperledger.besu.ethereum.core.MutableWorldState; import org.hyperledger.besu.ethereum.core.MutableWorldState;
import org.hyperledger.besu.ethereum.core.ParsedExtraData; import org.hyperledger.besu.ethereum.core.ParsedExtraData;
import org.hyperledger.besu.ethereum.core.Withdrawal; import org.hyperledger.besu.ethereum.core.Withdrawal;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput;
@ -286,7 +286,7 @@ public class BlockchainReferenceTestCaseSpec {
final BlockHeader header = BlockHeader.readFrom(input, blockHeaderFunctions); final BlockHeader header = BlockHeader.readFrom(input, blockHeaderFunctions);
final BlockBody body = final BlockBody body =
new BlockBody( new BlockBody(
input.readList(RlpTransactionProvider::readFrom), input.readList(RlpProvider.transaction()::readFrom),
input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)), input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)),
input.isEndOfCurrentList() input.isEndOfCurrentList()
? Optional.empty() ? Optional.empty()

@ -17,8 +17,7 @@ package org.hyperledger.besu.ethereum.core;
import static org.assertj.core.api.Assertions.assertThat; import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult; import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -174,7 +173,7 @@ public class TransactionTest {
} }
// Test transaction deserialization (will throw an exception if it fails). // Test transaction deserialization (will throw an exception if it fails).
final Transaction transaction = RlpTransactionProvider.readFrom(RLP.input(rlp)); final Transaction transaction = RlpProvider.transaction().readFrom(RLP.input(rlp));
final ValidationResult<TransactionInvalidReason> validation = final ValidationResult<TransactionInvalidReason> validation =
transactionValidator(milestone) transactionValidator(milestone)
.validate(transaction, baseFee, Optional.empty(), TransactionValidationParams.processingBlock()); .validate(transaction, baseFee, Optional.empty(), TransactionValidationParams.processingBlock());
@ -185,7 +184,7 @@ public class TransactionTest {
} }
// Test rlp encoding // Test rlp encoding
final Bytes actualRlp = RLP.encode(output -> RlpTransactionProvider.writeTo(transaction, output)); final Bytes actualRlp = RLP.encode(output -> RlpProvider.transaction().writeTo(transaction, output));
assertThat(expected.isSucceeds()) assertThat(expected.isSucceeds())
.withFailMessage("Transaction " + name + "/" + milestone + " was supposed to be invalid") .withFailMessage("Transaction " + name + "/" + milestone + " was supposed to be invalid")
.isTrue(); .isTrue();

Loading…
Cancel
Save