Skip to content

Commit

Permalink
Address import performance issues (hyperledger#5734)
Browse files Browse the repository at this point in the history
* ensure we are on a single tuweni version
* factor out an unneeded concatenate

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
  • Loading branch information
shemnon authored and elenduuche committed Aug 16, 2023
1 parent b078080 commit 8fe1dfb
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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();
}
}

Expand Down
8 changes: 7 additions & 1 deletion ethereum/p2p/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down

0 comments on commit 8fe1dfb

Please sign in to comment.