use of org.hyperledger.besu.consensus.common.EpochManager in project besu by hyperledger.
the class QbftBesuControllerBuilder method createConsensusContext.
@Override
protected BftContext createConsensusContext(final Blockchain blockchain, final WorldStateArchive worldStateArchive, final ProtocolSchedule protocolSchedule) {
final EpochManager epochManager = new EpochManager(qbftConfig.getEpochLength());
final BftValidatorOverrides validatorOverrides = convertBftForks(configOptionsSupplier.get().getTransitions().getQbftForks());
final BlockValidatorProvider blockValidatorProvider = BlockValidatorProvider.forkingValidatorProvider(blockchain, epochManager, bftBlockInterface().get(), validatorOverrides);
final TransactionSimulator transactionSimulator = new TransactionSimulator(blockchain, worldStateArchive, protocolSchedule);
transactionValidatorProvider = new TransactionValidatorProvider(blockchain, new ValidatorContractController(transactionSimulator), qbftForksSchedule);
final ValidatorProvider validatorProvider = new ForkingValidatorProvider(blockchain, qbftForksSchedule, blockValidatorProvider, transactionValidatorProvider);
return new QbftContext(validatorProvider, epochManager, bftBlockInterface().get(), pkiBlockCreationConfiguration);
}
use of org.hyperledger.besu.consensus.common.EpochManager in project besu by hyperledger.
the class CliqueBesuControllerBuilder method prepForBuild.
@Override
protected void prepForBuild() {
localAddress = Util.publicKeyToAddress(nodeKey.getPublicKey());
final CliqueConfigOptions cliqueConfig = configOptionsSupplier.get().getCliqueConfigOptions();
final long blocksPerEpoch = cliqueConfig.getEpochLength();
secondsBetweenBlocks = cliqueConfig.getBlockPeriodSeconds();
epochManager = new EpochManager(blocksPerEpoch);
}
use of org.hyperledger.besu.consensus.common.EpochManager in project besu by hyperledger.
the class IbftLegacyBesuControllerBuilder method createConsensusContext.
@Override
protected IbftLegacyContext createConsensusContext(final Blockchain blockchain, final WorldStateArchive worldStateArchive, final ProtocolSchedule protocolSchedule) {
final IbftLegacyConfigOptions ibftConfig = configOptionsSupplier.get().getIbftLegacyConfigOptions();
final EpochManager epochManager = new EpochManager(ibftConfig.getEpochLength());
final ValidatorProvider validatorProvider = BlockValidatorProvider.nonForkingValidatorProvider(blockchain, epochManager, blockInterface);
return new IbftLegacyContext(validatorProvider, epochManager, blockInterface);
}
use of org.hyperledger.besu.consensus.common.EpochManager in project besu by hyperledger.
the class CliqueMinerExecutorTest method extraDataCreatedOnEpochBlocksContainsValidators.
@Test
public void extraDataCreatedOnEpochBlocksContainsValidators() {
final Bytes vanityData = generateRandomVanityData();
final CliqueMinerExecutor executor = new CliqueMinerExecutor(cliqueProtocolContext, CliqueProtocolSchedule.create(GENESIS_CONFIG_OPTIONS, proposerNodeKey, false, EvmConfiguration.DEFAULT), new GasPricePendingTransactionsSorter(TransactionPoolConfiguration.DEFAULT_TX_RETENTION_HOURS, 1, TestClock.fixed(), metricsSystem, CliqueMinerExecutorTest::mockBlockHeader, TransactionPoolConfiguration.DEFAULT_PRICE_BUMP), proposerNodeKey, new MiningParameters.Builder().coinbase(AddressHelpers.ofValue(1)).minTransactionGasPrice(Wei.ZERO).extraData(vanityData).miningEnabled(false).build(), mock(CliqueBlockScheduler.class), new EpochManager(EPOCH_LENGTH));
// NOTE: Passing in the *parent* block, so must be 1 less than EPOCH
final BlockHeader header = blockHeaderBuilder.number(EPOCH_LENGTH - 1).buildHeader();
final Bytes extraDataBytes = executor.calculateExtraData(header);
final CliqueExtraData cliqueExtraData = CliqueExtraData.decode(blockHeaderBuilder.number(EPOCH_LENGTH).extraData(extraDataBytes).blockHeaderFunctions(new CliqueBlockHeaderFunctions()).buildHeader());
assertThat(cliqueExtraData.getVanityData()).isEqualTo(vanityData);
assertThat(cliqueExtraData.getValidators()).containsExactly(validatorList.toArray(new Address[0]));
}
use of org.hyperledger.besu.consensus.common.EpochManager in project besu by hyperledger.
the class CliqueExtraDataValidationRuleTest method missingSignerFailsValidation.
@Test
public void missingSignerFailsValidation() {
final Bytes extraData = CliqueExtraData.createWithoutProposerSeal(Bytes.wrap(new byte[32]), Lists.newArrayList());
final BlockHeaderTestFixture headerBuilder = new BlockHeaderTestFixture();
final BlockHeader parent = headerBuilder.number(1).buildHeader();
final BlockHeader child = headerBuilder.number(2).extraData(extraData).buildHeader();
final CliqueExtraDataValidationRule rule = new CliqueExtraDataValidationRule(new EpochManager(10));
assertThat(rule.validate(child, parent, cliqueProtocolContext)).isFalse();
}
Aggregations