Search in sources :

Example 1 with MutableBeaconStatePhase0

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

the class EpochProcessorPhase0 method processParticipationUpdates.

@Override
public void processParticipationUpdates(MutableBeaconState genericState) {
    // Rotate current/previous epoch attestations
    final MutableBeaconStatePhase0 state = MutableBeaconStatePhase0.required(genericState);
    state.getPrevious_epoch_attestations().setAll(state.getCurrent_epoch_attestations());
    state.getCurrent_epoch_attestations().clear();
}
Also used : MutableBeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0)

Example 2 with MutableBeaconStatePhase0

use of tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0 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 MutableBeaconStatePhase0

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

the class BlockProcessorPhase0 method processAttestation.

@Override
protected void processAttestation(final MutableBeaconState genericState, final Attestation attestation, final IndexedAttestationProvider indexedAttestationProvider) {
    final MutableBeaconStatePhase0 state = MutableBeaconStatePhase0.required(genericState);
    final AttestationData data = attestation.getData();
    PendingAttestation pendingAttestation = state.getBeaconStateSchema().getPendingAttestationSchema().create(attestation.getAggregationBits(), data, state.getSlot().minus(data.getSlot()), UInt64.valueOf(beaconStateAccessors.getBeaconProposerIndex(state)));
    if (data.getTarget().getEpoch().equals(beaconStateAccessors.getCurrentEpoch(state))) {
        state.getCurrent_epoch_attestations().append(pendingAttestation);
    } else {
        state.getPrevious_epoch_attestations().append(pendingAttestation);
    }
}
Also used : PendingAttestation(tech.pegasys.teku.spec.datastructures.state.PendingAttestation) MutableBeaconStatePhase0(tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0) AttestationData(tech.pegasys.teku.spec.datastructures.operations.AttestationData)

Aggregations

MutableBeaconStatePhase0 (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.MutableBeaconStatePhase0)3 SpecVersion (tech.pegasys.teku.spec.SpecVersion)1 AttestationData (tech.pegasys.teku.spec.datastructures.operations.AttestationData)1 PendingAttestation (tech.pegasys.teku.spec.datastructures.state.PendingAttestation)1 BeaconState (tech.pegasys.teku.spec.datastructures.state.beaconstate.BeaconState)1 BeaconStatePhase0 (tech.pegasys.teku.spec.datastructures.state.beaconstate.versions.phase0.BeaconStatePhase0)1