Skip to content

Commit

Permalink
Added capella fork epoch for Goerli. (#6901)
Browse files Browse the repository at this point in the history
  • Loading branch information
rolfyone committed Mar 3, 2023
1 parent d2d2006 commit a448ea3
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 7 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ For information on changes in released versions of Teku, see the [releases page]
- Added an optional query parameter `locally_submitted` to `/eth/v1/beacon/pool/bls_to_execution_changes` to allow users to query only bls changes submitted to the current node.
- Added `/eth/v1/builder/states/{state_id}/expected_withdrawals` rest api endpoint.
- Added `/eth/v1/beacon/rewards/sync_committee/{block_id}` rest api endpoint.
- Added Capella fork information for Goerli network configuration.

### Bug Fixes
- Included All forks in fork schedule if they're defined in configuration.
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,9 @@ ALTAIR_FORK_EPOCH: 36660
# BELLATRIX
BELLATRIX_FORK_VERSION: 0x02001020
BELLATRIX_FORK_EPOCH: 112260
#CAPELLA
CAPELLA_FORK_VERSION: 0x03001020
CAPELLA_FORK_EPOCH: 162304
# Sharding
SHARDING_FORK_VERSION: 0x03001020
SHARDING_FORK_EPOCH: 18446744073709551615
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ public class SpecFactoryTest {

private static final Set<String> NON_BELLATRIX_NETWORKS = Set.of("swift", "less-swift");

private static final Set<String> CAPELLA_NETWORKS = Set.of("sepolia");
private static final Set<String> CAPELLA_NETWORKS = Set.of("sepolia", "prater");

@Test
public void defaultFactoryShouldScheduleAltairAndBellatrixForMainNet() {
Expand All @@ -64,6 +64,18 @@ public void defaultFactoryShouldNotEnableBellatrixUnlessForkEpochIsSet(final Str
}
}

@ParameterizedTest(name = "{0}")
@MethodSource("getKnownConfigNames")
public void shouldSupportCapellaWhenForkEpochSetInConfig(final String configName) {
final Spec spec = SpecFactory.create(configName);
if (CAPELLA_NETWORKS.contains(configName)) {
assertThat(spec.getForkSchedule().getSupportedMilestones())
.containsExactly(PHASE0, ALTAIR, BELLATRIX, CAPELLA);
} else {
assertThat(spec.getForkSchedule().getSupportedMilestones()).doesNotContain(CAPELLA);
}
}

@Test
void shouldSupportAltairWhenForkEpochSetInConfig() {
final SpecConfig config =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,13 @@
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.spec.config.SpecConfigAltair;
import tech.pegasys.teku.spec.config.SpecConfigBellatrix;
import tech.pegasys.teku.spec.config.SpecConfigCapella;
import tech.pegasys.teku.spec.config.SpecConfigLoader;
import tech.pegasys.teku.spec.networks.Eth2Network;

public class SpecMilestoneTest {
private final SpecConfigCapella capellaSpecConfig =
SpecConfigCapella.required(SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()));
private final SpecConfigBellatrix bellatrixSpecConfig =
SpecConfigBellatrix.required(SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName()));
private final SpecConfigAltair altairSpecConfig =
Expand All @@ -34,13 +37,19 @@ public class SpecMilestoneTest {

@Test
public void isGreaterThanOrEqualTo() {
assertThat(SpecMilestone.ALTAIR.isGreaterThanOrEqualTo(SpecMilestone.PHASE0)).isTrue();
assertThat(SpecMilestone.ALTAIR.isGreaterThanOrEqualTo(SpecMilestone.ALTAIR)).isTrue();
assertThat(SpecMilestone.PHASE0.isGreaterThanOrEqualTo(SpecMilestone.PHASE0)).isTrue();
assertThat(SpecMilestone.PHASE0.isGreaterThanOrEqualTo(SpecMilestone.ALTAIR)).isFalse();

assertThat(SpecMilestone.ALTAIR.isGreaterThanOrEqualTo(SpecMilestone.PHASE0)).isTrue();
assertThat(SpecMilestone.ALTAIR.isGreaterThanOrEqualTo(SpecMilestone.ALTAIR)).isTrue();
assertThat(SpecMilestone.ALTAIR.isGreaterThanOrEqualTo(SpecMilestone.BELLATRIX)).isFalse();

assertThat(SpecMilestone.BELLATRIX.isGreaterThanOrEqualTo(SpecMilestone.ALTAIR)).isTrue();
assertThat(SpecMilestone.BELLATRIX.isGreaterThanOrEqualTo(SpecMilestone.BELLATRIX)).isTrue();
assertThat(SpecMilestone.ALTAIR.isGreaterThanOrEqualTo(SpecMilestone.BELLATRIX)).isFalse();

assertThat(SpecMilestone.CAPELLA.isGreaterThanOrEqualTo(SpecMilestone.BELLATRIX)).isTrue();
assertThat(SpecMilestone.CAPELLA.isGreaterThanOrEqualTo(SpecMilestone.CAPELLA)).isTrue();
assertThat(SpecMilestone.CAPELLA.isGreaterThanOrEqualTo(SpecMilestone.DENEB)).isFalse();
}

@Test
Expand All @@ -60,6 +69,12 @@ public void getAllPriorMilestones_bellatrix() {
.contains(SpecMilestone.PHASE0, SpecMilestone.ALTAIR);
}

@Test
public void getAllPriorMilestones_capella() {
assertThat(SpecMilestone.getAllPriorMilestones(SpecMilestone.CAPELLA))
.contains(SpecMilestone.PHASE0, SpecMilestone.ALTAIR, SpecMilestone.BELLATRIX);
}

@Test
public void getMilestonesUpTo_phase0() {
assertThat(SpecMilestone.getMilestonesUpTo(SpecMilestone.PHASE0))
Expand All @@ -78,6 +93,12 @@ public void getMilestonesUpTo_bellatrix() {
.contains(SpecMilestone.PHASE0, SpecMilestone.ALTAIR, SpecMilestone.BELLATRIX);
}

@Test
public void getMilestonesUpTo_capella() {
assertThat(SpecMilestone.getMilestonesUpTo(SpecMilestone.CAPELLA))
.contains(SpecMilestone.PHASE0, SpecMilestone.ALTAIR, SpecMilestone.BELLATRIX);
}

@Test
public void areMilestonesInOrder() {
assertThat(SpecMilestone.areMilestonesInOrder(SpecMilestone.PHASE0, SpecMilestone.ALTAIR))
Expand All @@ -98,6 +119,10 @@ public void areMilestonesInOrder() {
SpecMilestone.areMilestonesInOrder(
SpecMilestone.PHASE0, SpecMilestone.BELLATRIX, SpecMilestone.ALTAIR))
.isFalse();
assertThat(SpecMilestone.areMilestonesInOrder(SpecMilestone.BELLATRIX, SpecMilestone.CAPELLA))
.isTrue();
assertThat(SpecMilestone.areMilestonesInOrder(SpecMilestone.CAPELLA, SpecMilestone.BELLATRIX))
.isFalse();
}

@Test
Expand All @@ -122,26 +147,40 @@ public void getForkVersion_bellatrix() {
}

@Test
public void getForkSlot_phase0() {
public void getForkVersion_capella() {
final Bytes4 expected = capellaSpecConfig.getCapellaForkVersion();
assertThat(SpecMilestone.getForkVersion(capellaSpecConfig, SpecMilestone.CAPELLA))
.contains(expected);
}

@Test
public void getForkEpoch_phase0() {
final UInt64 expected = UInt64.ZERO;
assertThat(SpecMilestone.getForkEpoch(altairSpecConfig, SpecMilestone.PHASE0))
.contains(expected);
}

@Test
public void getForkSlot_altair() {
public void getForEpoch_altair() {
final UInt64 expected = altairSpecConfig.getAltairForkEpoch();
assertThat(SpecMilestone.getForkEpoch(altairSpecConfig, SpecMilestone.ALTAIR))
.contains(expected);
}

@Test
public void getForkSlot_bellatrix() {
public void getForkEpoch_bellatrix() {
final UInt64 expected = bellatrixSpecConfig.getBellatrixForkEpoch();
assertThat(SpecMilestone.getForkEpoch(bellatrixSpecConfig, SpecMilestone.BELLATRIX))
.contains(expected);
}

@Test
public void getForkEpoch_capella() {
final UInt64 expected = capellaSpecConfig.getCapellaForkEpoch();
assertThat(SpecMilestone.getForkEpoch(capellaSpecConfig, SpecMilestone.CAPELLA))
.contains(expected);
}

@Test
public void getForkSlot_altairNotScheduled() {
assertThat(SpecMilestone.getForkEpoch(phase0SpecConfig, SpecMilestone.ALTAIR))
Expand All @@ -153,4 +192,10 @@ public void getForkSlot_bellatrixNotScheduled() {
assertThat(SpecMilestone.getForkEpoch(phase0SpecConfig, SpecMilestone.BELLATRIX))
.contains(UInt64.MAX_VALUE);
}

@Test
public void getForkEpoch_capellaNotScheduled() {
assertThat(SpecMilestone.getForkEpoch(bellatrixSpecConfig, SpecMilestone.CAPELLA))
.contains(UInt64.MAX_VALUE);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.junit.jupiter.api.Test;
import tech.pegasys.teku.spec.config.SpecConfigAltair;
import tech.pegasys.teku.spec.config.SpecConfigBellatrix;
import tech.pegasys.teku.spec.config.SpecConfigCapella;
import tech.pegasys.teku.spec.config.SpecConfigLoader;
import tech.pegasys.teku.spec.networks.Eth2Network;

Expand Down Expand Up @@ -60,4 +61,16 @@ void shouldCreateBellatrixSpec() {
assertThat(actualVersion.get().getSchemaDefinitions())
.hasSameClassAs(expectedVersion.getSchemaDefinitions());
}

@Test
void shouldCreateCapellaSpec() {
final SpecConfigCapella capellaSpecConfig = SpecConfigCapella.required(minimalConfig);
final SpecVersion expectedVersion = SpecVersion.createCapella(capellaSpecConfig);
final Optional<SpecVersion> actualVersion =
SpecVersion.create(SpecMilestone.CAPELLA, minimalConfig);
assertThat(actualVersion).isPresent();
assertThat(actualVersion.get().getMilestone()).isEqualTo(SpecMilestone.CAPELLA);
assertThat(actualVersion.get().getSchemaDefinitions())
.hasSameClassAs(expectedVersion.getSchemaDefinitions());
}
}

0 comments on commit a448ea3

Please sign in to comment.