Search in sources :

Example 1 with BeaconStateSchemaPhase0

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0 in project teku by ConsenSys.

the class BeaconStateBuilderPhase0 method initDefaults.

@Override
protected void initDefaults() {
    super.initDefaults();
    final BeaconStateSchemaPhase0 schema = getBeaconStateSchema();
    previousEpochAttestations = dataStructureUtil.randomSszList(schema.getPreviousEpochAttestationsSchema(), defaultItemsInSSZLists, () -> dataStructureUtil.randomPendingAttestation(schema.getPendingAttestationSchema()));
    currentEpochAttestations = dataStructureUtil.randomSszList(schema.getCurrentEpochAttestationsSchema(), defaultItemsInSSZLists, () -> dataStructureUtil.randomPendingAttestation(schema.getPendingAttestationSchema()));
}
Also used : BeaconStateSchemaPhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0)

Example 2 with BeaconStateSchemaPhase0

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0 in project teku by ConsenSys.

the class ForkUpgradeTestExecutor method processAltairUpgrade.

private void processAltairUpgrade(final TestDefinition testDefinition) {
    final SpecVersion spec = testDefinition.getSpec().getGenesisSpec();
    final BeaconStateSchema<BeaconStatePhase0, MutableBeaconStatePhase0> phase0Schema = BeaconStateSchemaPhase0.create(spec.getConfig());
    final BeaconState preState = TestDataUtils.loadSsz(testDefinition, "pre.ssz_snappy", phase0Schema);
    final BeaconState postState = TestDataUtils.loadStateFromSsz(testDefinition, "post.ssz_snappy");
    final StateUpgrade<?> stateUpgrade = testDefinition.getSpec().getGenesisSpec().getStateUpgrade().orElseThrow();
    final BeaconState updated = stateUpgrade.upgrade(preState);
    assertThatSszData(updated).isEqualByGettersTo(postState);
}
Also used : MutableBeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0) SpecVersion(tech.pegasys.teku.spec.SpecVersion) MutableBeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0) BeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStatePhase0) BeaconState(tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)

Example 3 with BeaconStateSchemaPhase0

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0 in project teku by ConsenSys.

the class DataStructureUtil method randomPendingAttestation.

public PendingAttestation randomPendingAttestation() {
    final BeaconStateSchema<?, ?> beaconStateSchema = getBeaconStateSchema();
    checkState(beaconStateSchema instanceof BeaconStateSchemaPhase0, "Pending attestations only exist in phase0");
    final PendingAttestationSchema pendingAttestationSchema = ((BeaconStateSchemaPhase0) beaconStateSchema).getPendingAttestationSchema();
    return randomPendingAttestation(pendingAttestationSchema);
}
Also used : BeaconStateSchemaPhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0) PendingAttestationSchema(tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema)

Aggregations

BeaconStateSchemaPhase0 (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStateSchemaPhase0)2 SpecVersion (tech.pegasys.teku.spec.SpecVersion)1 PendingAttestationSchema (tech.pegasys.teku.spec.datastructures.state.PendingAttestation.PendingAttestationSchema)1 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)1 BeaconStatePhase0 (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStatePhase0)1 MutableBeaconStatePhase0 (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0)1