Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/rocksdb-sigsevv-fix' into rocksd…
Browse files Browse the repository at this point in the history
…b-sigsevv-fix
  • Loading branch information
gfukushima committed Jan 23, 2025
2 parents c5d6892 + 02e3c72 commit b12d493
Show file tree
Hide file tree
Showing 22 changed files with 194 additions and 87 deletions.
30 changes: 1 addition & 29 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,35 +7,7 @@
## Unreleased Changes

### Breaking Changes
- `--Xvalidators-builder-registration-default-gas-limit` CLI option is replaced by `--validators-builder-registration-default-gas-limit`
- `--Xp2p-sync-rate-limit` CLI option is removed in favour of `--Xp2p-sync-blocks-rate-limit` and `--Xp2p-sync-blob-sidecars-rate-limit`
- `--Xpeer-rate-limit` CLI options is removed in favour of `--Xpeer-blocks-rate-limit` and `--Xpeer-blob-sidecars-rate-limit`
- With the upgrade of the Prometheus Java Metrics library, there are the following changes:
- Gauge names are not allowed to end with `total`, therefore metrics as `beacon_proposers_data_total` and `beacon_eth1_current_period_votes_total` are dropping the `_total` suffix
- The `_created` timestamps are not returned by default.
- Some JVM metrics have changed name to adhere to the OTEL standard (see the table below), [Teku Detailed Dashboard](https://grafana.com/grafana/dashboards/16737-teku-detailed/) is updated to support both names

| Old Name | New Name |
|---------------------------------|---------------------------------|
| jvm_memory_bytes_committed | jvm_memory_committed_bytes |
| jvm_memory_bytes_init | jvm_memory_init_bytes |
| jvm_memory_bytes_max | jvm_memory_max_bytes |
| jvm_memory_bytes_used | jvm_memory_used_bytes |
| jvm_memory_pool_bytes_committed | jvm_memory_pool_committed_bytes |
| jvm_memory_pool_bytes_init | jvm_memory_pool_init_bytes |
| jvm_memory_pool_bytes_max | jvm_memory_pool_max_bytes |
| jvm_memory_pool_bytes_used | jvm_memory_pool_used_bytes |


### Additions and Improvements
- Default the gas limit to 36 million for externally produced blocks
- Optimized blobs validation pipeline
- Remove delay when fetching blobs from the local EL on block arrival
- New validator metric `validator_next_attestation_slot` to highlight the next slot that a validator is expected to publish an attestation [#8795](https://github.com/Consensys/teku/issues/8795)
- Support for SSZ format in builder API (mev-boost)
- Added the expected gas limit to the 'not honouring the validator gas limit preference' warning message.
- Implemented the ability to have fork based ascii art.

### Bug Fixes
- Fix `--version` command output [#8960](https://github.com/Consensys/teku/issues/8960)
- Fix issue (introduced in `24.12.1`) with peer stability when the upperbound is set to a high number
### Bug Fixes
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ synchronized void fail() {
}

private void reportOutage(final UInt64 outageStartInSeconds) {
STATUS_LOG.eth1ServiceDown(
timeProvider.getTimeInSeconds().minus(outageStartInSeconds).longValue());
STATUS_LOG.eth1ServiceDown(timeProvider.getTimeInSeconds().minus(outageStartInSeconds));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -97,12 +97,9 @@ public SafeFuture<Void> requestBlocksByRange(
@Override
public SafeFuture<Void> requestBlobSidecarsByRange(
final UInt64 startSlot, final UInt64 count, final RpcResponseListener<BlobSidecar> listener) {
final long blobSidecarsCount =
maybeMaxBlobsPerBlock
.map(maxBlobsPerBlock -> maxBlobsPerBlock * count.longValue())
.orElse(0L);
final UInt64 blobSidecarsCount = maybeMaxBlobsPerBlock.map(count::times).orElse(UInt64.ZERO);
return blobSidecarsRateTracker
.approveObjectsRequest(blobSidecarsCount)
.approveObjectsRequest(blobSidecarsCount.longValue())
.map(
requestApproval -> {
LOG.debug("Sending request for approximately {} blob sidecars", blobSidecarsCount);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ public void createUnsignedAttestation_withLatestBlockFromAnOldEpoch(
specContext.assumeIsNotOneOf(SpecMilestone.DENEB);
final UInt64 latestEpoch = UInt64.valueOf(2);
final UInt64 latestSlot = specContext.getSpec().computeStartSlotAtEpoch(latestEpoch).plus(ONE);
final UInt64 targetEpoch = UInt64.valueOf(latestEpoch.longValue() + 3);
final UInt64 targetEpoch = latestEpoch.plus(3);
final UInt64 targetEpochStartSlot = specContext.getSpec().computeStartSlotAtEpoch(targetEpoch);
final UInt64 targetSlot = targetEpochStartSlot.plus(2);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import tech.pegasys.teku.spec.datastructures.operations.SignedVoluntaryExit;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateCache;
import tech.pegasys.teku.spec.datastructures.state.versions.electra.PendingPartialWithdrawal;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.datastructures.type.SszKZGProof;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerBlockProductionManager;
Expand Down Expand Up @@ -146,7 +147,7 @@ public Function<BeaconBlockBodyBuilder, SafeFuture<Void>> createSelector(
final SszList<SignedVoluntaryExit> voluntaryExits =
voluntaryExitPool.getItemsForBlock(
blockSlotState,
exit -> !exitedValidators.contains(exit.getMessage().getValidatorIndex()),
exit -> voluntaryExitPredicate(blockSlotState, exitedValidators, exit),
exit -> exitedValidators.add(exit.getMessage().getValidatorIndex()));

bodyBuilder
Expand Down Expand Up @@ -204,6 +205,25 @@ public Function<BeaconBlockBodyBuilder, SafeFuture<Void>> createSelector(
};
}

private boolean voluntaryExitPredicate(
final BeaconState blockSlotState,
final Set<UInt64> exitedValidators,
final SignedVoluntaryExit exit) {
final UInt64 validatorIndex = exit.getMessage().getValidatorIndex();
if (exitedValidators.contains(validatorIndex)) {
return false;
}
// if there is a pending withdrawal, the exit is not valid for inclusion in a block.
return blockSlotState
.toVersionElectra()
.map(
beaconStateElectra ->
beaconStateElectra.getPendingPartialWithdrawals().stream()
.map(PendingPartialWithdrawal::getValidatorIndex)
.noneMatch(index -> index == validatorIndex.intValue()))
.orElse(true);
}

private SafeFuture<Void> setExecutionData(
final Optional<ExecutionPayloadContext> executionPayloadContext,
final BeaconBlockBodyBuilder bodyBuilder,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,6 +78,7 @@
import tech.pegasys.teku.spec.datastructures.operations.versions.altair.SignedContributionAndProof;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconStateCache;
import tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.electra.MutableBeaconStateElectra;
import tech.pegasys.teku.spec.datastructures.type.SszKZGCommitment;
import tech.pegasys.teku.spec.datastructures.type.SszKZGProof;
import tech.pegasys.teku.spec.executionlayer.ExecutionLayerBlockProductionManager;
Expand Down Expand Up @@ -264,6 +265,39 @@ void shouldNotSelectOperationsWhenNoneAreAvailable() {
assertThat(bodyBuilder.blsToExecutionChanges).isEmpty();
}

@Test
void shouldNotSelectVoluntaryExitWhenValidatorHasPendingWithdrawal() {
final UInt64 slot = UInt64.ONE;
final MutableBeaconStateElectra blockSlotState =
dataStructureUtil.randomBeaconState(slot).toVersionElectra().get().createWritableCopy();
blockSlotState
.getPendingPartialWithdrawals()
.append(dataStructureUtil.randomPendingPartialWithdrawal(1));
final SignedVoluntaryExit voluntaryExit =
dataStructureUtil.randomSignedVoluntaryExit(UInt64.valueOf(1));
final ExecutionPayload randomExecutionPayload = dataStructureUtil.randomExecutionPayload();
final UInt256 blockExecutionValue = dataStructureUtil.randomUInt256();

addToPool(voluntaryExitPool, voluntaryExit);
prepareBlockProductionWithPayload(
randomExecutionPayload,
executionPayloadContext,
blockSlotState,
Optional.of(blockExecutionValue));

safeJoin(
factory
.createSelector(
parentRoot,
blockSlotState,
randaoReveal,
Optional.of(defaultGraffiti),
Optional.empty(),
BlockProductionPerformance.NOOP)
.apply(bodyBuilder));
assertThat(bodyBuilder.voluntaryExits).isEmpty();
}

@Test
void shouldIncludeValidOperations() {
final UInt64 slot = UInt64.valueOf(2);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,15 +123,15 @@ public SyncCommitteeRewardData getSyncCommitteeRewardData(
blockAndMetadata.isExecutionOptimistic(), blockAndMetadata.isFinalized());
return calculateSyncCommitteeRewards(
committeeIndices,
participantReward.longValue(),
participantReward,
block.getBody().getOptionalSyncAggregate(),
rewardData);
}

@VisibleForTesting
SyncCommitteeRewardData calculateSyncCommitteeRewards(
final Map<Integer, Integer> committeeIndices,
final long participantReward,
final UInt64 participantReward,
final Optional<SyncAggregate> maybeAggregate,
final SyncCommitteeRewardData data) {
if (maybeAggregate.isEmpty()) {
Expand All @@ -143,9 +143,9 @@ SyncCommitteeRewardData calculateSyncCommitteeRewards(
committeeIndices.forEach(
(i, key) -> {
if (aggregate.getSyncCommitteeBits().getBit(i)) {
data.increaseReward(key, participantReward);
data.increaseReward(key, participantReward.longValue());
} else {
data.decreaseReward(key, participantReward);
data.decreaseReward(key, participantReward.longValue());
}
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,9 @@ void checkValidatorsList_shouldAcceptValidInput(
@Test
void calculateSyncCommitteeRewards_shouldNotChangeValuesWhenAggregateEmpty() {
final SyncCommitteeRewardData data = mock(SyncCommitteeRewardData.class);
assertThat(calculator.calculateSyncCommitteeRewards(Map.of(1, 1), 1L, Optional.empty(), data))
assertThat(
calculator.calculateSyncCommitteeRewards(
Map.of(1, 1), UInt64.ONE, Optional.empty(), data))
.isEqualTo(data);
verifyNoMoreInteractions(data);
}
Expand All @@ -222,7 +224,7 @@ void calculateSyncCommitteeRewards_shouldAdjustVRewards() {
final SyncAggregate aggregate = data.randomSyncAggregate(1);
assertThat(
calculator.calculateSyncCommitteeRewards(
Map.of(1, 1, 2, 2), 1L, Optional.of(aggregate), rewardData))
Map.of(1, 1, 2, 2), UInt64.ONE, Optional.of(aggregate), rewardData))
.isEqualTo(rewardData);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ public class ReferenceTestFinder {
TestFork.ALTAIR,
TestFork.BELLATRIX,
TestFork.CAPELLA,
TestFork.DENEB); // TODO: Add Electra fork tests back
TestFork.DENEB,
TestFork.ELECTRA);

@MustBeClosed
public static Stream<TestDefinition> findReferenceTests() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void setupResponse(final SafeFuture<Object> response) {
when(delegatedTestClient.testMethod(any()))
.thenAnswer(
__ -> {
stubTimeProvider.advanceTimeByMillis(RESPONSE_DELAY.longValue());
stubTimeProvider.advanceTimeByMillis(RESPONSE_DELAY);
return response;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,13 @@
public class DepositTree {
private MerkleTree tree;
private long totalDepositCount;
private long finalizedDepositCount;
private UInt64 finalizedDepositCount;
private Optional<BlockHashAndHeight> finalizedExecutionBlock;

public DepositTree() {
tree = MerkleTree.create(emptyList(), DEPOSIT_CONTRACT_TREE_DEPTH);
totalDepositCount = 0;
finalizedDepositCount = 0;
finalizedDepositCount = UInt64.ZERO;
finalizedExecutionBlock = Optional.empty();
}

Expand All @@ -53,7 +53,7 @@ public DepositTree(final DepositTreeSnapshot snapshot) {
"Incorrect Deposit Tree snapshot %s, deposit root doesn't match",
snapshot);
this.totalDepositCount = snapshot.getDepositCount();
this.finalizedDepositCount = snapshot.getDepositCount();
this.finalizedDepositCount = UInt64.valueOf(snapshot.getDepositCount());
this.finalizedExecutionBlock =
Optional.of(
new BlockHashAndHeight(
Expand Down Expand Up @@ -93,19 +93,21 @@ public static DepositTree fromSnapshot(final DepositTreeSnapshot snapshot) {

public void finalize(final Eth1Data eth1Data, final UInt64 blockHeight) {
checkArgument(
totalDepositCount >= eth1Data.getDepositCount().longValue(),
eth1Data.getDepositCount().isLessThanOrEqualTo(totalDepositCount),
"Merkle tree does not contain all deposits to be finalized");
if (eth1Data.getDepositCount().equals(UInt64.ZERO)) {
return;
}
finalizedExecutionBlock =
Optional.of(new BlockHashAndHeight(eth1Data.getBlockHash(), blockHeight));
finalizedDepositCount = eth1Data.getDepositCount().longValue();
tree = tree.finalize(finalizedDepositCount, DEPOSIT_CONTRACT_TREE_DEPTH);
finalizedDepositCount = eth1Data.getDepositCount();
tree = tree.finalize(finalizedDepositCount.longValue(), DEPOSIT_CONTRACT_TREE_DEPTH);
}

public List<Bytes32> getProof(final long index) {
checkArgument(index >= finalizedDepositCount, "Cannot get proof for finalized deposits");
checkArgument(
finalizedDepositCount.isLessThanOrEqualTo(index),
"Cannot get proof for finalized deposits");
final List<Bytes32> proof = tree.generateProof(index, DEPOSIT_CONTRACT_TREE_DEPTH);
proof.add(uintToBytes32(totalDepositCount));
return proof;
Expand All @@ -126,7 +128,7 @@ public long getDepositCount() {

public DepositTree getTreeAtDepositIndex(final long lastDepositIndex) {
checkArgument(
lastDepositIndex >= finalizedDepositCount,
finalizedDepositCount.isLessThanOrEqualTo(lastDepositIndex),
"Cannot recreate tree before finalized deposit count");
final DepositTree treeForProof =
getSnapshot().map(DepositTree::fromSnapshot).orElseGet(DepositTree::new);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,6 @@ public UInt64 getMaxSlot() {

@Override
public int getMaximumResponseChunks() {
return Math.toIntExact(getCount().longValue());
return getCount().intValue();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ public UInt64 getValidatorActivationChurnLimit(final BeaconState state) {

public Optional<BLSPublicKey> getValidatorPubKey(
final BeaconState state, final UInt64 validatorIndex) {
if (state.getValidators().size() <= validatorIndex.longValue()
if (validatorIndex.isGreaterThanOrEqualTo(state.getValidators().size())
|| validatorIndex.longValue() < 0) {
return Optional.empty();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ public UInt64 getCurrentSlotForMillis(
}
return currentTimeMillis
.minus(genesisTimeMillis)
.dividedBy(specConfig.getSecondsPerSlot() * MILLIS_PER_SECOND.longValue());
.dividedBy(MILLIS_PER_SECOND.times(specConfig.getSecondsPerSlot()));
}

public UInt64 getSlotStartTime(final UInt64 slotNumber, final UInt64 genesisTime) {
Expand All @@ -96,7 +96,7 @@ public UInt64 getSlotStartTime(final UInt64 slotNumber, final UInt64 genesisTime

public UInt64 getSlotStartTimeMillis(final UInt64 slotNumber, final UInt64 genesisTimeMillis) {
return genesisTimeMillis.plus(
slotNumber.times(specConfig.getSecondsPerSlot() * MILLIS_PER_SECOND.longValue()));
slotNumber.times(MILLIS_PER_SECOND.times(specConfig.getSecondsPerSlot())));
}

public UInt64 getCurrentSlot(final ReadOnlyStore store, final boolean useUnixTime) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2641,6 +2641,15 @@ public PendingPartialWithdrawal randomPendingPartialWithdrawal() {
SszUInt64.of(randomUInt64()));
}

public PendingPartialWithdrawal randomPendingPartialWithdrawal(final long validatorIndex) {
return getElectraSchemaDefinitions(randomSlot())
.getPendingPartialWithdrawalSchema()
.create(
SszUInt64.of(UInt64.valueOf(validatorIndex)),
SszUInt64.of(randomUInt64()),
SszUInt64.of(randomUInt64()));
}

public UInt64 randomBlobSidecarIndex() {
return randomUInt64(
spec.forMilestone(spec.getForkSchedule().getHighestSupportedMilestone())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -203,7 +203,7 @@ public void doppelgangerDetectionEnd(
}
}

public void doppelgangerCheck(final long epoch, final Set<String> publicKeys) {
public void doppelgangerCheck(final UInt64 epoch, final Set<String> publicKeys) {
log.info(
"Performing doppelganger check. Epoch {}, Public keys {}",
epoch,
Expand Down Expand Up @@ -388,7 +388,7 @@ public void validatorDataPathSet(final Path dataPath) {
log.info("Storing validator data in: {}", dataPath.toAbsolutePath());
}

public void eth1ServiceDown(final long interval) {
public void eth1ServiceDown(final UInt64 interval) {
log.warn("Eth1 service down or still syncing for {}s, retrying", interval);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,10 @@ public void advanceTimeByMillis(final long millis) {
this.timeInMillis = timeInMillis.plus(millis);
}

public void advanceTimeByMillis(final UInt64 millis) {
this.timeInMillis = timeInMillis.plus(millis);
}

@Override
public UInt64 getTimeInMillis() {
return timeInMillis;
Expand Down
Loading

0 comments on commit b12d493

Please sign in to comment.