Skip to content

Commit

Permalink
Adding engine_getPayloadV4 and engine_newPayloadV4 (hyperledger#6783)
Browse files Browse the repository at this point in the history
Moved engine_newPayload6110 and engine_getPayload6110 to V4

Signed-off-by: Lucas Saldanha <lucascrsaldanha@gmail.com>
Signed-off-by: Justin Florentine <justin+github@florentine.us>
  • Loading branch information
lucassaldanha authored and jflo committed Mar 26, 2024
1 parent 85aec93 commit bd2e18e
Show file tree
Hide file tree
Showing 25 changed files with 75 additions and 68 deletions.
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
- Transaction call object to accept both `input` and `data` field simultaneously if they are set to equal values [#6702](https://github.com/hyperledger/besu/pull/6702)
- `eth_call` for blob tx allows for empty `maxFeePerBlobGas` [#6731](https://github.com/hyperledger/besu/pull/6731)
- Extend error handling of plugin RPC methods [#6759](https://github.com/hyperledger/besu/pull/6759)
- Added engine_newPayloadV4 and engine_getPayloadV4 methods [#6783](https://github.com/hyperledger/besu/pull/6783)

### Bug fixes
- Fix txpool dump/restore race condition [#6665](https://github.com/hyperledger/besu/pull/6665)
Expand Down Expand Up @@ -442,7 +443,7 @@ https://hyperledger.jfrog.io/artifactory/besu-binaries/besu/23.4.4/besu-23.4.4.z
- Early access - layered transaction pool implementation [#5290](https://github.com/hyperledger/besu/pull/5290)
- New RPC method `debug_getRawReceipts` [#5476](https://github.com/hyperledger/besu/pull/5476)
- Add TrieLogFactory plugin support [#5440](https://github.com/hyperledger/besu/pull/5440)
- Ignore `min-block-occupancy-ratio` option when on PoS networks, since in some cases, it prevents to have full blocks even if enough transactions are present [#5491](https://github.com/hyperledger/besu/pull/5491)
- Ignore `min-block-occupancy-ratio` option when on PoS networks, since in some cases, it prevents to have full blocks even if enough transactions are present [#5491](https://github.com/hyperledger/besu/pull/5491)

### Bug Fixes
- Fix eth_feeHistory response for the case in which blockCount is higher than highestBlock requested. [#5397](https://github.com/hyperledger/besu/pull/5397)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,13 +22,13 @@
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.params.provider.Arguments;

public class ExecutionEngineEip6110AcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/eip6110/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/eip6110/test-cases/";
public class ExecutionEnginePragueAcceptanceTest extends AbstractJsonRpcTest {
private static final String GENESIS_FILE = "/jsonrpc/engine/prague/genesis.json";
private static final String TEST_CASE_PATH = "/jsonrpc/engine/prague/test-cases/";

private static JsonRpcTestsContext testsContext;

public ExecutionEngineEip6110AcceptanceTest() {
public ExecutionEnginePragueAcceptanceTest() {
super(testsContext);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"londonBlock":0,
"terminalTotalDifficulty":0,
"cancunTime":0,
"experimentalEipsTime":20,
"pragueTime":20,
"clique": {
"period": 5,
"epoch": 30000
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_getPayloadV6110",
"method": "engine_getPayloadV4",
"params": [
"0x282643b909febddf"
],
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_newPayloadV6110",
"method": "engine_newPayloadV4",
"params": [
{
"parentHash": "0x45811fa27a100ce9035e5e086b9669275041a4ec0ebbd920be028fd7b0aa2356",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_newPayloadV6110",
"method": "engine_newPayloadV4",
"params": [
{
"parentHash": "0x1dd4f141551d53ce393845e2873754e43396101a8ebc0fd0eeb2e6798a591315",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"request": {
"jsonrpc": "2.0",
"method": "engine_getPayloadV6110",
"method": "engine_getPayloadV4",
"params": [
"0x282643db882670cf"
],
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,11 +54,11 @@ public enum RpcMethod {
ENGINE_GET_PAYLOAD_V1("engine_getPayloadV1"),
ENGINE_GET_PAYLOAD_V2("engine_getPayloadV2"),
ENGINE_GET_PAYLOAD_V3("engine_getPayloadV3"),
ENGINE_GET_PAYLOAD_V6110("engine_getPayloadV6110"),
ENGINE_GET_PAYLOAD_V4("engine_getPayloadV4"),
ENGINE_NEW_PAYLOAD_V1("engine_newPayloadV1"),
ENGINE_NEW_PAYLOAD_V2("engine_newPayloadV2"),
ENGINE_NEW_PAYLOAD_V3("engine_newPayloadV3"),
ENGINE_NEW_PAYLOAD_V6110("engine_newPayloadV6110"),
ENGINE_NEW_PAYLOAD_V4("engine_newPayloadV4"),
ENGINE_FORKCHOICE_UPDATED_V1("engine_forkchoiceUpdatedV1"),
ENGINE_FORKCHOICE_UPDATED_V2("engine_forkchoiceUpdatedV2"),
ENGINE_FORKCHOICE_UPDATED_V3("engine_forkchoiceUpdatedV3"),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ public JsonRpcResponse syncResponse(final JsonRpcRequestContext requestContext)
.filter(e -> e.getMethodName().startsWith("engine_"))
.filter(e -> !e.equals(ENGINE_EXCHANGE_CAPABILITIES))
.filter(e -> !e.equals(ENGINE_PREPARE_PAYLOAD_DEBUG))
.filter(e -> !e.getMethodName().endsWith("6110"))
.map(RpcMethod::getMethodName)
.collect(Collectors.toList());

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

import io.vertx.core.Vertx;

public class EngineGetPayloadV6110 extends AbstractEngineGetPayload {
public class EngineGetPayloadV4 extends AbstractEngineGetPayload {

private final Optional<ScheduledProtocolSpec.Hardfork> eip6110;
private final Optional<ScheduledProtocolSpec.Hardfork> prague;

public EngineGetPayloadV6110(
public EngineGetPayloadV4(
final Vertx vertx,
final ProtocolContext protocolContext,
final MergeMiningCoordinator mergeMiningCoordinator,
Expand All @@ -50,12 +50,12 @@ public EngineGetPayloadV6110(
mergeMiningCoordinator,
blockResultFactory,
engineCallListener);
this.eip6110 = schedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips"));
this.prague = schedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("Prague"));
}

@Override
public String getName() {
return RpcMethod.ENGINE_GET_PAYLOAD_V6110.getMethodName();
return RpcMethod.ENGINE_GET_PAYLOAD_V4.getMethodName();
}

@Override
Expand All @@ -66,22 +66,22 @@ protected JsonRpcResponse createResponse(

return new JsonRpcSuccessResponse(
request.getRequest().getId(),
blockResultFactory.payloadTransactionCompleteV6110(blockWithReceipts));
blockResultFactory.payloadTransactionCompleteV4(blockWithReceipts));
}

@Override
protected ValidationResult<RpcErrorType> validateForkSupported(final long blockTimestamp) {
if (protocolSchedule.isPresent()) {
if (eip6110.isPresent() && blockTimestamp >= eip6110.get().milestone()) {
if (prague.isPresent() && blockTimestamp >= prague.get().milestone()) {
return ValidationResult.valid();
} else {
return ValidationResult.invalid(
RpcErrorType.UNSUPPORTED_FORK,
"EIP-6110 configured to start at timestamp: " + eip6110.get().milestone());
"Prague configured to start at timestamp: " + prague.get().milestone());
}
} else {
return ValidationResult.invalid(
RpcErrorType.UNSUPPORTED_FORK, "Configuration error, no schedule for EIP-6110 fork set");
RpcErrorType.UNSUPPORTED_FORK, "Configuration error, no schedule for Prague fork set");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

import io.vertx.core.Vertx;

public class EngineNewPayloadV6110 extends AbstractEngineNewPayload {
public class EngineNewPayloadV4 extends AbstractEngineNewPayload {

private final Optional<ScheduledProtocolSpec.Hardfork> eip6110;
private final Optional<ScheduledProtocolSpec.Hardfork> prague;

public EngineNewPayloadV6110(
public EngineNewPayloadV4(
final Vertx vertx,
final ProtocolSchedule timestampSchedule,
final ProtocolContext protocolContext,
Expand All @@ -42,13 +42,12 @@ public EngineNewPayloadV6110(
final EngineCallListener engineCallListener) {
super(
vertx, timestampSchedule, protocolContext, mergeCoordinator, ethPeers, engineCallListener);
this.eip6110 =
timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("ExperimentalEips"));
this.prague = timestampSchedule.hardforkFor(s -> s.fork().name().equalsIgnoreCase("prague"));
}

@Override
public String getName() {
return RpcMethod.ENGINE_NEW_PAYLOAD_V6110.getMethodName();
return RpcMethod.ENGINE_NEW_PAYLOAD_V4.getMethodName();
}

@Override
Expand All @@ -74,16 +73,16 @@ protected ValidationResult<RpcErrorType> validateParameters(
@Override
protected ValidationResult<RpcErrorType> validateForkSupported(final long blockTimestamp) {
if (protocolSchedule.isPresent()) {
if (eip6110.isPresent() && blockTimestamp >= eip6110.get().milestone()) {
if (prague.isPresent() && blockTimestamp >= prague.get().milestone()) {
return ValidationResult.valid();
} else {
return ValidationResult.invalid(
RpcErrorType.UNSUPPORTED_FORK,
"EIP-6110 configured to start at timestamp: " + eip6110.get().milestone());
"Prague configured to start at timestamp: " + prague.get().milestone());
}
} else {
return ValidationResult.invalid(
RpcErrorType.UNSUPPORTED_FORK, "Configuration error, no schedule for EIP-6110 fork set");
RpcErrorType.UNSUPPORTED_FORK, "Configuration error, no schedule for Prague fork set");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -154,7 +154,7 @@ public EngineGetPayloadResultV3 payloadTransactionCompleteV3(
blobsBundleV1);
}

public EngineGetPayloadResultV6110 payloadTransactionCompleteV6110(
public EngineGetPayloadResultV4 payloadTransactionCompleteV4(
final BlockWithReceipts blockWithReceipts) {
final List<String> txs =
blockWithReceipts.getBlock().getBody().getTransactions().stream()
Expand All @@ -168,7 +168,7 @@ public EngineGetPayloadResultV6110 payloadTransactionCompleteV6110(

final BlobsBundleV1 blobsBundleV1 =
new BlobsBundleV1(blockWithReceipts.getBlock().getBody().getTransactions());
return new EngineGetPayloadResultV6110(
return new EngineGetPayloadResultV4(
blockWithReceipts.getHeader(),
txs,
blockWithReceipts.getBlock().getBody().getWithdrawals(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,13 +30,13 @@
import org.apache.tuweni.bytes.Bytes32;

@JsonPropertyOrder({"executionPayload", "blockValue", "blobsBundle", "shouldOverrideBuilder"})
public class EngineGetPayloadResultV6110 {
public class EngineGetPayloadResultV4 {
protected final PayloadResult executionPayload;
private final String blockValue;
private final BlobsBundleV1 blobsBundle;
private final boolean shouldOverrideBuilder;

public EngineGetPayloadResultV6110(
public EngineGetPayloadResultV4(
final BlockHeader header,
final List<String> transactions,
final Optional<List<Withdrawal>> withdrawals,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,11 +28,11 @@
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV2;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV3;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV6110;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineGetPayloadV4;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV1;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV2;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV3;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV6110;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineNewPayloadV4;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EnginePreparePayloadDebug;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.engine.EngineQosTimer;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.results.BlockResultFactory;
Expand Down Expand Up @@ -160,9 +160,9 @@ protected Map<String, JsonRpcMethod> create() {
protocolSchedule));
}

if (protocolSchedule.anyMatch(p -> p.spec().getName().equalsIgnoreCase("ExperimentalEips"))) {
if (protocolSchedule.anyMatch(p -> p.spec().getName().equalsIgnoreCase("prague"))) {
executionEngineApisSupported.add(
new EngineGetPayloadV6110(
new EngineGetPayloadV4(
consensusEngineServer,
protocolContext,
mergeCoordinator.get(),
Expand All @@ -171,7 +171,7 @@ protected Map<String, JsonRpcMethod> create() {
protocolSchedule));

executionEngineApisSupported.add(
new EngineNewPayloadV6110(
new EngineNewPayloadV4(
consensusEngineServer,
protocolSchedule,
protocolContext,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ public class AbstractScheduledApiTest {
new ScheduledProtocolSpec.Hardfork("Shanghai", 20);
protected final ScheduledProtocolSpec.Hardfork cancunHardfork =
new ScheduledProtocolSpec.Hardfork("Cancun", 30);
protected final ScheduledProtocolSpec.Hardfork pragueHardfork =
new ScheduledProtocolSpec.Hardfork("Prague", 40);
protected final ScheduledProtocolSpec.Hardfork experimentalHardfork =
new ScheduledProtocolSpec.Hardfork("ExperimentalEips", 40);
new ScheduledProtocolSpec.Hardfork("ExperimentalEips", 50);

@Mock protected DefaultProtocolSchedule protocolSchedule;

Expand Down Expand Up @@ -74,6 +76,9 @@ public void before() {
lenient()
.when(protocolSchedule.hardforkFor(argThat(new HardforkMatcher(cancunHardfork))))
.thenReturn(Optional.of(cancunHardfork));
lenient()
.when(protocolSchedule.hardforkFor(argThat(new HardforkMatcher(pragueHardfork))))
.thenReturn(Optional.of(pragueHardfork));
lenient()
.when(protocolSchedule.hardforkFor(argThat(new HardforkMatcher(shanghaiHardfork))))
.thenReturn(Optional.of(shanghaiHardfork));
Expand Down
Loading

0 comments on commit bd2e18e

Please sign in to comment.