From 4683a65a0b1fe233d7f7b542b5b2af0763417936 Mon Sep 17 00:00:00 2001 From: fmacleal Date: Tue, 6 Feb 2024 00:30:16 +0100 Subject: [PATCH] Fix from jmh benchmark Fixing EthCallPlan to add gasLimit to the request Refactoring of branch to merge it to master In order to fix the jmh benchmarking test, we need to refactor and remove some changes made to run test locally. --- .../jmh/web3/BenchmarkLocalWalletWeb3.java | 4 +-- .../java/co/rsk/jmh/web3/BenchmarkWeb3.java | 2 +- .../co/rsk/jmh/web3/plan/EthCallPlan.java | 30 +++++-------------- ...aWalletlPlan.java => LocalWalletPlan.java} | 2 +- .../jmh/resources/conf/testnet-3_860_000.conf | 1 + 5 files changed, 12 insertions(+), 27 deletions(-) rename rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/{LocaWalletlPlan.java => LocalWalletPlan.java} (97%) diff --git a/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkLocalWalletWeb3.java b/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkLocalWalletWeb3.java index 6d5b0fa6bdb..8425156b6cd 100644 --- a/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkLocalWalletWeb3.java +++ b/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkLocalWalletWeb3.java @@ -18,7 +18,7 @@ package co.rsk.jmh.web3; -import co.rsk.jmh.web3.plan.LocaWalletlPlan; +import co.rsk.jmh.web3.plan.LocalWalletPlan; import co.rsk.jmh.web3.plan.TransactionPlan; import org.openjdk.jmh.annotations.*; import org.web3j.protocol.core.methods.request.Transaction; @@ -57,7 +57,7 @@ public void ethSendTransaction_ContractCall(TransactionPlan plan) throws Benchma } @Benchmark - public void ethSign(LocaWalletlPlan plan) throws BenchmarkWeb3Exception { + public void ethSign(LocalWalletPlan plan) throws BenchmarkWeb3Exception { String address = plan.getEthSignAddress(); String message = plan.getEthSignMessage(); plan.getWeb3Connector().ethSign(address, message); diff --git a/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkWeb3.java b/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkWeb3.java index 729c14c4ea5..d3e722a02c8 100644 --- a/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkWeb3.java +++ b/rskj-core/src/jmh/java/co/rsk/jmh/web3/BenchmarkWeb3.java @@ -198,7 +198,7 @@ public void traceFilterBetweenBlockRange(TracePlan plan) throws BenchmarkWeb3Exc } @Benchmark - @Timeout(time = 60) + @Timeout(time = 100) public void traceFilterBetweenAddresses(TracePlan plan) throws BenchmarkWeb3Exception { plan.getWeb3Connector().traceFilter(plan.getFromBlock(), plan.getToBlock(), plan.getFromAddresses(), plan.getToAddresses()); } diff --git a/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/EthCallPlan.java b/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/EthCallPlan.java index 76cd809a0c9..56144da0940 100644 --- a/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/EthCallPlan.java +++ b/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/EthCallPlan.java @@ -18,16 +18,13 @@ package co.rsk.jmh.web3.plan; -import co.rsk.jmh.helpers.BenchmarkHelper; import co.rsk.jmh.web3.BenchmarkWeb3Exception; import co.rsk.jmh.web3.e2e.RskModuleWeb3j; import org.openjdk.jmh.annotations.Level; import org.openjdk.jmh.annotations.Scope; import org.openjdk.jmh.annotations.Setup; import org.openjdk.jmh.annotations.State; -import org.openjdk.jmh.annotations.TearDown; import org.openjdk.jmh.infra.BenchmarkParams; -import org.web3j.protocol.core.methods.response.Transaction; import java.math.BigInteger; @@ -44,29 +41,16 @@ public void setUp(BenchmarkParams params) throws BenchmarkWeb3Exception { ethCallArguments = buildEthCallArguments(); } - private Transaction setupTransaction() { - Transaction tx = new Transaction(); - - tx.setFrom(configuration.getString("eth_call.transaction.from")); - tx.setTo(configuration.getString("eth_call.transaction.to")); - tx.setGas(configuration.getString("eth_call.transaction.gas")); - tx.setGasPrice(configuration.getString("eth_call.transaction.gasPrice")); - tx.setValue(configuration.getString("eth_call.transaction.value")); - tx.setInput(configuration.getString("eth_call.transaction.input")); - - return tx; - } - private RskModuleWeb3j.EthCallArguments buildEthCallArguments() { RskModuleWeb3j.EthCallArguments args = new RskModuleWeb3j.EthCallArguments(); - Transaction tx = setupTransaction(); - args.setFrom(tx.getFrom()); - args.setTo(tx.getTo()); - args.setGas("0x" + tx.getGas().toString(16)); - args.setGasPrice("0x" + tx.getGasPrice().toString(16)); - args.setValue("0x" + tx.getValue().toString(16)); - args.setData(tx.getInput()); + args.setGasLimit(configuration.getString("eth_call.gasLimit")); + args.setFrom(configuration.getString("eth_call.transaction.from")); + args.setTo(configuration.getString("eth_call.transaction.to")); + args.setGas(configuration.getString("eth_call.transaction.gas")); + args.setGasPrice(configuration.getString("eth_call.transaction.gasPrice")); + args.setValue(configuration.getString("eth_call.transaction.value")); + args.setData(configuration.getString("eth_call.transaction.input")); return args; } diff --git a/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/LocaWalletlPlan.java b/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/LocalWalletPlan.java similarity index 97% rename from rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/LocaWalletlPlan.java rename to rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/LocalWalletPlan.java index 7e34b60e4e7..8d87749530f 100644 --- a/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/LocaWalletlPlan.java +++ b/rskj-core/src/jmh/java/co/rsk/jmh/web3/plan/LocalWalletPlan.java @@ -26,7 +26,7 @@ import org.openjdk.jmh.infra.BenchmarkParams; @State(Scope.Benchmark) -public class LocaWalletlPlan extends BasePlan{ +public class LocalWalletPlan extends BasePlan{ public static final String ETH_SIGN_ADDRESS = "ethSign.address"; public static final String ETH_SIGN_MESSAGE = "ethSign.message"; diff --git a/rskj-core/src/jmh/resources/conf/testnet-3_860_000.conf b/rskj-core/src/jmh/resources/conf/testnet-3_860_000.conf index 444e0c1ec0a..46a249de586 100644 --- a/rskj-core/src/jmh/resources/conf/testnet-3_860_000.conf +++ b/rskj-core/src/jmh/resources/conf/testnet-3_860_000.conf @@ -69,6 +69,7 @@ trace.fromAddresses=0x0000000000000000000000000000000000000000 ############################ # eth_call ############################ +eth_call.gasLimit=0x4e252e0 eth_call.transaction.blockNumber=0x362193 eth_call.transaction.from=0x4a727d7943b563462c96d40689836600d20b983b eth_call.transaction.to=0x19f64674d8a5b4e652319f5e239efd3bc969a1fe