diff --git a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProvider.java b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProvider.java index 7593ca3234..5586dea301 100644 --- a/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProvider.java +++ b/consensus/common/src/main/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProvider.java @@ -32,7 +32,6 @@ public class BlockValidatorProvider implements ValidatorProvider { private final VoteTallyCache voteTallyCache; private final VoteProvider voteProvider; private final BlockInterface blockInterface; - private final Optional bftValidatorOverrides; public static BlockValidatorProvider forkingValidatorProvider( final Blockchain blockchain, @@ -68,7 +67,6 @@ public class BlockValidatorProvider implements ValidatorProvider { : new VoteTallyCache(blockchain, voteTallyUpdater, epochManager, blockInterface); this.voteProvider = new BlockVoteProvider(voteTallyCache, voteProposer); this.blockInterface = blockInterface; - this.bftValidatorOverrides = bftValidatorOverrides; } @Override @@ -90,8 +88,4 @@ public class BlockValidatorProvider implements ValidatorProvider { public Optional getVoteProviderAtHead() { return Optional.of(voteProvider); } - - public boolean hasValidatorOverridesForBlockNumber(final long blockNumber) { - return bftValidatorOverrides.map(bvo -> bvo.getForBlock(blockNumber).isPresent()).orElse(false); - } } diff --git a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProviderTest.java b/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProviderTest.java deleted file mode 100644 index c8c1a3873b..0000000000 --- a/consensus/common/src/test/java/org/hyperledger/besu/consensus/common/validator/blockbased/BlockValidatorProviderTest.java +++ /dev/null @@ -1,86 +0,0 @@ -/* - * Copyright Hyperledger Besu contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ -package org.hyperledger.besu.consensus.common.validator.blockbased; - -import static java.util.Collections.emptyMap; -import static org.assertj.core.api.Assertions.assertThat; - -import org.hyperledger.besu.consensus.common.BftValidatorOverrides; -import org.hyperledger.besu.consensus.common.BlockInterface; -import org.hyperledger.besu.consensus.common.EpochManager; -import org.hyperledger.besu.datatypes.Address; -import org.hyperledger.besu.ethereum.chain.Blockchain; - -import java.util.List; -import java.util.Map; - -import org.assertj.core.api.SoftAssertions; -import org.junit.Test; -import org.junit.runner.RunWith; -import org.mockito.Mock; -import org.mockito.junit.MockitoJUnitRunner; - -@RunWith(MockitoJUnitRunner.class) -public class BlockValidatorProviderTest { - - @Mock private BlockInterface blockInterface; - @Mock private Blockchain blockchain; - @Mock private EpochManager epochManager; - - @Test - public void nonForkingValidatorProviderHasNoOverrides() { - final BlockValidatorProvider blockValidatorProvider = - BlockValidatorProvider.nonForkingValidatorProvider( - blockchain, epochManager, blockInterface); - - assertThat(blockValidatorProvider.hasValidatorOverridesForBlockNumber(0)).isFalse(); - } - - @Test - public void forkingValidatorProviderHasNoOverrides() { - final BlockValidatorProvider blockValidatorProvider = - BlockValidatorProvider.forkingValidatorProvider( - blockchain, epochManager, blockInterface, new BftValidatorOverrides(emptyMap())); - - assertThat(blockValidatorProvider.hasValidatorOverridesForBlockNumber(0)).isFalse(); - } - - @Test - public void forkingValidatorProviderHasOverridesForBlock1() { - final Map> overriddenValidators = - Map.of(1L, List.of(Address.fromHexString("0"))); - final BftValidatorOverrides bftValidatorOverrides = - new BftValidatorOverrides(overriddenValidators); - final BlockValidatorProvider blockValidatorProvider = - BlockValidatorProvider.forkingValidatorProvider( - blockchain, epochManager, blockInterface, bftValidatorOverrides); - - SoftAssertions.assertSoftly( - (softly) -> { - softly - .assertThat(blockValidatorProvider.hasValidatorOverridesForBlockNumber(0)) - .as("Block 0 should have no overridden validators") - .isFalse(); - softly - .assertThat(blockValidatorProvider.hasValidatorOverridesForBlockNumber(1)) - .as("Block 1 should have some overridden validators") - .isTrue(); - softly - .assertThat(blockValidatorProvider.hasValidatorOverridesForBlockNumber(2)) - .as("Block 2 should have no overridden validators") - .isFalse(); - }); - } -}