From 8fe1dfb16936caf79375d03f28751956dc902f73 Mon Sep 17 00:00:00 2001 From: Danno Ferrin Date: Tue, 1 Aug 2023 20:56:37 -0600 Subject: [PATCH] Address import performance issues (#5734) * ensure we are on a single tuweni version * factor out an unneeded concatenate Signed-off-by: Danno Ferrin --- .../besu/ethereum/core/encoding/TransactionEncoder.java | 8 +++++--- ethereum/p2p/build.gradle | 8 +++++++- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java index 4a0f1f02257..22e88cae8bb 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java @@ -20,6 +20,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.rlp.BytesValueRLPOutput; import org.hyperledger.besu.ethereum.rlp.RLP; import org.hyperledger.besu.ethereum.rlp.RLPOutput; import org.hyperledger.besu.evm.AccessListEntry; @@ -76,9 +77,10 @@ public static Bytes encodeOpaqueBytes(final Transaction transaction) { TYPED_TRANSACTION_ENCODERS.get(transactionType), "Developer Error. A supported transaction type %s has no associated encoding logic", transactionType); - return Bytes.concatenate( - Bytes.of(transactionType.getSerializedType()), - RLP.encode(rlpOutput -> encoder.encode(transaction, rlpOutput))); + final BytesValueRLPOutput out = new BytesValueRLPOutput(); + out.writeByte(transactionType.getSerializedType()); + encoder.encode(transaction, out); + return out.encoded(); } } diff --git a/ethereum/p2p/build.gradle b/ethereum/p2p/build.gradle index ed2f9aa1e0e..dccbe0fb877 100644 --- a/ethereum/p2p/build.gradle +++ b/ethereum/p2p/build.gradle @@ -62,7 +62,13 @@ dependencies { annotationProcessor "org.immutables:value" implementation "org.immutables:value-annotations" - implementation 'tech.pegasys.discovery:discovery' + implementation('tech.pegasys.discovery:discovery') { + // version conflicts, prefer ours + exclude group: 'org.apache.tuweni', module:'tuweni-bytes' + exclude group: 'org.apache.tuweni', module:'tuweni-crypto' + exclude group: 'org.apache.tuweni', module:'tuweni-rlp' + exclude group: 'org.apache.tuweni', module:'tuweni-units' + } // test dependencies. testImplementation project(path: ':ethereum:core', configuration: 'testArtifacts')