Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into debugging-inclusion
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfyone committed Oct 23, 2024
2 parents ec2c8f0 + 21efe6e commit 61b25de
Show file tree
Hide file tree
Showing 279 changed files with 5,290 additions and 2,020 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
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,8 @@
### Breaking Changes

### Additions and Improvements
- Clean up old beacon states when switching from ARCHIVE to PRUNE or MINIMAL data storage mode

### Bug Fixes
- Fixed a block production issue for Validator Client (24.10.0 to 24.10.2 teku VC), where required headers were not provided for JSON payloads. Default SSZ block production was unaffected.
- Block production now uses json data (more like 24.8.0 did than 24.10) if the Eth-Consensus-version header is absent.
2 changes: 1 addition & 1 deletion acceptance-tests/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ dependencies {
testFixturesImplementation 'io.libp2p:jvm-libp2p'
testFixturesImplementation 'org.apache.commons:commons-lang3'
testFixturesImplementation 'commons-io:commons-io'
testFixturesImplementation 'org.apache.tuweni:tuweni-bytes'
testFixturesImplementation 'io.tmio:tuweni-bytes'
testFixturesImplementation 'org.junit.jupiter:junit-jupiter-api'
testFixturesImplementation 'org.testcontainers:testcontainers'
testFixturesImplementation 'org.testcontainers:junit-jupiter'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,8 @@
import java.util.Arrays;
import java.util.Locale;
import org.apache.tuweni.bytes.Bytes32;
import org.junit.jupiter.api.Test;
import org.junit.jupiter.params.ParameterizedTest;
import org.junit.jupiter.params.provider.ValueSource;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.test.acceptance.dsl.AcceptanceTestBase;
Expand All @@ -34,8 +35,9 @@
public class BlockProposalAcceptanceTest extends AcceptanceTestBase {
private static final URL JWT_FILE = Resources.getResource("auth/ee-jwt-secret.hex");

@Test
void shouldHaveCorrectFeeRecipientAndGraffiti() throws Exception {
@ParameterizedTest(name = "ssz_encode={0}")
@ValueSource(booleans = {true, false})
void shouldHaveCorrectFeeRecipientAndGraffiti(final boolean useSszBlocks) throws Exception {
final String networkName = "swift";

final ValidatorKeystores validatorKeystores =
Expand Down Expand Up @@ -69,6 +71,7 @@ void shouldHaveCorrectFeeRecipientAndGraffiti() throws Exception {
.withValidatorProposerDefaultFeeRecipient(defaultFeeRecipient)
.withInteropModeDisabled()
.withBeaconNodes(beaconNode)
.withBeaconNodeSszBlocksEnabled(useSszBlocks)
.withGraffiti(userGraffiti)
.withNetwork("auto")
.build());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,9 +78,9 @@ void triggerValidatorExitWithFullWithdrawal() throws Exception {
tekuNode.waitForNewFinalization();

final ValidatorKeys validator = validatorKeys.getValidatorKeys().get(0);
final BLSPublicKey validatorPublicKey = validator.getValidatorKey().getPublicKey();
final BLSPublicKey validatorPubkey = validator.getValidatorKey().getPublicKey();

besuNode.createWithdrawalRequest(eth1PrivateKey, validatorPublicKey, UInt64.ZERO);
besuNode.createWithdrawalRequest(eth1PrivateKey, validatorPubkey, UInt64.ZERO);

// Wait for validator exit confirmation
tekuNode.waitForLogMessageContaining(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -80,19 +80,19 @@ void consolidateValidator() throws Exception {
tekuNode.waitForNewFinalization();

final ValidatorKeys sourceValidator = validatorKeys.getValidatorKeys().get(0);
final BLSPublicKey sourceValidatorPublicKey = sourceValidator.getValidatorKey().getPublicKey();
final BLSPublicKey sourceValidatorPubkey = sourceValidator.getValidatorKey().getPublicKey();

final ValidatorKeys targetValidator = validatorKeys.getValidatorKeys().get(1);
final BLSPublicKey targetValidatorPublicKey = targetValidator.getValidatorKey().getPublicKey();
final BLSPublicKey targetValidatorPubkey = targetValidator.getValidatorKey().getPublicKey();

besuNode.createConsolidationRequest(
eth1PrivateKey, sourceValidatorPublicKey, targetValidatorPublicKey);
waitForValidatorExit(tekuNode, sourceValidatorPublicKey);
eth1PrivateKey, sourceValidatorPubkey, targetValidatorPubkey);
waitForValidatorExit(tekuNode, sourceValidatorPubkey);
}

private void waitForValidatorExit(
final TekuBeaconNode tekuNode, final BLSPublicKey validatorPublicKey) {
final String pubKeySubstring = validatorPublicKey.toHexString().substring(2, 9);
final TekuBeaconNode tekuNode, final BLSPublicKey validatorPubkey) {
final String pubKeySubstring = validatorPubkey.toHexString().substring(2, 9);
tekuNode.waitForLogMessageContaining(
"Validator "
+ pubKeySubstring
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 All @@ -282,7 +284,7 @@ private IndexedAttestation randomIndexedAttestation(
secretKey,
signingRootUtil.signingRootForSignAttestationData(attestationData, forkInfo));

final IndexedAttestationSchema<?> schema =
final IndexedAttestationSchema schema =
spec.getGenesisSchemaDefinitions().getIndexedAttestationSchema();
return schema.create(
Stream.of(index).collect(schema.getAttestingIndicesSchema().collectorUnboxed()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package tech.pegasys.teku.test.acceptance.dsl;

import static java.nio.charset.StandardCharsets.UTF_8;
import static org.assertj.core.api.Assertions.assertThat;
import static tech.pegasys.teku.test.acceptance.dsl.Node.DATA_PATH;
import static tech.pegasys.teku.test.acceptance.dsl.Node.JWT_SECRET_FILE_PATH;
import static tech.pegasys.teku.test.acceptance.dsl.Node.METRICS_PORT;
Expand Down Expand Up @@ -176,7 +177,7 @@ public TekuNodeConfigBuilder withTrustedSetupFromClasspath(final String trustedS
LOG.debug("Xtrusted-setup={}", TRUSTED_SETUP_FILE);
configMap.put("Xtrusted-setup", TRUSTED_SETUP_FILE);
final URL trustedSetupResource = Eth2NetworkConfiguration.class.getResource(trustedSetup);
assert trustedSetupResource != null;
assertThat(trustedSetupResource).isNotNull();
configFileMap.put(copyToTmpFile(trustedSetupResource), TRUSTED_SETUP_FILE);
return this;
}
Expand Down Expand Up @@ -417,6 +418,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 Expand Up @@ -524,6 +531,12 @@ public TekuNodeConfigBuilder withValidatorProposerDefaultFeeRecipient(
return this;
}

public TekuNodeConfigBuilder withBeaconNodeSszBlocksEnabled(final boolean enabled) {
LOG.debug("beacon-node-ssz-blocks-enabled={}", enabled);
configMap.put("beacon-node-ssz-blocks-enabled", enabled);
return this;
}

public TekuNodeConfigBuilder withStartupTargetPeerCount(final int startupTargetPeerCount) {
mustBe(NodeType.BEACON_NODE);
LOG.debug("Xstartup-target-peer-count={}", startupTargetPeerCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,15 +102,15 @@ public SafeFuture<TransactionReceipt> createWithdrawalRequest(
}

public SafeFuture<TransactionReceipt> createConsolidationRequest(
final BLSPublicKey sourceValidatorPublicKey, final BLSPublicKey targetValidatorPublicKey) {
final BLSPublicKey sourceValidatorPubkey, final BLSPublicKey targetValidatorPubkey) {
// Sanity check that we can interact with the contract
Waiter.waitFor(
() ->
assertThat(consolidationRequestContract.getExcessConsolidationRequests().get())
.isEqualTo(0));

return consolidationRequestContract
.createConsolidationRequest(sourceValidatorPublicKey, targetValidatorPublicKey)
.createConsolidationRequest(sourceValidatorPubkey, targetValidatorPubkey)
.thenCompose(
response -> {
final String txHash = response.getResult();
Expand Down
2 changes: 1 addition & 1 deletion beacon/pow/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ dependencies {

api 'org.web3j:core'

implementation 'org.apache.tuweni:tuweni-units'
implementation 'io.tmio:tuweni-units'

testImplementation testFixtures(project(':infrastructure:async'))
testImplementation testFixtures(project(':infrastructure:time'))
Expand Down
2 changes: 1 addition & 1 deletion beacon/sync/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ dependencies {
implementation project(':storage:api')
implementation project(':infrastructure:events')

implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'io.tmio:tuweni-bytes'

testImplementation testFixtures(project(':ethereum:spec'))
testImplementation testFixtures(project(':ethereum:statetransition'))
Expand Down
4 changes: 2 additions & 2 deletions beacon/validator/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,8 @@ dependencies {
implementation project(':ethereum:json-types')

implementation 'it.unimi.dsi:fastutil'
implementation 'org.apache.tuweni:tuweni-bytes'
implementation 'org.apache.tuweni:tuweni-ssz'
implementation 'io.tmio:tuweni-bytes'
implementation 'io.tmio:tuweni-ssz'

testImplementation project(':infrastructure:metrics')
testImplementation testFixtures(project(':ethereum:spec'))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadContext;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadHeader;
import tech.pegasys.teku.spec.datastructures.execution.ExecutionPayloadResult;
import tech.pegasys.teku.spec.datastructures.execution.versions.electra.ExecutionRequestsBuilderElectra;
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.ProposerSlashing;
Expand All @@ -64,7 +64,6 @@
import tech.pegasys.teku.spec.schemas.SchemaDefinitions;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsDeneb;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsElectra;
import tech.pegasys.teku.statetransition.OperationPool;
import tech.pegasys.teku.statetransition.attestation.AggregatingAttestationPool;
import tech.pegasys.teku.statetransition.attestation.AttestationForkChecker;
Expand Down Expand Up @@ -240,19 +239,11 @@ private SafeFuture<Void> setExecutionData(
requestedBuilderBoostFactor,
blockProductionPerformance);

// TODO Update as part of Electra Engine API updates
// (https://github.com/Consensys/teku/issues/8620)
if (bodyBuilder.supportsExecutionRequests()) {
bodyBuilder.executionRequests(
new ExecutionRequestsBuilderElectra(
SchemaDefinitionsElectra.required(schemaDefinitions).getExecutionRequestsSchema())
.build());
}

return SafeFuture.allOf(
cacheExecutionPayloadValue(executionPayloadResult, blockSlotState),
setPayloadOrPayloadHeader(bodyBuilder, executionPayloadResult),
setKzgCommitments(bodyBuilder, schemaDefinitions, executionPayloadResult));
setKzgCommitments(bodyBuilder, schemaDefinitions, executionPayloadResult),
setExecutionRequests(bodyBuilder, executionPayloadResult));
}

private SafeFuture<Void> cacheExecutionPayloadValue(
Expand Down Expand Up @@ -350,6 +341,43 @@ private SszList<SszKZGCommitment> getBlobKzgCommitmentsFromBuilderFlow(
.orElseThrow();
}

private SafeFuture<Void> setExecutionRequests(
final BeaconBlockBodyBuilder bodyBuilder,
final ExecutionPayloadResult executionPayloadResult) {
if (!bodyBuilder.supportsExecutionRequests()) {
return SafeFuture.COMPLETE;
}
final SafeFuture<ExecutionRequests> executionRequests;
if (executionPayloadResult.isFromLocalFlow()) {
// local, non-blinded flow
executionRequests =
executionPayloadResult
.getExecutionRequestsFutureFromLocalFlow()
.orElseThrow()
.thenApply(Optional::orElseThrow);
} else {
// builder, blinded flow
executionRequests =
executionPayloadResult
.getBuilderBidOrFallbackDataFuture()
.orElseThrow()
.thenApply(this::getExecutionRequestsFromBuilderFlow);
}

return executionRequests.thenAccept(bodyBuilder::executionRequests);
}

private ExecutionRequests getExecutionRequestsFromBuilderFlow(
final BuilderBidOrFallbackData builderBidOrFallbackData) {
return builderBidOrFallbackData
.getBuilderBid()
// from the builder bid
.flatMap(BuilderBid::getOptionalExecutionRequests)
// from the local fallback
.or(() -> builderBidOrFallbackData.getFallbackDataRequired().getExecutionRequests())
.orElseThrow();
}

public Consumer<SignedBeaconBlockUnblinder> createBlockUnblinderSelector(
final BlockPublishingPerformance blockPublishingPerformance) {
return bodyUnblinder -> {
Expand Down Expand Up @@ -437,7 +465,7 @@ public Function<SignedBlockContainer, List<BlobSidecar>> createBlobSidecarsSelec
// the blobs and the proofs wouldn't be part of the BlockContainer.
final BuilderPayloadOrFallbackData builderPayloadOrFallbackData =
executionLayerBlockProductionManager
.getCachedUnblindedPayload(slot)
.getCachedUnblindedPayload(block.getSlotAndBlockRoot())
.orElseThrow(
() ->
new IllegalStateException(
Expand Down
Loading

0 comments on commit 61b25de

Please sign in to comment.