Skip to content

Commit

Permalink
Merge branch 'master' into fix-return
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfyone authored Oct 14, 2024
2 parents 2157bbe + 67c1366 commit 9c7bd1d
Show file tree
Hide file tree
Showing 35 changed files with 171 additions and 269 deletions.
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ jobs:
path: build/test-results

acceptanceTests:
parallelism: 5
parallelism: 4
executor: machine_large_executor_amd64
steps:
- install_java_21
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
import org.junit.jupiter.params.provider.MethodSource;
import tech.pegasys.teku.bls.BLSKeyPair;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.SpecMilestone;
import tech.pegasys.teku.test.acceptance.dsl.TekuBeaconNode;
import tech.pegasys.teku.test.acceptance.dsl.TekuNodeConfigBuilder;
import tech.pegasys.teku.test.acceptance.dsl.TekuValidatorNode;
Expand All @@ -39,43 +38,25 @@ public class MultiPeersStandAloneVcBlocksAcceptanceTest
shouldShutDownWhenOwnedValidatorSlashed_StandAloneVC_MultiplePeers_SlashingThroughBlock_NoSlashingEventsGossip(
final SlashingEventType slashingEventType) throws Exception {

final int genesisTime = timeProvider.getTimeInSeconds().plus(10).intValue();
final UInt64 altairEpoch = UInt64.valueOf(100);
final int genesisTime = timeProvider.getTimeInSeconds().plus(30).intValue();

final TekuBeaconNode firstTekuNode =
createTekuBeaconNode(
TekuNodeConfigBuilder.createBeaconNode()
.withGenesisTime(genesisTime)
.withNetwork(network)
.withRealNetwork()
.withAltairEpoch(altairEpoch)
.withSubscribeAllSubnetsEnabled()
.withInteropValidators(0, 32)
.build());

firstTekuNode.start();

firstTekuNode.waitForEpochAtOrAbove(2);

final int slashedValidatorIndex = 34;
final BLSKeyPair slashedValidatorKeyPair = getBlsKeyPair(slashedValidatorIndex);
final int slotInThirdEpoch =
firstTekuNode.getSpec().forMilestone(SpecMilestone.ALTAIR).getSlotsPerEpoch() * 2 + 3;

postSlashing(
firstTekuNode,
UInt64.valueOf(slotInThirdEpoch),
UInt64.valueOf(slashedValidatorIndex),
slashedValidatorKeyPair.getSecretKey(),
slashingEventType);

final TekuBeaconNode secondBeaconNode =
createTekuBeaconNode(
TekuNodeConfigBuilder.createBeaconNode()
.withGenesisTime(genesisTime)
.withNetwork(network)
.withRealNetwork()
.withRealNetwork()
.withAltairEpoch(altairEpoch)
.withSubscribeAllSubnetsEnabled()
.withPeers(firstTekuNode)
.build());

Expand All @@ -89,10 +70,23 @@ public class MultiPeersStandAloneVcBlocksAcceptanceTest
.withBeaconNodes(secondBeaconNode)
.build());

firstTekuNode.start();
secondBeaconNode.start();

secondValidatorClient.start();

firstTekuNode.waitForEpochAtOrAbove(1);

final int slashedValidatorIndex = 34;
final BLSKeyPair slashedValidatorKeyPair = getBlsKeyPair(slashedValidatorIndex);
final int slotInSecondEpoch = firstTekuNode.getSpec().getGenesisSpec().getSlotsPerEpoch() + 3;

postSlashing(
firstTekuNode,
UInt64.valueOf(slotInSecondEpoch),
UInt64.valueOf(slashedValidatorIndex),
slashedValidatorKeyPair.getSecretKey(),
slashingEventType);

secondValidatorClient.waitForLogMessageContaining(
String.format(slashingActionLog, slashedValidatorKeyPair.getPublicKey().toHexString()));

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ public class ValidatorSlashingDetectionAcceptanceTest extends AcceptanceTestBase
final String slashingActionLog =
"Validator slashing detection is enabled and validator(s) with public key(s) %s detected as slashed. "
+ "Shutting down...";
final int shutdownWaitingSeconds = 60;
final int shutdownWaitingSeconds = 90;

enum SlashingEventType {
PROPOSER_SLASHING,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,6 +226,7 @@ public void postProposerSlashing(
randomSignedBeaconBlockHeader(slot, index, secretKey, signingRootUtil, forkInfo);
final SignedBeaconBlockHeader header2 =
randomSignedBeaconBlockHeader(slot, index, secretKey, signingRootUtil, forkInfo);
LOG.debug("Inserting proposer slashing for index {} at slot {}", index, slot);
final String body =
JsonUtil.serialize(
new ProposerSlashing(header1, header2),
Expand Down Expand Up @@ -256,6 +257,7 @@ public void postAttesterSlashing(
spec.getGenesisSchemaDefinitions()
.getAttesterSlashingSchema()
.create(indexedAttestation1, indexedAttestation2);
LOG.debug("Inserting attester slashing for index {} at slot {}", slashedIndex, slashingSlot);
final String body =
JsonUtil.serialize(
attesterSlashing,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,6 +417,12 @@ public TekuNodeConfigBuilder withDoppelgangerDetectionEnabled() {
return this;
}

public TekuNodeConfigBuilder withSubscribeAllSubnetsEnabled() {
LOG.debug("p2p-subscribe-all-subnets-enabled=true");
configMap.put("p2p-subscribe-all-subnets-enabled", true);
return this;
}

public TekuNodeConfigBuilder withDepositsFrom(final BesuNode eth1Node) {
mustBe(NodeType.BEACON_NODE);
configMap.put("Xinterop-enabled", false);
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
Loading

0 comments on commit 9c7bd1d

Please sign in to comment.