Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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 @@ -32,11 +32,8 @@
import java.util.stream.Collectors;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import tech.pegasys.teku.bls.BLSPublicKey;
import tech.pegasys.teku.bls.BLSSignature;
import tech.pegasys.teku.bls.BLSSignatureVerifier;
import tech.pegasys.teku.ethereum.performance.trackers.BlockProductionPerformance;
import tech.pegasys.teku.ethereum.performance.trackers.BlockPublishingPerformance;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
Expand Down Expand Up @@ -87,7 +84,6 @@
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.datastructures.util.BeaconBlockBodyLists;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerBlockProductionManager;
import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor;
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateAccessors;
import tech.pegasys.teku.spec.logic.common.helpers.MiscHelpers;
import tech.pegasys.teku.spec.schemas.SchemaDefinitionsBellatrix;
Expand Down Expand Up @@ -141,17 +137,6 @@ public abstract class AbstractBlockFactoryTest {
protected GraffitiBuilder graffitiBuilder =
new GraffitiBuilder(ClientGraffitiAppendFormat.DISABLED);

@BeforeAll
public static void initSession() {
AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;
}

@AfterAll
public static void resetSession() {
AbstractBlockProcessor.depositSignatureVerifier =
AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER;
}

abstract BlockFactory createBlockFactory(Spec spec);

protected SyncAggregate getSyncAggregate(final BeaconBlock block) {
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.stream.IntStream;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.bls.BLSSignatureVerifier;
import tech.pegasys.teku.ethereum.performance.trackers.BlockPublishingPerformance;
import tech.pegasys.teku.infrastructure.ssz.SszCollection;
import tech.pegasys.teku.infrastructure.ssz.SszList;
Expand All @@ -39,7 +40,9 @@

public class BlockFactoryDenebTest extends AbstractBlockFactoryTest {

private final Spec spec = TestSpecFactory.createMinimalDeneb();
private final Spec spec =
TestSpecFactory.createMinimalDeneb(
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@
import java.util.Optional;
import java.util.stream.IntStream;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.bls.BLSSignatureVerifier;
import tech.pegasys.teku.ethereum.performance.trackers.BlockPublishingPerformance;
import tech.pegasys.teku.infrastructure.async.SafeFuture;
import tech.pegasys.teku.infrastructure.ssz.SszCollection;
Expand All @@ -45,7 +46,9 @@

public class BlockFactoryFuluTest extends AbstractBlockFactoryTest {

private final Spec spec = TestSpecFactory.createMinimalFulu();
private final Spec spec =
TestSpecFactory.createMinimalFulu(
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));
private final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,21 @@
import static org.assertj.core.api.Assertions.assertThat;
import static org.assertj.core.api.Assertions.assertThatThrownBy;
import static org.mockito.Mockito.verify;
import static tech.pegasys.teku.spec.SpecMilestone.ALTAIR;
import static tech.pegasys.teku.spec.SpecMilestone.BELLATRIX;
import static tech.pegasys.teku.spec.SpecMilestone.CAPELLA;
import static tech.pegasys.teku.spec.SpecMilestone.PHASE0;
import static tech.pegasys.teku.spec.datastructures.blocks.blockbody.versions.altair.SyncAggregateAssert.assertThatSyncAggregate;
import static tech.pegasys.teku.spec.networks.Eth2Network.MINIMAL;

import java.util.function.Consumer;
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.bls.BLSSignatureVerifier;
import tech.pegasys.teku.infrastructure.ssz.SszList;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.config.builder.SpecConfigBuilder;
import tech.pegasys.teku.spec.datastructures.blocks.BeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBlockContainer;
Expand All @@ -35,25 +43,36 @@
import tech.pegasys.teku.spec.util.DataStructureUtil;

class BlockFactoryPhase0Test extends AbstractBlockFactoryTest {
private final Consumer<SpecConfigBuilder> configAdapter =
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP);

@Test
public void shouldCreateBlockAfterNormalSlot() {
assertBlockCreated(1, TestSpecFactory.createMinimalPhase0(), false, state -> {}, false);
assertBlockCreated(
1, TestSpecFactory.create(PHASE0, MINIMAL, configAdapter), false, state -> {}, false);
}

@Test
public void shouldCreateBlockAfterSkippedSlot() {
assertBlockCreated(2, TestSpecFactory.createMinimalPhase0(), false, state -> {}, false);
assertBlockCreated(
2, TestSpecFactory.create(PHASE0, MINIMAL, configAdapter), false, state -> {}, false);
}

@Test
public void shouldCreateBlockAfterMultipleSkippedSlot() {
assertBlockCreated(5, TestSpecFactory.createMinimalPhase0(), false, state -> {}, false);
assertBlockCreated(
5, TestSpecFactory.create(PHASE0, MINIMAL, configAdapter), false, state -> {}, false);
}

@Test
void shouldIncludeSyncAggregateWhenAltairIsActive() {
final BeaconBlock block =
assertBlockCreated(1, TestSpecFactory.createMinimalAltair(), false, state -> {}, false)
assertBlockCreated(
1,
TestSpecFactory.create(ALTAIR, MINIMAL, configAdapter),
false,
state -> {},
false)
.blockContainer()
.getBlock();
final SyncAggregate result = getSyncAggregate(block);
Expand All @@ -64,7 +83,7 @@ void shouldIncludeSyncAggregateWhenAltairIsActive() {

@Test
void shouldIncludeExecutionPayloadWhenBellatrixIsActive() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final Spec spec = TestSpecFactory.create(BELLATRIX, MINIMAL, configAdapter);
final BeaconBlock block =
assertBlockCreated(1, spec, false, state -> prepareDefaultPayload(spec), false)
.blockContainer()
Expand All @@ -75,7 +94,7 @@ void shouldIncludeExecutionPayloadWhenBellatrixIsActive() {

@Test
void shouldCreateCapellaBlock() {
final Spec spec = TestSpecFactory.createMinimalCapella();
final Spec spec = TestSpecFactory.create(CAPELLA, MINIMAL, configAdapter);
final BeaconBlock block =
assertBlockCreated(1, spec, true, state -> prepareValidPayload(spec, state), false)
.blockContainer()
Expand All @@ -87,7 +106,7 @@ void shouldCreateCapellaBlock() {

@Test
void shouldIncludeExecutionPayloadHeaderWhenBellatrixIsActiveAndBlindedBlockRequested() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final Spec spec = TestSpecFactory.create(BELLATRIX, MINIMAL, configAdapter);
final BeaconBlock block =
assertBlockCreated(1, spec, false, state -> prepareDefaultPayload(spec), true)
.blockContainer()
Expand All @@ -98,15 +117,15 @@ void shouldIncludeExecutionPayloadHeaderWhenBellatrixIsActiveAndBlindedBlockRequ

@Test
void shouldThrowPostMergeWithWrongPayload() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final Spec spec = TestSpecFactory.create(BELLATRIX, MINIMAL, configAdapter);
assertThatThrownBy(
() -> assertBlockCreated(1, spec, true, state -> prepareDefaultPayload(spec), false))
.hasCauseInstanceOf(StateTransitionException.class);
}

@Test
void unblindSignedBlock_shouldThrowWhenUnblindingBlockWithInconsistentExecutionPayload() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final Spec spec = TestSpecFactory.create(BELLATRIX, MINIMAL, configAdapter);
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

final SignedBeaconBlock signedBlock = dataStructureUtil.randomSignedBlindedBeaconBlock(1);
Expand All @@ -118,7 +137,7 @@ void unblindSignedBlock_shouldThrowWhenUnblindingBlockWithInconsistentExecutionP

@Test
void unblindSignedBlock_shouldPassthroughUnblindedBlocks() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final Spec spec = TestSpecFactory.create(BELLATRIX, MINIMAL, configAdapter);
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

final SignedBeaconBlock originalUnblindedSignedBlock =
Expand All @@ -132,7 +151,7 @@ void unblindSignedBlock_shouldPassthroughUnblindedBlocks() {

@Test
void unblindSignedBlock_shouldPassthroughInNonBellatrixBlocks() {
final Spec spec = TestSpecFactory.createMinimalAltair();
final Spec spec = TestSpecFactory.create(ALTAIR, MINIMAL, configAdapter);
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

final SignedBeaconBlock originalAltairSignedBlock =
Expand All @@ -146,7 +165,7 @@ void unblindSignedBlock_shouldPassthroughInNonBellatrixBlocks() {

@Test
void unblindSignedBlock_shouldUnblindBlockWhenBellatrixIsActive() {
final Spec spec = TestSpecFactory.createMinimalBellatrix();
final Spec spec = TestSpecFactory.create(BELLATRIX, MINIMAL, configAdapter);
final DataStructureUtil dataStructureUtil = new DataStructureUtil(spec);

final SignedBeaconBlock originalUnblindedSignedBlock =
Expand All @@ -170,15 +189,15 @@ void unblindSignedBlock_shouldUnblindBlockWhenBellatrixIsActive() {
@Test
void shouldCreateEmptyBlobSidecarsForBlock() {
final BlockAndBlobSidecars blockAndBlobSidecars =
createBlockAndBlobSidecars(false, TestSpecFactory.createMinimalPhase0());
createBlockAndBlobSidecars(false, TestSpecFactory.create(PHASE0, MINIMAL, configAdapter));

assertThat(blockAndBlobSidecars.blobSidecars()).isEmpty();
}

@Test
void shouldCreateEmptyBlobSidecarsForBlindedBlock() {
final BlockAndBlobSidecars blockAndBlobSidecars =
createBlockAndBlobSidecars(true, TestSpecFactory.createMinimalPhase0());
createBlockAndBlobSidecars(true, TestSpecFactory.create(PHASE0, MINIMAL, configAdapter));

assertThat(blockAndBlobSidecars.blobSidecars()).isEmpty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.MutableBeaconState;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel;
import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor;
import tech.pegasys.teku.spec.logic.common.statetransition.epoch.EpochProcessor;
import tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenalty;
import tech.pegasys.teku.spec.logic.common.statetransition.epoch.RewardAndPenaltyDeltas;
Expand Down Expand Up @@ -100,9 +99,11 @@ public class EpochTransitionBenchmark {
@Setup(Level.Trial)
@SuppressWarnings("deprecation")
public void init() throws Exception {
AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;

spec = TestSpecFactory.createMainnetAltair();
spec =
TestSpecFactory.createMainnetAltair(
specConfigBuilder ->
specConfigBuilder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));
asyncRunner = DelayedExecutorAsyncRunner.create();
String blocksFile =
"/blocks/blocks_epoch_"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,6 @@
import tech.pegasys.teku.spec.datastructures.state.SyncCommittee;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.BeaconStateAltair;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.altair.MutableBeaconStateAltair;
import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor;
import tech.pegasys.teku.spec.logic.common.block.BlockProcessor;
import tech.pegasys.teku.spec.util.DataStructureUtil;

Expand All @@ -61,8 +60,9 @@ public class ProcessSyncAggregateBenchmark {

@Setup(Level.Trial)
public void init() throws Exception {
spec = TestSpecFactory.createMainnetAltair();
AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;
spec =
TestSpecFactory.createMainnetAltair(
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));

final List<BLSKeyPair> validatorKeys = KeyFileGenerator.readValidatorKeys(validatorsCount);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,6 @@
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateSchema;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel;
import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor;
import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult;
import tech.pegasys.teku.spec.util.DataStructureUtil;
import tech.pegasys.teku.statetransition.BeaconChainUtil;
Expand All @@ -62,7 +61,9 @@
/** The test to be run manually for profiling block imports */
public class ProfilingRun {
public static Consumer<Object> blackHole = o -> {};
private Spec spec = TestSpecFactory.createMainnetPhase0();
private Spec spec =
TestSpecFactory.createMainnetPhase0(
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));

private final MetricsSystem metricsSystem = new StubMetricsSystem();
private final AsyncRunner asyncRunner = DelayedExecutorAsyncRunner.create();
Expand All @@ -71,9 +72,6 @@ public class ProfilingRun {
@Test
@SuppressWarnings("deprecation")
public void importBlocks() throws Exception {

AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;

int validatorsCount = 32 * 1024;
int iterationBlockLimit = 1024;

Expand Down Expand Up @@ -164,9 +162,6 @@ public static void main(String[] args) throws Exception {
@Test
@SuppressWarnings("deprecation")
public void importBlocksMemProfiling() throws Exception {

AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;

final int validatorsCount = 32 * 1024;

final String blocksFile =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@
import tech.pegasys.teku.spec.TestSpecFactory;
import tech.pegasys.teku.spec.datastructures.blocks.SignedBeaconBlock;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerChannel;
import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor;
import tech.pegasys.teku.spec.logic.common.statetransition.results.BlockImportResult;
import tech.pegasys.teku.statetransition.BeaconChainUtil;
import tech.pegasys.teku.statetransition.blobs.BlobSidecarManager;
Expand Down Expand Up @@ -79,8 +78,9 @@ public abstract class TransitionBenchmark {
@Setup(Level.Trial)
@SuppressWarnings("deprecation")
public void init() throws Exception {
spec = TestSpecFactory.createMainnetAltair();
AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;
spec =
TestSpecFactory.createMainnetAltair(
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));
AsyncRunner asyncRunner = DelayedExecutorAsyncRunner.create();

String blocksFile =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@
import tech.pegasys.teku.spec.datastructures.operations.Attestation;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.generator.AttestationGenerator;
import tech.pegasys.teku.spec.logic.common.block.AbstractBlockProcessor;
import tech.pegasys.teku.spec.logic.common.helpers.BeaconStateAccessors;
import tech.pegasys.teku.spec.logic.common.util.EpochAttestationSchedule;
import tech.pegasys.teku.spec.logic.common.util.ValidatorsUtil;
Expand All @@ -38,7 +37,9 @@
public class BlockArchiveGenerator {
private final int validatorCount;
private final int epochCount;
private final Spec spec = TestSpecFactory.createMainnetAltair();
private final Spec spec =
TestSpecFactory.createMainnetAltair(
builder -> builder.blsSignatureVerifier(BLSSignatureVerifier.NO_OP));
private final List<BLSKeyPair> validatorKeys;
private final RecentChainData localStorage;
private final AttestationGenerator attestationGenerator;
Expand Down Expand Up @@ -94,7 +95,6 @@ public static void main(final String[] args) throws Exception {
private BlockArchiveGenerator(final int validatorCount, final int epochCount) {
this.validatorCount = validatorCount;
this.epochCount = epochCount;
AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP;
this.validatorsUtil = spec.getGenesisSpec().getValidatorsUtil();
this.beaconStateAccessors = spec.getGenesisSpec().beaconStateAccessors();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package tech.pegasys.teku.ethtests.finder;

import java.nio.file.Path;
import tech.pegasys.teku.bls.BLSSignatureVerifier;
import tech.pegasys.teku.ethtests.TestFork;
import tech.pegasys.teku.ethtests.TestSpecConfig;
import tech.pegasys.teku.spec.Spec;
Expand Down Expand Up @@ -52,13 +53,17 @@ public String getFork() {
}

public Spec getSpec() {
return getSpec(true);
}

public Spec getSpec(final boolean blsSignatureVerificationEnabled) {
if (spec == null) {
createSpec();
createSpec(blsSignatureVerificationEnabled);
}
return spec;
}

private void createSpec() {
private void createSpec(final boolean blsSignatureVerificationEnabled) {
final Eth2Network network =
switch (configName) {
case TestSpecConfig.MAINNET -> Eth2Network.MAINNET;
Expand All @@ -76,7 +81,11 @@ private void createSpec() {
case TestFork.FULU -> SpecMilestone.FULU;
default -> throw new IllegalArgumentException("Unknown fork: " + fork);
};
spec = TestSpecFactory.create(milestone, network);
final BLSSignatureVerifier blsSignatureVerifier =
blsSignatureVerificationEnabled ? BLSSignatureVerifier.SIMPLE : BLSSignatureVerifier.NO_OP;
spec =
TestSpecFactory.create(
milestone, network, builder -> builder.blsSignatureVerifier(blsSignatureVerifier));
}

public String getTestType() {
Expand Down
Loading