Skip to content

Commit

Permalink
Merge branch 'master' into get-graffiti
Browse files Browse the repository at this point in the history
# Conflicts:
#	CHANGELOG.md
  • Loading branch information
courtneyeh committed Apr 19, 2024
2 parents 09794e1 + 38708fb commit e328b95
Show file tree
Hide file tree
Showing 411 changed files with 3,350 additions and 1,706 deletions.
10 changes: 8 additions & 2 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -148,7 +148,7 @@ commands:
name: "Publish Docker Images"
command: |
docker login --username "${DOCKER_USER_RW}" --password "${DOCKER_PASSWORD_RW}"
./gradlew --no-daemon --parallel "-Pbranch=${CIRCLE_BRANCH}" uploadDocker
./gradlew --no-daemon --parallel "-Pbranch=${CIRCLE_BRANCH} -PincludeCommitHashInDockerTag=<< pipeline.parameters.include_commit_hash_in_docker_tag >>" uploadDocker
notify:
description: "Notify Slack"
Expand All @@ -157,6 +157,12 @@ commands:
mentions: "team-centaur"
fail_only: true
only_for_branches: 'master'

parameters:
include_commit_hash_in_docker_tag:
type: boolean
default: false

jobs:
assemble:
executor: large_executor
Expand Down Expand Up @@ -497,7 +503,7 @@ jobs:
paths:
- .openapidoc/spec/teku.json

# longish story here: we store the openapi json spec in the `gh-pages` branch of teku on Github
# longish story here: we store the openapi json spec in the `gh-pages` branch of teku on Github
# The reason we don't use GHA and instead use Circle to push to GHA is:
# 1. We need assemble -> extractAPISpec -> publishAPISpec and this takes circa 10 mins to build in GHA,
# 2. We publish artifacts (openapi, docker, binaries etc) only after ALL tests and we can't check for all the jobs passing to kick this one off
Expand Down
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,8 @@ the [releases page](https://github.com/Consensys/teku/releases).
- Added `peers_direction_current` libp2p metric to track the number of peers by direction (inbound and outbound).
- Deposit tree snapshots will be loaded from database as a default unless custom snapshot has been provided.
- Added hidden option `--Xdeposit-contract-logs-syncing-enabled` to allow disabling the syncing of the deposit contract logs from the EL. This is useful when running a non-validating node. It is advisable to be used alongside with `--Xeth1-missing-deposits-event-logging-enabled=false` to avoid unnecessary logging of missing deposits.
- Updated the bootnodes for Chiado and Gnosis networks
- Updated the bootnodes for Chiado and Gnosis networks.
- Added hidden option `--Xp2p-dumps-to-file-enabled` to enable saving p2p dumps to file.
- Added GET `/eth/v1/validator/{pubkey}/graffiti` validator API.

### Bug Fixes
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
Loading

0 comments on commit e328b95

Please sign in to comment.