Skip to content

Commit

Permalink
Merge branch 'main' into release-v0.1.4-testX
Browse files Browse the repository at this point in the history
# Conflicts:
#	gradle.properties
  • Loading branch information
fab-10 committed Dec 16, 2024
2 parents 8620350 + be18e11 commit b6dc49a
Show file tree
Hide file tree
Showing 5 changed files with 154 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ protected void assertMinGasPriceLowerBound(final Wei baseFee, final Wei estimate
public void lineaEstimateGasPriorityFeeMinGasPriceLowerBound() {
final Account sender = accounts.getSecondaryBenefactor();

final CallParams callParams = new CallParams(sender.getAddress(), null, "", "", "0", null);
final CallParams callParams =
new CallParams(null, sender.getAddress(), null, "", "", "0", null, null, null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests()).getResult();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,11 +48,14 @@ public void estimateGasFailsForExceedingModuleLineCountTest() throws Exception {

final EstimateGasTest.CallParams callParams =
new EstimateGasTest.CallParams(
null,
sender.getAddress(),
simpleStorage.getContractAddress(),
null,
payload.toHexString(),
"0",
null,
null,
null);

final var reqLinea = new EstimateGasTest.BadLineaEstimateGasRequest(callParams);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
*/
package linea.plugin.acc.test.rpc.linea;

import static com.fasterxml.jackson.annotation.JsonInclude.Include.NON_NULL;
import static org.assertj.core.api.Assertions.assertThat;

import java.io.IOException;
Expand All @@ -27,6 +28,7 @@
import java.util.List;
import java.util.Map;

import com.fasterxml.jackson.annotation.JsonInclude;
import linea.plugin.acc.test.LineaPluginTestBase;
import linea.plugin.acc.test.TestCommandLineOptionsBuilder;
import linea.plugin.acc.test.tests.web3j.generated.SimpleStorage;
Expand Down Expand Up @@ -95,7 +97,15 @@ public void lineaEstimateGasMatchesEthEstimateGas() {

final CallParams callParams =
new CallParams(
sender.getAddress(), sender.getAddress(), null, Bytes.EMPTY.toHexString(), "0", null);
null,
sender.getAddress(),
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
null,
null,
null);

final var reqEth = new RawEstimateGasRequest(callParams);
final var reqLinea = new LineaEstimateGasRequest(callParams);
Expand All @@ -111,12 +121,84 @@ public void passingGasPriceFieldWorks() {

final CallParams callParams =
new CallParams(
null,
sender.getAddress(),
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
"0x1234");
"0x1234",
null,
null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.hasError()).isFalse();
assertThat(respLinea.getResult()).isNotNull();
}

@Test
public void passingChainIdFieldWorks() {

final Account sender = accounts.getSecondaryBenefactor();

final CallParams callParams =
new CallParams(
"0x539",
sender.getAddress(),
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
"0x1234",
null,
null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.hasError()).isFalse();
assertThat(respLinea.getResult()).isNotNull();
}

@Test
public void passingEIP1559FieldsWorks() {

final Account sender = accounts.getSecondaryBenefactor();

final CallParams callParams =
new CallParams(
null,
sender.getAddress(),
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
null,
"0x1234",
"0x1");

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.hasError()).isFalse();
assertThat(respLinea.getResult()).isNotNull();
}

@Test
public void passingChainIdAndEIP1559FieldsWorks() {

final Account sender = accounts.getSecondaryBenefactor();

final CallParams callParams =
new CallParams(
"0x539",
sender.getAddress(),
sender.getAddress(),
null,
Bytes.EMPTY.toHexString(),
"0",
null,
"0x1234",
null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
Expand All @@ -135,12 +217,15 @@ public void passingStateOverridesWorks() {

final CallParams callParams =
new CallParams(
"0x539",
sender.getAddress(),
sender.getAddress(),
"1",
Bytes.EMPTY.toHexString(),
"0",
"0x1234");
"0x1234",
null,
null);

final var zeroBalance = Map.of("balance", Wei.ZERO.toHexString());

Expand Down Expand Up @@ -172,7 +257,15 @@ public void lineaEstimateGasIsProfitable() {

final CallParams callParams =
new CallParams(
sender.getAddress(), sender.getAddress(), null, payload.toHexString(), "0", null);
null,
sender.getAddress(),
sender.getAddress(),
null,
payload.toHexString(),
"0",
null,
null,
null);

final var reqLinea = new LineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests()).getResult();
Expand Down Expand Up @@ -223,7 +316,16 @@ protected void assertIsProfitable(
public void invalidParametersLineaEstimateGasRequestReturnErrorResponse() {
final Account sender = accounts.getSecondaryBenefactor();
final CallParams callParams =
new CallParams(sender.getAddress(), null, "", "", String.valueOf(Integer.MAX_VALUE), null);
new CallParams(
null,
sender.getAddress(),
null,
"",
"",
String.valueOf(Integer.MAX_VALUE),
null,
null,
null);
final var reqLinea = new BadLineaEstimateGasRequest(callParams);
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.getCode()).isEqualTo(RpcErrorType.INVALID_PARAMS.getCode());
Expand All @@ -237,7 +339,15 @@ public void revertedTransactionReturnErrorResponse() throws Exception {
final var reqLinea =
new BadLineaEstimateGasRequest(
new CallParams(
sender.getAddress(), simpleStorage.getContractAddress(), "", "", "0", null));
null,
sender.getAddress(),
simpleStorage.getContractAddress(),
"",
"",
"0",
null,
null,
null));
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.getCode()).isEqualTo(-32000);
assertThat(respLinea.getMessage()).isEqualTo("Execution reverted");
Expand All @@ -250,11 +360,14 @@ public void failedTransactionReturnErrorResponse() {
final var reqLinea =
new BadLineaEstimateGasRequest(
new CallParams(
null,
sender.getAddress(),
null,
"",
Accounts.GENESIS_ACCOUNT_TWO_PRIVATE_KEY,
"0",
null,
null,
null));
final var respLinea = reqLinea.execute(minerNode.nodeRequests());
assertThat(respLinea.getCode()).isEqualTo(-32000);
Expand Down Expand Up @@ -374,8 +487,17 @@ public String execute(final NodeRequests nodeRequests) {
static class RawEstimateGasResponse extends org.web3j.protocol.core.Response<String> {}
}

@JsonInclude(NON_NULL)
record CallParams(
String from, String to, String value, String data, String gas, String gasPrice) {}
String chainId,
String from,
String to,
String value,
String data,
String gas,
String gasPrice,
String maxFeePerGas,
String maxPriorityFeePerGas) {}

record StateOverride(String account, String balance) {}
}
4 changes: 2 additions & 2 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
releaseVersion=0.1.4-test38
besuVersion=24.12-delivery40
releaseVersion=0.1.4-test39
besuVersion=24.12-delivery41
besuArtifactGroup=io.consensys.linea-besu
distributionIdentifier=besu-sequencer-plugins
distributionBaseUrl=https://artifacts.consensys.net/public/linea-besu/raw/names/linea-besu.tar.gz/versions/
Original file line number Diff line number Diff line change
Expand Up @@ -491,9 +491,8 @@ private Transaction createTransactionForSimulation(
.signature(FAKE_SIGNATURE_FOR_SIZE_CALCULATION);

if (isBaseFeeTransaction(callParameters)) {
callParameters.getMaxFeePerGas().ifPresent(txBuilder::maxFeePerGas);
callParameters.getMaxPriorityFeePerGas().ifPresent(txBuilder::maxPriorityFeePerGas);
callParameters.getMaxFeePerBlobGas().ifPresent(txBuilder::maxFeePerBlobGas);
txBuilder.maxFeePerGas(callParameters.getMaxFeePerGas().orElse(Wei.ZERO));
txBuilder.maxPriorityFeePerGas(callParameters.getMaxPriorityFeePerGas().orElse(Wei.ZERO));
} else {
txBuilder.gasPrice(
callParameters.getGasPrice() != null
Expand All @@ -503,6 +502,22 @@ private Transaction createTransactionForSimulation(

callParameters.getAccessList().ifPresent(txBuilder::accessList);

final var txType = txBuilder.guessType().getTransactionType();

if (txType.supportsBlob()) {
txBuilder.maxFeePerBlobGas(callParameters.getMaxFeePerBlobGas().orElse(Wei.ZERO));
}

callParameters
.getChainId()
.ifPresentOrElse(
txBuilder::chainId,
() -> {
if (txType.requiresChainId()) {
blockchainService.getChainId().ifPresent(txBuilder::chainId);
}
});

return txBuilder.build();
}

Expand Down

0 comments on commit b6dc49a

Please sign in to comment.