Rename BftForksSchedule to ForksSchedule and prepare for some more generic use cases (#3108)

* Rename BftForksSchedule to ForkSchedule
* Make ForksSchedule generic beyond BftConfigOptions to allow it to work for MiningCoordinator
* Extract BftForksScheduleFactory from ForksSchedule
* Move ForksSchedule to common package

Signed-off-by: Simon Dudley <simon.dudley@consensys.net>
pull/3121/head
Simon Dudley 3 years ago committed by Lucas Saldanha
parent 795d0d01ea
commit a154b48f23
  1. 10
      besu/src/main/java/org/hyperledger/besu/controller/IbftBesuControllerBuilder.java
  2. 4
      besu/src/main/java/org/hyperledger/besu/controller/QbftBesuControllerBuilder.java
  3. 49
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/ForksSchedule.java
  4. 5
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolSchedule.java
  5. 39
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BftForksScheduleFactory.java
  6. 11
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/BlockTimer.java
  7. 3
      consensus/common/src/main/java/org/hyperledger/besu/consensus/common/bft/MutableBftConfigOptions.java
  8. 68
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/ForksScheduleTest.java
  9. 3
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BaseBftProtocolScheduleTest.java
  10. 48
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BftForksScheduleFactoryTest.java
  11. 5
      consensus/common/src/test/java/org/hyperledger/besu/consensus/common/bft/BlockTimerTest.java
  12. 4
      consensus/ibft/src/integration-test/java/org/hyperledger/besu/consensus/ibft/support/TestContextBuilder.java
  13. 8
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftForksSchedulesFactory.java
  14. 10
      consensus/ibft/src/main/java/org/hyperledger/besu/consensus/ibft/IbftProtocolSchedule.java
  15. 6
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftForksSchedulesFactoryTest.java
  16. 4
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/IbftProtocolScheduleTest.java
  17. 8
      consensus/ibft/src/test/java/org/hyperledger/besu/consensus/ibft/blockcreation/BftBlockCreatorTest.java
  18. 4
      consensus/qbft/src/integration-test/java/org/hyperledger/besu/consensus/qbft/support/TestContextBuilder.java
  19. 4
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/MutableQbftConfigOptions.java
  20. 8
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftForksSchedulesFactory.java
  21. 8
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/QbftProtocolSchedule.java
  22. 6
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactory.java
  23. 6
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ForkingValidatorProvider.java
  24. 6
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/TransactionValidatorProvider.java
  25. 17
      consensus/qbft/src/main/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLogger.java
  26. 4
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/QbftProtocolScheduleTest.java
  27. 8
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/blockcreation/QbftBlockCreatorFactoryTest.java
  28. 30
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ForkingValidatorProviderTest.java
  29. 8
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/QbftForksSchedulesFactoryTest.java
  30. 7
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/TransactionValidatorProviderTest.java
  31. 24
      consensus/qbft/src/test/java/org/hyperledger/besu/consensus/qbft/validator/ValidatorModeTransitionLoggerTest.java
  32. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/IBFTGenesisFileModule.java
  33. 4
      ethereum/evmtool/src/main/java/org/hyperledger/besu/evmtool/QBFTGenesisFileModule.java

@ -19,11 +19,11 @@ import org.hyperledger.besu.config.BftFork;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.BftValidatorOverrides;
import org.hyperledger.besu.consensus.common.EpochManager;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftContext;
import org.hyperledger.besu.consensus.common.bft.BftEventQueue;
import org.hyperledger.besu.consensus.common.bft.BftExecutors;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftProcessor;
import org.hyperledger.besu.consensus.common.bft.BlockTimer;
import org.hyperledger.besu.consensus.common.bft.EthSynchronizerUpdater;
@ -86,7 +86,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
private static final Logger LOG = LogManager.getLogger();
private BftEventQueue bftEventQueue;
private BftConfigOptions bftConfig;
private BftForksSchedule<BftConfigOptions> bftForksSchedule;
private ForksSchedule<BftConfigOptions> forksSchedule;
private ValidatorPeers peers;
@Override
@ -98,7 +98,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
protected void prepForBuild() {
bftConfig = genesisConfig.getConfigOptions(genesisConfigOverrides).getBftConfigOptions();
bftEventQueue = new BftEventQueue(bftConfig.getMessageQueueLimit());
bftForksSchedule = IbftForksSchedulesFactory.create(genesisConfig.getConfigOptions());
forksSchedule = IbftForksSchedulesFactory.create(genesisConfig.getConfigOptions());
}
@Override
@ -163,7 +163,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
proposerSelector,
uniqueMessageMulticaster,
new RoundTimer(bftEventQueue, bftConfig.getRequestTimeoutSeconds(), bftExecutors),
new BlockTimer(bftEventQueue, bftForksSchedule, bftExecutors, clock),
new BlockTimer(bftEventQueue, forksSchedule, bftExecutors, clock),
blockCreatorFactory,
clock);
@ -235,7 +235,7 @@ public class IbftBesuControllerBuilder extends BftBesuControllerBuilder {
protected ProtocolSchedule createProtocolSchedule() {
return IbftProtocolSchedule.create(
genesisConfig.getConfigOptions(genesisConfigOverrides),
bftForksSchedule,
forksSchedule,
privacyParameters,
isRevertReasonEnabled,
bftExtraDataCodec().get(),

@ -22,11 +22,11 @@ import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.config.QbftFork;
import org.hyperledger.besu.consensus.common.BftValidatorOverrides;
import org.hyperledger.besu.consensus.common.EpochManager;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftContext;
import org.hyperledger.besu.consensus.common.bft.BftEventQueue;
import org.hyperledger.besu.consensus.common.bft.BftExecutors;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftProcessor;
import org.hyperledger.besu.consensus.common.bft.BlockTimer;
import org.hyperledger.besu.consensus.common.bft.EthSynchronizerUpdater;
@ -97,7 +97,7 @@ public class QbftBesuControllerBuilder extends BftBesuControllerBuilder {
private static final Logger LOG = LogManager.getLogger();
private BftEventQueue bftEventQueue;
private QbftConfigOptions qbftConfig;
private BftForksSchedule<QbftConfigOptions> qbftForksSchedule;
private ForksSchedule<QbftConfigOptions> qbftForksSchedule;
private ValidatorPeers peers;
private TransactionValidatorProvider transactionValidatorProvider;

@ -0,0 +1,49 @@
/*
* 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;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;
public class ForksSchedule<C> {
private final NavigableSet<ForkSpec<C>> forks =
new TreeSet<>(
Comparator.comparing((Function<ForkSpec<C>, Long>) ForkSpec::getBlock).reversed());
public ForksSchedule(final ForkSpec<C> genesisFork, final Collection<ForkSpec<C>> forks) {
this.forks.add(genesisFork);
this.forks.addAll(forks);
}
public ForkSpec<C> getFork(final long blockNumber) {
for (final ForkSpec<C> f : forks) {
if (blockNumber >= f.getBlock()) {
return f;
}
}
return forks.first();
}
public Set<ForkSpec<C>> getForks() {
return Collections.unmodifiableSet(forks);
}
}

@ -16,6 +16,7 @@ package org.hyperledger.besu.consensus.common.bft;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
@ -43,14 +44,14 @@ public abstract class BaseBftProtocolSchedule {
public ProtocolSchedule createProtocolSchedule(
final GenesisConfigOptions config,
final BftForksSchedule<? extends BftConfigOptions> bftForksSchedule,
final ForksSchedule<? extends BftConfigOptions> forksSchedule,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
final Map<Long, Function<ProtocolSpecBuilder, ProtocolSpecBuilder>> specMap = new HashMap<>();
bftForksSchedule
forksSchedule
.getForks()
.forEach(
forkSpec ->

@ -1,5 +1,5 @@
/*
* Copyright Hyperledger Besu Contributors.
* 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
@ -19,35 +19,20 @@ import static com.google.common.base.Preconditions.checkArgument;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.BftFork;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import java.util.Collection;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.NavigableSet;
import java.util.Set;
import java.util.TreeSet;
import java.util.function.Function;
import com.google.common.annotations.VisibleForTesting;
public class BftForksSchedule<C extends BftConfigOptions> {
private final NavigableSet<ForkSpec<C>> forks =
new TreeSet<>(
Comparator.comparing((Function<ForkSpec<C>, Long>) ForkSpec::getBlock).reversed());
public class BftForksScheduleFactory {
public interface BftSpecCreator<T extends BftConfigOptions, U extends BftFork> {
T create(ForkSpec<T> lastSpec, U fork);
}
@VisibleForTesting
public BftForksSchedule(final ForkSpec<C> genesisFork, final Collection<ForkSpec<C>> forks) {
this.forks.add(genesisFork);
this.forks.addAll(forks);
}
public static <T extends BftConfigOptions, U extends BftFork> BftForksSchedule<T> create(
public static <T extends BftConfigOptions, U extends BftFork> ForksSchedule<T> create(
final T initial, final List<U> forks, final BftSpecCreator<T, U> specCreator) {
checkArgument(
forks.stream().allMatch(f -> f.getForkBlock() > 0),
@ -68,20 +53,6 @@ public class BftForksSchedule<C extends BftConfigOptions> {
specs.add(new ForkSpec<>(f.getForkBlock(), spec));
});
return new BftForksSchedule<>(initialForkSpec, specs.tailSet(initialForkSpec, false));
}
public ForkSpec<C> getFork(final long blockNumber) {
for (final ForkSpec<C> f : forks) {
if (blockNumber >= f.getBlock()) {
return f;
}
}
return forks.first();
}
public Set<ForkSpec<C>> getForks() {
return Collections.unmodifiableSet(forks);
return new ForksSchedule<>(initialForkSpec, specs.tailSet(initialForkSpec, false));
}
}

@ -15,6 +15,7 @@
package org.hyperledger.besu.consensus.common.bft;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.events.BlockTimerExpiry;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -26,7 +27,7 @@ import java.util.concurrent.TimeUnit;
/** Class for starting and keeping organised block timers */
public class BlockTimer {
private final BftForksSchedule<? extends BftConfigOptions> bftForksSchedule;
private final ForksSchedule<? extends BftConfigOptions> forksSchedule;
private final BftExecutors bftExecutors;
private Optional<ScheduledFuture<?>> currentTimerTask;
private final BftEventQueue queue;
@ -36,17 +37,17 @@ public class BlockTimer {
* Construct a BlockTimer with primed executor service ready to start timers
*
* @param queue The queue in which to put block expiry events
* @param bftForksSchedule Bft fork schedule that contains block period seconds
* @param forksSchedule Bft fork schedule that contains block period seconds
* @param bftExecutors Executor services that timers can be scheduled with
* @param clock System clock
*/
public BlockTimer(
final BftEventQueue queue,
final BftForksSchedule<? extends BftConfigOptions> bftForksSchedule,
final ForksSchedule<? extends BftConfigOptions> forksSchedule,
final BftExecutors bftExecutors,
final Clock clock) {
this.queue = queue;
this.bftForksSchedule = bftForksSchedule;
this.forksSchedule = forksSchedule;
this.bftExecutors = bftExecutors;
this.currentTimerTask = Optional.empty();
this.clock = clock;
@ -81,7 +82,7 @@ public class BlockTimer {
// absolute time when the timer is supposed to expire
final int blockPeriodSeconds =
bftForksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodSeconds();
forksSchedule.getFork(round.getSequenceNumber()).getValue().getBlockPeriodSeconds();
final long minimumTimeBetweenBlocksMillis = blockPeriodSeconds * 1000L;
final long expiryTime = chainHeadHeader.getTimestamp() * 1_000 + minimumTimeBetweenBlocksMillis;

@ -15,6 +15,7 @@
package org.hyperledger.besu.consensus.common.bft;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import java.math.BigInteger;
import java.util.Map;
@ -22,7 +23,7 @@ import java.util.Optional;
/**
* A mutable {@link BftConfigOptions} that is used for building config for transitions in the {@link
* BftForksSchedule}.
* ForksSchedule}.
*/
public class MutableBftConfigOptions implements BftConfigOptions {
private long epochLength;

@ -0,0 +1,68 @@
/*
* 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;
import static org.assertj.core.api.Assertions.assertThat;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.JsonBftConfigOptions;
import org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions;
import java.util.List;
import org.junit.Test;
public class ForksScheduleTest {
@Test
public void retrievesGenesisFork() {
final ForkSpec<BftConfigOptions> genesisForkSpec =
new ForkSpec<>(0, JsonBftConfigOptions.DEFAULT);
final ForksSchedule<BftConfigOptions> schedule =
new ForksSchedule<>(genesisForkSpec, List.of());
assertThat(schedule.getFork(0)).isEqualTo(genesisForkSpec);
assertThat(schedule.getFork(1)).isEqualTo(genesisForkSpec);
}
@Test
public void retrievesLatestFork() {
final ForkSpec<BftConfigOptions> genesisForkSpec =
new ForkSpec<>(0, JsonBftConfigOptions.DEFAULT);
final ForkSpec<BftConfigOptions> forkSpec1 = createForkSpec(1, 10);
final ForkSpec<BftConfigOptions> forkSpec2 = createForkSpec(2, 20);
final ForksSchedule<BftConfigOptions> schedule =
new ForksSchedule<>(genesisForkSpec, List.of(forkSpec1, forkSpec2));
assertThat(schedule.getFork(0)).isEqualTo(genesisForkSpec);
assertThat(schedule.getFork(1)).isEqualTo(forkSpec1);
assertThat(schedule.getFork(2)).isEqualTo(forkSpec2);
assertThat(schedule.getFork(3)).isEqualTo(forkSpec2);
}
private ForkSpec<BftConfigOptions> createForkSpec(
final long block, final int blockPeriodSeconds) {
final MutableBftConfigOptions bftConfigOptions = createBftConfigOptions(blockPeriodSeconds);
return new ForkSpec<>(block, bftConfigOptions);
}
private MutableBftConfigOptions createBftConfigOptions(final int blockPeriodSeconds) {
final MutableBftConfigOptions bftConfigOptions =
new MutableBftConfigOptions(JsonBftConfigOptions.DEFAULT);
bftConfigOptions.setBlockPeriodSeconds(blockPeriodSeconds);
return bftConfigOptions;
}
}

@ -24,6 +24,7 @@ import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.JsonBftConfigOptions;
import org.hyperledger.besu.config.TransitionsConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -194,7 +195,7 @@ public class BaseBftProtocolScheduleTest {
};
return bftProtocolSchedule.createProtocolSchedule(
genesisConfig,
new BftForksSchedule<>(genesisFork, forks),
new ForksSchedule<>(genesisFork, forks),
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,

@ -1,5 +1,5 @@
/*
* Copyright Hyperledger Besu Contributors.
* 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
@ -23,7 +23,8 @@ import org.hyperledger.besu.config.BftFork;
import org.hyperledger.besu.config.JsonBftConfigOptions;
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule.BftSpecCreator;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftForksScheduleFactory.BftSpecCreator;
import java.util.List;
import java.util.Map;
@ -31,34 +32,7 @@ import java.util.Map;
import org.junit.Test;
import org.mockito.Mockito;
public class BftForksScheduleTest {
@Test
public void retrievesGenesisFork() {
final ForkSpec<BftConfigOptions> genesisForkSpec =
new ForkSpec<>(0, JsonBftConfigOptions.DEFAULT);
final BftForksSchedule<BftConfigOptions> schedule =
new BftForksSchedule<>(genesisForkSpec, List.of());
assertThat(schedule.getFork(0)).isEqualTo(genesisForkSpec);
assertThat(schedule.getFork(1)).isEqualTo(genesisForkSpec);
}
@Test
public void retrievesLatestFork() {
final ForkSpec<BftConfigOptions> genesisForkSpec =
new ForkSpec<>(0, JsonBftConfigOptions.DEFAULT);
final ForkSpec<BftConfigOptions> forkSpec1 = createForkSpec(1, 10);
final ForkSpec<BftConfigOptions> forkSpec2 = createForkSpec(2, 20);
final BftForksSchedule<BftConfigOptions> schedule =
new BftForksSchedule<>(genesisForkSpec, List.of(forkSpec1, forkSpec2));
assertThat(schedule.getFork(0)).isEqualTo(genesisForkSpec);
assertThat(schedule.getFork(1)).isEqualTo(forkSpec1);
assertThat(schedule.getFork(2)).isEqualTo(forkSpec2);
assertThat(schedule.getFork(3)).isEqualTo(forkSpec2);
}
public class BftForksScheduleFactoryTest {
@Test
@SuppressWarnings("unchecked")
@ -69,7 +43,7 @@ public class BftForksScheduleTest {
Mockito.mock(BftSpecCreator.class);
assertThatThrownBy(
() -> BftForksSchedule.create(genesisConfigOptions, List.of(fork), specCreator))
() -> BftForksScheduleFactory.create(genesisConfigOptions, List.of(fork), specCreator))
.hasMessage("Transition cannot be created for genesis block");
}
@ -85,7 +59,7 @@ public class BftForksScheduleTest {
assertThatThrownBy(
() ->
BftForksSchedule.create(
BftForksScheduleFactory.create(
genesisConfigOptions, List.of(fork1, fork2, fork3), specCreator))
.hasMessage("Duplicate transitions cannot be created for the same block");
}
@ -105,19 +79,13 @@ public class BftForksScheduleTest {
when(specCreator.create(genesisForkSpec, fork1)).thenReturn(configOptions1);
when(specCreator.create(new ForkSpec<>(1, configOptions1), fork2)).thenReturn(configOptions2);
final BftForksSchedule<BftConfigOptions> schedule =
BftForksSchedule.create(genesisConfigOptions, List.of(fork1, fork2), specCreator);
final ForksSchedule<BftConfigOptions> schedule =
BftForksScheduleFactory.create(genesisConfigOptions, List.of(fork1, fork2), specCreator);
assertThat(schedule.getFork(0)).isEqualTo(genesisForkSpec);
assertThat(schedule.getFork(1)).isEqualTo(new ForkSpec<>(1, configOptions1));
assertThat(schedule.getFork(2)).isEqualTo(new ForkSpec<>(2, configOptions2));
}
private ForkSpec<BftConfigOptions> createForkSpec(
final long block, final int blockPeriodSeconds) {
final MutableBftConfigOptions bftConfigOptions = createBftConfigOptions(blockPeriodSeconds);
return new ForkSpec<>(block, bftConfigOptions);
}
private MutableBftConfigOptions createBftConfigOptions(final int blockPeriodSeconds) {
final MutableBftConfigOptions bftConfigOptions =
new MutableBftConfigOptions(JsonBftConfigOptions.DEFAULT);

@ -27,6 +27,7 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.JsonBftConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.events.BftEvent;
import org.hyperledger.besu.consensus.common.bft.events.BlockTimerExpiry;
import org.hyperledger.besu.ethereum.core.BlockHeader;
@ -49,7 +50,7 @@ public class BlockTimerTest {
private BftExecutors bftExecutors;
private BftEventQueue mockQueue;
private Clock mockClock;
private BftForksSchedule<BftConfigOptions> mockForksSchedule;
private ForksSchedule<BftConfigOptions> mockForksSchedule;
@Before
@SuppressWarnings("unchecked")
@ -57,7 +58,7 @@ public class BlockTimerTest {
bftExecutors = mock(BftExecutors.class);
mockQueue = mock(BftEventQueue.class);
mockClock = mock(Clock.class);
mockForksSchedule = mock(BftForksSchedule.class);
mockForksSchedule = mock(ForksSchedule.class);
}
@Test

@ -23,13 +23,13 @@ import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.BftFork;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.consensus.common.EpochManager;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions;
import org.hyperledger.besu.consensus.common.bft.BftBlockInterface;
import org.hyperledger.besu.consensus.common.bft.BftContext;
import org.hyperledger.besu.consensus.common.bft.BftEventQueue;
import org.hyperledger.besu.consensus.common.bft.BftExecutors;
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftHelpers;
import org.hyperledger.besu.consensus.common.bft.BlockTimer;
import org.hyperledger.besu.consensus.common.bft.EventMultiplexer;
@ -307,7 +307,7 @@ public class TestContextBuilder {
genesisConfigOptions.byzantiumBlock(0);
genesisConfigOptions.transitions(TestTransitions.createIbftTestTransitions(bftForks));
final BftForksSchedule<BftConfigOptions> forksSchedule =
final ForksSchedule<BftConfigOptions> forksSchedule =
IbftForksSchedulesFactory.create(genesisConfigOptions);
final ProtocolSchedule protocolSchedule =

@ -18,14 +18,14 @@ import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.BftFork;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftForksScheduleFactory;
import org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions;
public class IbftForksSchedulesFactory {
public static BftForksSchedule<BftConfigOptions> create(
final GenesisConfigOptions genesisConfig) {
return BftForksSchedule.create(
public static ForksSchedule<BftConfigOptions> create(final GenesisConfigOptions genesisConfig) {
return BftForksScheduleFactory.create(
genesisConfig.getBftConfigOptions(),
genesisConfig.getTransitions().getIbftForks(),
IbftForksSchedulesFactory::createBftConfigOptions);

@ -16,9 +16,9 @@ package org.hyperledger.besu.consensus.ibft;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolSchedule;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -31,7 +31,7 @@ public class IbftProtocolSchedule extends BaseBftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final BftForksSchedule<BftConfigOptions> bftForksSchedule,
final ForksSchedule<BftConfigOptions> forksSchedule,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
@ -39,7 +39,7 @@ public class IbftProtocolSchedule extends BaseBftProtocolSchedule {
return new IbftProtocolSchedule()
.createProtocolSchedule(
config,
bftForksSchedule,
forksSchedule,
privacyParameters,
isRevertReasonEnabled,
bftExtraDataCodec,
@ -48,12 +48,12 @@ public class IbftProtocolSchedule extends BaseBftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final BftForksSchedule<BftConfigOptions> bftForksSchedule,
final ForksSchedule<BftConfigOptions> forksSchedule,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
return create(
config,
bftForksSchedule,
forksSchedule,
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,

@ -24,7 +24,7 @@ import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.config.TransitionsConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions;
import java.util.HashMap;
@ -44,7 +44,7 @@ public class IbftForksSchedulesFactoryTest {
final StubGenesisConfigOptions genesisConfigOptions = new StubGenesisConfigOptions();
genesisConfigOptions.bftConfigOptions(bftConfigOptions);
final BftForksSchedule<BftConfigOptions> forksSchedule =
final ForksSchedule<BftConfigOptions> forksSchedule =
IbftForksSchedulesFactory.create(genesisConfigOptions);
assertThat(forksSchedule.getFork(0)).usingRecursiveComparison().isEqualTo(expectedForkSpec);
assertThat(forksSchedule.getFork(1)).usingRecursiveComparison().isEqualTo(expectedForkSpec);
@ -66,7 +66,7 @@ public class IbftForksSchedulesFactoryTest {
BftFork.BLOCK_REWARD_KEY,
"5"));
final BftForksSchedule<BftConfigOptions> forksSchedule =
final ForksSchedule<BftConfigOptions> forksSchedule =
IbftForksSchedulesFactory.create(createGenesisConfig(configOptions, fork));
assertThat(forksSchedule.getFork(0))
.usingRecursiveComparison()

@ -27,10 +27,10 @@ import org.hyperledger.besu.config.JsonGenesisConfigOptions;
import org.hyperledger.besu.config.JsonQbftConfigOptions;
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftContext;
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions;
import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.crypto.NodeKeyUtils;
@ -95,7 +95,7 @@ public class IbftProtocolScheduleTest {
final List<ForkSpec<BftConfigOptions>> forks) {
return IbftProtocolSchedule.create(
genesisConfig,
new BftForksSchedule<>(genesisFork, forks),
new ForksSchedule<>(genesisFork, forks),
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,

@ -25,10 +25,10 @@ import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigFile;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolSchedule;
import org.hyperledger.besu.consensus.common.bft.BftBlockHashing;
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreator;
import org.hyperledger.besu.consensus.ibft.IbftBlockHeaderValidationRulesetFactory;
import org.hyperledger.besu.consensus.ibft.IbftExtraDataCodec;
@ -97,12 +97,12 @@ public class BftBlockCreatorTest {
final GenesisConfigOptions configOptions =
GenesisConfigFile.fromConfig("{\"config\": {\"spuriousDragonBlock\":0}}")
.getConfigOptions();
final BftForksSchedule<BftConfigOptions> bftForksSchedule =
new BftForksSchedule<>(new ForkSpec<>(0, configOptions.getBftConfigOptions()), List.of());
final ForksSchedule<BftConfigOptions> forksSchedule =
new ForksSchedule<>(new ForkSpec<>(0, configOptions.getBftConfigOptions()), List.of());
final ProtocolSchedule protocolSchedule =
bftProtocolSchedule.createProtocolSchedule(
configOptions,
bftForksSchedule,
forksSchedule,
PrivacyParameters.DEFAULT,
false,
bftExtraDataEncoder,

@ -27,6 +27,7 @@ import org.hyperledger.besu.config.QbftFork;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.consensus.common.BftValidatorOverrides;
import org.hyperledger.besu.consensus.common.EpochManager;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions;
import org.hyperledger.besu.consensus.common.bft.BftBlockInterface;
import org.hyperledger.besu.consensus.common.bft.BftContext;
@ -34,7 +35,6 @@ import org.hyperledger.besu.consensus.common.bft.BftEventQueue;
import org.hyperledger.besu.consensus.common.bft.BftExecutors;
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftHelpers;
import org.hyperledger.besu.consensus.common.bft.BlockTimer;
import org.hyperledger.besu.consensus.common.bft.EventMultiplexer;
@ -408,7 +408,7 @@ public class TestContextBuilder {
final BftBlockInterface blockInterface = new BftBlockInterface(BFT_EXTRA_DATA_ENCODER);
final BftForksSchedule<QbftConfigOptions> forksSchedule =
final ForksSchedule<QbftConfigOptions> forksSchedule =
QbftForksSchedulesFactory.create(genesisConfigOptions);
final ProtocolSchedule protocolSchedule =

@ -15,7 +15,7 @@
package org.hyperledger.besu.consensus.qbft;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions;
import java.util.Optional;
@ -23,7 +23,7 @@ import java.util.OptionalLong;
/**
* A mutable {@link QbftConfigOptions} that is used for building config for transitions in the
* {@link BftForksSchedule}.
* {@link ForksSchedule}.
*/
public class MutableQbftConfigOptions extends MutableBftConfigOptions implements QbftConfigOptions {
private Optional<String> validatorContractAddress;

@ -19,16 +19,16 @@ import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.config.QbftFork;
import org.hyperledger.besu.config.QbftFork.VALIDATOR_SELECTION_MODE;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftForksScheduleFactory;
import java.util.List;
import java.util.Optional;
public class QbftForksSchedulesFactory {
public static BftForksSchedule<QbftConfigOptions> create(
final GenesisConfigOptions genesisConfig) {
return BftForksSchedule.create(
public static ForksSchedule<QbftConfigOptions> create(final GenesisConfigOptions genesisConfig) {
return BftForksScheduleFactory.create(
genesisConfig.getQbftConfigOptions(),
genesisConfig.getTransitions().getQbftForks(),
QbftForksSchedulesFactory::createQbftConfigOptions);

@ -19,9 +19,9 @@ import static com.google.common.base.Preconditions.checkArgument;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BaseBftProtocolSchedule;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.ethereum.core.PrivacyParameters;
import org.hyperledger.besu.ethereum.mainnet.BlockHeaderValidator;
import org.hyperledger.besu.ethereum.mainnet.ProtocolSchedule;
@ -34,7 +34,7 @@ public class QbftProtocolSchedule extends BaseBftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final BftForksSchedule<QbftConfigOptions> qbftForksSchedule,
final ForksSchedule<QbftConfigOptions> qbftForksSchedule,
final PrivacyParameters privacyParameters,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec,
@ -51,7 +51,7 @@ public class QbftProtocolSchedule extends BaseBftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final BftForksSchedule<QbftConfigOptions> qbftForksSchedule,
final ForksSchedule<QbftConfigOptions> qbftForksSchedule,
final BftExtraDataCodec bftExtraDataCodec,
final EvmConfiguration evmConfiguration) {
return create(
@ -65,7 +65,7 @@ public class QbftProtocolSchedule extends BaseBftProtocolSchedule {
public static ProtocolSchedule create(
final GenesisConfigOptions config,
final BftForksSchedule<QbftConfigOptions> qbftForksSchedule,
final ForksSchedule<QbftConfigOptions> qbftForksSchedule,
final boolean isRevertReasonEnabled,
final BftExtraDataCodec bftExtraDataCodec) {
return create(

@ -16,9 +16,9 @@ package org.hyperledger.besu.consensus.qbft.blockcreation;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ConsensusHelpers;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.bft.blockcreation.BftBlockCreatorFactory;
import org.hyperledger.besu.consensus.qbft.QbftContext;
import org.hyperledger.besu.datatypes.Address;
@ -36,7 +36,7 @@ import org.apache.tuweni.bytes.Bytes;
/** Supports contract based voters and validators in extra data */
public class QbftBlockCreatorFactory extends BftBlockCreatorFactory {
private final BftForksSchedule<QbftConfigOptions> forksSchedule;
private final ForksSchedule<QbftConfigOptions> forksSchedule;
public QbftBlockCreatorFactory(
final AbstractPendingTransactionsSorter pendingTransactions,
@ -46,7 +46,7 @@ public class QbftBlockCreatorFactory extends BftBlockCreatorFactory {
final Address localAddress,
final Address miningBeneficiary,
final BftExtraDataCodec bftExtraDataCodec,
final BftForksSchedule<QbftConfigOptions> forksSchedule) {
final ForksSchedule<QbftConfigOptions> forksSchedule) {
super(
pendingTransactions,
protocolContext,

@ -17,7 +17,7 @@ package org.hyperledger.besu.consensus.qbft.validator;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.consensus.common.validator.VoteProvider;
import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider;
@ -31,13 +31,13 @@ import java.util.Optional;
public class ForkingValidatorProvider implements ValidatorProvider {
private final Blockchain blockchain;
private final BftForksSchedule<QbftConfigOptions> forksSchedule;
private final ForksSchedule<QbftConfigOptions> forksSchedule;
private final BlockValidatorProvider blockValidatorProvider;
private final TransactionValidatorProvider transactionValidatorProvider;
public ForkingValidatorProvider(
final Blockchain blockchain,
final BftForksSchedule<QbftConfigOptions> forksSchedule,
final ForksSchedule<QbftConfigOptions> forksSchedule,
final BlockValidatorProvider blockValidatorProvider,
final TransactionValidatorProvider transactionValidatorProvider) {
this.blockchain = blockchain;

@ -15,7 +15,7 @@
package org.hyperledger.besu.consensus.qbft.validator;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.validator.ValidatorProvider;
import org.hyperledger.besu.consensus.common.validator.VoteProvider;
import org.hyperledger.besu.datatypes.Address;
@ -34,7 +34,7 @@ public class TransactionValidatorProvider implements ValidatorProvider {
private final Blockchain blockchain;
private final ValidatorContractController validatorContractController;
private final BftForksSchedule<QbftConfigOptions> forksSchedule;
private final ForksSchedule<QbftConfigOptions> forksSchedule;
private final Cache<Long, Collection<Address>> afterBlockValidatorCache =
CacheBuilder.newBuilder().maximumSize(100).build();
private final Cache<Long, Collection<Address>> forBlockValidatorCache =
@ -43,7 +43,7 @@ public class TransactionValidatorProvider implements ValidatorProvider {
public TransactionValidatorProvider(
final Blockchain blockchain,
final ValidatorContractController validatorContractController,
final BftForksSchedule<QbftConfigOptions> forksSchedule) {
final ForksSchedule<QbftConfigOptions> forksSchedule) {
this.blockchain = blockchain;
this.validatorContractController = validatorContractController;
this.forksSchedule = forksSchedule;

@ -17,7 +17,7 @@ package org.hyperledger.besu.consensus.qbft.validator;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import java.util.function.Consumer;
@ -30,27 +30,26 @@ public class ValidatorModeTransitionLogger {
private static final Logger LOG = LogManager.getLogger();
private final BftForksSchedule<QbftConfigOptions> bftForksSchedule;
private final ForksSchedule<QbftConfigOptions> forksSchedule;
private final Consumer<String> msgConsumer;
public ValidatorModeTransitionLogger(final BftForksSchedule<QbftConfigOptions> bftForksSchedule) {
this.bftForksSchedule = bftForksSchedule;
public ValidatorModeTransitionLogger(final ForksSchedule<QbftConfigOptions> forksSchedule) {
this.forksSchedule = forksSchedule;
this.msgConsumer = LOG::info;
}
@VisibleForTesting
ValidatorModeTransitionLogger(
final BftForksSchedule<QbftConfigOptions> bftForksSchedule,
final Consumer<String> msgConsumer) {
this.bftForksSchedule = bftForksSchedule;
final ForksSchedule<QbftConfigOptions> forksSchedule, final Consumer<String> msgConsumer) {
this.forksSchedule = forksSchedule;
this.msgConsumer = msgConsumer;
}
public void logTransitionChange(final BlockHeader parentHeader) {
final ForkSpec<QbftConfigOptions> currentForkSpec =
bftForksSchedule.getFork(parentHeader.getNumber());
forksSchedule.getFork(parentHeader.getNumber());
final ForkSpec<QbftConfigOptions> nextForkSpec =
bftForksSchedule.getFork(parentHeader.getNumber() + 1L);
forksSchedule.getFork(parentHeader.getNumber() + 1L);
final QbftConfigOptions currentConfigOptions = currentForkSpec.getValue();
final QbftConfigOptions nextConfigOptions = nextForkSpec.getValue();

@ -25,8 +25,8 @@ import org.hyperledger.besu.config.JsonQbftConfigOptions;
import org.hyperledger.besu.config.JsonUtil;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftExtraDataCodec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.crypto.NodeKey;
import org.hyperledger.besu.crypto.NodeKeyUtils;
import org.hyperledger.besu.datatypes.Address;
@ -124,7 +124,7 @@ public class QbftProtocolScheduleTest {
final List<ForkSpec<QbftConfigOptions>> forks) {
return QbftProtocolSchedule.create(
genesisConfig,
new BftForksSchedule<>(genesisFork, forks),
new ForksSchedule<>(genesisFork, forks),
PrivacyParameters.DEFAULT,
false,
bftExtraDataCodec,

@ -23,8 +23,8 @@ import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.JsonQbftConfigOptions;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftExtraData;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions;
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
import org.hyperledger.besu.datatypes.Address;
@ -54,8 +54,8 @@ public class QbftBlockCreatorFactoryTest {
new MutableQbftConfigOptions(JsonQbftConfigOptions.DEFAULT);
qbftConfigOptions.setValidatorContractAddress(Optional.of("1"));
final ForkSpec<QbftConfigOptions> spec = new ForkSpec<>(0, qbftConfigOptions);
final BftForksSchedule<QbftConfigOptions> bftForksSchedule = mock(BftForksSchedule.class);
when(bftForksSchedule.getFork(anyLong())).thenReturn(spec);
final ForksSchedule<QbftConfigOptions> forksSchedule = mock(ForksSchedule.class);
when(forksSchedule.getFork(anyLong())).thenReturn(spec);
qbftBlockCreatorFactory =
new QbftBlockCreatorFactory(
@ -66,7 +66,7 @@ public class QbftBlockCreatorFactoryTest {
mock(Address.class),
mock(Address.class),
extraDataCodec,
bftForksSchedule);
forksSchedule);
}
@Test

@ -26,7 +26,7 @@ import static org.mockito.Mockito.verifyNoInteractions;
import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.validator.VoteProvider;
import org.hyperledger.besu.consensus.common.validator.blockbased.BlockValidatorProvider;
import org.hyperledger.besu.datatypes.Address;
@ -97,8 +97,8 @@ public class ForkingValidatorProviderTest {
@Test
public void usesInitialValidatorProviderWhenNoForks() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(createBlockForkSpec(0), List.of());
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(createBlockForkSpec(0), List.of());
final ForkingValidatorProvider validatorProvider =
new ForkingValidatorProvider(
@ -114,8 +114,8 @@ public class ForkingValidatorProviderTest {
@Test
public void migratesFromBlockToContractValidatorProvider() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(
createBlockForkSpec(0), List.of(createContractForkSpec(1L, CONTRACT_ADDRESS_1)));
final ForkingValidatorProvider validatorProvider =
new ForkingValidatorProvider(
@ -127,8 +127,8 @@ public class ForkingValidatorProviderTest {
@Test
public void migratesFromContractToBlockValidatorProvider() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(
createContractForkSpec(0, CONTRACT_ADDRESS_1), List.of(createBlockForkSpec(1)));
final ForkingValidatorProvider validatorProvider =
new ForkingValidatorProvider(
@ -145,8 +145,8 @@ public class ForkingValidatorProviderTest {
@Test
public void migratesFromContractToContractValidatorProvider() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(
createBlockForkSpec(0),
List.of(
createContractForkSpec(1L, CONTRACT_ADDRESS_1),
@ -163,8 +163,8 @@ public class ForkingValidatorProviderTest {
@Test
public void voteProviderIsDelegatesToHeadFork_whenHeadIsContractFork() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(
createBlockForkSpec(0),
List.of(createBlockForkSpec(1), createContractForkSpec(2, CONTRACT_ADDRESS_1)));
@ -180,8 +180,8 @@ public class ForkingValidatorProviderTest {
@Test
public void voteProviderIsDelegatesToHeadFork_whenHeadIsBlockFork() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(createBlockForkSpec(0), emptyList());
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(createBlockForkSpec(0), emptyList());
final ForkingValidatorProvider validatorProvider =
new ForkingValidatorProvider(
@ -195,8 +195,8 @@ public class ForkingValidatorProviderTest {
@Test
public void getVoteProviderAfterBlock_correctVoteProviderIsResolved() {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
new BftForksSchedule<>(
final ForksSchedule<QbftConfigOptions> forksSchedule =
new ForksSchedule<>(
createBlockForkSpec(0),
List.of(createBlockForkSpec(1), createContractForkSpec(2, CONTRACT_ADDRESS_1)));
final ForkingValidatorProvider validatorProvider =

@ -27,7 +27,7 @@ import org.hyperledger.besu.config.QbftFork.VALIDATOR_SELECTION_MODE;
import org.hyperledger.besu.config.StubGenesisConfigOptions;
import org.hyperledger.besu.config.TransitionsConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions;
import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory;
import org.hyperledger.besu.datatypes.Address;
@ -53,7 +53,7 @@ public class QbftForksSchedulesFactoryTest {
final StubGenesisConfigOptions genesisConfigOptions = new StubGenesisConfigOptions();
genesisConfigOptions.qbftConfigOptions(qbftConfigOptions);
final BftForksSchedule<QbftConfigOptions> forksSchedule =
final ForksSchedule<QbftConfigOptions> forksSchedule =
QbftForksSchedulesFactory.create(genesisConfigOptions);
assertThat(forksSchedule.getFork(0)).usingRecursiveComparison().isEqualTo(expectedForkSpec);
assertThat(forksSchedule.getFork(1)).usingRecursiveComparison().isEqualTo(expectedForkSpec);
@ -81,7 +81,7 @@ public class QbftForksSchedulesFactoryTest {
QbftFork.VALIDATOR_CONTRACT_ADDRESS_KEY,
"10"));
final BftForksSchedule<QbftConfigOptions> forksSchedule =
final ForksSchedule<QbftConfigOptions> forksSchedule =
QbftForksSchedulesFactory.create(createGenesisConfig(configOptions, fork));
assertThat(forksSchedule.getFork(0))
.usingRecursiveComparison()
@ -141,7 +141,7 @@ public class QbftForksSchedulesFactoryTest {
BftFork.VALIDATORS_KEY,
JsonUtil.getObjectMapper().createArrayNode().addAll(jsonValidators)));
final BftForksSchedule<QbftConfigOptions> forksSchedule =
final ForksSchedule<QbftConfigOptions> forksSchedule =
QbftForksSchedulesFactory.create(createGenesisConfig(configOptions, fork));
assertThat(forksSchedule.getFork(1).getValue().getValidatorContractAddress()).isEmpty();

@ -24,7 +24,7 @@ import static org.mockito.Mockito.verifyNoMoreInteractions;
import static org.mockito.Mockito.when;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.ethereum.chain.MutableBlockchain;
@ -54,15 +54,14 @@ public class TransactionValidatorProviderTest {
protected Block block_1;
protected Block block_2;
private Block block_3;
private BftForksSchedule<QbftConfigOptions> forksSchedule;
private ForksSchedule<QbftConfigOptions> forksSchedule;
private final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture();
private static final Address CONTRACT_ADDRESS = Address.fromHexString("1");
@Before
public void setup() {
forksSchedule =
new BftForksSchedule<>(createContractForkSpec(0L, CONTRACT_ADDRESS), emptyList());
forksSchedule = new ForksSchedule<>(createContractForkSpec(0L, CONTRACT_ADDRESS), emptyList());
genesisBlock = createEmptyBlock(0, Hash.ZERO);
blockChain = createInMemoryBlockchain(genesisBlock);
headerBuilder.extraData(Bytes.wrap(new byte[32]));

@ -24,7 +24,7 @@ import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.JsonQbftConfigOptions;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForkSpec;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.qbft.MutableQbftConfigOptions;
import org.hyperledger.besu.ethereum.core.BlockHeader;
import org.hyperledger.besu.ethereum.core.BlockHeaderTestFixture;
@ -41,7 +41,7 @@ import org.mockito.junit.MockitoJUnitRunner;
@RunWith(MockitoJUnitRunner.class)
public class ValidatorModeTransitionLoggerTest {
@Mock private BftForksSchedule<BftConfigOptions> bftForksSchedule;
@Mock private ForksSchedule<BftConfigOptions> forksSchedule;
@Mock private Consumer<String> msgConsumer;
@ -54,8 +54,8 @@ public class ValidatorModeTransitionLoggerTest {
final ForkSpec<BftConfigOptions> forkSpecB =
new ForkSpec<>(1, createQbftConfigOptionsForBlockHeader());
when(bftForksSchedule.getFork(0)).thenReturn(forkSpecA);
when(bftForksSchedule.getFork(1)).thenReturn(forkSpecB);
when(forksSchedule.getFork(0)).thenReturn(forkSpecA);
when(forksSchedule.getFork(1)).thenReturn(forkSpecB);
qbftTransitionNotifier.logTransitionChange(blockHeader(0));
@ -69,8 +69,8 @@ public class ValidatorModeTransitionLoggerTest {
final ForkSpec<BftConfigOptions> contractForkSpecB =
new ForkSpec<>(1, createQbftConfigOptionsForContract("0x0"));
when(bftForksSchedule.getFork(0)).thenReturn(contractForkSpecA);
when(bftForksSchedule.getFork(1)).thenReturn(contractForkSpecB);
when(forksSchedule.getFork(0)).thenReturn(contractForkSpecA);
when(forksSchedule.getFork(1)).thenReturn(contractForkSpecB);
qbftTransitionNotifier.logTransitionChange(blockHeader(0));
@ -84,8 +84,8 @@ public class ValidatorModeTransitionLoggerTest {
final ForkSpec<BftConfigOptions> contractForkSpecB =
new ForkSpec<>(1, createQbftConfigOptionsForContract("0x1"));
when(bftForksSchedule.getFork(0)).thenReturn(contractForkSpecA);
when(bftForksSchedule.getFork(1)).thenReturn(contractForkSpecB);
when(forksSchedule.getFork(0)).thenReturn(contractForkSpecA);
when(forksSchedule.getFork(1)).thenReturn(contractForkSpecB);
qbftTransitionNotifier.logTransitionChange(blockHeader(0));
@ -101,8 +101,8 @@ public class ValidatorModeTransitionLoggerTest {
final ForkSpec<BftConfigOptions> blockForkSpec =
new ForkSpec<>(1, createQbftConfigOptionsForBlockHeader());
when(bftForksSchedule.getFork(0)).thenReturn(contractForkSpec);
when(bftForksSchedule.getFork(1)).thenReturn(blockForkSpec);
when(forksSchedule.getFork(0)).thenReturn(contractForkSpec);
when(forksSchedule.getFork(1)).thenReturn(blockForkSpec);
qbftTransitionNotifier.logTransitionChange(blockHeader(0));
@ -118,8 +118,8 @@ public class ValidatorModeTransitionLoggerTest {
final ForkSpec<BftConfigOptions> contractForkSpec =
new ForkSpec<>(1, createQbftConfigOptionsForContract("0x0"));
when(bftForksSchedule.getFork(0)).thenReturn(blockForkSpec);
when(bftForksSchedule.getFork(1)).thenReturn(contractForkSpec);
when(forksSchedule.getFork(0)).thenReturn(blockForkSpec);
when(forksSchedule.getFork(1)).thenReturn(contractForkSpec);
qbftTransitionNotifier.logTransitionChange(blockHeader(0));

@ -17,8 +17,8 @@ package org.hyperledger.besu.evmtool;
import org.hyperledger.besu.config.BftConfigOptions;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.ibft.IbftExtraDataCodec;
import org.hyperledger.besu.consensus.ibft.IbftForksSchedulesFactory;
import org.hyperledger.besu.consensus.ibft.IbftProtocolSchedule;
@ -39,7 +39,7 @@ class IBFTGenesisFileModule extends GenesisFileModule {
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
final BftForksSchedule<BftConfigOptions> forksSchedule =
final ForksSchedule<BftConfigOptions> forksSchedule =
IbftForksSchedulesFactory.create(configOptions);
return IbftProtocolSchedule.create(
configOptions, forksSchedule, bftExtraDataEncoder, EvmConfiguration.DEFAULT);

@ -16,8 +16,8 @@ package org.hyperledger.besu.evmtool;
import org.hyperledger.besu.config.GenesisConfigOptions;
import org.hyperledger.besu.config.QbftConfigOptions;
import org.hyperledger.besu.consensus.common.ForksSchedule;
import org.hyperledger.besu.consensus.common.bft.BftBlockHeaderFunctions;
import org.hyperledger.besu.consensus.common.bft.BftForksSchedule;
import org.hyperledger.besu.consensus.qbft.QbftExtraDataCodec;
import org.hyperledger.besu.consensus.qbft.QbftForksSchedulesFactory;
import org.hyperledger.besu.consensus.qbft.QbftProtocolSchedule;
@ -38,7 +38,7 @@ class QBFTGenesisFileModule extends GenesisFileModule {
ProtocolSchedule provideProtocolSchedule(
final GenesisConfigOptions configOptions,
@Named("RevertReasonEnabled") final boolean revertReasonEnabled) {
final BftForksSchedule<QbftConfigOptions> forksSchedule =
final ForksSchedule<QbftConfigOptions> forksSchedule =
QbftForksSchedulesFactory.create(configOptions);
return QbftProtocolSchedule.create(
configOptions, forksSchedule, revertReasonEnabled, bftExtraDataEncoder);

Loading…
Cancel
Save