From 6a0e56e3471a72b443eadc390a3e7b7c4bd6f42b Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Tue, 23 Aug 2022 21:44:53 +0400 Subject: [PATCH 1/3] Replace AbstractBlockProcessor.blsVerifyDeposit static flag with BLSSignatureVerifier reference --- .../coordinator/BlockFactoryTest.java | 6 ++++-- .../benchmarks/EpochTransitionBenchmark.java | 3 ++- .../pegasys/teku/benchmarks/ProfilingRun.java | 5 +++-- .../teku/benchmarks/TransitionBenchmark.java | 3 ++- .../teku/benchmarks/gen/Generator.java | 3 ++- .../common/block/AbstractBlockProcessor.java | 19 +++++++++++-------- .../common/block/BlockProcessorTest.java | 5 +++-- .../block/BlockImporterTest.java | 6 ++++-- .../forkchoice/ForkChoiceNotifierTest.java | 6 ++++-- .../ForkChoicePayloadExecutorTest.java | 6 ++++-- .../MergeTransitionBlockValidatorTest.java | 6 ++++-- .../TerminalPowBlockMonitorTest.java | 6 ++++-- .../AggregateAttestationValidatorTest.java | 5 +++-- .../AttestationStateSelectorTest.java | 6 ++++-- .../validation/AttestationValidatorTest.java | 5 +++-- .../validation/BlockValidatorTest.java | 6 ++++-- .../eth2/PeerStatusIntegrationTest.java | 6 ++++-- .../storage/client/RecentChainDataTest.java | 6 ++++-- 18 files changed, 69 insertions(+), 39 deletions(-) diff --git a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java index b4fae3123d5..4311d05b738 100644 --- a/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java +++ b/beacon/validator/src/test/java/tech/pegasys/teku/validator/coordinator/BlockFactoryTest.java @@ -31,6 +31,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import tech.pegasys.teku.bls.BLSSignature; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.ssz.SszList; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -87,12 +88,13 @@ class BlockFactoryTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @Test diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java index 95f4ad1eb4f..1aed5c8e858 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/EpochTransitionBenchmark.java @@ -34,6 +34,7 @@ import tech.pegasys.teku.benchmarks.gen.BlsKeyPairIO; import tech.pegasys.teku.benchmarks.util.CustomRunner; import tech.pegasys.teku.bls.BLSKeyPair; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread; import tech.pegasys.teku.infrastructure.ssz.collections.SszMutableUInt64List; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -87,7 +88,7 @@ public class EpochTransitionBenchmark { @Setup(Level.Trial) public void init() throws Exception { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; spec = TestSpecFactory.createMainnetAltair(); String blocksFile = diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java index 8b010c4872d..4b184cd97b6 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/ProfilingRun.java @@ -28,6 +28,7 @@ import tech.pegasys.teku.benchmarks.gen.BlsKeyPairIO; import tech.pegasys.teku.bls.BLSKeyPair; import tech.pegasys.teku.bls.BLSPublicKey; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.bls.BLSTestUtil; import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -62,7 +63,7 @@ public class ProfilingRun { @Test public void importBlocks() throws Exception { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; int validatorsCount = 32 * 1024; int iterationBlockLimit = 1024; @@ -151,7 +152,7 @@ public static void main(String[] args) throws Exception { @Test public void importBlocksMemProfiling() throws Exception { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; int validatorsCount = 32 * 1024; diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java index 70c8630ba1e..f00bfa7d456 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/TransitionBenchmark.java @@ -32,6 +32,7 @@ import tech.pegasys.teku.benchmarks.gen.BlockIO; import tech.pegasys.teku.benchmarks.gen.BlsKeyPairIO; import tech.pegasys.teku.bls.BLSKeyPair; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; @@ -71,7 +72,7 @@ public abstract class TransitionBenchmark { @Setup(Level.Trial) public void init() throws Exception { spec = TestSpecFactory.createMainnetAltair(); - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; String blocksFile = "/blocks/blocks_epoch_" diff --git a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/gen/Generator.java b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/gen/Generator.java index 66a6fec3665..835df3a1355 100644 --- a/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/gen/Generator.java +++ b/eth-benchmark-tests/src/jmh/java/tech/pegasys/teku/benchmarks/gen/Generator.java @@ -25,6 +25,7 @@ import org.junit.jupiter.api.Test; import tech.pegasys.teku.benchmarks.gen.BlockIO.Writer; import tech.pegasys.teku.bls.BLSKeyPair; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.bls.BLSTestUtil; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; @@ -49,7 +50,7 @@ public class Generator { public void generateBlocks() throws Exception { final Spec spec = TestSpecFactory.createMainnetAltair(); - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; System.out.println("Generating keypairs..."); int validatorsCount = 400000; diff --git a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/block/AbstractBlockProcessor.java b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/block/AbstractBlockProcessor.java index 462627d8766..ee06f5dbb1b 100644 --- a/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/block/AbstractBlockProcessor.java +++ b/ethereum/spec/src/main/java/tech/pegasys/teku/spec/logic/common/block/AbstractBlockProcessor.java @@ -17,6 +17,7 @@ import static java.lang.Math.toIntExact; import static tech.pegasys.teku.spec.config.SpecConfig.FAR_FUTURE_EPOCH; +import com.google.common.annotations.VisibleForTesting; import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.objects.Object2IntMap; import java.util.ArrayList; @@ -28,7 +29,6 @@ import org.apache.logging.log4j.Logger; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; -import tech.pegasys.teku.bls.BLS; import tech.pegasys.teku.bls.BLSPublicKey; import tech.pegasys.teku.bls.BLSSignature; import tech.pegasys.teku.bls.BLSSignatureVerifier; @@ -77,11 +77,16 @@ import tech.pegasys.teku.spec.logic.versions.bellatrix.block.OptimisticExecutionPayloadExecutor; public abstract class AbstractBlockProcessor implements BlockProcessor { + + @VisibleForTesting + public static final BLSSignatureVerifier DEFAULT_DEPOSIT_SIGNATURE_VERIFIER = + BLSSignatureVerifier.SIMPLE; /** * For debug/test purposes only enables/disables {@link DepositData} BLS signature verification * Setting to false significantly speeds up state initialization */ - public static boolean blsVerifyDeposit = true; + @VisibleForTesting + public static BLSSignatureVerifier depositSignatureVerifier = DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; private static final Logger LOG = LogManager.getLogger(); @@ -605,8 +610,7 @@ public void processDeposits(MutableBeaconState state, SszList throws BlockProcessingException { safelyProcess( () -> { - final boolean depositSignaturesAreAllGood = - !blsVerifyDeposit || batchVerifyDepositSignatures(deposits); + final boolean depositSignaturesAreAllGood = batchVerifyDepositSignatures(deposits); for (Deposit deposit : deposits) { processDeposit(state, deposit, depositSignaturesAreAllGood); } @@ -624,7 +628,7 @@ private boolean batchVerifyDepositSignatures(SszList deposits signatures.add(deposit.getData().getSignature()); } // Overwhelmingly often we expect all the deposit signatures to be good - return BLS.batchVerify(publicKeys, messages, signatures); + return depositSignatureVerifier.verify(publicKeys, messages, signatures); } public void processDeposit( @@ -700,9 +704,8 @@ private void handleInvalidDeposit( } private boolean depositSignatureIsValid(final Deposit deposit, BLSPublicKey pubkey) { - return !blsVerifyDeposit - || BLS.verify( - pubkey, computeDepositSigningRoot(deposit, pubkey), deposit.getData().getSignature()); + return depositSignatureVerifier.verify( + pubkey, computeDepositSigningRoot(deposit, pubkey), deposit.getData().getSignature()); } private Bytes computeDepositSigningRoot(final Deposit deposit, BLSPublicKey pubkey) { diff --git a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/common/block/BlockProcessorTest.java b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/common/block/BlockProcessorTest.java index a5ae0cbaa16..fe03b42da2f 100644 --- a/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/common/block/BlockProcessorTest.java +++ b/ethereum/spec/src/test/java/tech/pegasys/teku/spec/logic/common/block/BlockProcessorTest.java @@ -57,8 +57,9 @@ public abstract class BlockProcessorTest { protected abstract Spec createSpec(); @Test - void ensureVerifyDepositDefaultsToTrue() { - assertThat(AbstractBlockProcessor.blsVerifyDeposit).isTrue(); + void ensureDepositSignatureVerifierHasDefaultValue() { + assertThat(AbstractBlockProcessor.depositSignatureVerifier) + .isSameAs(AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER); } @Test diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java index 663c8fc27c5..bfc79e076a3 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockImporterTest.java @@ -33,6 +33,7 @@ import org.junit.jupiter.api.Test; import tech.pegasys.teku.bls.BLSKeyGenerator; import tech.pegasys.teku.bls.BLSKeyPair; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.bls.BLSTestUtil; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread; @@ -107,12 +108,13 @@ public class BlockImporterTest { @BeforeAll public static void init() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void dispose() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java index 7dd9c69e6b9..1beb7bc44f9 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoiceNotifierTest.java @@ -37,6 +37,7 @@ import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; import org.mockito.invocation.InvocationOnMock; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.SafeFutureAssert; import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread; @@ -91,12 +92,13 @@ class ForkChoiceNotifierTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java index b53a17b48ab..4cf75d53044 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/ForkChoicePayloadExecutorTest.java @@ -26,6 +26,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; @@ -59,12 +60,13 @@ class ForkChoicePayloadExecutorTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java index a5014e778b2..35315a9ce02 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/MergeTransitionBlockValidatorTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.exceptions.FatalServiceFailureException; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -52,12 +53,13 @@ class MergeTransitionBlockValidatorTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } /** diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java index 2dfb0a437cb..eca2fdeac45 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/forkchoice/TerminalPowBlockMonitorTest.java @@ -35,6 +35,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.mockito.Mockito; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.StubAsyncRunner; import tech.pegasys.teku.infrastructure.logging.EventLogger; @@ -77,12 +78,13 @@ public class TerminalPowBlockMonitorTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } private void setUpTerminalBlockHashConfig() { diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AggregateAttestationValidatorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AggregateAttestationValidatorTest.java index e27fe81e88f..19d877547db 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AggregateAttestationValidatorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AggregateAttestationValidatorTest.java @@ -127,12 +127,13 @@ class AggregateAttestationValidatorTest { @BeforeAll public static void init() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void reset() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationStateSelectorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationStateSelectorTest.java index 4c60816c25d..e8d3422a888 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationStateSelectorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationStateSelectorTest.java @@ -23,6 +23,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; @@ -52,12 +53,13 @@ class AttestationStateSelectorTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationValidatorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationValidatorTest.java index a6190b436a1..fb24bbac680 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationValidatorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/AttestationValidatorTest.java @@ -108,12 +108,13 @@ class AttestationValidatorTest { @BeforeAll public static void init() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void reset() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/BlockValidatorTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/BlockValidatorTest.java index fc83b2f6a26..6fe399fe86a 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/BlockValidatorTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/validation/BlockValidatorTest.java @@ -26,6 +26,7 @@ import tech.pegasys.teku.bls.BLSKeyGenerator; import tech.pegasys.teku.bls.BLSKeyPair; import tech.pegasys.teku.bls.BLSSignature; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.bls.BLSTestUtil; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -54,12 +55,13 @@ public class BlockValidatorTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/PeerStatusIntegrationTest.java b/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/PeerStatusIntegrationTest.java index 435d152d21c..bddec462209 100644 --- a/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/PeerStatusIntegrationTest.java +++ b/networking/eth2/src/integration-test/java/tech/pegasys/teku/networking/eth2/PeerStatusIntegrationTest.java @@ -24,6 +24,7 @@ import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.bytes.Bytes4; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.networking.eth2.peers.Eth2Peer; @@ -49,12 +50,13 @@ public class PeerStatusIntegrationTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @AfterEach diff --git a/storage/src/test/java/tech/pegasys/teku/storage/client/RecentChainDataTest.java b/storage/src/test/java/tech/pegasys/teku/storage/client/RecentChainDataTest.java index 83f3b7a2940..4501af4e243 100644 --- a/storage/src/test/java/tech/pegasys/teku/storage/client/RecentChainDataTest.java +++ b/storage/src/test/java/tech/pegasys/teku/storage/client/RecentChainDataTest.java @@ -32,6 +32,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import tech.pegasys.teku.bls.BLSKeyGenerator; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.metrics.TekuMetricCategory; import tech.pegasys.teku.infrastructure.unsigned.UInt64; @@ -98,12 +99,13 @@ private void generateGenesisWithoutIniting() { @BeforeAll public static void disableDepositBlsVerification() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void enableDepositBlsVerification() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @Test From 4b3399a3c314d2f902f03c26653e01b481b33207 Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Tue, 23 Aug 2022 23:16:50 +0400 Subject: [PATCH 2/3] Adjusted another tests --- .../executionlayer/BuilderCircuitBreakerImplTest.java | 5 +++-- .../pegasys/teku/statetransition/block/BlockManagerTest.java | 5 +++-- 2 files changed, 6 insertions(+), 4 deletions(-) diff --git a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java index b754508da25..c67953b12cb 100644 --- a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java +++ b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java @@ -19,6 +19,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.unsigned.UInt64; import tech.pegasys.teku.spec.Spec; import tech.pegasys.teku.spec.TestSpecFactory; @@ -41,12 +42,12 @@ public class BuilderCircuitBreakerImplTest { @BeforeAll public static void disableDepositBlsVerification() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void enableDepositBlsVerification() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java index 2ab54d0b9ab..9af838e449e 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java @@ -42,6 +42,7 @@ import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import tech.pegasys.teku.bls.BLSSignatureVerifier; import tech.pegasys.teku.infrastructure.async.SafeFuture; import tech.pegasys.teku.infrastructure.async.eventthread.InlineEventThread; import tech.pegasys.teku.infrastructure.logging.EventLogger; @@ -134,12 +135,12 @@ public class BlockManagerTest { @BeforeAll public static void initSession() { - AbstractBlockProcessor.blsVerifyDeposit = false; + AbstractBlockProcessor.depositSignatureVerifier = BLSSignatureVerifier.NO_OP; } @AfterAll public static void resetSession() { - AbstractBlockProcessor.blsVerifyDeposit = true; + AbstractBlockProcessor.depositSignatureVerifier = AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach From 861b992ac64938cf689cc69ca6c33c7e58206cc1 Mon Sep 17 00:00:00 2001 From: Anton Nashatyrev Date: Tue, 23 Aug 2022 23:20:04 +0400 Subject: [PATCH 3/3] Spotless --- .../ethereum/executionlayer/BuilderCircuitBreakerImplTest.java | 3 ++- .../pegasys/teku/statetransition/block/BlockManagerTest.java | 3 ++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java index c67953b12cb..c3af33f7f36 100644 --- a/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java +++ b/ethereum/executionlayer/src/test/java/tech/pegasys/teku/ethereum/executionlayer/BuilderCircuitBreakerImplTest.java @@ -47,7 +47,8 @@ public static void disableDepositBlsVerification() { @AfterAll public static void enableDepositBlsVerification() { - AbstractBlockProcessor.depositSignatureVerifier = AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach diff --git a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java index 9af838e449e..36ff8ba3127 100644 --- a/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java +++ b/ethereum/statetransition/src/test/java/tech/pegasys/teku/statetransition/block/BlockManagerTest.java @@ -140,7 +140,8 @@ public static void initSession() { @AfterAll public static void resetSession() { - AbstractBlockProcessor.depositSignatureVerifier = AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; + AbstractBlockProcessor.depositSignatureVerifier = + AbstractBlockProcessor.DEFAULT_DEPOSIT_SIGNATURE_VERIFIER; } @BeforeEach