Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

8944 focil spec config #8949

Merged
merged 4 commits into from
Dec 20, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,8 @@ public BeaconBlock getBlindedBlock(
block.getParentRoot(),
block.getStateRoot(),
getBlindedBlockBodyDeneb(block.getBody()));
case ELECTRA ->
// TODO update for EIP7805
case ELECTRA, EIP7805 ->
new BlindedBlockElectra(
block.getSlot(),
block.getProposerIndex(),
Expand Down Expand Up @@ -147,7 +148,8 @@ public BeaconBlock getBeaconBlock(
block.getParentRoot(),
block.getStateRoot(),
getBeaconBlockBodyDeneb(block.getBody()));
case ELECTRA ->
// TODO update for EIP7805
case ELECTRA, EIP7805 ->
new BeaconBlockElectra(
block.getSlot(),
block.getProposerIndex(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,8 @@ public enum Version {
bellatrix,
capella,
deneb,
electra;
electra,
eip7805;

public static Version fromMilestone(final SpecMilestone milestone) {
return switch (milestone) {
Expand All @@ -32,6 +33,7 @@ public static Version fromMilestone(final SpecMilestone milestone) {
case CAPELLA -> capella;
case DENEB -> deneb;
case ELECTRA -> electra;
case EIP7805 -> eip7805;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,8 @@ public void shouldConvertToInternalObject(final SpecContext ctx) {
case BELLATRIX -> new BeaconStateBellatrix(beaconStateInternal);
case CAPELLA -> new BeaconStateCapella(beaconStateInternal);
case DENEB -> new BeaconStateDeneb(beaconStateInternal);
case ELECTRA -> new BeaconStateElectra(beaconStateInternal);
// TODO update for EIP7805
case ELECTRA, EIP7805 -> new BeaconStateElectra(beaconStateInternal);
};

assertThat(beaconState.asInternalBeaconState(spec)).isEqualTo(beaconStateInternal);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public MilestoneBasedEngineJsonRpcMethodsResolver(
case DENEB:
methodsByMilestone.put(milestone, denebSupportedMethods());
break;
case ELECTRA:
case ELECTRA, EIP7805:
methodsByMilestone.put(milestone, electraSupportedMethods());
break;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
import tech.pegasys.teku.spec.config.SpecConfigBellatrix;
import tech.pegasys.teku.spec.config.SpecConfigCapella;
import tech.pegasys.teku.spec.config.SpecConfigDeneb;
import tech.pegasys.teku.spec.config.SpecConfigEip7805;
import tech.pegasys.teku.spec.config.SpecConfigElectra;
import tech.pegasys.teku.spec.config.SpecConfigLoader;
import tech.pegasys.teku.spec.networks.Eth2Network;
Expand Down Expand Up @@ -84,6 +85,14 @@ void shouldCreateSpec(final SpecMilestone milestone) {
SpecVersion.create(
SpecMilestone.ELECTRA, minimalConfig, SchemaRegistryBuilder.create());
}
case EIP7805 -> {
expectedVersion =
SpecVersion.createEip7805(
SpecConfigEip7805.required(minimalConfig), SchemaRegistryBuilder.create());
actualVersion =
SpecVersion.create(
SpecMilestone.EIP7805, minimalConfig, SchemaRegistryBuilder.create());
}
}

assertThat(actualVersion).isPresent();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,7 +88,7 @@ public void setup(final SpecContext specContext) {
afterBeaconStateClass = BeaconStateDeneb.class;
yield TestSpecFactory.createMinimalWithDenebForkEpoch(milestoneTransitionEpoch);
}
case ELECTRA -> {
case ELECTRA, EIP7805 -> {
beforeBeaconStateClass = BeaconStateDeneb.class;
afterBeaconStateClass = BeaconStateElectra.class;
yield TestSpecFactory.createMinimalWithElectraForkEpoch(milestoneTransitionEpoch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ public static Spec createMinimal(final SpecMilestone specMilestone) {
case CAPELLA -> createMinimalCapella();
case DENEB -> createMinimalDeneb();
case ELECTRA -> createMinimalElectra();
case EIP7805 -> createMainnetEip7805();
case EIP7805 -> createMinimalEip7805();
};
}

Expand Down Expand Up @@ -120,6 +120,12 @@ public static Spec createMinimalElectra(final Consumer<SpecConfigBuilder> config
return create(specConfig, SpecMilestone.ELECTRA);
}

public static Spec createMinimalEip7805() {
final SpecConfigAndParent<? extends SpecConfig> specConfig =
getEip7805SpecConfig(Eth2Network.MINIMAL);
return create(specConfig, SpecMilestone.EIP7805);
}

/**
* Create a spec that forks to altair at the provided slot
*
Expand Down Expand Up @@ -181,6 +187,19 @@ public static Spec createMinimalWithElectraForkEpoch(final UInt64 electraForkEpo
return create(config, SpecMilestone.ELECTRA);
}

/**
* Create a spec that forks to EIP7805 at the provided epoch
*
* @param eip7805ForkEpoch The EIP7805 fork epoch
* @return A spec with EIP7805 enabled, forking to EIP7805 at the given epoch
*/
public static Spec createMinimalWithEip7805ForkEpoch(final UInt64 eip7805ForkEpoch) {
final SpecConfigAndParent<? extends SpecConfig> config =
getEip7805SpecConfig(
Eth2Network.MINIMAL, UInt64.ZERO, UInt64.ZERO, UInt64.ZERO, eip7805ForkEpoch);
return create(config, SpecMilestone.EIP7805);
}

public static Spec createMinimalPhase0() {
final SpecConfigAndParent<? extends SpecConfig> configAndParent =
SpecConfigLoader.loadConfig(Eth2Network.MINIMAL.configName());
Expand Down Expand Up @@ -225,7 +244,7 @@ public static Spec createMainnetElectra() {

public static Spec createMainnetEip7805() {
final SpecConfigAndParent<? extends SpecConfig> specConfig =
getElectraSpecConfig(Eth2Network.MAINNET);
getEip7805SpecConfig(Eth2Network.MAINNET);
return create(specConfig, SpecMilestone.ELECTRA);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -1922,6 +1922,7 @@ public BeaconState randomBeaconState(
case CAPELLA -> stateBuilderCapella(validatorCount, numItemsInSszLists);
case DENEB -> stateBuilderDeneb(validatorCount, numItemsInSszLists);
case ELECTRA -> stateBuilderElectra(validatorCount, numItemsInSszLists);
case EIP7805 -> stateBuilderElectra(validatorCount, numItemsInSszLists);
};
}

Expand Down Expand Up @@ -1972,6 +1973,13 @@ public BeaconStateBuilderElectra stateBuilderElectra(
this, spec, defaultValidatorCount, defaultItemsInSSZLists);
}

public BeaconStateBuilderElectra stateBuilderEip7805(
final int defaultValidatorCount, final int defaultItemsInSSZLists) {
// TODO update for EIP7805
return BeaconStateBuilderElectra.create(
this, spec, defaultValidatorCount, defaultItemsInSSZLists);
}

public BeaconState randomBeaconState(final UInt64 slot) {
return randomBeaconState().updated(state -> state.setSlot(slot));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@ public void setUp(final TestSpecInvocationContextProvider.SpecContext specContex
case CAPELLA -> TestSpecFactory.createMinimalWithCapellaForkEpoch(currentForkEpoch);
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(currentForkEpoch);
};
dataStructureUtil = specContext.getDataStructureUtil();
defaultAddress = dataStructureUtil.randomEth1Address();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,13 @@ private void setUpNextSpec(final SpecMilestone nextSpecMilestone) {
checkState(nextSpecMilestone.equals(SpecMilestone.ELECTRA), "next spec should be electra");
nextSpec = Optional.of(TestSpecFactory.createMinimalWithElectraForkEpoch(nextSpecEpoch));
}
case ELECTRA -> throw new RuntimeException("Base spec is already latest supported milestone");
case ELECTRA -> {
checkState(nextSpecMilestone.equals(SpecMilestone.EIP7805), "next spec should be eip7732");
nextSpec = Optional.of(TestSpecFactory.createMinimalWithEip7805ForkEpoch(nextSpecEpoch));
}
case EIP7805 ->
throw new UnsupportedOperationException(
"Base spec is already latest supported milestone");
}
nextSpecSlot = nextSpec.orElseThrow().computeStartSlotAtEpoch(nextSpecEpoch);
}
Expand Down Expand Up @@ -261,7 +267,8 @@ protected static Class<?> milestoneToBeaconBlockBodyClass(final SpecMilestone mi
case BELLATRIX -> BeaconBlockBodyBellatrix.class;
case CAPELLA -> BeaconBlockBodyCapella.class;
case DENEB -> BeaconBlockBodyDeneb.class;
case ELECTRA -> BeaconBlockBodyElectra.class;
// TODO update for EIP7805
case ELECTRA, EIP7805 -> BeaconBlockBodyElectra.class;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ public void requestMetadata_withDisparateVersionsEnabled(
private static Class<?> milestoneToMetadataClass(final SpecMilestone milestone) {
return switch (milestone) {
case PHASE0 -> MetadataMessagePhase0.class;
case ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA -> MetadataMessageAltair.class;
case ALTAIR, BELLATRIX, CAPELLA, DENEB, ELECTRA, EIP7805 -> MetadataMessageAltair.class;
};
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -304,7 +304,8 @@ private GossipForkSubscriptions createSubscriptions(
gossipedSyncCommitteeMessageProcessor,
gossipedSignedBlsToExecutionChangeProcessor,
debugDataDumper);
case ELECTRA ->
// TODO update for EIP7805
case ELECTRA, EIP7805 ->
new GossipForkSubscriptionsElectra(
forkAndSpecMilestone.getFork(),
spec,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void setUp(final SpecContext specContext) {
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(nextMilestoneForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(nextMilestoneForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(nextMilestoneForkEpoch);
};

final StorageSystem storageSystem = InMemoryStorageSystemBuilder.buildDefault(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ void setUp(final SpecContext specContext) {
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(currentForkEpoch);
};
currentForkFirstSlot = spec.computeStartSlotAtEpoch(currentForkEpoch);
dataStructureUtil = new DataStructureUtil(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ public void setUp(final TestSpecInvocationContextProvider.SpecContext specContex
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(currentForkEpoch);
};

dataStructureUtil = new DataStructureUtil(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ void setUp(final TestSpecInvocationContextProvider.SpecContext specContext) {
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(currentForkEpoch);
};
dataStructureUtil = new DataStructureUtil(spec);
currentForkFirstSlot = spec.computeStartSlotAtEpoch(currentForkEpoch);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ public void setup(final TestSpecInvocationContextProvider.SpecContext specContex
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(currentForkEpoch);
};
dataStructureUtil = new DataStructureUtil(spec);
messageSchema =
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ void setUp(final TestSpecInvocationContextProvider.SpecContext specContext) {
case CAPELLA -> throw new IllegalArgumentException("Capella is an unsupported milestone");
case DENEB -> TestSpecFactory.createMinimalWithDenebForkEpoch(currentForkEpoch);
case ELECTRA -> TestSpecFactory.createMinimalWithElectraForkEpoch(currentForkEpoch);
case EIP7805 -> TestSpecFactory.createMinimalWithEip7805ForkEpoch(currentForkEpoch);
};
currentForkFirstSlot = spec.computeStartSlotAtEpoch(currentForkEpoch);
dataStructureUtil = new DataStructureUtil(spec);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -436,7 +436,8 @@ private GossipForkSubscriptions createSubscriptions(
syncCommitteeMessageProcessor,
signedBlsToExecutionChangeProcessor,
debugDataDumper);
case ELECTRA ->
// TODO update for EIP7805
case ELECTRA, EIP7805 ->
new GossipForkSubscriptionsElectra(
forkAndSpecMilestone.getFork(),
spec,
Expand Down
Loading