fix spotless

Signed-off-by: Gabriel-Trintinalia <gabriel.trintinalia@consensys.net>
pull/7871/head
Gabriel-Trintinalia 3 weeks ago
parent 910b88ce8f
commit ea6494ccf4
  1. 1
      acceptance-tests/test-plugins/src/main/java/org/hyperledger/besu/tests/acceptance/plugins/privacy/TestSigningPrivateMarkerTransactionFactory.java
  2. 2
      besu/src/main/java/org/hyperledger/besu/cli/subcommands/TxParseSubCommand.java
  3. 1
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/DebugGetRawTransaction.java
  4. 12
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/BlockResultFactory.java
  5. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/EngineGetPayloadBodiesResultV1.java
  6. 5
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionPendingResult.java
  7. 2
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtils.java
  8. 6
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionByHashTest.java
  9. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/engine/EngineNewPayloadV3Test.java
  10. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/util/DomainObjectDecodeUtilsTest.java
  11. 2
      ethereum/core/src/integration-test/java/org/hyperledger/besu/ethereum/vm/TraceTransactionIntegrationTest.java
  12. 4
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java
  13. 18
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/MainnetTransactionDecoder.java
  14. 13
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/MainnetTransactionEncoder.java
  15. 51
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/PooledMainnetTransactionDecoder.java
  16. 9
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/PooledMainnetTransactionEncoder.java
  17. 14
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/SignatureEncoder.java
  18. 3
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpDecoder.java
  19. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpEncoder.java
  20. 36
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpPooledTransactionProvider.java
  21. 22
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpRegistry.java
  22. 35
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/RlpTransactionProvider.java
  23. 17
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionDecoder.java
  24. 20
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/registry/TransactionEncoder.java
  25. 6
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/mainnet/BodyValidation.java
  26. 1
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/privacy/markertransaction/SigningPrivateMarkerTransactionFactory.java
  27. 12
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/BlobTransactionEncodingTest.java
  28. 23
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPDecoderTest.java
  29. 18
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/core/encoding/TransactionRLPEncoderTest.java
  30. 6
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/FixedKeySigningPrivateMarkerTransactionFactoryTest.java
  31. 6
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/privacy/markertransaction/RandomSigningPrivateMarkerTransactionFactoryTest.java
  32. 1
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/manager/EthServer.java
  33. 10
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/messages/PooledTransactionsMessage.java
  34. 8
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/TransactionPool.java
  35. 10
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/layered/LayeredPendingTransactions.java
  36. 5
      ethereum/eth/src/main/java/org/hyperledger/besu/ethereum/eth/transactions/sorter/AbstractPendingTransactionsSorter.java
  37. 27
      ethereum/eth/src/test/java/org/hyperledger/besu/ethereum/eth/transactions/PendingTransactionEstimatedMemorySizeTest.java
  38. 3
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/T8nExecutor.java

@ -25,7 +25,6 @@ import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.plugin.data.PrivateTransaction;
import org.hyperledger.besu.plugin.data.UnsignedPrivateMarkerTransaction;
import org.hyperledger.besu.plugin.services.privacy.PrivateMarkerTransactionFactory;

@ -19,6 +19,7 @@ import static org.hyperledger.besu.cli.subcommands.TxParseSubCommand.COMMAND_NAM
import org.hyperledger.besu.cli.util.VersionProvider;
import org.hyperledger.besu.crypto.SignatureAlgorithmFactory;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import java.io.BufferedReader;
import java.io.InputStreamReader;
@ -29,7 +30,6 @@ import java.nio.file.Paths;
import java.util.stream.Stream;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import picocli.CommandLine;
/**

@ -24,7 +24,6 @@ import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSucces
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.RpcErrorType;
import org.hyperledger.besu.ethereum.api.query.BlockchainQueries;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
public class DebugGetRawTransaction implements JsonRpcMethod {

@ -95,8 +95,7 @@ public class BlockResultFactory {
public EngineGetPayloadResultV1 payloadTransactionCompleteV1(final Block block) {
final List<String> txs =
block.getBody().getTransactions().stream()
.map(
RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
@ -107,8 +106,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(
RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
@ -132,8 +130,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(
RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
@ -151,8 +148,7 @@ public class BlockResultFactory {
final var blockWithReceipts = payload.blockWithReceipts();
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
.map(
RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
final Optional<List<String>> requestsWithoutRequestId =

@ -52,8 +52,7 @@ public class EngineGetPayloadBodiesResultV1 {
public PayloadBody(final BlockBody blockBody) {
this.transactions =
blockBody.getTransactions().stream()
.map(
RlpTransactionProvider::encodeOpaqueBytes)
.map(RlpTransactionProvider::encodeOpaqueBytes)
.map(Bytes::toHexString)
.collect(Collectors.toList());
this.withdrawals =

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

@ -28,7 +28,7 @@ public class DomainObjectDecodeUtils {
throws InvalidJsonRpcRequestException {
try {
Bytes txnBytes = Bytes.fromHexString(rawTransaction);
return RlpPooledTransactionProvider.decodeOpaqueBytes(txnBytes);
return RlpPooledTransactionProvider.decodeOpaqueBytes(txnBytes);
} catch (final IllegalArgumentException e) {
throw new InvalidJsonRpcRequestException(
"Invalid raw transaction hex", RpcErrorType.INVALID_TRANSACTION_PARAMS, e);

@ -109,8 +109,7 @@ class EthGetTransactionByHashTest {
@Test
void shouldReturnPendingTransactionWhenTransactionExistsAndIsPending() {
final org.hyperledger.besu.ethereum.core.Transaction transaction =
RlpTransactionProvider.readFrom(
Bytes.fromHexString(VALID_TRANSACTION));
RlpTransactionProvider.readFrom(Bytes.fromHexString(VALID_TRANSACTION));
when(transactionPool.getTransactionByHash(transaction.getHash()))
.thenReturn(Optional.of(transaction));
@ -132,8 +131,7 @@ class EthGetTransactionByHashTest {
@Test
void shouldReturnCompleteTransactionWhenTransactionExistsInBlockchain() {
final org.hyperledger.besu.ethereum.core.Transaction transaction =
RlpTransactionProvider.readFrom(
Bytes.fromHexString(VALID_TRANSACTION));
RlpTransactionProvider.readFrom(Bytes.fromHexString(VALID_TRANSACTION));
final TransactionWithMetadata transactionWithMetadata =
new TransactionWithMetadata(transaction, 1, Optional.empty(), Hash.ZERO, 0);

@ -225,8 +225,7 @@ public class EngineNewPayloadV3Test extends EngineNewPayloadV2Test {
public void shouldRejectTransactionsWithFullBlobs() {
Bytes transactionWithBlobsBytes =
RlpPooledTransactionProvider.encodeOpaqueBytes(
createTransactionWithBlobs());
RlpPooledTransactionProvider.encodeOpaqueBytes(createTransactionWithBlobs());
List<String> transactions = List.of(transactionWithBlobsBytes.toString());

@ -66,8 +66,7 @@ public class DomainObjectDecodeUtilsTest {
@Test
public void testAccessList2718OpaqueSerDes() {
final Bytes encoded =
RlpPooledTransactionProvider.encodeOpaqueBytes(accessListTxn);
final Bytes encoded = 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);

@ -171,7 +171,7 @@ public class TraceTransactionIntegrationTest {
final DebugOperationTracer tracer =
new DebugOperationTracer(new TraceOptions(true, true, true), false);
final Transaction transaction =
RlpTransactionProvider.readFrom(
RlpTransactionProvider.readFrom(
new BytesValueRLPInput(Bytes.fromHexString(CONTRACT_CREATION_TX), false));
final BlockHeader genesisBlockHeader = genesisBlock.getHeader();
transactionProcessor.processTransaction(

@ -40,7 +40,6 @@ import org.hyperledger.besu.ethereum.core.encoding.AccessListTransactionEncoder;
import org.hyperledger.besu.ethereum.core.encoding.BlobTransactionEncoder;
import org.hyperledger.besu.ethereum.core.encoding.CodeDelegationEncoder;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
@ -541,8 +540,7 @@ public class Transaction
final Bytes bytes = RlpTransactionProvider.encodeOpaqueBytes(this);
hash = Hash.hash(bytes);
if (transactionType.supportsBlob() && getBlobsWithCommitments().isPresent()) {
final Bytes pooledBytes =
RlpPooledTransactionProvider.encodeOpaqueBytes(this);
final Bytes pooledBytes = RlpPooledTransactionProvider.encodeOpaqueBytes(this);
size = pooledBytes.size();
return;
}

@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.core.encoding;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionDecoder;
@ -25,6 +24,7 @@ import org.hyperledger.besu.ethereum.rlp.RLPInput;
import java.util.Optional;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import org.apache.tuweni.bytes.Bytes;
@ -53,8 +53,7 @@ public class MainnetTransactionDecoder implements TransactionDecoder {
* @param rlpInput the RLP input
* @return the decoded transaction
*/
public Transaction readFrom(
final RLPInput rlpInput) {
public Transaction readFrom(final RLPInput rlpInput) {
if (!rlpInput.nextIsList()) {
return decodeTypedTransaction(rlpInput);
} else {
@ -73,8 +72,7 @@ public class MainnetTransactionDecoder implements TransactionDecoder {
* @param rlpInput the RLP input
* @return the decoded transaction
*/
private Transaction decodeTypedTransaction(
final RLPInput rlpInput) {
private Transaction decodeTypedTransaction(final RLPInput rlpInput) {
// Read the typed transaction bytes from the RLP input
final Bytes typedTransactionBytes = rlpInput.readBytes();
@ -95,8 +93,7 @@ public class MainnetTransactionDecoder implements TransactionDecoder {
* @return the decoded transaction
*/
private Transaction decodeTypedTransaction(
final Bytes transactionBytes,
final TransactionType transactionType) {
final Bytes transactionBytes, final TransactionType transactionType) {
// Slice the transaction bytes to exclude the transaction type and prepare for decoding
final RLPInput transactionInput = RLP.input(transactionBytes.slice(1));
// Use the appropriate decoder for the transaction type to decode the remaining bytes
@ -111,8 +108,7 @@ public class MainnetTransactionDecoder implements TransactionDecoder {
* @param opaqueBytes the opaque bytes
* @return the decoded transaction
*/
public Transaction decodeOpaqueBytes(
final Bytes opaqueBytes) {
public Transaction decodeOpaqueBytes(final Bytes opaqueBytes) {
var transactionType = getTransactionType(opaqueBytes);
if (transactionType.isPresent()) {
return decodeTypedTransaction(opaqueBytes, transactionType.get());
@ -140,7 +136,6 @@ public class MainnetTransactionDecoder implements TransactionDecoder {
}
}
/**
* Gets the decoder for a given transaction type
*
@ -148,8 +143,7 @@ public class MainnetTransactionDecoder implements TransactionDecoder {
* @return the decoder
*/
@VisibleForTesting
protected Decoder getDecoder(
final TransactionType transactionType) {
protected Decoder getDecoder(final TransactionType transactionType) {
return checkNotNull(
TYPED_TRANSACTION_DECODERS.get(transactionType),
"Developer Error. A supported transaction type %s has no associated decoding logic",

@ -16,7 +16,6 @@ package org.hyperledger.besu.ethereum.core.encoding;
import static com.google.common.base.Preconditions.checkNotNull;
import com.google.common.annotations.VisibleForTesting;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.TransactionEncoder;
@ -24,6 +23,7 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import org.apache.tuweni.bytes.Bytes;
@ -51,9 +51,7 @@ public class MainnetTransactionEncoder implements TransactionEncoder {
* @param transaction the transaction to encode
* @param rlpOutput the RLP output stream
*/
public void writeTo(
final Transaction transaction,
final RLPOutput rlpOutput) {
public void writeTo(final Transaction transaction, final RLPOutput rlpOutput) {
final TransactionType transactionType = getTransactionType(transaction);
Bytes opaqueBytes = encodeOpaqueBytes(transaction);
encodeRLP(transactionType, opaqueBytes, rlpOutput);
@ -83,8 +81,7 @@ public class MainnetTransactionEncoder implements TransactionEncoder {
* @param transaction the transaction to encode
* @return the encoded transaction as bytes
*/
public Bytes encodeOpaqueBytes(
final Transaction transaction) {
public Bytes encodeOpaqueBytes(final Transaction transaction) {
final TransactionType transactionType = getTransactionType(transaction);
if (TransactionType.FRONTIER.equals(transactionType)) {
return RLP.encode(rlpOutput -> FrontierTransactionEncoder.encode(transaction, rlpOutput));
@ -97,15 +94,13 @@ public class MainnetTransactionEncoder implements TransactionEncoder {
}
}
private static TransactionType getTransactionType(final Transaction transaction) {
return checkNotNull(
transaction.getType(), "Transaction type for %s was not specified.", transaction);
}
@VisibleForTesting
protected Encoder getEncoder(
final TransactionType transactionType) {
protected Encoder getEncoder(final TransactionType transactionType) {
return checkNotNull(
TYPED_TRANSACTION_ENCODERS.get(transactionType),
"Developer Error. A supported transaction type %s has no associated encoding logic",

@ -1,23 +1,39 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding;
import static com.google.common.base.Preconditions.checkNotNull;
import org.hyperledger.besu.datatypes.TransactionType;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.collect.ImmutableMap;
import org.hyperledger.besu.datatypes.TransactionType;
public class PooledMainnetTransactionDecoder extends MainnetTransactionDecoder {
private static final ImmutableMap<TransactionType, MainnetTransactionDecoder.Decoder> POOLED_TRANSACTION_DECODERS =
ImmutableMap.of(
TransactionType.ACCESS_LIST,
AccessListTransactionDecoder::decode,
TransactionType.EIP1559,
EIP1559TransactionDecoder::decode,
TransactionType.BLOB,
BlobPooledTransactionDecoder::decode ,
TransactionType.DELEGATE_CODE,
CodeDelegationTransactionDecoder::decode);
private static final ImmutableMap<TransactionType, MainnetTransactionDecoder.Decoder>
POOLED_TRANSACTION_DECODERS =
ImmutableMap.of(
TransactionType.ACCESS_LIST,
AccessListTransactionDecoder::decode,
TransactionType.EIP1559,
EIP1559TransactionDecoder::decode,
TransactionType.BLOB,
BlobPooledTransactionDecoder::decode,
TransactionType.DELEGATE_CODE,
CodeDelegationTransactionDecoder::decode);
/**
* Gets the decoder for a given transaction type
@ -25,13 +41,12 @@ public class PooledMainnetTransactionDecoder extends MainnetTransactionDecoder {
* @param transactionType the transaction type
* @return the decoder
*/
@VisibleForTesting
@Override
protected MainnetTransactionDecoder.Decoder getDecoder(
final TransactionType transactionType) {
@VisibleForTesting
@Override
protected MainnetTransactionDecoder.Decoder getDecoder(final TransactionType transactionType) {
return checkNotNull(
POOLED_TRANSACTION_DECODERS.get(transactionType),
"Developer Error. A supported transaction type %s has no associated decoding logic",
transactionType);
POOLED_TRANSACTION_DECODERS.get(transactionType),
"Developer Error. A supported transaction type %s has no associated decoding logic",
transactionType);
}
}

@ -16,10 +16,10 @@ package org.hyperledger.besu.ethereum.core.encoding;
import static com.google.common.base.Preconditions.checkNotNull;
import org.hyperledger.besu.datatypes.TransactionType;
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.RlpTransactionProvider;
public class PooledMainnetTransactionEncoder extends MainnetTransactionEncoder {
@ -35,10 +35,9 @@ public class PooledMainnetTransactionEncoder extends MainnetTransactionEncoder {
CodeDelegationEncoder::encode);
@VisibleForTesting
protected Encoder getEncoder(
final TransactionType transactionType) {
protected Encoder getEncoder(final TransactionType transactionType) {
return checkNotNull(
POOLED_TRANSACTION_ENCODERS.get(transactionType),
POOLED_TRANSACTION_ENCODERS.get(transactionType),
"Developer Error. A supported transaction type %s has no associated encoding logic",
transactionType);
}

@ -1,3 +1,17 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding;
import org.hyperledger.besu.ethereum.core.Transaction;

@ -14,10 +14,11 @@
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import org.apache.tuweni.bytes.Bytes;
public interface RlpDecoder<T> {
T readFrom(final RLPInput input);

@ -14,7 +14,6 @@
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.hyperledger.besu.ethereum.rlp.RLPOutput;
public interface RlpEncoder<T> {

@ -1,23 +1,38 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.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;
import org.apache.tuweni.bytes.Bytes;
public class RlpPooledTransactionProvider {
private RlpPooledTransactionProvider(){}
private RlpPooledTransactionProvider() {}
public static Transaction readFrom(final RLPInput rlpInput){
return getDecoder().readFrom(rlpInput);
public static Transaction readFrom(final RLPInput rlpInput) {
return getDecoder().readFrom(rlpInput);
}
public static Transaction readFrom(final Bytes bytes){
public static Transaction readFrom(final Bytes bytes) {
return getDecoder().readFrom(bytes);
}
public static Transaction decodeOpaqueBytes(final Bytes bytes){
public static Transaction decodeOpaqueBytes(final Bytes bytes) {
return getDecoder().decodeOpaqueBytes(bytes);
}
@ -25,18 +40,15 @@ public class RlpPooledTransactionProvider {
getEncoder().writeTo(transaction, output);
}
public static Bytes encodeOpaqueBytes(Transaction transaction){
public static Bytes encodeOpaqueBytes(Transaction transaction) {
return getEncoder().encodeOpaqueBytes(transaction);
}
private static
TransactionEncoder getEncoder(){
private static TransactionEncoder getEncoder() {
return RlpRegistry.getInstance().getPooledTransactionEncoder();
}
private static
TransactionDecoder getDecoder(){
private static TransactionDecoder getDecoder() {
return RlpRegistry.getInstance().getPooledTransactionDecoder();
}
}

@ -25,13 +25,13 @@ public class RlpRegistry {
private TransactionDecoder transactionDecoder;
private TransactionDecoder pooledTransactionDecoder;
private TransactionEncoder transactionEncoder;
private TransactionEncoder transactionEncoder;
private TransactionEncoder pooledTransactionEncoder;
private RlpRegistry() {
transactionDecoder = new MainnetTransactionDecoder();
pooledTransactionDecoder = new PooledMainnetTransactionDecoder();
transactionEncoder =new MainnetTransactionEncoder();
transactionEncoder = new MainnetTransactionEncoder();
pooledTransactionEncoder = new PooledMainnetTransactionEncoder();
}
@ -42,35 +42,35 @@ public class RlpRegistry {
return INSTANCE;
}
public void setTransactionDecoder(final TransactionDecoder decoder){
public void setTransactionDecoder(final TransactionDecoder decoder) {
this.transactionDecoder = decoder;
}
public TransactionDecoder getTransactionDecoder(){
public TransactionDecoder getTransactionDecoder() {
return transactionDecoder;
}
public void setPooledTransactionDecoder(final TransactionDecoder pooledTransactionDecoder){
public void setPooledTransactionDecoder(final TransactionDecoder pooledTransactionDecoder) {
this.pooledTransactionDecoder = pooledTransactionDecoder;
}
public TransactionDecoder getPooledTransactionDecoder(){
public TransactionDecoder getPooledTransactionDecoder() {
return pooledTransactionDecoder;
}
public void setTransactionEncoder(final TransactionEncoder encoder){
public void setTransactionEncoder(final TransactionEncoder encoder) {
this.transactionEncoder = encoder;
}
public TransactionEncoder getTransactionEncoder(){
public TransactionEncoder getTransactionEncoder() {
return transactionEncoder;
}
public void setPooledTransactionEncoder(final TransactionEncoder pooledTransactionEncoder){
public void setPooledTransactionEncoder(final TransactionEncoder pooledTransactionEncoder) {
this.pooledTransactionEncoder = pooledTransactionEncoder;
}
public TransactionEncoder getPooledTransactionEncoder(){
public TransactionEncoder getPooledTransactionEncoder() {
return pooledTransactionEncoder;
}
}

@ -1,22 +1,37 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.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;
import org.apache.tuweni.bytes.Bytes;
public class RlpTransactionProvider {
private RlpTransactionProvider(){}
private RlpTransactionProvider() {}
public static Transaction readFrom(final RLPInput rlpInput){
return getDecoder().readFrom(rlpInput);
public static Transaction readFrom(final RLPInput rlpInput) {
return getDecoder().readFrom(rlpInput);
}
public static Transaction readFrom(final Bytes bytes){
public static Transaction readFrom(final Bytes bytes) {
return getDecoder().readFrom(bytes);
}
public static Transaction decodeOpaqueBytes(final Bytes bytes){
public static Transaction decodeOpaqueBytes(final Bytes bytes) {
return getDecoder().decodeOpaqueBytes(bytes);
}
@ -24,17 +39,15 @@ public class RlpTransactionProvider {
getEncoder().writeTo(transaction, output);
}
public static Bytes encodeOpaqueBytes(Transaction transaction){
public static Bytes encodeOpaqueBytes(Transaction transaction) {
return getEncoder().encodeOpaqueBytes(transaction);
}
private static
TransactionDecoder getDecoder(){
private static TransactionDecoder getDecoder() {
return RlpRegistry.getInstance().getTransactionDecoder();
}
private static
TransactionEncoder getEncoder(){
private static TransactionEncoder getEncoder() {
return RlpRegistry.getInstance().getTransactionEncoder();
}
}

@ -1,8 +1,23 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.apache.tuweni.bytes.Bytes;
public interface TransactionDecoder extends RlpDecoder<Transaction> {
Transaction decodeOpaqueBytes(Bytes bytes);

@ -1,10 +1,24 @@
/*
* Copyright contributors to Besu.
*
* Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with
* the License. You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on
* an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the
* specific language governing permissions and limitations under the License.
*
* SPDX-License-Identifier: Apache-2.0
*/
package org.hyperledger.besu.ethereum.core.encoding.registry;
import org.apache.tuweni.bytes.Bytes;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.apache.tuweni.bytes.Bytes;
public interface TransactionEncoder extends RlpEncoder<Transaction> {
Bytes encodeOpaqueBytes(
final Transaction transaction);
Bytes encodeOpaqueBytes(final Transaction transaction);
}

@ -23,8 +23,8 @@ 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.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.WithdrawalEncoder;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.trie.MerkleTrie;
import org.hyperledger.besu.ethereum.trie.patricia.SimpleMerklePatriciaTrie;
@ -65,9 +65,7 @@ public final class BodyValidation {
.forEach(
i ->
trie.put(
indexKey(i),
RlpTransactionProvider.encodeOpaqueBytes(
transactions.get(i))));
indexKey(i), RlpTransactionProvider.encodeOpaqueBytes(transactions.get(i))));
return Hash.wrap(trie.getRootHash());
}

@ -18,7 +18,6 @@ import org.hyperledger.besu.crypto.KeyPair;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.plugin.data.UnsignedPrivateMarkerTransaction;
import org.apache.tuweni.bytes.Bytes;

@ -18,7 +18,6 @@ import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
@ -60,15 +59,13 @@ public class BlobTransactionEncodingTest {
final TypedTransactionBytesArgument argument) {
Bytes bytes = argument.bytes;
// Decode the transaction from the wire using the TransactionDecoder.
final Transaction transaction =
RlpPooledTransactionProvider.decodeOpaqueBytes(bytes);
final Transaction transaction = RlpPooledTransactionProvider.decodeOpaqueBytes(bytes);
final BytesValueRLPOutput output = new BytesValueRLPOutput();
new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, output);
final BytesValueRLPOutput bytesValueRLPOutput = new BytesValueRLPOutput();
RlpPooledTransactionProvider.writeTo(
transaction, bytesValueRLPOutput);
RlpPooledTransactionProvider.writeTo(transaction, bytesValueRLPOutput);
assertThat(transaction.getSize()).isEqualTo(bytes.size());
}
@ -77,8 +74,7 @@ public class BlobTransactionEncodingTest {
public void blobTransactionEncodingDecodingTest(final TypedTransactionBytesArgument argument) {
Bytes bytes = argument.bytes;
// Decode the transaction from the wire using the TransactionDecoder.
final Transaction transaction =
RlpTransactionProvider.decodeOpaqueBytes(bytes);
final Transaction transaction = RlpTransactionProvider.decodeOpaqueBytes(bytes);
// Encode the transaction for wire using the TransactionEncoder.
Bytes encoded = RlpTransactionProvider.encodeOpaqueBytes(transaction);
@ -86,7 +82,7 @@ public class BlobTransactionEncodingTest {
assertThat(encoded.toHexString()).isEqualTo(bytes.toHexString());
final BytesValueRLPOutput rlpOutput = new BytesValueRLPOutput();
new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, rlpOutput);
new MainnetTransactionEncoder().encodeRLP(transaction.getType(), bytes, rlpOutput);
assertThat(transaction.getSize()).isEqualTo(bytes.size());
}

@ -24,7 +24,6 @@ import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPException;
@ -71,9 +70,7 @@ class TransactionRLPDecoderTest {
final String txWithBigFees =
"0x02f84e0101a1648a5f8b2dcad5ea5ba6b720ff069c1d87c21a4a6a5b3766b39e2c2792367bb066a1ffa5ffaf5b0560d3a9fb186c2ede2ae6751bc0b4fef9107cf36389630b6196a38805800180c0010203";
assertThatThrownBy(
() ->
RlpTransactionProvider.decodeOpaqueBytes(
Bytes.fromHexString(txWithBigFees)))
() -> RlpTransactionProvider.decodeOpaqueBytes(Bytes.fromHexString(txWithBigFees)))
.isInstanceOf(RLPException.class);
}
@ -118,8 +115,7 @@ class TransactionRLPDecoderTest {
final Bytes bytes = Bytes.fromHexString(rlp_tx);
// Decode bytes into a transaction
final Transaction transaction = decodeRLP(RLP.input(bytes));
Bytes transactionBytes =
RlpPooledTransactionProvider.encodeOpaqueBytes(transaction);
Bytes transactionBytes = RlpPooledTransactionProvider.encodeOpaqueBytes(transaction);
// Bytes size should be equal to transaction size
assertThat(transaction.getSize()).isEqualTo(transactionBytes.size());
}
@ -147,13 +143,16 @@ class TransactionRLPDecoderTest {
}
@Test
void shouldHaveDecodersForAllTransactionTypes(){
void shouldHaveDecodersForAllTransactionTypes() {
Stream.of(TransactionType.values())
.filter(v -> v != TransactionType.FRONTIER).forEach( v -> {
assertThatNoException().isThrownBy(() -> new MainnetTransactionDecoder().getDecoder(v));
assertThatNoException().isThrownBy(() -> new PooledMainnetTransactionDecoder().getDecoder(v));
}
);
.filter(v -> v != TransactionType.FRONTIER)
.forEach(
v -> {
assertThatNoException()
.isThrownBy(() -> new MainnetTransactionDecoder().getDecoder(v));
assertThatNoException()
.isThrownBy(() -> new PooledMainnetTransactionDecoder().getDecoder(v));
});
}
private Transaction decodeRLP(final RLPInput input) {

@ -17,7 +17,6 @@ package org.hyperledger.besu.ethereum.core.encoding;
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatNoException;
import java.util.stream.Stream;
import org.hyperledger.besu.datatypes.TransactionType;
import org.hyperledger.besu.ethereum.core.Block;
import org.hyperledger.besu.ethereum.core.BlockDataGenerator;
@ -28,6 +27,8 @@ import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.ethereum.rlp.RLP;
import org.hyperledger.besu.ethereum.rlp.RLPInput;
import java.util.stream.Stream;
import org.apache.tuweni.bytes.Bytes;
import org.junit.jupiter.api.Test;
@ -80,13 +81,16 @@ class TransactionRLPEncoderTest {
}
@Test
void shouldHaveEncodersForAllTransactionTypes(){
void shouldHaveEncodersForAllTransactionTypes() {
Stream.of(TransactionType.values())
.filter(v -> v != TransactionType.FRONTIER).forEach( v -> {
assertThatNoException().isThrownBy(() -> new MainnetTransactionEncoder().getEncoder(v));
assertThatNoException().isThrownBy(() -> new PooledMainnetTransactionEncoder().getEncoder(v));
}
);
.filter(v -> v != TransactionType.FRONTIER)
.forEach(
v -> {
assertThatNoException()
.isThrownBy(() -> new MainnetTransactionEncoder().getEncoder(v));
assertThatNoException()
.isThrownBy(() -> new PooledMainnetTransactionEncoder().getEncoder(v));
});
}
private Transaction decodeRLP(final RLPInput input) {

@ -65,7 +65,8 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest {
.build();
final Transaction transaction =
RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(transaction.getNonce()).isEqualTo(providedNonce);
assertThat(transaction.getGasLimit()).isEqualTo(gasLimit);
@ -77,7 +78,8 @@ public class FixedKeySigningPrivateMarkerTransactionFactoryTest {
assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey));
final Transaction nextTransaction =
RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(nextTransaction.getSender()).isEqualTo(transaction.getSender());
}
}

@ -61,7 +61,8 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest {
new RandomSigningPrivateMarkerTransactionFactory();
final Transaction transaction =
RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(transaction.getNonce()).isEqualTo(0);
assertThat(transaction.getGasLimit()).isEqualTo(gasLimit);
@ -71,7 +72,8 @@ public class RandomSigningPrivateMarkerTransactionFactoryTest {
assertThat(transaction.getPayload()).isEqualTo(Bytes.fromBase64String(enclaveKey));
final Transaction nextTransaction =
RlpTransactionProvider.readFrom(factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
RlpTransactionProvider.readFrom(
factory.create(unsignedPrivateMarkerTransaction, privTransaction, ""));
assertThat(nextTransaction.getSender()).isNotEqualTo(transaction.getSender());
}
}

@ -21,7 +21,6 @@ import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.eth.EthProtocolConfiguration;
import org.hyperledger.besu.ethereum.eth.messages.BlockBodiesMessage;
import org.hyperledger.besu.ethereum.eth.messages.BlockHeadersMessage;

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

@ -799,8 +799,9 @@ public class TransactionPool implements BlockAddedObserver {
allTxs.parallelStream()
.takeWhile(unused -> !isCancelled.get())
.map(
ptx -> (ptx.isReceivedFromLocalSource() ? "l" : "r")
+ ptx.getTransaction().encoded().toBase64String())
ptx ->
(ptx.isReceivedFromLocalSource() ? "l" : "r")
+ ptx.getTransaction().encoded().toBase64String())
.mapToInt(
line -> {
synchronized (bw) {
@ -841,7 +842,8 @@ public class TransactionPool implements BlockAddedObserver {
line -> {
final boolean isLocal = line.charAt(0) == 'l';
final Transaction tx =
RlpTransactionProvider.readFrom(Bytes.fromBase64String(line.substring(1)));
RlpTransactionProvider.readFrom(
Bytes.fromBase64String(line.substring(1)));
final ValidationResult<TransactionInvalidReason> result =
addTransaction(tx, isLocal);

@ -234,8 +234,7 @@ public class LayeredPendingTransactions implements PendingTransactions {
.addArgument(pendingTransaction.getNonce())
.addArgument(pendingTransaction.getTransaction().getType())
.addArgument(pendingTransaction::getHash)
.addArgument(
() -> pendingTransaction.getTransaction().encoded().toHexString())
.addArgument(() -> pendingTransaction.getTransaction().encoded().toHexString())
.log();
}
@ -251,17 +250,14 @@ public class LayeredPendingTransactions implements PendingTransactions {
.addArgument(pendingTransaction.getNonce())
.addArgument(pendingTransaction.getTransaction().getType())
.addArgument(pendingTransaction::getHash)
.addArgument(
() -> pendingTransaction.getTransaction().encoded().toHexString())
.addArgument(() -> pendingTransaction.getTransaction().encoded().toHexString())
.log();
LOG.atInfo()
.addMarker(INVALID_TX_REMOVED)
.addKeyValue("txhash", pendingTransaction::getHash)
.addKeyValue("txlog", pendingTransaction::toTraceLog)
.addKeyValue("reason", result)
.addKeyValue(
"txrlp",
() -> pendingTransaction.getTransaction().encoded().toHexString())
.addKeyValue("txrlp", () -> pendingTransaction.getTransaction().encoded().toHexString())
.log();
}

@ -36,7 +36,6 @@ import org.hyperledger.besu.ethereum.eth.transactions.TransactionAddedResult;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolConfiguration;
import org.hyperledger.besu.ethereum.eth.transactions.TransactionPoolReplacementHandler;
import org.hyperledger.besu.ethereum.mainnet.feemarket.FeeMarket;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
import org.hyperledger.besu.evm.account.Account;
import org.hyperledger.besu.evm.account.AccountState;
import org.hyperledger.besu.metrics.BesuMetricCategory;
@ -276,9 +275,7 @@ public abstract class AbstractPendingTransactionsSorter implements PendingTransa
.addKeyValue("txhash", pendingTransaction::getHash)
.addKeyValue("txlog", pendingTransaction::toTraceLog)
.addKeyValue("reason", result)
.addKeyValue(
"txrlp",
() -> pendingTransaction.getTransaction().encoded().toHexString())
.addKeyValue("txrlp", () -> pendingTransaction.getTransaction().encoded().toHexString())
.log();
}

@ -25,9 +25,7 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionTestFixture;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpTransactionProvider;
import org.hyperledger.besu.ethereum.core.encoding.registry.RlpPooledTransactionProvider;
import org.hyperledger.besu.ethereum.eth.transactions.layered.BaseTransactionPoolTest;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPInput;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
@ -76,7 +74,9 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
BytesValueRLPOutput rlpOut = new BytesValueRLPOutput();
RlpTransactionProvider.writeTo(txTo, rlpOut);
txTo = RlpTransactionProvider.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());
@ -120,7 +120,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txPayload = preparedTx.createTransaction(KEYS1);
txPayload =
RlpTransactionProvider.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());
@ -212,8 +213,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
RlpPooledTransactionProvider.writeTo(txBlob, rlpOut);
txBlob =
RlpPooledTransactionProvider.readFrom(
new BytesValueRLPInput(rlpOut.encoded(), false))
RlpPooledTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy();
System.out.println(txBlob.getSender());
System.out.println(txBlob.getHash());
@ -244,8 +244,7 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
RlpPooledTransactionProvider.writeTo(txBlob, rlpOut);
txBlob =
RlpPooledTransactionProvider.readFrom(
new BytesValueRLPInput(rlpOut.encoded(), false))
RlpPooledTransactionProvider.readFrom(new BytesValueRLPInput(rlpOut.encoded(), false))
.detachedCopy();
System.out.println(txBlob.getSender());
System.out.println(txBlob.getHash());
@ -271,7 +270,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txPayload = preparedTx.createTransaction(KEYS1);
txPayload =
RlpTransactionProvider.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());
@ -301,7 +301,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txAccessList = preparedTx.accessList(ales).createTransaction(KEYS1);
txAccessList =
RlpTransactionProvider.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());
@ -341,7 +342,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txEip1559 = createEIP1559Transaction(1, KEYS1, 10);
txEip1559 =
RlpTransactionProvider.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());
@ -383,7 +385,8 @@ public class PendingTransactionEstimatedMemorySizeTest extends BaseTransactionPo
Transaction txFrontier = createTransaction(TransactionType.FRONTIER, 1, Wei.of(500), 0, KEYS1);
txFrontier =
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false)).detachedCopy();
RlpTransactionProvider.readFrom(new BytesValueRLPInput(txFrontier.encoded(), false))
.detachedCopy();
System.out.println(txFrontier.getSender());
System.out.println(txFrontier.getHash());
System.out.println(txFrontier.getSize());

@ -147,7 +147,8 @@ public class T8nExecutor {
} else if (txNode.isObject()) {
if (txNode.has("txBytes")) {
Transaction tx =
RlpTransactionProvider.readFrom(Bytes.fromHexString(txNode.get("txbytes").asText()));
RlpTransactionProvider.readFrom(
Bytes.fromHexString(txNode.get("txbytes").asText()));
transactions.add(tx);
} else {
Transaction.Builder builder = Transaction.builder();

Loading…
Cancel
Save