use of org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions in project besu by hyperledger.
the class IbftForksSchedulesFactoryTest method createsScheduleWithForkThatOverridesGenesisValues.
@Test
public void createsScheduleWithForkThatOverridesGenesisValues() {
final MutableBftConfigOptions configOptions = new MutableBftConfigOptions(JsonBftConfigOptions.DEFAULT);
final ObjectNode fork = JsonUtil.objectNodeFromMap(Map.of(BftFork.FORK_BLOCK_KEY, 1, BftFork.BLOCK_PERIOD_SECONDS_KEY, 10, BftFork.BLOCK_REWARD_KEY, "5"));
final ForksSchedule<BftConfigOptions> forksSchedule = IbftForksSchedulesFactory.create(createGenesisConfig(configOptions, fork));
assertThat(forksSchedule.getFork(0)).usingRecursiveComparison().isEqualTo(new ForkSpec<>(0, configOptions));
final Map<String, Object> forkOptions = new HashMap<>(configOptions.asMap());
forkOptions.put(BftFork.BLOCK_PERIOD_SECONDS_KEY, 10);
forkOptions.put(BftFork.BLOCK_REWARD_KEY, "5");
final BftConfigOptions expectedForkConfig = new MutableBftConfigOptions(new JsonBftConfigOptions(JsonUtil.objectNodeFromMap(forkOptions)));
final ForkSpec<BftConfigOptions> expectedFork = new ForkSpec<>(1, expectedForkConfig);
assertThat(forksSchedule.getFork(1)).usingRecursiveComparison().isEqualTo(expectedFork);
assertThat(forksSchedule.getFork(2)).usingRecursiveComparison().isEqualTo(expectedFork);
}
use of org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions in project besu by hyperledger.
the class ForksScheduleTest method createBftConfigOptions.
private MutableBftConfigOptions createBftConfigOptions(final int blockPeriodSeconds) {
final MutableBftConfigOptions bftConfigOptions = new MutableBftConfigOptions(JsonBftConfigOptions.DEFAULT);
bftConfigOptions.setBlockPeriodSeconds(blockPeriodSeconds);
return bftConfigOptions;
}
use of org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions in project besu by hyperledger.
the class IbftForksSchedulesFactory method createBftConfigOptions.
private static BftConfigOptions createBftConfigOptions(final ForkSpec<BftConfigOptions> lastSpec, final BftFork fork) {
final MutableBftConfigOptions bftConfigOptions = new MutableBftConfigOptions(lastSpec.getValue());
fork.getBlockPeriodSeconds().ifPresent(bftConfigOptions::setBlockPeriodSeconds);
fork.getBlockRewardWei().ifPresent(bftConfigOptions::setBlockRewardWei);
if (fork.isMiningBeneficiaryConfigured()) {
// Only override if mining beneficiary is explicitly configured
bftConfigOptions.setMiningBeneficiary(fork.getMiningBeneficiary());
}
return bftConfigOptions;
}
use of org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions in project besu by hyperledger.
the class IbftForksSchedulesFactoryTest method createBftOptions.
@Override
protected BftConfigOptions createBftOptions(final Consumer<MutableBftConfigOptions> optionModifier) {
final MutableBftConfigOptions options = new MutableBftConfigOptions(JsonBftConfigOptions.DEFAULT);
optionModifier.accept(options);
return options;
}
use of org.hyperledger.besu.consensus.common.bft.MutableBftConfigOptions in project besu by hyperledger.
the class IbftProtocolScheduleTest method blockModeTransitionsCreatesBlockModeHeaderValidators.
@Test
public void blockModeTransitionsCreatesBlockModeHeaderValidators() {
final MutableBftConfigOptions arbitraryTransition = new MutableBftConfigOptions(JsonQbftConfigOptions.DEFAULT);
arbitraryTransition.setBlockRewardWei(BigInteger.ONE);
final BlockHeader parentHeader = IbftBlockHeaderUtils.createPresetHeaderBuilder(1, proposerNodeKey, validators, null).buildHeader();
final BlockHeader blockHeader = IbftBlockHeaderUtils.createPresetHeaderBuilder(2, proposerNodeKey, validators, parentHeader).buildHeader();
final ProtocolSchedule schedule = createProtocolSchedule(JsonGenesisConfigOptions.fromJsonObject(JsonUtil.createEmptyObjectNode()), List.of(new ForkSpec<>(0, JsonQbftConfigOptions.DEFAULT), new ForkSpec<>(1, arbitraryTransition), new ForkSpec<>(2, JsonQbftConfigOptions.DEFAULT)));
assertThat(schedule.streamMilestoneBlocks().count()).isEqualTo(3);
assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 0)).isTrue();
assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 1)).isTrue();
assertThat(validateHeader(schedule, validators, parentHeader, blockHeader, 2)).isTrue();
}
Aggregations