Skip to content
Merged
Show file tree
Hide file tree
Changes from 20 commits
Commits
Show all changes
37 commits
Select commit Hold shift + click to select a range
f9442d7
Check gas limit consistency with the target
zilm13 May 19, 2026
ac74eb6
restore merge deleted test
zilm13 May 28, 2026
9823b60
remove unneeded mocks
zilm13 May 28, 2026
a17ca40
Alpha.8 reference tests
zilm13 May 20, 2026
80b9688
remove hidden executor test skips
zilm13 May 28, 2026
980ca15
add temporary exceptions for specrefs
zilm13 May 28, 2026
d9c1a59
Merge branch 'master' into reftests-alpha8
zilm13 May 29, 2026
8786fc3
enable gloas reference tests
zilm13 May 29, 2026
475fb3b
specrefs alpha.8 todo later
zilm13 May 29, 2026
201c042
add missing is_within_slot_range added later to phase0
gfukushima Jun 1, 2026
37123dc
refactor the isAttestationSlotInCurrentOrPreviousEpoch to use new mis…
gfukushima Jun 1, 2026
7eaa2ff
storeBlockMetaData loads slot from block not from state
gfukushima Jun 1, 2026
5e89904
enable attestation and aggregate suites
gfukushima Jun 1, 2026
ab771fb
use similar approach for creating anchor and checkpoint and override …
gfukushima Jun 1, 2026
1708a1a
add aggregate committee bits validation
gfukushima Jun 1, 2026
8fdf205
add unit test for aggregation committee bits validation bit
gfukushima Jun 1, 2026
6736dbc
refactor to test to to show we're using genesisTime in seconds
gfukushima Jun 1, 2026
08fdb96
add validation for when attestation/aggregation is not descendent of …
gfukushima Jun 1, 2026
4bf51c8
Merge branch 'master' into reftests-att-and-aggregate
gfukushima Jun 1, 2026
0fded54
Merge branch 'master' into reftests-att-and-aggregate
zilm13 Jun 1, 2026
0b2af45
remove duplicates
zilm13 Jun 1, 2026
14cb80c
addressing PR review comments
gfukushima Jun 2, 2026
ac45250
Merge branch 'master' into reftests-att-and-aggregate
gfukushima Jun 2, 2026
157963a
remove unused param
gfukushima Jun 2, 2026
beb9744
Merge remote-tracking branch 'origin/reftests-att-and-aggregate' into…
gfukushima Jun 2, 2026
654f967
spotless
gfukushima Jun 2, 2026
0d66c80
Merge branch 'master' into reftests-att-and-aggregate
gfukushima Jun 2, 2026
2222de0
fix gossip test and add gossip blob sidecar test executor
gfukushima Jun 2, 2026
17bc0e7
add a skip for gossip manager subnet validation
gfukushima Jun 2, 2026
77abd1b
remove changes commited accidentally in the wrong branch
gfukushima Jun 2, 2026
3770929
Merge remote-tracking branch 'origin/reftests-att-and-aggregate' into…
gfukushima Jun 2, 2026
31709b5
spotless
gfukushima Jun 2, 2026
870adfc
add similar mechanism to override the checkpoint descendent check whi…
gfukushima Jun 4, 2026
4c8c187
Merge branch 'master' into reftests-att-and-aggregate
gfukushima Jun 4, 2026
a896462
add check against invalidBlock map for attestations as per spec, foll…
gfukushima Jun 4, 2026
db861c5
Merge remote-tracking branch 'origin/reftests-att-and-aggregate' into…
gfukushima Jun 4, 2026
62ba614
Merge branch 'master' into reftests-att-and-aggregate
gfukushima Jun 4, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Optional;
import java.util.function.Function;
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.xerial.snappy.Snappy;
import org.yaml.snakeyaml.LoaderOptions;
import tech.pegasys.teku.ethtests.finder.TestDefinition;
Expand Down Expand Up @@ -149,12 +150,28 @@ public static AnchorPoint createAnchorFromState(final Spec spec, final BeaconSta
*/
public static AnchorPoint createAnchorFromStateAndMatchingBlock(
final Spec spec, final BeaconState state, final Collection<SignedBeaconBlock> blocks) {
final Optional<AnchorPoint> anchorFromMatchingStateRoot =
blocks.stream()
.filter(block -> block.getStateRoot().equals(state.hashTreeRoot()))
.findFirst()
.map(
block ->
AnchorPoint.fromInitialBlockAndState(
spec, new SignedBlockAndState(block, state)));
if (anchorFromMatchingStateRoot.isPresent()) {
return anchorFromMatchingStateRoot.get();
}

final Bytes32 stateBlockRoot = BeaconBlockHeader.fromState(state).hashTreeRoot();
return blocks.stream()
.filter(block -> block.getStateRoot().equals(state.hashTreeRoot()))
.filter(block -> block.getRoot().equals(stateBlockRoot))
.findFirst()
.map(
block ->
AnchorPoint.fromInitialBlockAndState(spec, new SignedBlockAndState(block, state)))
block -> {
final UInt64 epoch = spec.computeNextEpochBoundary(state.getSlot());
final Checkpoint checkpoint = new Checkpoint(epoch, block.getRoot());
return AnchorPoint.create(spec, checkpoint, state, Optional.of(block));
})
.orElseGet(() -> createAnchorFromState(spec, state));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.operations.SignedAggregateAndProof;
import tech.pegasys.teku.spec.datastructures.state.AnchorPoint;
import tech.pegasys.teku.spec.datastructures.state.Checkpoint;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannelStub;
import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult;
Expand All @@ -60,6 +61,7 @@
import tech.pegasys.teku.storage.server.StateStorageMode;
import tech.pegasys.teku.storage.storageSystem.InMemoryStorageSystemBuilder;
import tech.pegasys.teku.storage.storageSystem.StorageSystem;
import tech.pegasys.teku.storage.store.UpdatableStore;

public class GossipBeaconAggregateAndProofTestExecutor implements TestExecutor {

Expand Down Expand Up @@ -129,10 +131,6 @@ public void runTest(final TestDefinition testDefinition) throws Throwable {
// spec distinction between "block not seen" (IGNORE) and "block failed validation" (REJECT).
final Set<Bytes32> failedBlockRoots = new HashSet<>();

// When a custom finalized_checkpoint is set, its root will not be in the chain, so any block
// import attempt would fail. Skip all imports so that the validator's block-not-available path
// produces the expected IGNORE result.
final boolean hasCustomFinalizedCheckpoint = metaData.getFinalizedCheckpoint() != null;
for (final BlockEntryAndBlock blockEntryAndBlock : blocks) {
final GossipBeaconAggregateAndProofMetaData.BlockEntry blockEntry =
blockEntryAndBlock.blockEntry();
Expand All @@ -141,7 +139,7 @@ public void runTest(final TestDefinition testDefinition) throws Throwable {
// Record the root of this invalid block so aggregates voting for it are rejected.
// Don't import it — a NOOP BLS verifier would accept it despite the bad signature.
failedBlockRoots.add(block.getRoot());
} else if (!hasCustomFinalizedCheckpoint && !block.getRoot().equals(anchorPoint.getRoot())) {
} else if (!block.getRoot().equals(anchorPoint.getRoot())) {
final BlockImportResult importResult =
safeJoin(
forkChoice.onBlock(
Expand All @@ -152,11 +150,27 @@ public void runTest(final TestDefinition testDefinition) throws Throwable {
}
}

Optional<Checkpoint> customFinalizedCheckpoint = Optional.empty();
if (metaData.getFinalizedCheckpoint() != null) {
final GossipBeaconAggregateAndProofMetaData.FinalizedCheckpoint finalizedCheckpoint =
metaData.getFinalizedCheckpoint();
if (finalizedCheckpoint.getBlock() != null) {
final Checkpoint checkpoint = finalizedCheckpoint.toCheckpoint(testDefinition, spec);
final UpdatableStore.StoreTransaction tx = recentChainData.startStoreTransaction();
tx.setFinalizedCheckpoint(checkpoint, false);
safeJoin(tx.commit());
} else {
customFinalizedCheckpoint =
Optional.of(finalizedCheckpoint.toCheckpoint(testDefinition, spec));
}
}

final AttestationValidator attestationValidator =
new AttestationValidator(
spec,
AsyncBLSSignatureVerifier.wrap(blsVerifier),
new GossipValidationHelper(spec, recentChainData, metricsSystem));
createGossipValidationHelper(
spec, recentChainData, metricsSystem, customFinalizedCheckpoint));
final AggregateAttestationValidator aggregateValidator =
new AggregateAttestationValidator(
spec, attestationValidator, AsyncBLSSignatureVerifier.wrap(blsVerifier));
Expand Down Expand Up @@ -218,6 +232,26 @@ public void runTest(final TestDefinition testDefinition) throws Throwable {
}
}

private static GossipValidationHelper createGossipValidationHelper(
final Spec spec,
final RecentChainData recentChainData,
final StubMetricsSystem metricsSystem,
final Optional<Checkpoint> finalizedCheckpointOverride) {
// Some generated tests pin the finalized checkpoint to a root that has no corresponding block
// in Store (so it cannot be committed via setFinalizedCheckpoint). For those we override only
// the checkpoint source, leaving the real ancestor validation in GossipValidationHelper intact.
return finalizedCheckpointOverride
.<GossipValidationHelper>map(
finalizedCheckpoint ->
new GossipValidationHelper(spec, recentChainData, metricsSystem) {
@Override
protected Checkpoint getFinalizedCheckpoint() {
return finalizedCheckpoint;
}
})
.orElseGet(() -> new GossipValidationHelper(spec, recentChainData, metricsSystem));
}

@SuppressWarnings("unused")
@JsonIgnoreProperties(ignoreUnknown = true)
private static class GossipBeaconAggregateAndProofMetaData {
Expand All @@ -238,7 +272,7 @@ private static class GossipBeaconAggregateAndProofMetaData {
private int blsSetting;

@JsonProperty(value = "finalized_checkpoint", required = false)
private Object finalizedCheckpoint;
private FinalizedCheckpoint finalizedCheckpoint;

public List<BlockEntry> getBlocks() {
return blocks;
Expand All @@ -256,7 +290,7 @@ public BlsSetting getBlsSetting() {
return BlsSetting.forCode(blsSetting);
}

public Object getFinalizedCheckpoint() {
public FinalizedCheckpoint getFinalizedCheckpoint() {
return finalizedCheckpoint;
}

Expand Down Expand Up @@ -305,6 +339,38 @@ public String getExpected() {
return expected;
}
}

@JsonIgnoreProperties(ignoreUnknown = true)
private static class FinalizedCheckpoint {

@JsonProperty(value = "epoch", required = true)
private long epoch;

@JsonProperty(value = "root")
private String root;

@JsonProperty(value = "block")
private String block;

public String getBlock() {
return block;
}

public Checkpoint toCheckpoint(final TestDefinition testDefinition, final Spec spec) {
final Bytes32 checkpointRoot;
if (root != null) {
checkpointRoot = Bytes32.fromHexString(root);
} else if (block != null) {
final SignedBeaconBlock signedBlock =
loadSsz(testDefinition, block + ".ssz_snappy", spec::deserializeSignedBeaconBlock);
checkpointRoot = signedBlock.getRoot();
} else {
throw new IllegalStateException(
"finalized_checkpoint must specify either 'root' or 'block'");
}
return new Checkpoint(UInt64.valueOf(epoch), checkpointRoot);
}
}
}

private record BlockEntryAndBlock(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,10 @@ public class GossipTests {
public static final ImmutableMap<String, TestExecutor> GOSSIP_TEST_TYPES =
ImmutableMap.<String, TestExecutor>builder()
.put("networking/gossip_attester_slashing", new GossipAttesterSlashingTestExecutor())
// TODO: https://github.com/Consensys/teku/issues/10578
.put("networking/gossip_beacon_aggregate_and_proof", TestExecutor.IGNORE_TESTS)
.put("networking/gossip_beacon_attestation", TestExecutor.IGNORE_TESTS)
.put(
"networking/gossip_beacon_aggregate_and_proof",
new GossipBeaconAggregateAndProofTestExecutor())
.put("networking/gossip_beacon_attestation", new GossipBeaconAttestationTestExecutor())
.put("networking/gossip_blob_sidecar", TestExecutor.IGNORE_TESTS)
Comment thread
gfukushima marked this conversation as resolved.
Resolved
.put(
"networking/gossip_bls_to_execution_change",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@

import static com.google.common.base.Preconditions.checkArgument;
import static tech.pegasys.teku.infrastructure.crypto.Hash.getSha256Instance;
import static tech.pegasys.teku.infrastructure.time.TimeUtilities.secondsToMillis;
import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH;
import static tech.pegasys.teku.spec.logic.common.helpers.MathHelpers.bytesToUInt64;
import static tech.pegasys.teku.spec.logic.common.helpers.MathHelpers.uint64ToBytes;
Expand Down Expand Up @@ -201,6 +202,35 @@ public UInt64 computeTimeMillisAtSlot(final UInt64 genesisTimeMillis, final UInt
return genesisTimeMillis.plus(slotsSinceGenesis.times(specConfig.getSlotDurationMillis()));
}

/**
* Mirrors the consensus-specs {@code is_within_slot_range} helper.
*
* <p>{@code inclusiveEndSlotOffset} is the offset from {@code startSlot} to the final included
* slot, not the number of slots in the range. For example, an epoch-sized range passes {@code
* SLOTS_PER_EPOCH - 1}, covering {@code [startSlot, startSlot + SLOTS_PER_EPOCH - 1]}. The time
* window ends at the start of the first slot after that inclusive range, with {@code
* MAXIMUM_GOSSIP_CLOCK_DISPARITY} applied to both boundaries.
*/
public boolean isCurrentTimeWithinInclusiveSlotRange(
final UInt64 startSlot,
final UInt64 inclusiveEndSlotOffset,
final UInt64 genesisTimeSeconds,
final UInt64 currentTimeMillis) {
final UInt64 genesisTimeMillis = secondsToMillis(genesisTimeSeconds);
final UInt64 startTimeMillis = computeTimeMillisAtSlot(genesisTimeMillis, startSlot);
if (currentTimeMillis
.plus(specConfig.getMaximumGossipClockDisparity())
.isLessThan(startTimeMillis)) {
return false;
}

final UInt64 endTimeMillis =
computeTimeMillisAtSlot(genesisTimeMillis, startSlot.plus(inclusiveEndSlotOffset).plus(1));
return !endTimeMillis
.plus(specConfig.getMaximumGossipClockDisparity())
.isLessThan(currentTimeMillis);
}

public boolean isSlotAtNthEpochBoundary(
final UInt64 blockSlot, final UInt64 parentSlot, final int n) {
checkArgument(n > 0, "Parameter n must be greater than 0");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,6 @@

package tech.pegasys.teku.spec.logic.versions.deneb.util;

import static tech.pegasys.teku.infrastructure.time.TimeUtilities.millisToSeconds;
import static tech.pegasys.teku.infrastructure.time.TimeUtilities.secondsToMillis;

import com.google.common.annotations.VisibleForTesting;
Expand Down Expand Up @@ -47,49 +46,50 @@ public AttestationUtilDeneb(
*/
@Override
public Optional<SlotInclusionGossipValidationResult> performSlotInclusionGossipValidation(
final Attestation attestation, final UInt64 genesisTime, final UInt64 currentTimeMillis) {
final Attestation attestation,
final UInt64 genesisTimeSeconds,
final UInt64 currentTimeMillis) {
final UInt64 attestationSlot = attestation.getData().getSlot();
if (isAttestationSlotAfterCurrentTime(attestationSlot, genesisTime, currentTimeMillis)) {
if (isAttestationSlotAfterCurrentTime(attestationSlot, genesisTimeSeconds, currentTimeMillis)) {
return Optional.of(
isFromFarFuture(attestation, genesisTime, currentTimeMillis)
isFromFarFuture(attestation, genesisTimeSeconds, currentTimeMillis)
? SlotInclusionGossipValidationResult.IGNORE
: SlotInclusionGossipValidationResult.SAVE_FOR_FUTURE);
}
if (!isAttestationSlotInCurrentOrPreviousEpoch(
attestationSlot, genesisTime, currentTimeMillis)) {
attestationSlot, genesisTimeSeconds, currentTimeMillis)) {
return Optional.of(SlotInclusionGossipValidationResult.IGNORE);
}
return Optional.empty();
}

@VisibleForTesting
boolean isAttestationSlotAfterCurrentTime(
final UInt64 attestationSlot, final UInt64 genesisTime, final UInt64 currentTimeMillis) {
final UInt64 attestationSlot,
final UInt64 genesisTimeSeconds,
final UInt64 currentTimeMillis) {
final UInt64 attestationSlotTimeMillis =
secondsToMillis(miscHelpers.computeTimeAtSlot(genesisTime, attestationSlot));
secondsToMillis(miscHelpers.computeTimeAtSlot(genesisTimeSeconds, attestationSlot));
return attestationSlotTimeMillis.isGreaterThan(
currentTimeMillis.plus(specConfig.getMaximumGossipClockDisparity()));
}

@VisibleForTesting
boolean isAttestationSlotInCurrentOrPreviousEpoch(
final UInt64 attestationSlot, final UInt64 genesisTime, final UInt64 currentTimeMillis) {
final UInt64 currentSlot =
miscHelpers.computeSlotAtTime(genesisTime, millisToSeconds(currentTimeMillis));
final UInt64 currentEpoch = miscHelpers.computeEpochAtSlot(currentSlot);
final UInt64 previousEpoch = currentEpoch.minusMinZero(1);
final int slotDisparity = calculateMaximumGossipClockDisparityInSlots();
// min and max slot for the given attestation slot based on previous and current epoch with
// MAXIMUM_GOSSIP_CLOCK_DISPARITY
final UInt64 minSlot =
miscHelpers.computeStartSlotAtEpoch(previousEpoch).minusMinZero(slotDisparity);
final UInt64 maxSlot = miscHelpers.computeEndSlotAtEpoch(currentEpoch).plus(slotDisparity);

return attestationSlot.isGreaterThanOrEqualTo(minSlot)
&& attestationSlot.isLessThanOrEqualTo(maxSlot);
}

private int calculateMaximumGossipClockDisparityInSlots() {
return (specConfig.getMaximumGossipClockDisparity() / specConfig.getSlotDurationMillis()) + 1;
final UInt64 attestationSlot,
final UInt64 genesisTimeSeconds,
final UInt64 currentTimeMillis) {
final UInt64 attestationEpoch = miscHelpers.computeEpochAtSlot(attestationSlot);
final UInt64 epochInclusiveEndSlotOffset = UInt64.valueOf(specConfig.getSlotsPerEpoch() - 1);
return miscHelpers.isCurrentTimeWithinInclusiveSlotRange(
miscHelpers.computeStartSlotAtEpoch(attestationEpoch.plus(1)),
epochInclusiveEndSlotOffset,
genesisTimeSeconds,
currentTimeMillis)
|| miscHelpers.isCurrentTimeWithinInclusiveSlotRange(
miscHelpers.computeStartSlotAtEpoch(attestationEpoch),
epochInclusiveEndSlotOffset,
genesisTimeSeconds,
currentTimeMillis);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -40,23 +40,23 @@ public class AttestationUtilDenebTest {
public void testAttestationSlotIsAfterCurrentTime(
final int attestationSlot, final UInt64 currentTimeMillis, final boolean expectedResult) {
// set genesisTime as 0 for simplification
final UInt64 genesisTime = UInt64.ZERO;
final UInt64 genesisTimeSeconds = UInt64.ZERO;
final boolean actualResult =
attestationUtilDeneb.isAttestationSlotAfterCurrentTime(
UInt64.valueOf(attestationSlot), genesisTime, currentTimeMillis);
UInt64.valueOf(attestationSlot), genesisTimeSeconds, currentTimeMillis);
assertThat(actualResult).isEqualTo(expectedResult);
}

@ParameterizedTest
@MethodSource("provideAttestationSlotInCurrentOrPreviousEpochArguments")
public void testAttestationSlotInCurrentOrPreviousEpoch(
final int attestationSlot, final UInt64 currentTime, final boolean expectedResult) {
final UInt64 currentTimeMillis = secondsToMillis(currentTime);
final int attestationSlot, final UInt64 currentTimeSeconds, final boolean expectedResult) {
final UInt64 currentTimeMillis = secondsToMillis(currentTimeSeconds);
// set genesisTime as 0 for simplification
final UInt64 genesisTime = UInt64.ZERO;
final UInt64 genesisTimeSeconds = UInt64.ZERO;
final boolean actualResult =
attestationUtilDeneb.isAttestationSlotInCurrentOrPreviousEpoch(
UInt64.valueOf(attestationSlot), genesisTime, currentTimeMillis);
UInt64.valueOf(attestationSlot), genesisTimeSeconds, currentTimeMillis);
assertThat(actualResult).isEqualTo(expectedResult);
}

Expand All @@ -69,22 +69,21 @@ private static Stream<Arguments> provideAttestationSlotIsAfterCurrentTimeArgumen
Arguments.of(2, getTimeForSlotInMillis(2).minus(501), true));
}

// minimal is 6 seconds per slot, 8 slots per epoch, MAXIMUM_GOSSIP_CLOCK_DISPARITY is 500 ms (1
// slot disparity)
// minimal is 6 seconds per slot, 8 slots per epoch, MAXIMUM_GOSSIP_CLOCK_DISPARITY is 500 ms
private static Stream<Arguments> provideAttestationSlotInCurrentOrPreviousEpochArguments() {
return Stream.of(
// lower_bound pass
Arguments.of(7, getTimeForSlot(17), true),
Arguments.of(8, getTimeForSlot(17), true),
Arguments.of(15, getTimeForSlot(17), true),
Arguments.of(16, getTimeForSlot(17), true),
// lower_bound fail
Arguments.of(7, getTimeForSlot(17), false),
Arguments.of(6, getTimeForSlot(17), false),
// upper_bound pass
Arguments.of(23, getTimeForSlot(17), true),
Arguments.of(24, getTimeForSlot(17), true),
Arguments.of(22, getTimeForSlot(17), true),
// upper_bound fail
Arguments.of(24, getTimeForSlot(17), false),
Arguments.of(25, getTimeForSlot(17), false),
// edge case
Arguments.of(0, getTimeForSlot(0), true));
Expand Down
Loading
Loading