Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/master' into voluntary-exit-api
Browse files Browse the repository at this point in the history
  • Loading branch information
courtneyeh committed Aug 14, 2023
2 parents f626372 + b54882a commit e18418b
Show file tree
Hide file tree
Showing 68 changed files with 927 additions and 677 deletions.
8 changes: 2 additions & 6 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,14 +10,10 @@ For information on changes in released versions of Teku, see the [releases page]

### Breaking Changes

- Upgrading the minimum Java version to Java 17, which means users will need to upgrade their Java installation to at least `Java 17`. The docker versions relying on `jdk16` will no longer be published, so docker users explicitly referencing the `jdk16` build need to update their package to reference `jdk17`, as tags `develop-jdk16`, `develop-jdk16-arm64`, `latest-jdk16` will no longer be updated.
- Users who make heavy use of API calls to fetch non finalized states data other than head may wish to adjust the states-cache if they see excessive `regeneration of state` messages. This can be accomplished via the `--Xstore-state-cache-size`, which previously defaulted to 160.
- The Development option `--Xp2p-minimum-subnet-subscriptions` has been removed and will no longer be recognised as a command line option.

### Additions and Improvements

- Introduce `--exchange-capabilities-monitoring-enabled` parameter. If enabled, EL will be queried periodically for the Engine API methods it supports. If incompatibility is detected, a warning is raised in the logs. The default is `true`.
- Add support for [Lukso network](https://lukso.network/) `--network=lukso`
- The development option `--Xfork-choice-update-head-on-block-import-enabled` was changed to default to `false` to ensure fork-choice is run when new blocks arrive.
- The default state-cache size has been changed to 8 (previously 160), and there is now an epoch-states-cache, which defaults to a maximum of 6 elements.
- Update attestation subnet subscriptions strategy according to [the spec changes](https://github.com/ethereum/consensus-specs/blob/dev/specs/phase0/p2p-interface.md#attestation-subnet-subscription). All nodes (including non-validating ones) will subscribe to 2 subnets regardless of the number of validators.

### Bug Fixes
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
import org.apache.logging.log4j.Logger;
import tech.pegasys.teku.ethereum.events.SlotEventsChannel;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.gossip.subnets.StableSubnetSubscriber;
import tech.pegasys.teku.spec.Spec;

public class ActiveValidatorTracker implements SlotEventsChannel {
Expand All @@ -34,11 +33,7 @@ public class ActiveValidatorTracker implements SlotEventsChannel {
private final NavigableMap<UInt64, Set<Integer>> validatorsPerEpoch =
new ConcurrentSkipListMap<>();

private final StableSubnetSubscriber stableSubnetSubscriber;

public ActiveValidatorTracker(
final StableSubnetSubscriber stableSubnetSubscriber, final Spec spec) {
this.stableSubnetSubscriber = stableSubnetSubscriber;
public ActiveValidatorTracker(final Spec spec) {
this.spec = spec;
}

Expand All @@ -54,7 +49,6 @@ public void onSlot(final UInt64 slot) {
final UInt64 epoch = spec.computeEpochAtSlot(slot);
final int validatorCount = getNumberOfValidatorsForEpoch(epoch);
LOG.debug("{} active validators counted for epoch {}", validatorCount, epoch);
stableSubnetSubscriber.onSlot(slot, validatorCount);

// PerformanceTracker uses validator counts to determine expected attestation count.
// Thus we wait ATTESTATION_INCLUSION_RANGE epochs, after which the performance is determined,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,26 +13,17 @@

package tech.pegasys.teku.validator.coordinator;

import static org.mockito.Mockito.inOrder;
import static org.mockito.Mockito.mock;
import static org.mockito.Mockito.verify;
import static tech.pegasys.teku.validator.coordinator.performance.DefaultPerformanceTracker.ATTESTATION_INCLUSION_RANGE;

import org.junit.jupiter.api.Test;
import org.mockito.InOrder;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.networking.eth2.gossip.subnets.StableSubnetSubscriber;
import tech.pegasys.teku.networking.eth2.gossip.subnets.ValidatorBasedStableSubnetSubscriber;
import tech.pegasys.teku.spec.Spec;
import tech.pegasys.teku.spec.TestSpecFactory;

class ActiveValidatorTrackerTest {
private final Spec spec = TestSpecFactory.createMinimalPhase0();
private final StableSubnetSubscriber stableSubnetSubscriber =
mock(ValidatorBasedStableSubnetSubscriber.class);

private final ActiveValidatorTracker tracker =
new ActiveValidatorTracker(stableSubnetSubscriber, spec);
private final ActiveValidatorTracker tracker = new ActiveValidatorTracker(spec);

@Test
void shouldUpdateValidatorCountAtStartOfEpoch() {
Expand All @@ -44,9 +35,6 @@ void shouldUpdateValidatorCountAtStartOfEpoch() {

final UInt64 epochStartSlot = spec.computeStartSlotAtEpoch(epoch);
tracker.onSlot(epochStartSlot);

final InOrder inOrder = inOrder(stableSubnetSubscriber);
inOrder.verify(stableSubnetSubscriber).onSlot(epochStartSlot, 3);
}

@Test
Expand All @@ -59,9 +47,6 @@ void shouldNotCountDuplicateValidators() {

final UInt64 epochStartSlot = spec.computeStartSlotAtEpoch(epoch);
tracker.onSlot(epochStartSlot);

final InOrder inOrder = inOrder(stableSubnetSubscriber);
inOrder.verify(stableSubnetSubscriber).onSlot(epochStartSlot, 1);
}

@Test
Expand All @@ -79,10 +64,6 @@ void shouldPruneValidatorCountsAtTheEndOfAttestationInclusionRangeEpochs() {
// For the purpose of testing, we get the slots out of order, so all the requests get dropped
tracker.onSlot(afterInclusionRangeStartSlot);
tracker.onSlot(epochStartSlot);

// And both slot updates wind up setting 0 validators
verify(stableSubnetSubscriber).onSlot(afterInclusionRangeStartSlot, 0);
verify(stableSubnetSubscriber).onSlot(epochStartSlot, 0);
}

@Test
Expand All @@ -100,8 +81,5 @@ void shouldNotPruneBeforeTheEndOfAttestationInclusionRangeEpochs() {
// For the purpose of testing, we get the slots out of order, to see if the requests get dropped
tracker.onSlot(rightBeforeInclusionRangeStartSlot);
tracker.onSlot(epochStartSlot);

// And both slot updates wind up setting 3 validators
verify(stableSubnetSubscriber).onSlot(epochStartSlot, 3);
}
}
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,10 @@ buildscript {
}

plugins {
id 'com.diffplug.spotless' version '6.19.0'
id 'com.diffplug.spotless' version '6.20.0'
id 'com.github.ben-manes.versions' version '0.47.0'
id 'com.github.jk1.dependency-license-report' version '2.5'
id 'io.spring.dependency-management' version '1.1.0'
id 'io.spring.dependency-management' version '1.1.2'
id 'net.ltgt.errorprone' version '3.1.0' apply false
id 'de.undercouch.download' version '5.4.0'
id 'org.ajoberstar.grgit' version '5.2.0'
Expand Down Expand Up @@ -294,7 +294,7 @@ allprojects {
}
}

def refTestVersion = 'v1.4.0-beta.0' // Arbitrary change to refresh cache number: 1
def refTestVersion = 'v1.4.0-beta.1' // Arbitrary change to refresh cache number: 1
def blsRefTestVersion = 'v0.1.2'
def refTestBaseUrl = 'https://github.com/ethereum/consensus-spec-tests/releases/download'
def blsRefTestBaseUrl = 'https://github.com/ethereum/bls12-381-tests/releases/download'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,6 @@ public Map<String, String> getConfigMap() {

configAttributes.put("BLS_WITHDRAWAL_PREFIX", getBlsWithdrawalPrefix().toHexString());
configAttributes.put("TARGET_AGGREGATORS_PER_COMMITTEE", getTargetAggregatorsPerCommittee());
configAttributes.put("RANDOM_SUBNETS_PER_VALIDATOR", getRandomSubnetsPerValidator());
configAttributes.put("SUBNETS_PER_NODE", getSubnetsPerNode());
configAttributes.put(
"EPOCHS_PER_RANDOM_SUBNET_SUBSCRIPTION", getEpochsPerRandomSubnetSubscription());
Expand Down Expand Up @@ -106,10 +105,6 @@ private String getMaxRequestBlocks() {
return Integer.toString(specConfig.getNetworkingConfig().getMaxRequestBlocks());
}

private String getRandomSubnetsPerValidator() {
return Integer.toString(ValidatorConstants.RANDOM_SUBNETS_PER_VALIDATOR);
}

private String getTtfbTimeout() {
return Integer.toString(specConfig.getNetworkingConfig().getTtfbTimeout());
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,8 @@ public class ReferenceTestFinder {
private static final Path TEST_PATH_FROM_MODULE =
Path.of("src", "referenceTest", "resources", "consensus-spec-tests", "tests");
private static final List<String> SUPPORTED_FORKS =
List.of(TestFork.PHASE0, TestFork.ALTAIR, TestFork.BELLATRIX, TestFork.CAPELLA);
List.of(
TestFork.PHASE0, TestFork.ALTAIR, TestFork.BELLATRIX, TestFork.CAPELLA, TestFork.DENEB);

@MustBeClosed
public static Stream<TestDefinition> findReferenceTests() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,22 +14,28 @@
package tech.pegasys.teku.ethereum.executionclient.schema;

import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import java.util.List;
import java.util.Optional;
import org.apache.tuweni.bytes.Bytes32;
import tech.pegasys.teku.ethereum.executionclient.serialization.Bytes32Deserializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.BytesSerializer;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.executionlayer.PayloadBuildingAttributes;

public class PayloadAttributesV3 extends PayloadAttributesV2 {

@JsonSerialize(using = BytesSerializer.class)
@JsonDeserialize(using = Bytes32Deserializer.class)
public final Bytes32 parentBeaconBlockRoot;

public PayloadAttributesV3(
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("prevRandao") Bytes32 prevRandao,
@JsonProperty("suggestedFeeRecipient") Bytes20 suggestedFeeRecipient,
@JsonProperty("withdrawals") final List<WithdrawalV1> withdrawals,
@JsonProperty("withdrawals") List<WithdrawalV1> withdrawals,
@JsonProperty("parentBeaconBlockRoot") final Bytes32 parentBeaconBlockRoot) {
super(timestamp, prevRandao, suggestedFeeRecipient, withdrawals);
this.parentBeaconBlockRoot = parentBeaconBlockRoot;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -189,18 +189,13 @@ public boolean isForkChoiceUpdateHeadOnBlockImportEnabled() {
}

public Optional<UInt64> getForkEpoch(final SpecMilestone specMilestone) {
switch (specMilestone) {
case ALTAIR:
return altairForkEpoch;
case BELLATRIX:
return bellatrixForkEpoch;
case CAPELLA:
return capellaForkEpoch;
case DENEB:
return denebForkEpoch;
default:
return Optional.empty();
}
return switch (specMilestone) {
case ALTAIR -> altairForkEpoch;
case BELLATRIX -> bellatrixForkEpoch;
case CAPELLA -> capellaForkEpoch;
case DENEB -> denebForkEpoch;
default -> Optional.empty();
};
}

public Optional<Bytes32> getTerminalBlockHashOverride() {
Expand Down Expand Up @@ -481,28 +476,17 @@ private Builder resetAndApplyBasicDefaults(final String networkName) {
}

public Builder applyNetworkDefaults(final Eth2Network network) {
switch (network) {
case MAINNET:
return applyMainnetNetworkDefaults();
case MINIMAL:
return applyMinimalNetworkDefaults();
case PRATER:
return applyPraterNetworkDefaults();
case SEPOLIA:
return applySepoliaNetworkDefaults();
case LUKSO:
return applyLuksoNetworkDefaults();
case GNOSIS:
return applyGnosisNetworkDefaults();
case CHIADO:
return applyChiadoNetworkDefaults();
case SWIFT:
return applySwiftNetworkDefaults();
case LESS_SWIFT:
return applyLessSwiftNetworkDefaults();
default:
return resetAndApplyBasicDefaults(network.configName());
}
return switch (network) {
case MAINNET -> applyMainnetNetworkDefaults();
case MINIMAL -> applyMinimalNetworkDefaults();
case PRATER -> applyPraterNetworkDefaults();
case SEPOLIA -> applySepoliaNetworkDefaults();
case LUKSO -> applyLuksoNetworkDefaults();
case GNOSIS -> applyGnosisNetworkDefaults();
case CHIADO -> applyChiadoNetworkDefaults();
case SWIFT -> applySwiftNetworkDefaults();
case LESS_SWIFT -> applyLessSwiftNetworkDefaults();
};
}

private Builder reset() {
Expand All @@ -523,7 +507,10 @@ public Builder applyTestnetDefaults() {
}

public Builder applyMinimalNetworkDefaults() {
return applyTestnetDefaults().constants(MINIMAL.configName()).startupTargetPeerCount(0);
return applyTestnetDefaults()
.trustedSetupFromClasspath("minimal-trusted-setup.txt")
.constants(MINIMAL.configName())
.startupTargetPeerCount(0);
}

public Builder applySwiftNetworkDefaults() {
Expand Down
Loading

0 comments on commit e18418b

Please sign in to comment.