Add accessList field to Transaction Call Object (#4802)

Signed-off-by: Gabriel Trintinalia gabriel.trintinalia@gmail.com
pull/4832/head
Gabriel-Trintinalia 2 years ago committed by Jason Frame
parent 97588ae744
commit 4cf6c38e76
  1. 3
      CHANGELOG.md
  2. 17
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthCallIntegrationTest.java
  3. 12
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/frontier/EthEstimateGasIntegrationTest.java
  4. 9
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthCallIntegrationTest.java
  5. 159
      ethereum/api/src/integration-test/java/org/hyperledger/besu/ethereum/api/jsonrpc/methods/fork/london/EthEstimateGasIntegrationTest.java
  6. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/graphql/internal/pojoadapter/BlockAdapterBase.java
  7. 3
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGas.java
  8. 8
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/parameters/JsonCallParameter.java
  9. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthCallTest.java
  10. 12
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthEstimateGasTest.java
  11. 4
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/privacy/methods/priv/PrivCallTest.java
  12. 16
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/CallParameter.java
  13. 8
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulator.java
  14. 3
      ethereum/core/src/test/java/org/hyperledger/besu/ethereum/transaction/TransactionSimulatorTest.java

@ -1,6 +1,9 @@
# Changelog
## 22.10.4
### Additions and Improvements
- Add access list to Transaction Call Object [#4802](https://github.com/hyperledger/besu/issues/4801)
### Breaking Changes
### Additions and Improvements

@ -73,6 +73,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -96,6 +97,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "0x8");
final JsonRpcResponse expectedResponse =
@ -120,6 +122,7 @@ public class EthCallIntegrationTest {
null,
Bytes.fromHexString(
"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -144,6 +147,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -166,7 +170,8 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
true);
true,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
@ -188,7 +193,8 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
false);
false,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(
@ -211,6 +217,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -233,6 +240,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -256,6 +264,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -278,6 +287,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -301,6 +311,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -324,6 +335,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x12a7b914"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -347,6 +359,7 @@ public class EthCallIntegrationTest {
null,
null,
null,
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x");

@ -64,7 +64,7 @@ public class EthEstimateGasIntegrationTest {
@Test
public void shouldReturnExpectedValueForEmptyCallParameter() {
final JsonCallParameter callParameter =
new JsonCallParameter(null, null, null, null, null, null, null, null, null);
new JsonCallParameter(null, null, null, null, null, null, null, null, null, null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x5208");
@ -85,6 +85,7 @@ public class EthEstimateGasIntegrationTest {
null,
Wei.ONE,
null,
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x5208");
@ -107,6 +108,7 @@ public class EthEstimateGasIntegrationTest {
null,
Bytes.fromHexString(
"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x1b551");
@ -129,7 +131,8 @@ public class EthEstimateGasIntegrationTest {
null,
Bytes.fromHexString(
"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029"),
false);
false,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x1b551");
@ -151,7 +154,8 @@ public class EthEstimateGasIntegrationTest {
null,
Bytes.fromHexString(
"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029"),
true);
true,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse =
new JsonRpcErrorResponse(null, JsonRpcError.TRANSACTION_UPFRONT_COST_EXCEEDS_BALANCE);
@ -163,7 +167,7 @@ public class EthEstimateGasIntegrationTest {
@Test
public void shouldReturnExpectedValueForInsufficientGas() {
final JsonCallParameter callParameter =
new JsonCallParameter(null, null, 1L, null, null, null, null, null, null);
new JsonCallParameter(null, null, 1L, null, null, null, null, null, null, null);
final JsonRpcRequestContext request = requestWithParams(callParameter);
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x5208");

@ -73,6 +73,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -96,6 +97,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -118,6 +120,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -141,6 +144,7 @@ public class EthCallIntegrationTest {
null,
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -163,6 +167,7 @@ public class EthCallIntegrationTest {
Wei.fromHexString("0x3B9ACA01"),
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -186,6 +191,7 @@ public class EthCallIntegrationTest {
Wei.fromHexString("0x3B9ACA01"),
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -209,6 +215,7 @@ public class EthCallIntegrationTest {
Wei.fromHexString("0x0A"),
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -231,6 +238,7 @@ public class EthCallIntegrationTest {
Wei.fromHexString("0x3B9ACA01"),
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =
@ -254,6 +262,7 @@ public class EthCallIntegrationTest {
Wei.fromHexString("0x3B9ACA01"),
null,
Bytes.fromHexString("0x2e64cec1"),
null,
null);
final JsonRpcRequestContext request = requestWithParams(callParameter, "latest");
final JsonRpcResponse expectedResponse =

@ -0,0 +1,159 @@
/*
* Copyright ConsenSys AG.
*
* 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.api.jsonrpc.methods.fork.london;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.BlockchainImporter;
import org.hyperledger.besu.ethereum.api.jsonrpc.JsonRpcTestMethodsFactory;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequest;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.JsonRpcRequestContext;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.JsonRpcMethod;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.parameters.JsonCallParameter;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcResponse;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.response.JsonRpcSuccessResponse;
import org.hyperledger.besu.evm.AccessListEntry;
import org.hyperledger.besu.testutil.BlockTestUtil;
import java.util.List;
import java.util.Map;
import com.google.common.base.Charsets;
import com.google.common.io.Resources;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
public class EthEstimateGasIntegrationTest {
private final String METHOD_NAME = "eth_estimateGas";
private static JsonRpcTestMethodsFactory BLOCKCHAIN;
private JsonRpcMethod method;
@BeforeAll
public static void setUpOnce() throws Exception {
final String genesisJson =
Resources.toString(BlockTestUtil.getTestLondonGenesisUrl(), Charsets.UTF_8);
BLOCKCHAIN =
new JsonRpcTestMethodsFactory(
new BlockchainImporter(BlockTestUtil.getTestLondonBlockchainUrl(), genesisJson));
}
@BeforeEach
public void setUp() {
final Map<String, JsonRpcMethod> methods = BLOCKCHAIN.methods();
method = methods.get(METHOD_NAME);
}
@Test
public void shouldReturnExpectedValueForTransfer() {
final JsonCallParameter callParameter =
new JsonCallParameter(
Address.fromHexString("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"),
Address.fromHexString("0x8888f1f195afa192cfee860698584c030f4c9db1"),
null,
null,
null,
null,
Wei.ONE,
null,
null,
null);
final JsonRpcResponse response = method.response(requestWithParams(callParameter));
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x5208");
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}
@Test
public void shouldReturnExpectedValueForTransfer_WithAccessList() {
final JsonCallParameter callParameter =
new JsonCallParameter(
Address.fromHexString("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"),
Address.fromHexString("0x8888f1f195afa192cfee860698584c030f4c9db1"),
null,
null,
null,
null,
Wei.ONE,
null,
null,
createAccessList());
final JsonRpcResponse response = method.response(requestWithParams(callParameter));
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x62d4");
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}
@Test
public void shouldReturnExpectedValueForContractDeploy() {
final JsonCallParameter callParameter =
new JsonCallParameter(
Address.fromHexString("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"),
null,
null,
null,
null,
null,
null,
Bytes.fromHexString(
"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029"),
null,
null);
final JsonRpcResponse response = method.response(requestWithParams(callParameter));
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x1f081");
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}
@Test
public void shouldReturnExpectedValueForContractDeploy_WithAccessList() {
final JsonCallParameter callParameter =
new JsonCallParameter(
Address.fromHexString("0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b"),
null,
null,
null,
null,
null,
null,
Bytes.fromHexString(
"0x608060405234801561001057600080fd5b50610157806100206000396000f30060806040526004361061004c576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff1680633bdab8bf146100515780639ae97baa14610068575b600080fd5b34801561005d57600080fd5b5061006661007f565b005b34801561007457600080fd5b5061007d6100b9565b005b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60016040518082815260200191505060405180910390a1565b7fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60026040518082815260200191505060405180910390a17fa53887c1eed04528e23301f55ad49a91634ef5021aa83a97d07fd16ed71c039a60036040518082815260200191505060405180910390a15600a165627a7a7230582010ddaa52e73a98c06dbcd22b234b97206c1d7ed64a7c048e10c2043a3d2309cb0029"),
null,
createAccessList());
final JsonRpcResponse response = method.response(requestWithParams(callParameter));
final JsonRpcResponse expectedResponse = new JsonRpcSuccessResponse(null, "0x2014d");
assertThat(response).usingRecursiveComparison().isEqualTo(expectedResponse);
}
private List<AccessListEntry> createAccessList() {
return List.of(
new AccessListEntry(
Address.fromHexString("0x8888f1f195afa192cfee860698584c030f4c9db1"),
List.of(Bytes32.ZERO)));
}
private JsonRpcRequestContext requestWithParams(final Object... params) {
return new JsonRpcRequestContext(new JsonRpcRequest("2.0", METHOD_NAME, params));
}
}

@ -237,7 +237,8 @@ public class BlockAdapterBase extends AdapterBase {
maxPriorityFeePerGas,
maxFeePerGas,
valueParam,
data);
data,
Optional.empty());
final Optional<TransactionSimulatorResult> opt =
transactionSimulator.process(

@ -105,7 +105,8 @@ public class EthEstimateGas implements JsonRpcMethod {
callParams.getMaxPriorityFeePerGas(),
callParams.getMaxFeePerGas(),
callParams.getValue(),
callParams.getPayload());
callParams.getPayload(),
callParams.getAccessList());
}
private Function<TransactionSimulatorResult, JsonRpcResponse> gasEstimateResponse(

@ -19,7 +19,9 @@ import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.json.HexLongDeserializer;
import org.hyperledger.besu.ethereum.core.json.HexStringDeserializer;
import org.hyperledger.besu.ethereum.transaction.CallParameter;
import org.hyperledger.besu.evm.AccessListEntry;
import java.util.List;
import java.util.Optional;
import com.fasterxml.jackson.annotation.JsonAnySetter;
@ -49,7 +51,8 @@ public class JsonCallParameter extends CallParameter {
@JsonProperty("value") final Wei value,
@JsonDeserialize(using = HexStringDeserializer.class) @JsonProperty("data")
final Bytes payload,
@JsonProperty("strict") final Boolean strict) {
@JsonProperty("strict") final Boolean strict,
@JsonProperty("accessList") final List<AccessListEntry> accessList) {
super(
from,
to,
@ -58,7 +61,8 @@ public class JsonCallParameter extends CallParameter {
Optional.ofNullable(maxPriorityFeePerGas),
Optional.ofNullable(maxFeePerGas),
value,
payload);
payload,
Optional.ofNullable(accessList));
this.strict = Optional.ofNullable(strict);
}

@ -95,7 +95,7 @@ public class EthCallTest {
@Test
public void shouldAcceptRequestWhenMissingOptionalFields() {
final JsonCallParameter callParameter =
new JsonCallParameter(null, null, null, null, null, null, null, null, null);
new JsonCallParameter(null, null, null, null, null, null, null, null, null, null);
final JsonRpcRequestContext request = ethCallRequest(callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(null, Bytes.of().toString());
@ -262,6 +262,7 @@ public class EthCallTest {
maxPriorityFeesPerGas,
Wei.ZERO,
Bytes.EMPTY,
null,
null);
}

@ -359,7 +359,8 @@ public class EthEstimateGasTest {
null,
Wei.ZERO,
Bytes.EMPTY,
isStrict);
isStrict,
null);
}
private CallParameter modifiedLegacyTransactionCallParameter(final Wei gasPrice) {
@ -371,7 +372,8 @@ public class EthEstimateGasTest {
Optional.empty(),
Optional.empty(),
Wei.ZERO,
Bytes.EMPTY);
Bytes.EMPTY,
Optional.empty());
}
private CallParameter eip1559TransactionCallParameter() {
@ -388,7 +390,8 @@ public class EthEstimateGasTest {
Wei.fromHexString("0x10"),
Wei.ZERO,
Bytes.EMPTY,
false);
false,
null);
}
private CallParameter modifiedEip1559TransactionCallParameter() {
@ -400,7 +403,8 @@ public class EthEstimateGasTest {
Optional.of(Wei.fromHexString("0x10")),
Optional.of(Wei.fromHexString("0x10")),
Wei.ZERO,
Bytes.EMPTY);
Bytes.EMPTY,
Optional.empty());
}
private JsonRpcRequestContext ethEstimateGasRequest(final CallParameter callParameter) {

@ -84,6 +84,7 @@ public class PrivCallTest {
null,
Wei.ZERO,
Bytes.EMPTY,
null,
null);
final JsonRpcRequestContext request = ethCallRequest(privacyGroupId, callParameter, "latest");
@ -110,7 +111,7 @@ public class PrivCallTest {
public void shouldAcceptRequestWhenMissingOptionalFields() {
final JsonCallParameter callParameter =
new JsonCallParameter(
null, Address.fromHexString("0x0"), null, null, null, null, null, null, null);
null, Address.fromHexString("0x0"), null, null, null, null, null, null, null, null);
final JsonRpcRequestContext request = ethCallRequest(privacyGroupId, callParameter, "latest");
final JsonRpcResponse expectedResponse =
new JsonRpcSuccessResponse(null, Bytes.of().toString());
@ -189,6 +190,7 @@ public class PrivCallTest {
null,
Wei.ZERO,
Bytes.EMPTY,
null,
null);
}

@ -17,7 +17,9 @@ package org.hyperledger.besu.ethereum.transaction;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.evm.AccessListEntry;
import java.util.List;
import java.util.Objects;
import java.util.Optional;
@ -42,6 +44,8 @@ public class CallParameter {
private final Bytes payload;
private final Optional<List<AccessListEntry>> accessList;
public CallParameter(
final Address from,
final Address to,
@ -52,6 +56,7 @@ public class CallParameter {
this.from = from;
this.to = to;
this.gasLimit = gasLimit;
this.accessList = Optional.empty();
this.maxPriorityFeePerGas = Optional.empty();
this.maxFeePerGas = Optional.empty();
this.gasPrice = gasPrice;
@ -67,7 +72,8 @@ public class CallParameter {
final Optional<Wei> maxPriorityFeePerGas,
final Optional<Wei> maxFeePerGas,
final Wei value,
final Bytes payload) {
final Bytes payload,
final Optional<List<AccessListEntry>> accessList) {
this.from = from;
this.to = to;
this.gasLimit = gasLimit;
@ -76,6 +82,7 @@ public class CallParameter {
this.gasPrice = gasPrice;
this.value = value;
this.payload = payload;
this.accessList = accessList;
}
public Address getFrom() {
@ -110,6 +117,10 @@ public class CallParameter {
return payload;
}
public Optional<List<AccessListEntry>> getAccessList() {
return accessList;
}
@Override
public boolean equals(final Object o) {
if (this == o) {
@ -144,6 +155,7 @@ public class CallParameter {
Optional.of(Wei.fromQuantity(tx.getMaxPriorityFeePerGas().orElseGet(() -> Wei.ZERO))),
tx.getMaxFeePerGas(),
Wei.fromQuantity(tx.getValue()),
tx.getPayload());
tx.getPayload(),
tx.getAccessList());
}
}

@ -144,7 +144,7 @@ public class TransactionSimulator {
return Optional.empty();
}
try (var ws = getWorldState(header)) {
try (final var ws = getWorldState(header)) {
WorldUpdater updater = getEffectiveWorldStateUpdater(header, ws);
@ -282,6 +282,9 @@ public class TransactionSimulator {
.payload(payload)
.signature(FAKE_SIGNATURE);
// Set access list if present
callParams.getAccessList().ifPresent(transactionBuilder::accessList);
final Wei gasPrice;
final Wei maxFeePerGas;
final Wei maxPriorityFeePerGas;
@ -309,6 +312,7 @@ public class TransactionSimulator {
.getChainId()
.orElse(BigInteger.ONE)); // needed to make some transactions valid
}
final Transaction transaction = transactionBuilder.build();
return Optional.ofNullable(transaction);
}
@ -337,7 +341,7 @@ public class TransactionSimulator {
.getMutable(header.getStateRoot(), header.getHash(), false)
.orElseThrow()) {
return doesAddressExist(worldState, address, header);
} catch (Exception ex) {
} catch (final Exception ex) {
return Optional.empty();
}
}

@ -589,6 +589,7 @@ public class TransactionSimulatorTest {
Optional.of(maxFeePerGas),
Optional.of(maxPriorityFeePerGas),
Wei.of(0),
Bytes.EMPTY);
Bytes.EMPTY,
Optional.empty());
}
}

Loading…
Cancel
Save