Skip to content

Commit

Permalink
Merge branch 'master' into sort-schema-defs
Browse files Browse the repository at this point in the history
  • Loading branch information
gfukushima authored Oct 11, 2024
2 parents b9ff2e8 + bc3a5e7 commit 6115b0a
Show file tree
Hide file tree
Showing 17 changed files with 94 additions and 128 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -323,11 +323,11 @@ public void newPayloadV4_shouldBuildRequestAndResponseSuccessfully() {

final List<VersionedHash> blobVersionedHashes = dataStructureUtil.randomVersionedHashes(3);
final Bytes32 parentBeaconBlockRoot = dataStructureUtil.randomBytes32();
final Bytes32 executionRequestHash = dataStructureUtil.randomBytes32();
final List<Bytes> executionRequests = dataStructureUtil.randomEncodedExecutionRequests();

final SafeFuture<Response<PayloadStatusV1>> futureResponse =
eeClient.newPayloadV4(
executionPayloadV3, blobVersionedHashes, parentBeaconBlockRoot, executionRequestHash);
executionPayloadV3, blobVersionedHashes, parentBeaconBlockRoot, executionRequests);

assertThat(futureResponse)
.succeedsWithin(1, TimeUnit.SECONDS)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.List;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.ethereum.executionclient.schema.BlobAndProofV1;
import tech.pegasys.teku.ethereum.executionclient.schema.ClientVersionV1;
Expand Down Expand Up @@ -64,7 +65,7 @@ SafeFuture<Response<PayloadStatusV1>> newPayloadV4(
ExecutionPayloadV3 executionPayload,
List<VersionedHash> blobVersionedHashes,
Bytes32 parentBeaconBlockRoot,
Bytes32 executionRequestHash);
List<Bytes> executionRequests);

SafeFuture<Response<ForkChoiceUpdatedResult>> forkChoiceUpdatedV1(
ForkChoiceStateV1 forkChoiceState, Optional<PayloadAttributesV1> payloadAttributes);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import java.util.List;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.ethereum.executionclient.schema.BlobAndProofV1;
Expand Down Expand Up @@ -112,14 +113,11 @@ public SafeFuture<Response<PayloadStatusV1>> newPayloadV4(
final ExecutionPayloadV3 executionPayload,
final List<VersionedHash> blobVersionedHashes,
final Bytes32 parentBeaconBlockRoot,
final Bytes32 executionRequestHash) {
final List<Bytes> executionRequests) {
return taskQueue.queueTask(
() ->
delegate.newPayloadV4(
executionPayload,
blobVersionedHashes,
parentBeaconBlockRoot,
executionRequestHash));
executionPayload, blobVersionedHashes, parentBeaconBlockRoot, executionRequests));
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient;
import tech.pegasys.teku.ethereum.executionclient.response.ResponseUnwrapper;
Expand Down Expand Up @@ -51,21 +52,21 @@ public SafeFuture<PayloadStatus> execute(final JsonRpcRequestParams params) {
final List<VersionedHash> blobVersionedHashes =
params.getRequiredListParameter(1, VersionedHash.class);
final Bytes32 parentBeaconBlockRoot = params.getRequiredParameter(2, Bytes32.class);
final Bytes32 executionRequestHash = params.getRequiredParameter(3, Bytes32.class);
final List<Bytes> executionRequests = params.getRequiredListParameter(3, Bytes.class);

LOG.trace(
"Calling {}(executionPayload={}, blobVersionedHashes={}, parentBeaconBlockRoot={}, executionRequestHash={})",
"Calling {}(executionPayload={}, blobVersionedHashes={}, parentBeaconBlockRoot={}, executionRequests={})",
getVersionedName(),
executionPayload,
blobVersionedHashes,
parentBeaconBlockRoot,
executionRequestHash);
executionRequests);

final ExecutionPayloadV3 executionPayloadV3 =
ExecutionPayloadV3.fromInternalExecutionPayload(executionPayload);
return executionEngineClient
.newPayloadV4(
executionPayloadV3, blobVersionedHashes, parentBeaconBlockRoot, executionRequestHash)
executionPayloadV3, blobVersionedHashes, parentBeaconBlockRoot, executionRequests)
.thenApply(ResponseUnwrapper::unwrapExecutionClientResponseOrThrow)
.thenApply(PayloadStatusV1::asInternalExecutionPayload)
.thenPeek(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.List;
import java.util.Map;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.hyperledger.besu.plugin.services.MetricsSystem;
import tech.pegasys.teku.ethereum.executionclient.ExecutionEngineClient;
Expand Down Expand Up @@ -143,11 +144,11 @@ public SafeFuture<Response<PayloadStatusV1>> newPayloadV4(
final ExecutionPayloadV3 executionPayload,
final List<VersionedHash> blobVersionedHashes,
final Bytes32 parentBeaconBlockRoot,
final Bytes32 executionRequestHash) {
final List<Bytes> executionRequests) {
return countRequest(
() ->
delegate.newPayloadV4(
executionPayload, blobVersionedHashes, parentBeaconBlockRoot, executionRequestHash),
executionPayload, blobVersionedHashes, parentBeaconBlockRoot, executionRequests),
NEW_PAYLOAD_V4_METHOD);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@
import java.util.Collections;
import java.util.List;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256;
import org.web3j.protocol.core.DefaultBlockParameterName;
Expand Down Expand Up @@ -180,7 +181,7 @@ public SafeFuture<Response<PayloadStatusV1>> newPayloadV4(
final ExecutionPayloadV3 executionPayload,
final List<VersionedHash> blobVersionedHashes,
final Bytes32 parentBeaconBlockRoot,
final Bytes32 executionRequestHash) {
final List<Bytes> executionRequests) {
final List<String> expectedBlobVersionedHashes =
blobVersionedHashes.stream().map(VersionedHash::toHexString).toList();
final Request<?, PayloadStatusV1Web3jResponse> web3jRequest =
Expand All @@ -190,7 +191,7 @@ public SafeFuture<Response<PayloadStatusV1>> newPayloadV4(
executionPayload,
expectedBlobVersionedHashes,
parentBeaconBlockRoot.toHexString(),
executionRequestHash.toHexString()),
executionRequests),
web3JClient.getWeb3jService(),
PayloadStatusV1Web3jResponse.class);
return web3JClient.doRequest(web3jRequest, EL_ENGINE_BLOCK_EXECUTION_TIMEOUT);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ public void shouldCallGetPayloadV4AndParseResponseSuccessfully() {
final ExecutionPayload executionPayloadElectra = dataStructureUtil.randomExecutionPayload();
final ExecutionRequests executionRequests = dataStructureUtil.randomExecutionRequests();
final List<Bytes> encodedExecutionRequests =
executionRequestsDataCodec.encodeWithoutTypePrefix(executionRequests);
executionRequestsDataCodec.encode(executionRequests);
assertThat(executionPayloadElectra).isInstanceOf(ExecutionPayloadDeneb.class);

when(executionEngineClient.getPayloadV4(eq(executionPayloadContext.getPayloadId())))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@

import java.util.List;
import java.util.concurrent.TimeUnit;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.BeforeEach;
import org.junit.jupiter.api.Test;
Expand Down Expand Up @@ -119,7 +120,7 @@ public void shouldReturnFailedExecutionWhenEngineClientRequestFails() {
final ExecutionPayload executionPayload = dataStructureUtil.randomExecutionPayload();
final List<VersionedHash> blobVersionedHashes = dataStructureUtil.randomVersionedHashes(3);
final Bytes32 parentBeaconBlockRoot = dataStructureUtil.randomBytes32();
final Bytes32 executionRequestHash = dataStructureUtil.randomBytes32();
final List<Bytes> executionRequests = dataStructureUtil.randomEncodedExecutionRequests();
final String errorResponseFromClient = "error!";

when(executionEngineClient.newPayloadV4(any(), any(), any(), any()))
Expand All @@ -130,7 +131,7 @@ public void shouldReturnFailedExecutionWhenEngineClientRequestFails() {
.add(executionPayload)
.add(blobVersionedHashes)
.add(parentBeaconBlockRoot)
.add(executionRequestHash)
.add(executionRequests)
.build();

assertThat(jsonRpcMethod.execute(params))
Expand All @@ -143,7 +144,7 @@ public void shouldCallNewPayloadV4WithExecutionPayloadV3AndCorrectParameters() {
final ExecutionPayload executionPayload = dataStructureUtil.randomExecutionPayload();
final List<VersionedHash> blobVersionedHashes = dataStructureUtil.randomVersionedHashes(4);
final Bytes32 parentBeaconBlockRoot = dataStructureUtil.randomBytes32();
final Bytes32 executionRequestHash = dataStructureUtil.randomBytes32();
final List<Bytes> executionRequests = dataStructureUtil.randomEncodedExecutionRequests();

final ExecutionPayloadV3 executionPayloadV3 =
ExecutionPayloadV3.fromInternalExecutionPayload(executionPayload);
Expand All @@ -155,15 +156,15 @@ public void shouldCallNewPayloadV4WithExecutionPayloadV3AndCorrectParameters() {
eq(executionPayloadV3),
eq(blobVersionedHashes),
eq(parentBeaconBlockRoot),
eq(executionRequestHash)))
eq(executionRequests)))
.thenReturn(dummySuccessfulResponse());

final JsonRpcRequestParams params =
new JsonRpcRequestParams.Builder()
.add(executionPayload)
.add(blobVersionedHashes)
.add(parentBeaconBlockRoot)
.add(executionRequestHash)
.add(executionRequests)
.build();

assertThat(jsonRpcMethod.execute(params)).isCompleted();
Expand All @@ -173,7 +174,7 @@ public void shouldCallNewPayloadV4WithExecutionPayloadV3AndCorrectParameters() {
eq(executionPayloadV3),
eq(blobVersionedHashes),
eq(parentBeaconBlockRoot),
eq(executionRequestHash));
eq(executionRequests));
verifyNoMoreInteractions(executionEngineClient);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ public SafeFuture<PayloadStatus> engineNewPayload(
.add(executionPayload)
.addOptional(newPayloadRequest.getVersionedHashes())
.addOptional(newPayloadRequest.getParentBeaconBlockRoot())
.addOptional(newPayloadRequest.getExecutionRequestsHash());
.addOptional(newPayloadRequest.getExecutionRequests());

return engineMethodsResolver
.getMethod(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@

import java.util.List;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.jupiter.api.BeforeEach;
Expand Down Expand Up @@ -98,10 +99,10 @@ void engineNewPayload_shouldCallNewPayloadV4() {
final ExecutionPayload payload = dataStructureUtil.randomExecutionPayload();
final List<VersionedHash> versionedHashes = dataStructureUtil.randomVersionedHashes(3);
final Bytes32 parentBeaconBlockRoot = dataStructureUtil.randomBytes32();
final Bytes32 executionRequestsHash = dataStructureUtil.randomBytes32();
final List<Bytes> encodedExecutionRequests = dataStructureUtil.randomEncodedExecutionRequests();
final NewPayloadRequest newPayloadRequest =
new NewPayloadRequest(
payload, versionedHashes, parentBeaconBlockRoot, executionRequestsHash);
payload, versionedHashes, parentBeaconBlockRoot, encodedExecutionRequests);
final ExecutionPayloadV3 payloadV3 = ExecutionPayloadV3.fromInternalExecutionPayload(payload);
final PayloadStatusV1 responseData =
new PayloadStatusV1(
Expand All @@ -112,7 +113,7 @@ void engineNewPayload_shouldCallNewPayloadV4() {
eq(payloadV3),
eq(versionedHashes),
eq(parentBeaconBlockRoot),
eq(executionRequestsHash)))
eq(encodedExecutionRequests)))
.thenReturn(dummyResponse);
final SafeFuture<PayloadStatus> future =
handler.engineNewPayload(newPayloadRequest, UInt64.ZERO);
Expand All @@ -121,7 +122,7 @@ void engineNewPayload_shouldCallNewPayloadV4() {
eq(payloadV3),
eq(versionedHashes),
eq(parentBeaconBlockRoot),
eq(executionRequestsHash));
eq(encodedExecutionRequests));
assertThat(future).isCompletedWithValue(responseData.asInternalExecutionPayload());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import java.util.List;
import java.util.Objects;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.spec.logic.versions.deneb.types.VersionedHash;

Expand All @@ -25,13 +26,13 @@ public class NewPayloadRequest {
private final ExecutionPayload executionPayload;
private final Optional<List<VersionedHash>> versionedHashes;
private final Optional<Bytes32> parentBeaconBlockRoot;
private final Optional<Bytes32> executionRequestsHash;
private final Optional<List<Bytes>> executionRequests;

public NewPayloadRequest(final ExecutionPayload executionPayload) {
this.executionPayload = executionPayload;
this.versionedHashes = Optional.empty();
this.parentBeaconBlockRoot = Optional.empty();
this.executionRequestsHash = Optional.empty();
this.executionRequests = Optional.empty();
}

public NewPayloadRequest(
Expand All @@ -41,18 +42,18 @@ public NewPayloadRequest(
this.executionPayload = executionPayload;
this.versionedHashes = Optional.of(versionedHashes);
this.parentBeaconBlockRoot = Optional.of(parentBeaconBlockRoot);
this.executionRequestsHash = Optional.empty();
this.executionRequests = Optional.empty();
}

public NewPayloadRequest(
final ExecutionPayload executionPayload,
final List<VersionedHash> versionedHashes,
final Bytes32 parentBeaconBlockRoot,
final Bytes32 executionRequestsHash) {
final List<Bytes> executionRequests) {
this.executionPayload = executionPayload;
this.versionedHashes = Optional.of(versionedHashes);
this.parentBeaconBlockRoot = Optional.of(parentBeaconBlockRoot);
this.executionRequestsHash = Optional.of(executionRequestsHash);
this.executionRequests = Optional.of(executionRequests);
}

public ExecutionPayload getExecutionPayload() {
Expand All @@ -67,8 +68,8 @@ public Optional<Bytes32> getParentBeaconBlockRoot() {
return parentBeaconBlockRoot;
}

public Optional<Bytes32> getExecutionRequestsHash() {
return executionRequestsHash;
public Optional<List<Bytes>> getExecutionRequests() {
return executionRequests;
}

@Override
Expand All @@ -83,13 +84,13 @@ public boolean equals(final Object o) {
return Objects.equals(executionPayload, that.executionPayload)
&& Objects.equals(versionedHashes, that.versionedHashes)
&& Objects.equals(parentBeaconBlockRoot, that.parentBeaconBlockRoot)
&& Objects.equals(executionRequestsHash, that.executionRequestsHash);
&& Objects.equals(executionRequests, that.executionRequests);
}

@Override
public int hashCode() {
return Objects.hash(
executionPayload, versionedHashes, parentBeaconBlockRoot, executionRequestsHash);
executionPayload, versionedHashes, parentBeaconBlockRoot, executionRequests);
}

@Override
Expand All @@ -98,7 +99,7 @@ public String toString() {
.add("executionPayload", executionPayload)
.add("versionedHashes", versionedHashes)
.add("parentBeaconBlockRoot", parentBeaconBlockRoot)
.add("executionRequestsHash", executionRequestsHash)
.add("executionRequests", executionRequests)
.toString();
}
}
Loading

0 comments on commit 6115b0a

Please sign in to comment.