Skip to content

Commit

Permalink
Merge branch 'master' into graffiti-management
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Apr 18, 2024
2 parents b6e5976 + 9973928 commit 60567e4
Show file tree
Hide file tree
Showing 199 changed files with 482 additions and 449 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -30,16 +30,16 @@ protected enum Result {
protected Result lastCallResult = Result.FAILED;
protected Result lastValidationResult = Result.FAILED;

protected AbstractMonitorableEth1Provider(TimeProvider timeProvider) {
protected AbstractMonitorableEth1Provider(final TimeProvider timeProvider) {
this.timeProvider = timeProvider;
}

protected synchronized void updateLastValidation(Result result) {
protected synchronized void updateLastValidation(final Result result) {
lastValidationTime = timeProvider.getTimeInSeconds();
lastValidationResult = result;
}

protected synchronized void updateLastCall(Result result) {
protected synchronized void updateLastCall(final Result result) {
lastCallTime = timeProvider.getTimeInSeconds();
lastCallResult = result;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,13 +27,13 @@ public class DepositEventsAccessor {
private final Eth1Provider eth1Provider;
private final String contractAddress;

public DepositEventsAccessor(Eth1Provider eth1Provider, String contractAddress) {
public DepositEventsAccessor(final Eth1Provider eth1Provider, final String contractAddress) {
this.eth1Provider = eth1Provider;
this.contractAddress = contractAddress;
}

public SafeFuture<List<DepositEventEventResponse>> depositEventInRange(
DefaultBlockParameter startBlock, DefaultBlockParameter endBlock) {
final DefaultBlockParameter startBlock, final DefaultBlockParameter endBlock) {
final EthFilter filter = new EthFilter(startBlock, endBlock, this.contractAddress);
filter.addSingleTopic(EventEncoder.encode(DepositContract.DEPOSITEVENT_EVENT));
return SafeFuture.of(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ public DepositFetcher(

// Inclusive on both sides
public synchronized SafeFuture<Void> fetchDepositsInRange(
BigInteger fromBlockNumber, BigInteger toBlockNumber) {
final BigInteger fromBlockNumber, final BigInteger toBlockNumber) {
checkArgument(
fromBlockNumber.compareTo(toBlockNumber) <= 0,
"From block number (%s) must be less than or equal to block number (%s)",
Expand Down Expand Up @@ -161,10 +161,11 @@ private SafeFuture<Void> processDepositsInBatch(
}

private SafeFuture<Void> postDepositEvents(
List<SafeFuture<EthBlock.Block>> blockRequests,
Map<BlockNumberAndHash, List<DepositContract.DepositEventEventResponse>> depositEventsByBlock,
BigInteger fromBlock,
BigInteger toBlock) {
final List<SafeFuture<EthBlock.Block>> blockRequests,
final Map<BlockNumberAndHash, List<DepositContract.DepositEventEventResponse>>
depositEventsByBlock,
final BigInteger fromBlock,
final BigInteger toBlock) {
LOG.trace("Posting deposit events for {} blocks", depositEventsByBlock.size());
BigInteger from = fromBlock;
// First process completed requests using iteration.
Expand Down Expand Up @@ -220,7 +221,7 @@ private DepositsFromBlockEvent createDepositFromBlockEvent(
}

private List<SafeFuture<EthBlock.Block>> getListOfEthBlockFutures(
Set<BlockNumberAndHash> neededBlockHashes) {
final Set<BlockNumberAndHash> neededBlockHashes) {
return neededBlockHashes.stream()
.map(BlockNumberAndHash::getHash)
.map(eth1Provider::getGuaranteedEth1Block)
Expand All @@ -229,7 +230,7 @@ private List<SafeFuture<EthBlock.Block>> getListOfEthBlockFutures(

private NavigableMap<BlockNumberAndHash, List<DepositEventEventResponse>>
groupDepositEventResponsesByBlockHash(
List<DepositContract.DepositEventEventResponse> events) {
final List<DepositContract.DepositEventEventResponse> events) {
return events.stream()
.collect(
groupingBy(
Expand All @@ -239,7 +240,7 @@ private List<SafeFuture<EthBlock.Block>> getListOfEthBlockFutures(
toList()));
}

private void postDeposits(DepositsFromBlockEvent event) {
private void postDeposits(final DepositsFromBlockEvent event) {
eth1EventsChannel.onDepositsFromBlock(event);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,13 +51,13 @@ public class DepositProcessingController {
private final Eth1BlockFetcher eth1BlockFetcher;

public DepositProcessingController(
SpecConfig config,
Eth1Provider eth1Provider,
Eth1EventsChannel eth1EventsChannel,
AsyncRunner asyncRunner,
DepositFetcher depositFetcher,
Eth1BlockFetcher eth1BlockFetcher,
Eth1HeadTracker headTracker) {
final SpecConfig config,
final Eth1Provider eth1Provider,
final Eth1EventsChannel eth1EventsChannel,
final AsyncRunner asyncRunner,
final DepositFetcher depositFetcher,
final Eth1BlockFetcher eth1BlockFetcher,
final Eth1HeadTracker headTracker) {
this.config = config;
this.eth1Provider = eth1Provider;
this.eth1EventsChannel = eth1EventsChannel;
Expand All @@ -73,7 +73,7 @@ public synchronized void switchToBlockByBlockMode() {
}

// inclusive of start block
public synchronized void startSubscription(BigInteger subscriptionStartBlock) {
public synchronized void startSubscription(final BigInteger subscriptionStartBlock) {
LOG.debug("Starting subscription at block {}", subscriptionStartBlock);
latestSuccessfullyQueriedBlock = subscriptionStartBlock.subtract(BigInteger.ONE);
newBlockSubscription = headTracker.subscribe(this::onNewCanonicalBlockNumber);
Expand All @@ -89,7 +89,7 @@ public synchronized SafeFuture<Void> fetchDepositsInRange(
return depositFetcher.fetchDepositsInRange(fromBlockNumber, toBlockNumber);
}

private synchronized void onNewCanonicalBlockNumber(UInt64 newCanonicalBlockNumber) {
private synchronized void onNewCanonicalBlockNumber(final UInt64 newCanonicalBlockNumber) {
this.latestCanonicalBlockNumber = newCanonicalBlockNumber.bigIntegerValue();
fetchLatestSubscriptionDeposits();
}
Expand Down Expand Up @@ -165,7 +165,8 @@ private boolean isActiveOrAlreadyQueriedLatestCanonicalBlock() {
return active || latestCanonicalBlockNumber.compareTo(latestSuccessfullyQueriedBlock) <= 0;
}

private synchronized void onSubscriptionDepositRequestSuccessful(BigInteger requestToBlock) {
private synchronized void onSubscriptionDepositRequestSuccessful(
final BigInteger requestToBlock) {
active = false;
latestSuccessfullyQueriedBlock = requestToBlock;
if (latestCanonicalBlockNumber.compareTo(latestSuccessfullyQueriedBlock) > 0) {
Expand All @@ -177,12 +178,12 @@ private synchronized void onSubscriptionDepositRequestSuccessful(BigInteger requ
}

private synchronized void onSubscriptionDepositRequestFailed(
Throwable err, BigInteger fromBlock) {
final Throwable err, final BigInteger fromBlock) {
onSubscriptionDepositRequestFailed(err, fromBlock, fromBlock);
}

private synchronized void onSubscriptionDepositRequestFailed(
Throwable err, BigInteger fromBlock, BigInteger toBlock) {
final Throwable err, final BigInteger fromBlock, final BigInteger toBlock) {
active = false;

if (Throwables.getRootCause(err) instanceof InvalidDepositEventsException) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,7 @@ public SafeFuture<Boolean> ethSyncing() {
}

@Override
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(EthFilter ethFilter) {
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(final EthFilter ethFilter) {
return logStatus(delegate.ethGetLogs(ethFilter));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -147,11 +147,11 @@ private void backfillEth1Blocks(final UInt64 nextBlockToRequest) {
error -> LOG.error("Unexpected error while back-filling ETH1 blocks", error));
}

private boolean isAboveLowerBound(UInt64 timestamp) {
private boolean isAboveLowerBound(final UInt64 timestamp) {
return timestamp.compareTo(getCacheRangeLowerBound(timeProvider.getTimeInSeconds())) >= 0;
}

private UInt64 getCacheRangeLowerBound(UInt64 currentTime) {
private UInt64 getCacheRangeLowerBound(final UInt64 currentTime) {
return currentTime.compareTo(cacheDuration) > 0 ? currentTime.minus(cacheDuration) : ZERO;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public interface Eth1Provider {
SafeFuture<Optional<Block>> getEth1BlockWithRetry(
UInt64 blockNumber, Duration retryDelay, int maxRetries);

default SafeFuture<Optional<Block>> getEth1BlockWithRetry(UInt64 blockNumber) {
default SafeFuture<Optional<Block>> getEth1BlockWithRetry(final UInt64 blockNumber) {
return getEth1BlockWithRetry(blockNumber, Duration.ofSeconds(5), 2);
}

Expand All @@ -43,7 +43,7 @@ default SafeFuture<Optional<Block>> getEth1BlockWithRetry(UInt64 blockNumber) {
SafeFuture<Optional<Block>> getEth1BlockWithRetry(
String blockHash, Duration retryDelay, int maxRetries);

default SafeFuture<Optional<Block>> getEth1BlockWithRetry(String blockHash) {
default SafeFuture<Optional<Block>> getEth1BlockWithRetry(final String blockHash) {
return getEth1BlockWithRetry(blockHash, Duration.ofSeconds(5), 2);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ public SafeFuture<Boolean> ethSyncing() {
}

@Override
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(EthFilter ethFilter) {
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(final EthFilter ethFilter) {
return run(eth1Provider -> eth1Provider.ethGetLogs(ethFilter));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,9 @@ public class MinimumGenesisTimeBlockFinder {
private final Optional<UInt64> eth1DepositContractDeployBlock;

public MinimumGenesisTimeBlockFinder(
SpecConfig config,
Eth1Provider eth1Provider,
Optional<UInt64> eth1DepositContractDeployBlock) {
final SpecConfig config,
final Eth1Provider eth1Provider,
final Optional<UInt64> eth1DepositContractDeployBlock) {
this.config = config;
this.eth1Provider = eth1Provider;
this.eth1DepositContractDeployBlock = eth1DepositContractDeployBlock;
Expand Down Expand Up @@ -191,12 +191,15 @@ private boolean blockIsAtOrAfterMinGenesis(final SpecConfig config, final EthBlo
}

private void traceWithBlock(
final String message, final EthBlock.Block block, Object... otherArgs) {
final String message, final EthBlock.Block block, final Object... otherArgs) {
logWithBlock(Level.TRACE, message, block, otherArgs);
}

private void logWithBlock(
final Level level, final String message, final EthBlock.Block block, Object... otherArgs) {
final Level level,
final String message,
final EthBlock.Block block,
final Object... otherArgs) {
final Object[] args = new Object[otherArgs.length + 3];
System.arraycopy(otherArgs, 0, args, 0, otherArgs.length);

Expand All @@ -211,24 +214,26 @@ private UInt64 calculateMinGenesisTimeThreshold() {
return config.getMinGenesisTime().minusMinZero(config.getGenesisDelay());
}

static UInt64 calculateCandidateGenesisTimestamp(SpecConfig config, BigInteger eth1Timestamp) {
static UInt64 calculateCandidateGenesisTimestamp(
final SpecConfig config, final BigInteger eth1Timestamp) {
return UInt64.valueOf(eth1Timestamp).plus(config.getGenesisDelay());
}

static int compareBlockTimestampToMinGenesisTime(SpecConfig config, EthBlock.Block block) {
static int compareBlockTimestampToMinGenesisTime(
final SpecConfig config, final EthBlock.Block block) {
return calculateCandidateGenesisTimestamp(config, block.getTimestamp())
.compareTo(config.getMinGenesisTime());
}

static Boolean isBlockAfterMinGenesis(SpecConfig config, EthBlock.Block block) {
static Boolean isBlockAfterMinGenesis(final SpecConfig config, final EthBlock.Block block) {
int comparison = compareBlockTimestampToMinGenesisTime(config, block);
// If block timestamp is greater than min genesis time,
// min genesis block must be in the future
return comparison > 0;
}

static void notifyMinGenesisTimeBlockReached(
Eth1EventsChannel eth1EventsChannel, EthBlock.Block block) {
final Eth1EventsChannel eth1EventsChannel, final EthBlock.Block block) {
MinGenesisTimeBlockEvent event =
new MinGenesisTimeBlockEvent(
UInt64.valueOf(block.getTimestamp()),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ public SafeFuture<Boolean> ethSyncing() {
}

@Override
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(EthFilter ethFilter) {
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(final EthFilter ethFilter) {
return taskQueue.queueTask(() -> delegate.ethGetLogs(ethFilter));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ private void assertDepositEventIsValid(final DepositsFromBlockEvent event) {
}

@Override
public void onInitialDepositTreeSnapshot(DepositTreeSnapshot depositTreeSnapshot) {
public void onInitialDepositTreeSnapshot(final DepositTreeSnapshot depositTreeSnapshot) {
delegate.onInitialDepositTreeSnapshot(depositTreeSnapshot);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,7 @@ public SafeFuture<EthBlock.Block> getGuaranteedLatestEth1Block() {

@Override
public SafeFuture<EthCall> ethCall(
final String from, String to, String data, final UInt64 blockNumber) {
final String from, final String to, final String data, final UInt64 blockNumber) {
return SafeFuture.of(
web3j
.ethCall(
Expand All @@ -203,7 +203,7 @@ public SafeFuture<Boolean> ethSyncing() {

@Override
@SuppressWarnings({"unchecked", "rawtypes"})
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(EthFilter ethFilter) {
public SafeFuture<List<EthLog.LogResult<?>>> ethGetLogs(final EthFilter ethFilter) {
return sendAsync(web3j.ethGetLogs(ethFilter))
.thenApply(EthLog::getLogs)
.thenApply(logs -> (List<EthLog.LogResult<?>>) (List) logs);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,23 +57,23 @@ public class DepositContract extends Contract {
new TypeReference<DynamicBytes>() {}));

protected DepositContract(
String contractAddress,
Web3j web3j,
TransactionManager transactionManager,
ContractGasProvider contractGasProvider) {
final String contractAddress,
final Web3j web3j,
final TransactionManager transactionManager,
final ContractGasProvider contractGasProvider) {
super(BINARY, contractAddress, web3j, transactionManager, contractGasProvider);
}

public static EventValuesWithLog staticExtractDepositEventWithLog(Log log) {
public static EventValuesWithLog staticExtractDepositEventWithLog(final Log log) {
return staticExtractEventParametersWithLog(DEPOSITEVENT_EVENT, log);
}

public RemoteFunctionCall<TransactionReceipt> deposit(
byte[] pubkey,
byte[] withdrawalCredentials,
byte[] signature,
byte[] depositDataRoot,
BigInteger weiValue) {
final byte[] pubkey,
final byte[] withdrawalCredentials,
final byte[] signature,
final byte[] depositDataRoot,
final BigInteger weiValue) {
final Function function =
new Function(
FUNC_DEPOSIT,
Expand All @@ -87,10 +87,10 @@ public RemoteFunctionCall<TransactionReceipt> deposit(
}

public static DepositContract load(
String contractAddress,
Web3j web3j,
TransactionManager transactionManager,
ContractGasProvider contractGasProvider) {
final String contractAddress,
final Web3j web3j,
final TransactionManager transactionManager,
final ContractGasProvider contractGasProvider) {
return new DepositContract(contractAddress, web3j, transactionManager, contractGasProvider);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public Eth1RequestException() {
super("Some eth1 endpoints threw an Exception or no eth1 endpoints available");
}

public static boolean shouldTryWithSmallerRange(Throwable err) {
public static boolean shouldTryWithSmallerRange(final Throwable err) {
return ExceptionUtil.hasCause(
err,
SocketTimeoutException.class,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public long subscribeToSyncChanges(final SyncSubscriber subscriber) {
}

@Override
public long subscribeToSyncStateChangesAndUpdate(SyncStateSubscriber subscriber) {
public long subscribeToSyncStateChangesAndUpdate(final SyncStateSubscriber subscriber) {
final long subscriptionId = subscribeToSyncStateChanges(subscriber);
subscriber.onSyncStateChange(getCurrentSyncState());
return subscriptionId;
Expand Down Expand Up @@ -116,7 +116,7 @@ public void cancelRecentBlobSidecarRequest(final BlobIdentifier blobIdentifier)
}

@Override
public void onOptimisticHeadChanged(boolean isSyncingOptimistically) {
public void onOptimisticHeadChanged(final boolean isSyncingOptimistically) {
// No-op
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -124,7 +124,7 @@ public long subscribeToSyncStateChangesAndUpdate(final SyncStateSubscriber subsc
}

@Override
public boolean unsubscribeFromSyncStateChanges(long subscriberId) {
public boolean unsubscribeFromSyncStateChanges(final long subscriberId) {
return subscribers.unsubscribe(subscriberId);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ public static <T> FetchResult<T> createSuccessful(final T result) {
return new FetchResult<>(Optional.empty(), Status.SUCCESSFUL, Optional.of(result));
}

public static <T> FetchResult<T> createSuccessful(final Eth2Peer peer, T result) {
public static <T> FetchResult<T> createSuccessful(final Eth2Peer peer, final T result) {
return new FetchResult<>(Optional.of(peer), Status.SUCCESSFUL, Optional.of(result));
}

Expand Down
Loading

0 comments on commit 60567e4

Please sign in to comment.