Search in sources :

Example 1 with InvalidDepositEventsException

use of tech.pegasys.teku.ethereum.pow.api.InvalidDepositEventsException in project teku by ConsenSys.

the class DepositFetcher method sendNextBatchRequest.

private SafeFuture<Void> sendNextBatchRequest(final DepositFetchState fetchState) {
    final BigInteger nextBatchEnd = fetchState.getNextBatchEnd();
    LOG.debug("Requesting deposits between {} and {}. Batch size: {}", fetchState.nextBatchStart, nextBatchEnd, fetchState.batchSize);
    return processDepositsInBatch(fetchState.nextBatchStart, nextBatchEnd).exceptionallyCompose((err) -> {
        LOG.debug("Failed to request deposit events for block numbers in the range ({}, {}). Retrying.", fetchState.nextBatchStart, nextBatchEnd, err);
        final Throwable rootCause = Throwables.getRootCause(err);
        if (rootCause instanceof InvalidDepositEventsException) {
            STATUS_LOG.eth1DepositEventsFailure(rootCause);
        } else if (rootCause instanceof Eth1RequestException && ((Eth1RequestException) rootCause).containsExceptionSolvableWithSmallerRange()) {
            STATUS_LOG.eth1FetchDepositsRequiresSmallerRange(fetchState.batchSize);
            fetchState.reduceBatchSize();
        }
        return asyncRunner.runAfterDelay(() -> sendNextBatchRequest(fetchState), Constants.ETH1_DEPOSIT_REQUEST_RETRY_TIMEOUT);
    }).thenCompose(__ -> {
        fetchState.moveToNextBatch();
        LOG.trace("Batch request completed. Done? {}", fetchState.isDone());
        if (fetchState.isDone()) {
            return SafeFuture.COMPLETE;
        } else {
            return sendNextBatchRequest(fetchState);
        }
    });
}
Also used : EthBlock(org.web3j.protocol.core.methods.response.EthBlock) Collectors.groupingBy(java.util.stream.Collectors.groupingBy) SafeFuture(tech.pegasys.teku.infrastructure.async.SafeFuture) Eth1RequestException(tech.pegasys.teku.pow.exception.Eth1RequestException) DepositEventEventResponse(tech.pegasys.teku.pow.contract.DepositContract.DepositEventEventResponse) Preconditions.checkArgument(com.google.common.base.Preconditions.checkArgument) Map(java.util.Map) UInt64(tech.pegasys.teku.infrastructure.unsigned.UInt64) BigInteger(java.math.BigInteger) Constants(tech.pegasys.teku.spec.config.Constants) DepositsFromBlockEvent(tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent) Bytes32(org.apache.tuweni.bytes.Bytes32) AsyncRunner(tech.pegasys.teku.infrastructure.async.AsyncRunner) Preconditions.checkNotNull(com.google.common.base.Preconditions.checkNotNull) Throwables(com.google.common.base.Throwables) Set(java.util.Set) DefaultBlockParameter(org.web3j.protocol.core.DefaultBlockParameter) NavigableMap(java.util.NavigableMap) Objects(java.util.Objects) Collectors.toList(java.util.stream.Collectors.toList) List(java.util.List) InvalidDepositEventsException(tech.pegasys.teku.ethereum.pow.api.InvalidDepositEventsException) Logger(org.apache.logging.log4j.Logger) TreeMap(java.util.TreeMap) STATUS_LOG(tech.pegasys.teku.infrastructure.logging.StatusLogger.STATUS_LOG) Comparator(java.util.Comparator) DepositContract(tech.pegasys.teku.pow.contract.DepositContract) LogManager(org.apache.logging.log4j.LogManager) Eth1EventsChannel(tech.pegasys.teku.pow.api.Eth1EventsChannel) Eth1RequestException(tech.pegasys.teku.pow.exception.Eth1RequestException) BigInteger(java.math.BigInteger) InvalidDepositEventsException(tech.pegasys.teku.ethereum.pow.api.InvalidDepositEventsException)

Aggregations

Preconditions.checkArgument (com.google.common.base.Preconditions.checkArgument)1 Preconditions.checkNotNull (com.google.common.base.Preconditions.checkNotNull)1 Throwables (com.google.common.base.Throwables)1 BigInteger (java.math.BigInteger)1 Comparator (java.util.Comparator)1 List (java.util.List)1 Map (java.util.Map)1 NavigableMap (java.util.NavigableMap)1 Objects (java.util.Objects)1 Set (java.util.Set)1 TreeMap (java.util.TreeMap)1 Collectors.groupingBy (java.util.stream.Collectors.groupingBy)1 Collectors.toList (java.util.stream.Collectors.toList)1 LogManager (org.apache.logging.log4j.LogManager)1 Logger (org.apache.logging.log4j.Logger)1 Bytes32 (org.apache.tuweni.bytes.Bytes32)1 DefaultBlockParameter (org.web3j.protocol.core.DefaultBlockParameter)1 EthBlock (org.web3j.protocol.core.methods.response.EthBlock)1 DepositsFromBlockEvent (tech.pegasys.teku.ethereum.pow.api.DepositsFromBlockEvent)1 InvalidDepositEventsException (tech.pegasys.teku.ethereum.pow.api.InvalidDepositEventsException)1