diff --git a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/TxParseSubCommand.java b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/TxParseSubCommand.java index 26de73abea..09d82c4f63 100644 --- a/besu/src/main/java/org/hyperledger/besu/cli/subcommands/TxParseSubCommand.java +++ b/besu/src/main/java/org/hyperledger/besu/cli/subcommands/TxParseSubCommand.java @@ -29,7 +29,7 @@ import java.nio.file.Paths; import java.util.stream.Stream; import org.apache.tuweni.bytes.Bytes; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import picocli.CommandLine; /** @@ -104,7 +104,7 @@ public class TxParseSubCommand implements Runnable { void dump(final Bytes tx) { try { - var transaction = TransactionDecoderProvider.decodeOpaqueBytes(tx); + var transaction = RlpTransactionProvider.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)) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java index ffbc9f9ab6..f5878d4553 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/GraphQLDataFetchers.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 = TransactionDecoderProvider.readFrom(RLP.input(rawTran)); + final Transaction transaction = RlpTransactionProvider.readFrom(RLP.input(rawTran)); final ValidationResult validationResult = transactionPool.addTransactionViaApi(transaction); if (validationResult.isValid()) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java index d20a0f5f53..c5d6c9043e 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/AbstractEngineNewPayload.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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(TransactionDecoderProvider::decodeOpaqueBytes) + .map(RlpTransactionProvider::decodeOpaqueBytes) .collect(Collectors.toList()); transactions.forEach( transaction -> diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java index 4a6a7f2d3d..3e500eb390 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/eea/AbstractEeaSendRawTransaction.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 TransactionDecoderProvider.readFrom(rlpBytes); + return RlpTransactionProvider.readFrom(rlpBytes); } protected abstract long getGasLimit(PrivateTransaction privateTransaction, String pmtPayload); diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java index 111d654c20..a465c4a16f 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java @@ -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.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import java.util.ArrayList; import java.util.Comparator; @@ -96,7 +96,7 @@ public class BlockResultFactory { final List txs = block.getBody().getTransactions().stream() .map( - TransactionEncoderProvider::encodeOpaqueBytes) + RlpTransactionProvider::encodeOpaqueBytes) .map(Bytes::toHexString) .collect(Collectors.toList()); @@ -108,7 +108,7 @@ public class BlockResultFactory { final List txs = blockWithReceipts.getBlock().getBody().getTransactions().stream() .map( - TransactionEncoderProvider::encodeOpaqueBytes) + RlpTransactionProvider::encodeOpaqueBytes) .map(Bytes::toHexString) .collect(Collectors.toList()); @@ -133,7 +133,7 @@ public class BlockResultFactory { final List txs = blockWithReceipts.getBlock().getBody().getTransactions().stream() .map( - TransactionEncoderProvider::encodeOpaqueBytes) + RlpTransactionProvider::encodeOpaqueBytes) .map(Bytes::toHexString) .collect(Collectors.toList()); @@ -152,7 +152,7 @@ public class BlockResultFactory { final List txs = blockWithReceipts.getBlock().getBody().getTransactions().stream() .map( - TransactionEncoderProvider::encodeOpaqueBytes) + RlpTransactionProvider::encodeOpaqueBytes) .map(Bytes::toHexString) .collect(Collectors.toList()); final Optional> requestsWithoutRequestId = diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadBodiesResultV1.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadBodiesResultV1.java index 7658d72934..9ce81dddfa 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadBodiesResultV1.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadBodiesResultV1.java @@ -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.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import java.util.Collections; import java.util.List; @@ -53,7 +53,7 @@ public class EngineGetPayloadBodiesResultV1 { this.transactions = blockBody.getTransactions().stream() .map( - TransactionEncoderProvider::encodeOpaqueBytes) + RlpTransactionProvider::encodeOpaqueBytes) .map(Bytes::toHexString) .collect(Collectors.toList()); this.withdrawals = diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java index 059943850c..94818708d3 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java @@ -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.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import java.util.List; @@ -103,7 +103,7 @@ public class TransactionPendingResult implements TransactionResult { this.nonce = Quantity.create(transaction.getNonce()); this.publicKey = transaction.getPublicKey().orElse(null); this.raw = - PooledTransactionEncoderProvider.encodeOpaqueBytes(transaction) + RlpPooledTransactionProvider.encodeOpaqueBytes(transaction) .toString(); this.to = transaction.getTo().map(Address::toHexString).orElse(null); if (transactionType == TransactionType.FRONTIER) { diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java index e19d03788f..3fb9f404c5 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java @@ -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.PooledTransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; 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 PooledTransactionDecoderProvider.decodeOpaqueBytes(txnBytes); + return RlpPooledTransactionProvider.decodeOpaqueBytes(txnBytes); } catch (final IllegalArgumentException e) { throw new InvalidJsonRpcRequestException( "Invalid raw transaction hex", RpcErrorType.INVALID_TRANSACTION_PARAMS, e); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHashTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHashTest.java index 342e29e9df..a268701979 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHashTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHashTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 = - TransactionDecoderProvider.readFrom( + RlpTransactionProvider.readFrom( Bytes.fromHexString(VALID_TRANSACTION)); when(transactionPool.getTransactionByHash(transaction.getHash())) @@ -132,7 +132,7 @@ class EthGetTransactionByHashTest { @Test void shouldReturnCompleteTransactionWhenTransactionExistsInBlockchain() { final org.hyperledger.besu.ethereum.core.Transaction transaction = - TransactionDecoderProvider.readFrom( + RlpTransactionProvider.readFrom( Bytes.fromHexString(VALID_TRANSACTION)); final TransactionWithMetadata transactionWithMetadata = new TransactionWithMetadata(transaction, 1, Optional.empty(), Hash.ZERO, 0); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java index c33927f3b3..37bf10c208 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java @@ -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.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; 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 = - PooledTransactionEncoderProvider.encodeOpaqueBytes( + RlpPooledTransactionProvider.encodeOpaqueBytes( createTransactionWithBlobs()); List transactions = List.of(transactionWithBlobsBytes.toString()); diff --git a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java index 8345cba063..96facd06b3 100644 --- a/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java +++ b/ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java @@ -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.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; 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(); - PooledTransactionEncoderProvider.writeTo(accessListTxn, encoded); + RlpPooledTransactionProvider.writeTo(accessListTxn, encoded); Transaction decoded = DomainObjectDecodeUtils.decodeRawTransaction(encoded.encoded().toHexString()); Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue(); @@ -67,7 +67,7 @@ public class DomainObjectDecodeUtilsTest { @Test public void testAccessList2718OpaqueSerDes() { final Bytes encoded = - PooledTransactionEncoderProvider.encodeOpaqueBytes(accessListTxn); + RlpPooledTransactionProvider.encodeOpaqueBytes(accessListTxn); Transaction decoded = DomainObjectDecodeUtils.decodeRawTransaction(encoded.toString()); Assertions.assertThat(decoded.getAccessList().isPresent()).isTrue(); Assertions.assertThat(decoded.getAccessList().map(List::size).get()).isEqualTo(1); diff --git a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java index eea32b2388..8fe3a974cf 100644 --- a/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java +++ b/ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.debug.TraceFrame; import org.hyperledger.besu.ethereum.debug.TraceOptions; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; @@ -171,7 +171,7 @@ public class TraceTransactionIntegrationTest { final DebugOperationTracer tracer = new DebugOperationTracer(new TraceOptions(true, true, true), false); final Transaction transaction = - TransactionDecoderProvider.readFrom( + RlpTransactionProvider.readFrom( new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false)); final BlockHeader genesisBlockHeader = genesisBlock.getHeader(); transactionProcessor.processTransaction( diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java index dc44ed1ab2..0b971b0516 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Block.java @@ -15,8 +15,7 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.datatypes.Hash; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; @@ -61,7 +60,7 @@ public class Block { out.startList(); header.writeTo(out); - out.writeList(body.getTransactions(), TransactionEncoderProvider::writeTo); + out.writeList(body.getTransactions(), RlpTransactionProvider::writeTo); out.writeList(body.getOmmers(), BlockHeader::writeTo); body.getWithdrawals().ifPresent(withdrawals -> out.writeList(withdrawals, Withdrawal::writeTo)); @@ -71,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 transactions = in.readList(TransactionDecoderProvider::readFrom); + final List transactions = in.readList(RlpTransactionProvider::readFrom); final List ommers = in.readList(rlp -> BlockHeader.readFrom(rlp, hashFunction)); final Optional> withdrawals = in.isEndOfCurrentList() ? Optional.empty() : Optional.of(in.readList(Withdrawal::readFrom)); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java index 72806de3d2..7c11c2f9f5 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/BlockBody.java @@ -14,8 +14,7 @@ */ package org.hyperledger.besu.ethereum.core; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; @@ -97,7 +96,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { } public void writeTo(final RLPOutput output) { - output.writeList(getTransactions(), TransactionEncoderProvider::writeTo); + output.writeList(getTransactions(), RlpTransactionProvider::writeTo); output.writeList(getOmmers(), BlockHeader::writeTo); withdrawals.ifPresent(withdrawals -> output.writeList(withdrawals, Withdrawal::writeTo)); } @@ -144,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(TransactionDecoderProvider::readFrom), + input.readList(RlpTransactionProvider::readFrom), input.readList(rlp -> BlockHeader.readFrom(rlp, blockHeaderFunctions)), input.isEndOfCurrentList() ? Optional.empty() diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java index edd06ae926..1062bf5c7d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java @@ -39,9 +39,9 @@ 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.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPOutput; @@ -473,7 +473,7 @@ public class Transaction @Override public Bytes encoded() { final BytesValueRLPOutput rplOutput = new BytesValueRLPOutput(); - TransactionEncoderProvider.writeTo(this, rplOutput); + RlpTransactionProvider.writeTo(this, rplOutput); return rplOutput.encoded(); } @@ -538,11 +538,11 @@ public class Transaction } private void memoizeHashAndSize() { - final Bytes bytes = TransactionEncoderProvider.encodeOpaqueBytes(this); + final Bytes bytes = RlpTransactionProvider.encodeOpaqueBytes(this); hash = Hash.hash(bytes); if (transactionType.supportsBlob() && getBlobsWithCommitments().isPresent()) { final Bytes pooledBytes = - PooledTransactionEncoderProvider.encodeOpaqueBytes(this); + RlpPooledTransactionProvider.encodeOpaqueBytes(this); size = pooledBytes.size(); return; } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/PooledMainnetTransactionEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/PooledMainnetTransactionEncoder.java index ad8e887a6d..cfdc554796 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/PooledMainnetTransactionEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/PooledMainnetTransactionEncoder.java @@ -19,7 +19,7 @@ import static com.google.common.base.Preconditions.checkNotNull; import com.google.common.annotations.VisibleForTesting; import com.google.common.collect.ImmutableMap; import org.hyperledger.besu.datatypes.TransactionType; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; public class PooledMainnetTransactionEncoder extends MainnetTransactionEncoder { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/PooledTransactionEncoderProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/PooledTransactionEncoderProvider.java deleted file mode 100644 index 05590146f9..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/PooledTransactionEncoderProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hyperledger.besu.ethereum.core.encoding.registry; - -import org.apache.tuweni.bytes.Bytes; -import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -public class PooledTransactionEncoderProvider { - private PooledTransactionEncoderProvider(){} - - public static void writeTo(Transaction transaction, RLPOutput output) { - getEncoder().writeTo(transaction, output); - } - - public static Bytes encodeOpaqueBytes(Transaction transaction){ - return getEncoder().encodeOpaqueBytes(transaction); - } - - private static - TransactionEncoder getEncoder(){ - return RLPRegistry.getInstance().getPooledTransactionEncoder(); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpDecoder.java similarity index 90% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPDecoder.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpDecoder.java index 8528ac9424..e74548c10b 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPDecoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpDecoder.java @@ -15,11 +15,10 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.apache.tuweni.bytes.Bytes; -import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; -public interface RLPDecoder { +public interface RlpDecoder { T readFrom(final RLPInput input); default T readFrom(final Bytes bytes) { diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpEncoder.java similarity index 96% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPEncoder.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpEncoder.java index aaca74db76..66b93fcda2 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpEncoder.java @@ -17,7 +17,7 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.hyperledger.besu.ethereum.rlp.RLPOutput; -public interface RLPEncoder { +public interface RlpEncoder { void writeTo(T t, RLPOutput output); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoderProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpPooledTransactionProvider.java similarity index 50% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoderProvider.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpPooledTransactionProvider.java index 6a880860a8..f6ae55c3e6 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoderProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpPooledTransactionProvider.java @@ -3,9 +3,11 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.apache.tuweni.bytes.Bytes; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.rlp.RLPInput; +import org.hyperledger.besu.ethereum.rlp.RLPOutput; -public class TransactionDecoderProvider { - private TransactionDecoderProvider(){} +public class RlpPooledTransactionProvider { + + private RlpPooledTransactionProvider(){} public static Transaction readFrom(final RLPInput rlpInput){ return getDecoder().readFrom(rlpInput); @@ -19,8 +21,22 @@ public class TransactionDecoderProvider { return getDecoder().decodeOpaqueBytes(bytes); } + public static void writeTo(Transaction transaction, RLPOutput output) { + getEncoder().writeTo(transaction, output); + } + + public static Bytes encodeOpaqueBytes(Transaction transaction){ + return getEncoder().encodeOpaqueBytes(transaction); + } + + private static + TransactionEncoder getEncoder(){ + return RlpRegistry.getInstance().getPooledTransactionEncoder(); + } + private static TransactionDecoder getDecoder(){ - return RLPRegistry.getInstance().getPooledTransactionDecoder(); + return RlpRegistry.getInstance().getPooledTransactionDecoder(); } + } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPRegistry.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpRegistry.java similarity index 77% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPRegistry.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpRegistry.java index bb8fca0ff1..8cd27c7cc3 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RLPRegistry.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpRegistry.java @@ -15,10 +15,12 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.hyperledger.besu.ethereum.core.encoding.MainnetTransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.MainnetTransactionEncoder; import org.hyperledger.besu.ethereum.core.encoding.PooledMainnetTransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.PooledMainnetTransactionEncoder; -public class RLPRegistry { - private static RLPRegistry INSTANCE; +public class RlpRegistry { + private static RlpRegistry INSTANCE; private TransactionDecoder transactionDecoder; private TransactionDecoder pooledTransactionDecoder; @@ -26,13 +28,16 @@ public class RLPRegistry { private TransactionEncoder transactionEncoder; private TransactionEncoder pooledTransactionEncoder; - private RLPRegistry() { - registerDefaultDecoders(); + private RlpRegistry() { + transactionDecoder = new MainnetTransactionDecoder(); + pooledTransactionDecoder = new PooledMainnetTransactionDecoder(); + transactionEncoder =new MainnetTransactionEncoder(); + pooledTransactionEncoder = new PooledMainnetTransactionEncoder(); } - protected static RLPRegistry getInstance() { + protected static RlpRegistry getInstance() { if (INSTANCE == null) { - INSTANCE = new RLPRegistry(); + INSTANCE = new RlpRegistry(); } return INSTANCE; } @@ -53,9 +58,6 @@ public class RLPRegistry { return pooledTransactionDecoder; } - - - public void setTransactionEncoder(final TransactionEncoder encoder){ this.transactionEncoder = encoder; } @@ -71,9 +73,4 @@ public class RLPRegistry { public TransactionEncoder getPooledTransactionEncoder(){ return pooledTransactionEncoder; } - - private void registerDefaultDecoders() { - setTransactionDecoder(new MainnetTransactionDecoder()); - setPooledTransactionDecoder(new PooledMainnetTransactionDecoder()); - } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/PooledTransactionDecoderProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpTransactionProvider.java similarity index 51% rename from ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/PooledTransactionDecoderProvider.java rename to ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpTransactionProvider.java index af38628fa9..c493af5611 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/PooledTransactionDecoderProvider.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpTransactionProvider.java @@ -3,10 +3,10 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.apache.tuweni.bytes.Bytes; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.rlp.RLPInput; +import org.hyperledger.besu.ethereum.rlp.RLPOutput; -public class PooledTransactionDecoderProvider { - - private PooledTransactionDecoderProvider(){} +public class RlpTransactionProvider { + private RlpTransactionProvider(){} public static Transaction readFrom(final RLPInput rlpInput){ return getDecoder().readFrom(rlpInput); @@ -20,8 +20,21 @@ public class PooledTransactionDecoderProvider { return getDecoder().decodeOpaqueBytes(bytes); } + public static void writeTo(Transaction transaction, RLPOutput output) { + getEncoder().writeTo(transaction, output); + } + + public static Bytes encodeOpaqueBytes(Transaction transaction){ + return getEncoder().encodeOpaqueBytes(transaction); + } + private static TransactionDecoder getDecoder(){ - return RLPRegistry.getInstance().getPooledTransactionDecoder(); + return RlpRegistry.getInstance().getTransactionDecoder(); + } + + private static + TransactionEncoder getEncoder(){ + return RlpRegistry.getInstance().getTransactionEncoder(); } } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoder.java index cc1a21db77..2d1a3caa14 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoder.java @@ -3,7 +3,7 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.apache.tuweni.bytes.Bytes; import org.hyperledger.besu.ethereum.core.Transaction; -public interface TransactionDecoder extends RLPDecoder { +public interface TransactionDecoder extends RlpDecoder { Transaction decodeOpaqueBytes(Bytes bytes); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoder.java index 9b320e8d88..33ee022658 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoder.java @@ -3,7 +3,7 @@ package org.hyperledger.besu.ethereum.core.encoding.registry; import org.apache.tuweni.bytes.Bytes; import org.hyperledger.besu.ethereum.core.Transaction; -public interface TransactionEncoder extends RLPEncoder { +public interface TransactionEncoder extends RlpEncoder { Bytes encodeOpaqueBytes( final Transaction transaction); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoderProvider.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoderProvider.java deleted file mode 100644 index ff48ad1a78..0000000000 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoderProvider.java +++ /dev/null @@ -1,22 +0,0 @@ -package org.hyperledger.besu.ethereum.core.encoding.registry; - -import org.apache.tuweni.bytes.Bytes; -import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.rlp.RLPOutput; - -public class TransactionEncoderProvider{ - private TransactionEncoderProvider(){} - - public static void writeTo(Transaction transaction, RLPOutput output) { - getEncoder().writeTo(transaction, output); - } - - public static Bytes encodeOpaqueBytes(Transaction transaction){ - return getEncoder().encodeOpaqueBytes(transaction); - } - - private static - TransactionEncoder getEncoder(){ - return RLPRegistry.getInstance().getTransactionEncoder(); - } -} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java index 39a74e5381..1a2e104b66 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java @@ -23,7 +23,7 @@ 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.Withdrawal; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.core.encoding.WithdrawalEncoder; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.trie.MerkleTrie; @@ -66,7 +66,7 @@ public final class BodyValidation { i -> trie.put( indexKey(i), - TransactionEncoderProvider.encodeOpaqueBytes( + RlpTransactionProvider.encodeOpaqueBytes( transactions.get(i)))); return Hash.wrap(trie.getRootHash()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionIntegrationTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionIntegrationTest.java index efa2796fef..f2e1aefe0e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionIntegrationTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionIntegrationTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 = TransactionDecoderProvider.readFrom(input); + final Transaction transaction = RlpTransactionProvider.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 = TransactionDecoderProvider.readFrom(input); + final Transaction transaction = RlpTransactionProvider.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 = TransactionDecoderProvider.readFrom(input); + final Transaction transaction = RlpTransactionProvider.readFrom(input); assertThat(transaction).isNotNull(); assertThat(transaction.isContractCreation()).isFalse(); assertThat(transaction.getChainId()).contains(BigInteger.valueOf(2147483647)); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java index d040bc624e..39b9de23e0 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java @@ -17,10 +17,9 @@ 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.PooledTransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.PooledTransactionEncoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import java.io.BufferedReader; @@ -62,13 +61,13 @@ public class BlobTransactionEncodingTest { Bytes bytes = argument.bytes; // Decode the transaction from the wire using the TransactionDecoder. final Transaction transaction = - PooledTransactionDecoderProvider.decodeOpaqueBytes(bytes); + RlpPooledTransactionProvider.decodeOpaqueBytes(bytes); final BytesValueRLPOutput output = new BytesValueRLPOutput(); new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, output); final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput(); - PooledTransactionEncoderProvider.writeTo( + RlpPooledTransactionProvider.writeTo( transaction, bytesValueRLPOutput); assertThat(transaction.getSize()).isEqualTo(bytes.size()); } @@ -79,10 +78,10 @@ public class BlobTransactionEncodingTest { Bytes bytes = argument.bytes; // Decode the transaction from the wire using the TransactionDecoder. final Transaction transaction = - TransactionDecoderProvider.decodeOpaqueBytes(bytes); + RlpTransactionProvider.decodeOpaqueBytes(bytes); // Encode the transaction for wire using the TransactionEncoder. - Bytes encoded = TransactionEncoderProvider.encodeOpaqueBytes(transaction); + Bytes encoded = RlpTransactionProvider.encodeOpaqueBytes(transaction); // Assert that the encoded transaction matches the original bytes. assertThat(encoded.toHexString()).isEqualTo(bytes.toHexString()); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java index 01c1466f6a..4c8d3c5510 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java @@ -23,9 +23,9 @@ 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.PooledTransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.PooledTransactionEncoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPException; import org.hyperledger.besu.ethereum.rlp.RLPInput; @@ -72,7 +72,7 @@ class TransactionRLPDecoderTest { "0x02f84e0101a1648a5f8b2dcad5ea5ba6b720ff069c1d87c21a4a6a5b3766b39e2c2792367bb066a1ffa5ffaf5b0560d3a9fb186c2ede2ae6751bc0b4fef9107cf36389630b6196a38805800180c0010203"; assertThatThrownBy( () -> - TransactionDecoderProvider.decodeOpaqueBytes( + RlpTransactionProvider.decodeOpaqueBytes( Bytes.fromHexString(txWithBigFees))) .isInstanceOf(RLPException.class); } @@ -119,7 +119,7 @@ class TransactionRLPDecoderTest { // Decode bytes into a transaction final Transaction transaction = decodeRLP(RLP.input(bytes)); Bytes transactionBytes = - PooledTransactionEncoderProvider.encodeOpaqueBytes(transaction); + RlpPooledTransactionProvider.encodeOpaqueBytes(transaction); // Bytes size should be equal to transaction size assertThat(transaction.getSize()).isEqualTo(transactionBytes.size()); } @@ -157,6 +157,6 @@ class TransactionRLPDecoderTest { } private Transaction decodeRLP(final RLPInput input) { - return PooledTransactionDecoderProvider.readFrom(input); + return RlpPooledTransactionProvider.readFrom(input); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPEncoderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPEncoderTest.java index 87b8d7c585..9484823a5e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPEncoderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPEncoderTest.java @@ -22,8 +22,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.TransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; @@ -91,10 +90,10 @@ class TransactionRLPEncoderTest { } private Transaction decodeRLP(final RLPInput input) { - return TransactionDecoderProvider.readFrom(input); + return RlpTransactionProvider.readFrom(input); } private void encodeRLP(final Transaction transaction, final BytesValueRLPOutput output) { - TransactionEncoderProvider.writeTo(transaction, output); + RlpTransactionProvider.writeTo(transaction, output); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java index 3ca49005fc..9a9f398301 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/IntrinsicGasTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 = TransactionDecoderProvider.readFrom(RLP.input(Bytes.fromHexString(txRlp))); + Transaction t = RlpTransactionProvider.readFrom(RLP.input(Bytes.fromHexString(txRlp))); Assertions.assertThat( gasCalculator.transactionIntrinsicGasCost(t.getPayload(), t.isContractCreation())) .isEqualTo(expectedGas); diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java index cec526e94b..bd1a1272f3 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/mainnet/ValidationTestUtils.java @@ -19,7 +19,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.Withdrawal; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.RLPInput; @@ -52,7 +52,7 @@ public final class ValidationTestUtils { false); input.enterList(); input.skipNext(); - final List transactions = input.readList(TransactionDecoderProvider::readFrom); + final List transactions = input.readList(RlpTransactionProvider::readFrom); final List ommers = input.readList(rlp -> BlockHeader.readFrom(rlp, new MainnetBlockHeaderFunctions())); final Optional> withdrawals = diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/FixedKeySigningPrivateMarkerTransactionFactoryTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/FixedKeySigningPrivateMarkerTransactionFactoryTest.java index 73fc1bb84a..1db6699811 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/FixedKeySigningPrivateMarkerTransactionFactoryTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/FixedKeySigningPrivateMarkerTransactionFactoryTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import java.util.Optional; @@ -65,7 +65,7 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest { .build(); final Transaction transaction = - TransactionDecoderProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); + RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); assertThat(transaction.getNonce()).isEqualTo(providedNonce); assertThat(transaction.getGasLimit()).isEqualTo(gasLimit); @@ -77,7 +77,7 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest { assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey)); final Transaction nextTransaction = - TransactionDecoderProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); + RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); assertThat(nextTransaction.getSender()).isEqualTo(transaction.getSender()); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/RandomSigningPrivateMarkerTransactionFactoryTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/RandomSigningPrivateMarkerTransactionFactoryTest.java index 5e2a02a5ac..b5f758dfb7 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/RandomSigningPrivateMarkerTransactionFactoryTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/RandomSigningPrivateMarkerTransactionFactoryTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.privacy.PrivateTransaction; import java.util.Optional; @@ -61,7 +61,7 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest { new RandomSigningPrivateMarkerTransactionFactory(); final Transaction transaction = - TransactionDecoderProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); + RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); assertThat(transaction.getNonce()).isEqualTo(0); assertThat(transaction.getGasLimit()).isEqualTo(gasLimit); @@ -71,7 +71,7 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest { assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey)); final Transaction nextTransaction = - TransactionDecoderProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); + RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, "")); assertThat(nextTransaction.getSender()).isNotEqualTo(transaction.getSender()); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/util/RawBlockIteratorTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/util/RawBlockIteratorTest.java index ac1589ae8f..d4f77754b8 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/util/RawBlockIteratorTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/util/RawBlockIteratorTest.java @@ -20,7 +20,7 @@ import org.hyperledger.besu.ethereum.core.Block; import org.hyperledger.besu.ethereum.core.BlockDataGenerator; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; @@ -99,7 +99,7 @@ public class RawBlockIteratorTest { final BytesValueRLPOutput out = new BytesValueRLPOutput(); out.startList(); block.getHeader().writeTo(out); - out.writeList(block.getBody().getTransactions(), TransactionEncoderProvider::writeTo); + out.writeList(block.getBody().getTransactions(), RlpTransactionProvider::writeTo); out.writeList(block.getBody().getOmmers(), BlockHeader::writeTo); out.endList(); return out.encoded().toArray(); diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthServer.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthServer.java index 30a1499e97..cdb7163193 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthServer.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthServer.java @@ -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.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage; @@ -273,7 +273,7 @@ class EthServer { } final BytesValueRLPOutput txRlp = new BytesValueRLPOutput(); - PooledTransactionEncoderProvider.writeTo(maybeTx.get(), txRlp); + RlpPooledTransactionProvider.writeTo(maybeTx.get(), txRlp); final int encodedSize = txRlp.encodedSize(); if (responseSizeEstimate + encodedSize > maxMessageSize) { break; diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/PooledTransactionsMessage.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/PooledTransactionsMessage.java index 3283c95ae2..14a7e1ca0f 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/PooledTransactionsMessage.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/PooledTransactionsMessage.java @@ -15,9 +15,9 @@ package org.hyperledger.besu.ethereum.eth.messages; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.encoding.registry.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.PooledTransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; 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; @@ -45,7 +45,7 @@ public final class PooledTransactionsMessage extends AbstractMessageData { final BytesValueRLPOutput out = new BytesValueRLPOutput(); out.writeList( transactions, - PooledTransactionEncoderProvider::writeTo); + RlpPooledTransactionProvider::writeTo); return new PooledTransactionsMessage(out.encoded()); } @@ -78,7 +78,7 @@ public final class PooledTransactionsMessage extends AbstractMessageData { final BytesValueRLPInput in = new BytesValueRLPInput(getData(), false); pooledTransactions = in.readList( - PooledTransactionDecoderProvider::readFrom); + RlpPooledTransactionProvider::readFrom); } return pooledTransactions; } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/TransactionsMessage.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/TransactionsMessage.java index 9a2fec2d0f..82ec104269 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/TransactionsMessage.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/TransactionsMessage.java @@ -15,8 +15,7 @@ package org.hyperledger.besu.ethereum.eth.messages; import org.hyperledger.besu.ethereum.core.Transaction; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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; @@ -44,7 +43,7 @@ public class TransactionsMessage extends AbstractMessageData { final BytesValueRLPOutput tmp = new BytesValueRLPOutput(); tmp.startList(); for (final Transaction transaction : transactions) { - TransactionEncoderProvider.writeTo(transaction, tmp); + RlpTransactionProvider.writeTo(transaction, tmp); } tmp.endList(); return new TransactionsMessage(tmp.encoded()); @@ -60,6 +59,6 @@ public class TransactionsMessage extends AbstractMessageData { } public List transactions() { - return new BytesValueRLPInput(data, false).readList(TransactionDecoderProvider::readFrom); + return new BytesValueRLPInput(data, false).readList(RlpTransactionProvider::readFrom); } } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java index bfa9d26e83..b7a82c2009 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.eth.manager.EthContext; import org.hyperledger.besu.ethereum.eth.manager.EthPeer; import org.hyperledger.besu.ethereum.eth.manager.EthScheduler; @@ -841,7 +841,7 @@ public class TransactionPool implements BlockAddedObserver { line -> { final boolean isLocal = line.charAt(0) == 'l'; final Transaction tx = - TransactionDecoderProvider.readFrom(Bytes.fromBase64String(line.substring(1))); + RlpTransactionProvider.readFrom(Bytes.fromBase64String(line.substring(1))); final ValidationResult result = addTransaction(tx, isLocal); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthServerTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthServerTest.java index 655a699b58..798ab82e5d 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthServerTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/manager/EthServerTest.java @@ -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.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 -> TransactionEncoderProvider.writeTo(tx, output)).size(); + return RLP.encode(output -> RlpTransactionProvider.writeTo(tx, output)).size(); } private int calculateRlpEncodedSize(final Bytes data) { diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java index 430bf32420..3f9cbfc5fe 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/messages/BlockBodiesMessageTest.java @@ -22,7 +22,7 @@ import org.hyperledger.besu.ethereum.core.BlockBody; import org.hyperledger.besu.ethereum.core.BlockHeader; import org.hyperledger.besu.ethereum.core.BlockHeaderFunctions; import org.hyperledger.besu.ethereum.core.MiningConfiguration; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.difficulty.fixed.FixedDifficultyProtocolSchedule; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -83,7 +83,7 @@ public final class BlockBodiesMessageTest { bodies.add( // We know the test data to only contain Frontier blocks new BlockBody( - oneBlock.readList(TransactionDecoderProvider::readFrom), + oneBlock.readList(RlpTransactionProvider::readFrom), oneBlock.readList( rlp -> BlockHeader.readFrom(rlp, new MainnetBlockHeaderFunctions())))); } diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java index 22bb457a91..a527995726 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java @@ -24,11 +24,10 @@ 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.PooledTransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.PooledTransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider; import org.hyperledger.besu.ethereum.eth.transactions.layered.BaseTransactionPoolTest; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; @@ -75,9 +74,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txTo = preparedTx.to(Optional.of(Address.extract(Bytes32.random()))).createTransaction(KEYS1); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - TransactionEncoderProvider.writeTo(txTo, rlpOut); + RlpTransactionProvider.writeTo(txTo, rlpOut); - txTo = TransactionDecoderProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); + txTo = RlpTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); System.out.println(txTo.getSender()); System.out.println(txTo.getHash()); System.out.println(txTo.getSize()); @@ -121,7 +120,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txPayload = preparedTx.createTransaction(KEYS1); txPayload = - TransactionDecoderProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)).detachedCopy(); + RlpTransactionProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)).detachedCopy(); System.out.println(txPayload.getSender()); System.out.println(txPayload.getHash()); System.out.println(txPayload.getSize()); @@ -210,10 +209,10 @@ 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(); - PooledTransactionEncoderProvider.writeTo(txBlob, rlpOut); + RlpPooledTransactionProvider.writeTo(txBlob, rlpOut); txBlob = - PooledTransactionDecoderProvider.readFrom( + RlpPooledTransactionProvider.readFrom( new BytesValueRLPInput(rlpOut.encoded(), false)) .detachedCopy(); System.out.println(txBlob.getSender()); @@ -242,10 +241,10 @@ 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(); - PooledTransactionEncoderProvider.writeTo(txBlob, rlpOut); + RlpPooledTransactionProvider.writeTo(txBlob, rlpOut); txBlob = - PooledTransactionDecoderProvider.readFrom( + RlpPooledTransactionProvider.readFrom( new BytesValueRLPInput(rlpOut.encoded(), false)) .detachedCopy(); System.out.println(txBlob.getSender()); @@ -272,7 +271,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txPayload = preparedTx.createTransaction(KEYS1); txPayload = - TransactionDecoderProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)).detachedCopy(); + RlpTransactionProvider.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)).detachedCopy(); System.out.println(txPayload.getSender()); System.out.println(txPayload.getHash()); System.out.println(txPayload.getSize()); @@ -302,7 +301,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1); txAccessList = - TransactionDecoderProvider.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false)).detachedCopy(); + RlpTransactionProvider.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false)).detachedCopy(); System.out.println(txAccessList.getSender()); System.out.println(txAccessList.getHash()); System.out.println(txAccessList.getSize()); @@ -342,7 +341,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txEip1559 = createEIP1559Transaction(1, KEYS1, 10); txEip1559 = - TransactionDecoderProvider.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false)).detachedCopy(); + RlpTransactionProvider.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false)).detachedCopy(); System.out.println(txEip1559.getSender()); System.out.println(txEip1559.getHash()); System.out.println(txEip1559.getSize()); @@ -384,7 +383,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txFrontier = createTransaction(TransactionType.FRONTIER, 1, Wei.of(500), 0, KEYS1); txFrontier = - TransactionDecoderProvider.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false)).detachedCopy(); + RlpTransactionProvider.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false)).detachedCopy(); System.out.println(txFrontier.getSender()); System.out.println(txFrontier.getHash()); System.out.println(txFrontier.getSize()); diff --git a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java index 66ea5cedb3..5ed9df4eae 100644 --- a/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java +++ b/ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/layered/ReplayTest.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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 = TransactionDecoderProvider.readFrom(rlp); + final Transaction tx = RlpTransactionProvider.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 = TransactionDecoderProvider.readFrom(rlp); + final Transaction tx = RlpTransactionProvider.readFrom(rlp); if (tx.getSender().equals(senderToLog)) { LOG.warn("D {}, Before {}", tx.getNonce(), prioritizedTransactions.logSender(senderToLog)); } diff --git a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java index 46892944e8..b58fcbb247 100644 --- a/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java +++ b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java @@ -37,8 +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.TransactionDecoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -142,13 +141,13 @@ public class T8nExecutor { new BytesValueRLPInput(Bytes.fromHexString(txNode.asText()), false); rlpInput.enterList(); while (!rlpInput.isEndOfCurrentList()) { - Transaction tx = TransactionDecoderProvider.readFrom(rlpInput); + Transaction tx = RlpTransactionProvider.readFrom(rlpInput); transactions.add(tx); } } else if (txNode.isObject()) { if (txNode.has("txBytes")) { Transaction tx = - TransactionDecoderProvider.readFrom(Bytes.fromHexString(txNode.get("txbytes").asText())); + RlpTransactionProvider.readFrom(Bytes.fromHexString(txNode.get("txbytes").asText())); transactions.add(tx); } else { Transaction.Builder builder = Transaction.builder(); @@ -617,7 +616,7 @@ public class T8nExecutor { }); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - rlpOut.writeList(transactions, TransactionEncoderProvider::writeTo); + rlpOut.writeList(transactions, RlpTransactionProvider::writeTo); TextNode bodyBytes = TextNode.valueOf(rlpOut.encoded().toHexString()); return new T8nResult(allocObject, bodyBytes, resultObject); } diff --git a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java index 79d1e66d94..403b2faa81 100644 --- a/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java +++ b/ethereum/referencetests/src/main/java/org/hyperledger/besu/ethereum/referencetests/BlockchainReferenceTestCaseSpec.java @@ -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.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; 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(TransactionDecoderProvider::readFrom), + input.readList(RlpTransactionProvider::readFrom), input.readList(inputData -> BlockHeader.readFrom(inputData, blockHeaderFunctions)), input.isEndOfCurrentList() ? Optional.empty() diff --git a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java index e1af80da2d..17763def08 100644 --- a/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java +++ b/ethereum/referencetests/src/reference-test/java/org/hyperledger/besu/ethereum/core/TransactionTest.java @@ -17,8 +17,8 @@ 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.TransactionEncoderProvider; -import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoderProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; +import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; @@ -174,7 +174,7 @@ public class TransactionTest { } // Test transaction deserialization (will throw an exception if it fails). - final Transaction transaction = TransactionDecoderProvider.readFrom(RLP.input(rlp)); + final Transaction transaction = RlpTransactionProvider.readFrom(RLP.input(rlp)); final ValidationResult validation = transactionValidator(milestone) .validate(transaction, baseFee, Optional.empty(), TransactionValidationParams.processingBlock()); @@ -185,7 +185,7 @@ public class TransactionTest { } // Test rlp encoding - final Bytes actualRlp = RLP.encode(output -> TransactionEncoderProvider.writeTo(transaction, output)); + final Bytes actualRlp = RLP.encode(output -> RlpTransactionProvider.writeTo(transaction, output)); assertThat(expected.isSucceeds()) .withFailMessage("Transaction " + name + "/" + milestone + " was supposed to be invalid") .isTrue();