Search in sources :

Example 1 with RequiredBlocksPeerValidator

use of org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator in project besu by hyperledger.

the class MergeBesuControllerBuilder method createPeerValidators.

@Override
protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protocolSchedule) {
    List<PeerValidator> retval = super.createPeerValidators(protocolSchedule);
    final OptionalLong powTerminalBlockNumber = configOptionsSupplier.get().getTerminalBlockNumber();
    final Optional<Hash> powTerminalBlockHash = configOptionsSupplier.get().getTerminalBlockHash();
    if (powTerminalBlockHash.isPresent() && powTerminalBlockNumber.isPresent()) {
        retval.add(new RequiredBlocksPeerValidator(protocolSchedule, metricsSystem, powTerminalBlockNumber.getAsLong(), powTerminalBlockHash.get(), 0));
    } else {
        LOG.debug("unable to validate peers with terminal difficulty blocks");
    }
    return retval;
}
Also used : RequiredBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator) PeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator) OptionalLong(java.util.OptionalLong) Hash(org.hyperledger.besu.datatypes.Hash) RequiredBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator)

Example 2 with RequiredBlocksPeerValidator

use of org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator in project besu by hyperledger.

the class BesuControllerBuilder method createPeerValidators.

protected List<PeerValidator> createPeerValidators(final ProtocolSchedule protocolSchedule) {
    final List<PeerValidator> validators = new ArrayList<>();
    final OptionalLong daoBlock = configOptionsSupplier.get().getDaoForkBlock();
    if (daoBlock.isPresent()) {
        // Setup dao validator
        validators.add(new DaoForkPeerValidator(protocolSchedule, metricsSystem, daoBlock.getAsLong()));
    }
    final OptionalLong classicBlock = configOptionsSupplier.get().getClassicForkBlock();
    // setup classic validator
    if (classicBlock.isPresent()) {
        validators.add(new ClassicForkPeerValidator(protocolSchedule, metricsSystem, classicBlock.getAsLong()));
    }
    for (final Map.Entry<Long, Hash> requiredBlock : requiredBlocks.entrySet()) {
        validators.add(new RequiredBlocksPeerValidator(protocolSchedule, metricsSystem, requiredBlock.getKey(), requiredBlock.getValue()));
    }
    final CheckpointConfigOptions checkpointConfigOptions = genesisConfig.getConfigOptions(genesisConfigOverrides).getCheckpointOptions();
    if (SyncMode.X_CHECKPOINT.equals(syncConfig.getSyncMode()) && checkpointConfigOptions.isValid()) {
        validators.add(new CheckpointBlocksPeerValidator(protocolSchedule, metricsSystem, checkpointConfigOptions.getNumber().orElseThrow(), checkpointConfigOptions.getHash().map(Hash::fromHexString).orElseThrow()));
    }
    return validators;
}
Also used : CheckpointBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator) ArrayList(java.util.ArrayList) ClassicForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator) Hash(org.hyperledger.besu.datatypes.Hash) DaoForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.DaoForkPeerValidator) ClassicForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator) CheckpointBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator) RequiredBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator) PeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator) DaoForkPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.DaoForkPeerValidator) OptionalLong(java.util.OptionalLong) CheckpointConfigOptions(org.hyperledger.besu.config.CheckpointConfigOptions) OptionalLong(java.util.OptionalLong) Map(java.util.Map) RequiredBlocksPeerValidator(org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator)

Aggregations

OptionalLong (java.util.OptionalLong)2 Hash (org.hyperledger.besu.datatypes.Hash)2 PeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.PeerValidator)2 RequiredBlocksPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.RequiredBlocksPeerValidator)2 ArrayList (java.util.ArrayList)1 Map (java.util.Map)1 CheckpointConfigOptions (org.hyperledger.besu.config.CheckpointConfigOptions)1 CheckpointBlocksPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.CheckpointBlocksPeerValidator)1 ClassicForkPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.ClassicForkPeerValidator)1 DaoForkPeerValidator (org.hyperledger.besu.ethereum.eth.peervalidation.DaoForkPeerValidator)1