Skip to content

Commit

Permalink
Merge branch 'master' into AT-flakyness-attempt
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfyone authored Oct 11, 2024
2 parents 778e65c + 456eb94 commit 5d88720
Show file tree
Hide file tree
Showing 29 changed files with 143 additions and 224 deletions.
5 changes: 5 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -844,6 +844,11 @@ subprojects {
propertyTestRuntimeOnly.extendsFrom testRuntimeOnly
referenceTestRuntimeOnly.extendsFrom testRuntimeOnly

// exclude until Besu dependencies start using io.consensys.protocols:jc-kzg-4844
implementation {
exclude(group: "tech.pegasys", module: "jc-kzg-4844")
}

// Details at https://github.com/Hakky54/log-captor#using-log-captor-alongside-with-other-logging-libraries
testImplementation {
exclude(group: "org.apache.logging.log4j", module: "log4j-slf4j-impl")
Expand Down
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 @@ -33,6 +33,7 @@
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadSummary;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequests;
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.operations.AttesterSlashing;
import tech.pegasys.teku.spec.datastructures.operations.Deposit;
Expand Down Expand Up @@ -87,6 +88,10 @@ default Optional<SszList<SszKZGCommitment>> getOptionalBlobKzgCommitments() {
return Optional.empty();
}

default Optional<ExecutionRequests> getOptionalExecutionRequests() {
return Optional.empty();
}

default boolean isBlinded() {
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ public enum BlockBodyFields implements SszFieldName {
EXECUTION_PAYLOAD_HEADER,
BLS_TO_EXECUTION_CHANGES,
BLOB_KZG_COMMITMENTS,
CONSOLIDATIONS,
EXECUTION_REQUESTS;

private final String sszFieldName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -223,6 +223,12 @@ public ExecutionPayloadSchema<?> getExecutionPayloadSchema() {
getChildSchema(getFieldIndex(BlockBodyFields.BLOB_KZG_COMMITMENTS));
}

@Override
public ExecutionRequestsSchema getExecutionRequestsSchema() {
return (ExecutionRequestsSchema)
getChildSchema(getFieldIndex(BlockBodyFields.EXECUTION_REQUESTS));
}

@Override
public long getBlobKzgCommitmentsGeneralizedIndex() {
return getChildGeneralizedIndex(getFieldIndex(BlockBodyFields.BLOB_KZG_COMMITMENTS));
Expand All @@ -234,9 +240,4 @@ public LongList getBlindedNodeGeneralizedIndices() {
getChildGeneralizedIndex(getFieldIndex(BlockBodyFields.EXECUTION_PAYLOAD)),
getExecutionPayloadSchema().getBlindedNodeGeneralizedIndices());
}

@Override
public ExecutionRequestsSchema getExecutionRequestsSchema() {
return (ExecutionRequestsSchema) getFieldSchema12();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.util.Optional;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.BeaconBlockBody;
import tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.deneb.BlindedBeaconBlockBodyDeneb;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequests;

public interface BlindedBeaconBlockBodyElectra extends BlindedBeaconBlockBodyDeneb {
static BlindedBeaconBlockBodyElectra required(final BeaconBlockBody body) {
Expand All @@ -27,6 +28,13 @@ static BlindedBeaconBlockBodyElectra required(final BeaconBlockBody body) {
+ body.getClass().getSimpleName()));
}

ExecutionRequests getExecutionRequests();

@Override
default Optional<ExecutionRequests> getOptionalExecutionRequests() {
return Optional.of(getExecutionRequests());
}

@Override
default Optional<BlindedBeaconBlockBodyElectra> toBlindedVersionElectra() {
return Optional.of(this);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,11 @@ public SszList<SszKZGCommitment> getBlobKzgCommitments() {
return getField11();
}

@Override
public ExecutionRequests getExecutionRequests() {
return getField12();
}

@Override
public BlindedBeaconBlockBodySchemaElectraImpl getSchema() {
return (BlindedBeaconBlockBodySchemaElectraImpl) super.getSchema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,5 @@ public interface ExecutionPayloadHeaderBuilder {

ExecutionPayloadHeaderBuilder excessBlobGas(Supplier<UInt64> excessBlobGasSupplier);

ExecutionPayloadHeaderBuilder depositRequestsRoot(Supplier<Bytes32> depositRequestsRootSupplier);

ExecutionPayloadHeaderBuilder withdrawalRequestsRoot(
Supplier<Bytes32> withdrawalRequestsRootSupplier);

ExecutionPayloadHeaderBuilder consolidationRequestsRoot(
Supplier<Bytes32> consolidationRequestsRootSupplier);

ExecutionPayloadHeader build();
}
Loading

0 comments on commit 5d88720

Please sign in to comment.