diff --git a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java index 98ad8e9cf5..e62e496a5b 100644 --- a/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java +++ b/acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java @@ -72,9 +72,7 @@ public class TestSigningPrivateMarkerTransactionFactory implements PrivateMarker LOG.info("Signing PMT from {}", sender); - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - transaction.writeTo(out); - return out.encoded(); + return transaction.encoded(); } @Override diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java index f8e60c5527..13f64e558c 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/TransactionAdapter.java @@ -527,9 +527,7 @@ public class TransactionAdapter extends AdapterBase { * @return an Optional containing a Bytes object representing the raw transaction data. */ public Optional getRaw() { - final BytesValueRLPOutput rlpOutput = new BytesValueRLPOutput(); - transactionWithMetadata.getTransaction().writeTo(rlpOutput); - return Optional.of(rlpOutput.encoded()); + return Optional.of(transactionWithMetadata.getTransaction().encoded()); } /** diff --git a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawTransaction.java b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawTransaction.java index 2b1e756d22..8d7c3fe8da 100644 --- a/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawTransaction.java +++ b/ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawTransaction.java @@ -61,8 +61,6 @@ public class DebugGetRawTransaction implements JsonRpcMethod { } private String toRawString(final Transaction transaction) { - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - transaction.writeTo(out); - return out.encoded().toHexString(); + return transaction.encoded().toHexString(); } } 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 b7f79efdbd..b66421efd7 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 @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.datatypes.Hash; import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; @@ -60,7 +61,7 @@ public class Block { out.startList(); header.writeTo(out); - out.writeList(body.getTransactions(), Transaction::writeTo); + out.writeList(body.getTransactions(), TransactionEncoder::writeTo); out.writeList(body.getOmmers(), BlockHeader::writeTo); body.getWithdrawals().ifPresent(withdrawals -> out.writeList(withdrawals, Withdrawal::writeTo)); 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 7f9ab27702..4b19cafde6 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 @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.core; import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.rlp.RLPInput; import org.hyperledger.besu.ethereum.rlp.RLPOutput; @@ -96,7 +97,7 @@ public class BlockBody implements org.hyperledger.besu.plugin.data.BlockBody { } public void writeTo(final RLPOutput output) { - output.writeList(getTransactions(), Transaction::writeTo); + output.writeList(getTransactions(), TransactionEncoder::writeTo); output.writeList(getOmmers(), BlockHeader::writeTo); withdrawals.ifPresent(withdrawals -> output.writeList(withdrawals, Withdrawal::writeTo)); } 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 32b51817d7..4b4f2fecae 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 @@ -469,15 +469,6 @@ public class Transaction return hashNoSignature; } - /** - * Writes the transaction to RLP - * - * @param out the output to write the transaction to - */ - public void writeTo(final RLPOutput out) { - TransactionEncoder.writeTo(this, out); - } - @Override public Bytes encoded() { final BytesValueRLPOutput rplOutput = new BytesValueRLPOutput(); diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/markertransaction/SigningPrivateMarkerTransactionFactory.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/markertransaction/SigningPrivateMarkerTransactionFactory.java index 5463311598..058e9f11ee 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/markertransaction/SigningPrivateMarkerTransactionFactory.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/markertransaction/SigningPrivateMarkerTransactionFactory.java @@ -40,8 +40,6 @@ public class SigningPrivateMarkerTransactionFactory { .payload(unsignedPrivateMarkerTransaction.getPayload()) .signAndBuild(signingKey); - final BytesValueRLPOutput out = new BytesValueRLPOutput(); - transaction.writeTo(out); - return out.encoded(); + return transaction.encoded(); } } diff --git a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java index e56b9bc0e8..b6dd98067e 100644 --- a/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java +++ b/ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/TransactionBuilderTest.java @@ -25,6 +25,7 @@ import org.hyperledger.besu.crypto.SignatureAlgorithmFactory; import org.hyperledger.besu.datatypes.AccessListEntry; import org.hyperledger.besu.datatypes.TransactionType; import org.hyperledger.besu.datatypes.Wei; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; import java.math.BigInteger; @@ -88,10 +89,6 @@ class TransactionBuilderTest { final Transaction copy = builder.copiedFrom(transaction).build(); assertThat(copy).isEqualTo(transaction).isNotSameAs(transaction); assertThat(copy.getHash()).isEqualTo(transaction.getHash()); - BytesValueRLPOutput sourceRLP = new BytesValueRLPOutput(); - transaction.writeTo(sourceRLP); - BytesValueRLPOutput copyRLP = new BytesValueRLPOutput(); - copy.writeTo(copyRLP); - assertEquals(sourceRLP.encoded(), copyRLP.encoded()); + assertEquals(transaction.encoded(), copy.encoded()); } } 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 4ad3c01717..9a08b45226 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 @@ -51,9 +51,7 @@ public class TransactionIntegrationTest { final Bytes encoded = Bytes.fromHexString(encodedString); final RLPInput input = RLP.input(encoded); final Transaction transaction = TransactionDecoder.readFrom(input); - final BytesValueRLPOutput output = new BytesValueRLPOutput(); - transaction.writeTo(output); - assertThat(output.encoded().toString()).isEqualTo(encodedString); + assertThat(transaction.encoded().toString()).isEqualTo(encodedString); } @Test 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 408377b717..d85ccb7ed0 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 @@ -21,6 +21,7 @@ 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.Transaction; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.MainnetBlockHeaderFunctions; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; @@ -99,7 +100,7 @@ public class RawBlockIteratorTest { final BytesValueRLPOutput out = new BytesValueRLPOutput(); out.startList(); block.getHeader().writeTo(out); - out.writeList(block.getBody().getTransactions(), Transaction::writeTo); + out.writeList(block.getBody().getTransactions(), TransactionEncoder::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/messages/LimitedTransactionsMessages.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/LimitedTransactionsMessages.java index 7136a60ad2..0c0a43821c 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/LimitedTransactionsMessages.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/LimitedTransactionsMessages.java @@ -42,9 +42,7 @@ public final class LimitedTransactionsMessages { int messageSize = 0; message.startList(); for (final Transaction transaction : transactions) { - final BytesValueRLPOutput encodedTransaction = new BytesValueRLPOutput(); - transaction.writeTo(encodedTransaction); - final Bytes encodedBytes = encodedTransaction.encoded(); + final Bytes encodedBytes = transaction.encoded(); if (messageSize != 0 // always at least one message && messageSize + encodedBytes.size() > LIMIT) { break; 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 2dd76ac049..16b022d7a1 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 @@ -16,6 +16,7 @@ package org.hyperledger.besu.ethereum.eth.messages; import org.hyperledger.besu.ethereum.core.Transaction; import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; 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 +44,7 @@ public class TransactionsMessage extends AbstractMessageData { final BytesValueRLPOutput tmp = new BytesValueRLPOutput(); tmp.startList(); for (final Transaction transaction : transactions) { - transaction.writeTo(tmp); + TransactionEncoder.writeTo(transaction, tmp); } tmp.endList(); return new TransactionsMessage(tmp.encoded()); 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 4539945c71..2730513177 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 @@ -800,12 +800,8 @@ public class TransactionPool implements BlockAddedObserver { allTxs.parallelStream() .takeWhile(unused -> !isCancelled.get()) .map( - ptx -> { - final BytesValueRLPOutput rlp = new BytesValueRLPOutput(); - ptx.getTransaction().writeTo(rlp); - return (ptx.isReceivedFromLocalSource() ? "l" : "r") - + rlp.encoded().toBase64String(); - }) + ptx -> (ptx.isReceivedFromLocalSource() ? "l" : "r") + + ptx.getTransaction().encoded().toBase64String()) .mapToInt( line -> { synchronized (bw) { diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java index bde1568e98..7ad3713531 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java @@ -235,11 +235,7 @@ public class LayeredPendingTransactions implements PendingTransactions { .addArgument(pendingTransaction.getTransaction().getType()) .addArgument(pendingTransaction::getHash) .addArgument( - () -> { - final BytesValueRLPOutput rlp = new BytesValueRLPOutput(); - pendingTransaction.getTransaction().writeTo(rlp); - return rlp.encoded().toHexString(); - }) + () -> pendingTransaction.getTransaction().encoded().toHexString()) .log(); } @@ -256,11 +252,7 @@ public class LayeredPendingTransactions implements PendingTransactions { .addArgument(pendingTransaction.getTransaction().getType()) .addArgument(pendingTransaction::getHash) .addArgument( - () -> { - final BytesValueRLPOutput rlp = new BytesValueRLPOutput(); - pendingTransaction.getTransaction().writeTo(rlp); - return rlp.encoded().toHexString(); - }) + () -> pendingTransaction.getTransaction().encoded().toHexString()) .log(); LOG.atInfo() .addMarker(INVALID_TX_REMOVED) @@ -269,11 +261,7 @@ public class LayeredPendingTransactions implements PendingTransactions { .addKeyValue("reason", result) .addKeyValue( "txrlp", - () -> { - final BytesValueRLPOutput rlp = new BytesValueRLPOutput(); - pendingTransaction.getTransaction().writeTo(rlp); - return rlp.encoded().toHexString(); - }) + () -> pendingTransaction.getTransaction().encoded().toHexString()) .log(); } diff --git a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java index 2ff7da7c52..c804ceb8b7 100644 --- a/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java +++ b/ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java @@ -278,11 +278,7 @@ public abstract class AbstractPendingTransactionsSorter implements PendingTransa .addKeyValue("reason", result) .addKeyValue( "txrlp", - () -> { - final BytesValueRLPOutput rlp = new BytesValueRLPOutput(); - pendingTransaction.getTransaction().writeTo(rlp); - return rlp.encoded().toHexString(); - }) + () -> pendingTransaction.getTransaction().encoded().toHexString()) .log(); } 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 7cd7bdcdaa..a1ca44d7be 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,6 +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.TransactionEncoder; import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration; import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage; import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage; @@ -387,7 +388,7 @@ public class EthServerTest { } private int calculateRlpEncodedSize(final Transaction tx) { - return RLP.encode(tx::writeTo).size(); + return RLP.encode(output -> TransactionEncoder.writeTo(tx, output)).size(); } private int calculateRlpEncodedSize(final Bytes data) { 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 c64bdd417f..d60939c200 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 @@ -27,6 +27,7 @@ import org.hyperledger.besu.ethereum.core.TransactionTestFixture; import org.hyperledger.besu.ethereum.core.encoding.PooledTransactionDecoder; import org.hyperledger.besu.ethereum.core.encoding.PooledTransactionEncoder; import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.eth.transactions.layered.BaseTransactionPoolTest; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput; import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput; @@ -73,7 +74,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo Transaction txTo = preparedTx.to(Optional.of(Address.extract(Bytes32.random()))).createTransaction(KEYS1); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - txTo.writeTo(rlpOut); + TransactionEncoder.writeTo(txTo, rlpOut); txTo = TransactionDecoder.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); System.out.println(txTo.getSender()); @@ -117,11 +118,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo TransactionTestFixture preparedTx = prepareTransaction(TransactionType.ACCESS_LIST, 10, Wei.of(500), Wei.ZERO, 10, 0); Transaction txPayload = preparedTx.createTransaction(KEYS1); - BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - txPayload.writeTo(rlpOut); txPayload = - TransactionDecoder.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); + TransactionDecoder.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)).detachedCopy(); System.out.println(txPayload.getSender()); System.out.println(txPayload.getHash()); System.out.println(txPayload.getSize()); @@ -270,11 +269,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo TransactionTestFixture preparedTx = prepareTransaction(TransactionType.ACCESS_LIST, 10, Wei.of(500), Wei.ZERO, 10, 0); Transaction txPayload = preparedTx.createTransaction(KEYS1); - BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - txPayload.writeTo(rlpOut); txPayload = - TransactionDecoder.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); + TransactionDecoder.readFrom(new BytesValueRLPInput(txPayload.encoded(), false)).detachedCopy(); System.out.println(txPayload.getSender()); System.out.println(txPayload.getHash()); System.out.println(txPayload.getSize()); @@ -302,11 +299,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo TransactionTestFixture preparedTx = prepareTransaction(TransactionType.ACCESS_LIST, 0, Wei.of(500), Wei.ZERO, 0, 0); Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1); - BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - txAccessList.writeTo(rlpOut); txAccessList = - TransactionDecoder.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); + TransactionDecoder.readFrom(new BytesValueRLPInput(txAccessList.encoded(), false)).detachedCopy(); System.out.println(txAccessList.getSender()); System.out.println(txAccessList.getHash()); System.out.println(txAccessList.getSize()); @@ -344,11 +339,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo public void baseEIP1559AndEIP4844TransactionMemorySize() { System.setProperty("jol.magicFieldOffset", "true"); Transaction txEip1559 = createEIP1559Transaction(1, KEYS1, 10); - BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - txEip1559.writeTo(rlpOut); txEip1559 = - TransactionDecoder.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); + TransactionDecoder.readFrom(new BytesValueRLPInput(txEip1559.encoded(), false)).detachedCopy(); System.out.println(txEip1559.getSender()); System.out.println(txEip1559.getHash()); System.out.println(txEip1559.getSize()); @@ -388,11 +381,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo public void baseFrontierAndAccessListTransactionMemorySize() { System.setProperty("jol.magicFieldOffset", "true"); Transaction txFrontier = createTransaction(TransactionType.FRONTIER, 1, Wei.of(500), 0, KEYS1); - BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - txFrontier.writeTo(rlpOut); txFrontier = - TransactionDecoder.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false)).detachedCopy(); + TransactionDecoder.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/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java b/ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java index 522d0e8c55..2a2d41480c 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 @@ -38,6 +38,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.encoding.TransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.BodyValidation; import org.hyperledger.besu.ethereum.mainnet.MainnetTransactionProcessor; import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule; @@ -616,7 +617,7 @@ public class T8nExecutor { }); BytesValueRLPOutput rlpOut = new BytesValueRLPOutput(); - rlpOut.writeList(transactions, Transaction::writeTo); + rlpOut.writeList(transactions, TransactionEncoder::writeTo); TextNode bodyBytes = TextNode.valueOf(rlpOut.encoded().toHexString()); return new T8nResult(allocObject, bodyBytes, resultObject); } 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 9e17b1b753..30be46c620 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 @@ -18,6 +18,7 @@ import static org.assertj.core.api.Assertions.assertThat; import org.hyperledger.besu.datatypes.Wei; import org.hyperledger.besu.ethereum.core.encoding.TransactionDecoder; +import org.hyperledger.besu.ethereum.core.encoding.TransactionEncoder; import org.hyperledger.besu.ethereum.mainnet.TransactionValidator; import org.hyperledger.besu.ethereum.mainnet.TransactionValidationParams; import org.hyperledger.besu.ethereum.mainnet.ValidationResult; @@ -184,7 +185,7 @@ public class TransactionTest { } // Test rlp encoding - final Bytes actualRlp = RLP.encode(transaction::writeTo); + final Bytes actualRlp = RLP.encode(output -> TransactionEncoder.writeTo(transaction, output)); assertThat(expected.isSucceeds()) .withFailMessage("Transaction " + name + "/" + milestone + " was supposed to be invalid") .isTrue();