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.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.InputStreamReader;
@ -104,7 +104,7 @@ public class TxParseSubCommand implements Runnable {
void dump(final Bytes tx) {
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
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.Synchronizer;
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.transactions.TransactionPool;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -130,7 +130,7 @@ public class GraphQLDataFetchers {
dataFetchingEnvironment.getGraphQlContext().get(GraphQLContextType.TRANSACTION_POOL);
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 =
transactionPool.addTransactionViaApi(transaction);
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.Transaction;
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.mainnet.BodyValidation;
import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions;
@ -220,7 +220,7 @@ public abstract class AbstractEngineNewPayload extends ExecutionEngineJsonRpcMet
transactions =
blockParam.getTransactions().stream()
.map(Bytes::fromHexString)
.map(RlpTransactionProvider::decodeOpaqueBytes)
.map(RlpProvider.transaction()::decodeOpaqueBytes)
.collect(Collectors.toList());
transactions.forEach(
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.RpcErrorType;
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.mainnet.ValidationResult;
import org.hyperledger.besu.ethereum.privacy.PrivateTransaction;
@ -156,7 +156,7 @@ public abstract class AbstractEeaSendRawTransaction implements JsonRpcMethod {
final Bytes rlpBytes =
privateMarkerTransactionFactory.create(
unsignedPrivateMarkerTransaction, privateTransaction, privacyUserId);
return RlpTransactionProvider.readFrom(rlpBytes);
return RlpProvider.transaction().readFrom(rlpBytes);
}
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.BlockHeader;
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.Comparator;
@ -95,7 +95,7 @@ public class BlockResultFactory {
public EngineGetPayloadResultV1 payloadTransactionCompleteV1(final Block block) {
final List<String> txs =
block.getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
@ -106,7 +106,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
@ -130,7 +130,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
@ -148,7 +148,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
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.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.List;
@ -52,7 +52,7 @@ public class EngineGetPayloadBodiesResultV1 {
public PayloadBody(final BlockBody blockBody) {
this.transactions =
blockBody.getTransactions().stream()
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpProvider.transaction()::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
this.withdrawals =

@ -20,7 +20,7 @@ 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.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import java.util.List;
@ -101,7 +101,7 @@ public class TransactionPendingResult implements TransactionResult {
this.input = transaction.getPayload().toString();
this.nonce = Quantity.create(transaction.getNonce());
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);
if (transactionType == TransactionType.FRONTIER) {
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.response.RpcErrorType;
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.apache.tuweni.bytes.Bytes;
@ -28,7 +28,7 @@ public class DomainObjectDecodeUtils {
throws InvalidJsonRpcRequestException {
try {
Bytes txnBytes = Bytes.fromHexString(rawTransaction);
return RlpPooledTransactionProvider.decodeOpaqueBytes(txnBytes);
return RlpProvider.pooledTransaction().decodeOpaqueBytes(txnBytes);
} catch (final IllegalArgumentException e) {
throw new InvalidJsonRpcRequestException(
"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.TransactionWithMetadata;
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.TransactionPool;
@ -109,7 +109,7 @@ class EthGetTransactionByHashTest {
@Test
void shouldReturnPendingTransactionWhenTransactionExistsAndIsPending() {
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()))
.thenReturn(Optional.of(transaction));
@ -131,7 +131,7 @@ class EthGetTransactionByHashTest {
@Test
void shouldReturnCompleteTransactionWhenTransactionExistsInBlockchain() {
final org.hyperledger.besu.ethereum.core.Transaction transaction =
RlpTransactionProvider.readFrom(Bytes.fromHexString(VALID_TRANSACTION));
RlpProvider.transaction().readFrom(Bytes.fromHexString(VALID_TRANSACTION));
final TransactionWithMetadata transactionWithMetadata =
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.TransactionTestFixture;
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.CancunTargetingGasLimitCalculator;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -225,7 +225,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
public void shouldRejectTransactionsWithFullBlobs() {
Bytes transactionWithBlobsBytes =
RlpPooledTransactionProvider.encodeOpaqueBytes(createTransactionWithBlobs());
RlpProvider.pooledTransaction().encodeOpaqueBytes(createTransactionWithBlobs());
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.ethereum.core.BlockDataGenerator;
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 java.math.BigInteger;
@ -57,7 +57,7 @@ public class DomainObjectDecodeUtilsTest {
@Test
public void testAccessListRLPSerDes() {
final BytesValueRLPOutput encoded = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(accessListTxn, encoded);
RlpProvider.pooledTransaction().writeTo(accessListTxn, encoded);
Transaction decoded =
DomainObjectDecodeUtils.decodeRawTransaction(encoded.encoded().toHexString());
Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue();
@ -66,7 +66,7 @@ public class DomainObjectDecodeUtilsTest {
@Test
public void testAccessList2718OpaqueSerDes() {
final Bytes encoded = RlpPooledTransactionProvider.encodeOpaqueBytes(accessListTxn);
final Bytes encoded = RlpProvider.pooledTransaction().encodeOpaqueBytes(accessListTxn);
Transaction decoded = DomainObjectDecodeUtils.decodeRawTransaction(encoded.toString());
Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue();
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.MutableWorldState;
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.TraceOptions;
import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor;
@ -171,8 +171,8 @@ public class TraceTransactionIntegrationTest {
final DebugOperationTracer tracer =
new DebugOperationTracer(new TraceOptions(true, true, true), false);
final Transaction transaction =
RlpTransactionProvider.readFrom(
new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false));
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false));
final BlockHeader genesisBlockHeader = genesisBlock.getHeader();
transactionProcessor.processTransaction(
worldStateArchive

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.core;
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.RLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
@ -60,7 +60,7 @@ public class Block {
out.startList();
header.writeTo(out);
out.writeList(body.getTransactions(), RlpTransactionProvider::writeTo);
out.writeList(body.getTransactions(), RlpProvider.transaction()::writeTo);
out.writeList(body.getOmmers(), BlockHeader::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) {
in.enterList();
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 Optional<List<Withdrawal>> withdrawals =
in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Withdrawal::readFrom));

@ -14,7 +14,7 @@
*/
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.RLPOutput;
@ -96,7 +96,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody {
}
public void writeTo(final RLPOutput output) {
output.writeList(getTransactions(), RlpTransactionProvider::writeTo);
output.writeList(getTransactions(), RlpProvider.transaction()::writeTo);
output.writeList(getOmmers(), BlockHeader::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(
final RLPInput input, final BlockHeaderFunctions blockHeaderFunctions) {
return new BlockBody(
input.readList(RlpTransactionProvider::readFrom),
input.readList(RlpProvider.transaction()::readFrom),
input.readList(rlp -> BlockHeader.readFrom(rlp, blockHeaderFunctions)),
input.isEndOfCurrentList()
? 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.BlobTransactionEncoder;
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.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
@ -472,7 +471,7 @@ public class Transaction
@Override
public Bytes encoded() {
final BytesValueRLPOutput rplOutput = new BytesValueRLPOutput();
RlpTransactionProvider.writeTo(this, rplOutput);
RlpProvider.transaction().writeTo(this, rplOutput);
return rplOutput.encoded();
}
@ -537,10 +536,10 @@ public class Transaction
}
private void memoizeHashAndSize() {
final Bytes bytes = RlpTransactionProvider.encodeOpaqueBytes(this);
final Bytes bytes = RlpProvider.transaction().encodeOpaqueBytes(this);
hash = Hash.hash(bytes);
if (transactionType.supportsBlob() && getBlobsWithCommitments().isPresent()) {
final Bytes pooledBytes = RlpPooledTransactionProvider.encodeOpaqueBytes(this);
final Bytes pooledBytes = RlpProvider.pooledTransaction().encodeOpaqueBytes(this);
size = pooledBytes.size();
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.Withdrawal;
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.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie;
@ -65,7 +65,7 @@ public final class BodyValidation {
.forEach(
i ->
trie.put(
indexKey(i), RlpTransactionProvider.encodeOpaqueBytes(transactions.get(i))));
indexKey(i), RlpProvider.transaction().encodeOpaqueBytes(transactions.get(i))));
return Hash.wrap(trie.getRootHash());
}

@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.core;
import static org.assertj.core.api.Assertions.assertThat;
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.RLPInput;
@ -35,7 +35,7 @@ public class TransactionIntegrationTest {
"0xf902560c843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000007b820fe8a009e7b69af4c318e7fb915f53649bd9f99e5423d41c2cd6a01ab69bb34a951b2fa01b5d39b7c9041ec022d13e6e89eec2cddbe27572eda7956ada5de1032cd5da15";
final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded);
final Transaction transaction = RlpTransactionProvider.readFrom(input);
final Transaction transaction = RlpProvider.transaction().readFrom(input);
assertThat(transaction).isNotNull();
assertThat(transaction.isContractCreation()).isTrue();
assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2018));
@ -49,7 +49,7 @@ public class TransactionIntegrationTest {
"0xf9025780843b9aca00832dc6c08080b90202608060405234801561001057600080fd5b506040516020806101e283398101604052516000556101ae806100346000396000f30060806040526004361061006c5763ffffffff7c01000000000000000000000000000000000000000000000000000000006000350416632113522a81146100715780632a1afcd9146100af5780633bc5de30146100d657806360fe47b1146100eb578063db613e8114610105575b600080fd5b34801561007d57600080fd5b5061008661011a565b6040805173ffffffffffffffffffffffffffffffffffffffff9092168252519081900360200190f35b3480156100bb57600080fd5b506100c4610136565b60408051918252519081900360200190f35b3480156100e257600080fd5b506100c461013c565b3480156100f757600080fd5b50610103600435610142565b005b34801561011157600080fd5b50610086610166565b60015473ffffffffffffffffffffffffffffffffffffffff1681565b60005481565b60005490565b6000556001805473ffffffffffffffffffffffffffffffffffffffff191633179055565b60015473ffffffffffffffffffffffffffffffffffffffff16905600a165627a7a723058208293fac83e9cc01039adf5e41eefd557d1324a3a4c830a4802fa1dd2515227a20029000000000000000000000000000000000000000000000000000000000000000c830628cba0482ba9b1136cd9337408938eea6b991fd153900a014867da2f4bb113d4003888a00c5a2f8f279fe2c86831afb5c9578dd1c3be457e3aca3abe439b1a5dd122e676";
final Bytes encoded = Bytes.fromHexString(encodedString);
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);
}
@ -59,7 +59,7 @@ public class TransactionIntegrationTest {
"0xf86a018609184e72a0008276c094d30c3d13b07029deba00de1da369cd69a02c20560180850100000021a07d344f26d7329e8932d2878b99f07b12752bbd13a0b3b822644dbf9600fe718da01d6e6b6c66e1aadf4e33e318a7eef03d3bd3602de52662f0cb5af5b372d44dcd";
final Bytes encoded = Bytes.fromHexString(encodedString);
final RLPInput input = RLP.input(encoded);
final Transaction transaction = RlpTransactionProvider.readFrom(input);
final Transaction transaction = RlpProvider.transaction().readFrom(input);
assertThat(transaction).isNotNull();
assertThat(transaction.isContractCreation()).isFalse();
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 org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import java.io.BufferedReader;
@ -59,13 +58,13 @@ public class BlobTransactionEncodingTest {
final TypedTransactionBytesArgument argument) {
Bytes bytes = argument.bytes;
// 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();
new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, output);
final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(transaction, bytesValueRLPOutput);
RlpProvider.pooledTransaction().writeTo(transaction, bytesValueRLPOutput);
assertThat(transaction.getSize()).isEqualTo(bytes.size());
}
@ -74,10 +73,10 @@ public class BlobTransactionEncodingTest {
public void blobTransactionEncodingDecodingTest(final TypedTransactionBytesArgument argument) {
Bytes bytes = argument.bytes;
// 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.
Bytes encoded = RlpTransactionProvider.encodeOpaqueBytes(transaction);
Bytes encoded = RlpProvider.transaction().encodeOpaqueBytes(transaction);
// Assert that the encoded transaction matches the original bytes.
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.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
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.RLPException;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
@ -70,7 +69,7 @@ class TransactionRLPDecoderTest {
final String txWithBigFees =
"0x02f84e0101a1648a5f8b2dcad5ea5ba6b720ff069c1d87c21a4a6a5b3766b39e2c2792367bb066a1ffa5ffaf5b0560d3a9fb186c2ede2ae6751bc0b4fef9107cf36389630b6196a38805800180c0010203";
assertThatThrownBy(
() -> RlpTransactionProvider.decodeOpaqueBytes(Bytes.fromHexString(txWithBigFees)))
() -> RlpProvider.transaction().decodeOpaqueBytes(Bytes.fromHexString(txWithBigFees)))
.isInstanceOf(RLPException.class);
}
@ -115,7 +114,7 @@ class TransactionRLPDecoderTest {
final Bytes bytes = Bytes.fromHexString(rlp_tx);
// Decode bytes into a transaction
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
assertThat(transaction.getSize()).isEqualTo(transactionBytes.size());
}
@ -156,6 +155,6 @@ class TransactionRLPDecoderTest {
}
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.BlockDataGenerator;
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.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
@ -94,10 +94,10 @@ class TransactionRLPEncoderTest {
}
private Transaction decodeRLP(final RLPInput input) {
return RlpTransactionProvider.readFrom(input);
return RlpProvider.transaction().readFrom(input);
}
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 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.evm.gascalculator.FrontierGasCalculator;
import org.hyperledger.besu.evm.gascalculator.GasCalculator;
@ -89,7 +89,7 @@ public class IntrinsicGasTest {
@MethodSource("data")
public void validateGasCost(
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(
gasCalculator.transactionIntrinsicGasCost(t.getPayload(), t.isContractCreation()))
.isEqualTo(expectedGas);

@ -24,7 +24,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
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 java.util.Optional;
@ -65,8 +65,8 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest {
.build();
final Transaction transaction =
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpProvider.transaction()
.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(transaction.getNonce()).isEqualTo(providedNonce);
assertThat(transaction.getGasLimit()).isEqualTo(gasLimit);
@ -78,8 +78,8 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest {
assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey));
final Transaction nextTransaction =
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpProvider.transaction()
.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
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.Wei;
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 java.util.Optional;
@ -61,8 +61,8 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest {
new RandomSigningPrivateMarkerTransactionFactory();
final Transaction transaction =
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpProvider.transaction()
.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(transaction.getNonce()).isEqualTo(0);
assertThat(transaction.getGasLimit()).isEqualTo(gasLimit);
@ -72,8 +72,8 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest {
assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey));
final Transaction nextTransaction =
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpProvider.transaction()
.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
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.Transaction;
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.messages.BlockBodiesMessage;
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;
@ -272,7 +272,7 @@ class EthServer {
}
final BytesValueRLPOutput txRlp = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(maybeTx.get(), txRlp);
RlpProvider.pooledTransaction().writeTo(maybeTx.get(), txRlp);
final int encodedSize = txRlp.encodedSize();
if (responseSizeEstimate + encodedSize > maxMessageSize) {
break;

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.eth.messages;
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.MessageData;
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) {
final BytesValueRLPOutput out = new BytesValueRLPOutput();
out.writeList(transactions, RlpPooledTransactionProvider::writeTo);
out.writeList(transactions, RlpProvider.pooledTransaction()::writeTo);
return new PooledTransactionsMessage(out.encoded());
}
@ -72,7 +72,7 @@ public final class PooledTransactionsMessage extends AbstractMessageData {
public List<Transaction> transactions() {
if (pooledTransactions == null) {
final BytesValueRLPInput in = new BytesValueRLPInput(getData(), false);
pooledTransactions = in.readList(RlpPooledTransactionProvider::readFrom);
pooledTransactions = in.readList(RlpProvider.pooledTransaction()::readFrom);
}
return pooledTransactions;
}

@ -15,7 +15,7 @@
package org.hyperledger.besu.ethereum.eth.messages;
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.MessageData;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
@ -43,7 +43,7 @@ public class TransactionsMessage extends AbstractMessageData {
final BytesValueRLPOutput tmp = new BytesValueRLPOutput();
tmp.startList();
for (final Transaction transaction : transactions) {
RlpTransactionProvider.writeTo(transaction, tmp);
RlpProvider.transaction().writeTo(transaction, tmp);
}
tmp.endList();
return new TransactionsMessage(tmp.encoded());
@ -59,6 +59,6 @@ public class TransactionsMessage extends AbstractMessageData {
}
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.core.BlockHeader;
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.EthPeer;
import org.hyperledger.besu.ethereum.eth.manager.EthScheduler;
@ -842,8 +842,8 @@ public class TransactionPool implements BlockAddedObserver {
line -> {
final boolean isLocal = line.charAt(0) == 'l';
final Transaction tx =
RlpTransactionProvider.readFrom(
Bytes.fromBase64String(line.substring(1)));
RlpProvider.transaction()
.readFrom(Bytes.fromBase64String(line.substring(1)));
final ValidationResult<TransactionInvalidReason> result =
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.Transaction;
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.messages.BlockBodiesMessage;
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;
@ -388,7 +388,7 @@ public class EthServerTest {
}
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) {

@ -24,8 +24,7 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
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.layered.BaseTransactionPoolTest;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
@ -72,10 +71,11 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txTo =
preparedTx.to(Optional.of(Address.extract(Bytes32.random()))).createTransaction(KEYS1);
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpTransactionProvider.writeTo(txTo, rlpOut);
RlpProvider.transaction().writeTo(txTo, rlpOut);
txTo =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy();
System.out.println(txTo.getSender());
System.out.println(txTo.getHash());
@ -120,7 +120,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txPayload = preparedTx.createTransaction(KEYS1);
txPayload =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false))
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txPayload.encoded(), false))
.detachedCopy();
System.out.println(txPayload.getSender());
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);
Transaction txBlob = preparedTx.createTransaction(KEYS1);
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(txBlob, rlpOut);
RlpProvider.pooledTransaction().writeTo(txBlob, rlpOut);
txBlob =
RlpPooledTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
RlpProvider.pooledTransaction()
.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy();
System.out.println(txBlob.getSender());
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);
Transaction txBlob = preparedTx.createTransaction(KEYS1);
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(txBlob, rlpOut);
RlpProvider.pooledTransaction().writeTo(txBlob, rlpOut);
txBlob =
RlpPooledTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
RlpProvider.pooledTransaction()
.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy();
System.out.println(txBlob.getSender());
System.out.println(txBlob.getHash());
@ -270,7 +273,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txPayload = preparedTx.createTransaction(KEYS1);
txPayload =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false))
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txPayload.encoded(), false))
.detachedCopy();
System.out.println(txPayload.getSender());
System.out.println(txPayload.getHash());
@ -301,7 +305,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1);
txAccessList =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false))
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false))
.detachedCopy();
System.out.println(txAccessList.getSender());
System.out.println(txAccessList.getHash());
@ -342,7 +347,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txEip1559 = createEIP1559Transaction(1, KEYS1, 10);
txEip1559 =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false))
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false))
.detachedCopy();
System.out.println(txEip1559.getSender());
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);
txFrontier =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false))
RlpProvider.transaction()
.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false))
.detachedCopy();
System.out.println(txFrontier.getSender());
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.MiningConfiguration;
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.transactions.BlobCache;
import org.hyperledger.besu.ethereum.eth.transactions.ImmutableTransactionPoolConfiguration;
@ -295,7 +295,7 @@ public class ReplayTest {
final LayeredPendingTransactions pendingTransactions,
final AbstractPrioritizedTransactions prioritizedTransactions) {
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 long nonce = Long.parseLong(commaSplit[4]);
when(mockAccount.getNonce()).thenReturn(nonce);
@ -319,7 +319,7 @@ public class ReplayTest {
private void processInvalid(
final String[] commaSplit, final AbstractPrioritizedTransactions prioritizedTransactions) {
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)) {
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.Transaction;
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.MainnetTransactionProcessor;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -141,14 +141,14 @@ public class T8nExecutor {
new BytesValueRLPInput(Bytes.fromHexString(txNode.asText()), false);
rlpInput.enterList();
while (!rlpInput.isEndOfCurrentList()) {
Transaction tx = RlpTransactionProvider.readFrom(rlpInput);
Transaction tx = RlpProvider.transaction().readFrom(rlpInput);
transactions.add(tx);
}
} else if (txNode.isObject()) {
if (txNode.has("txBytes")) {
Transaction tx =
RlpTransactionProvider.readFrom(
Bytes.fromHexString(txNode.get("txbytes").asText()));
RlpProvider.transaction()
.readFrom(Bytes.fromHexString(txNode.get("txbytes").asText()));
transactions.add(tx);
} else {
Transaction.Builder builder = Transaction.builder();
@ -617,7 +617,7 @@ public class T8nExecutor {
});
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
rlpOut.writeList(transactions, RlpTransactionProvider::writeTo);
rlpOut.writeList(transactions, RlpProvider.transaction()::writeTo);
TextNode bodyBytes = TextNode.valueOf(rlpOut.encoded().toHexString());
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.ParsedExtraData;
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.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
@ -286,7 +286,7 @@ public class BlockchainReferenceTestCaseSpec {
final BlockHeader header = BlockHeader.readFrom(input, blockHeaderFunctions);
final BlockBody body =
new BlockBody(
input.readList(RlpTransactionProvider::readFrom),
input.readList(RlpProvider.transaction()::readFrom),
input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)),
input.isEndOfCurrentList()
? Optional.empty()

@ -17,8 +17,7 @@ package org.hyperledger.besu.ethereum.core;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpProvider;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidator;
import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams;
import org.hyperledger.besu.ethereum.mainnet.ValidationResult;
@ -174,7 +173,7 @@ public class TransactionTest {
}
// 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 =
transactionValidator(milestone)
.validate(transaction, baseFee, Optional.empty(), TransactionValidationParams.processingBlock());
@ -185,7 +184,7 @@ public class TransactionTest {
}
// 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())
.withFailMessage("Transaction " + name + "/" + milestone + " was supposed to be invalid")
.isTrue();

Loading…
Cancel
Save