use of tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema in project teku by ConsenSys.
the class AttestationUtil method getIndexedAttestation.
/**
* Return the indexed attestation corresponding to ``attestation``.
*
* @param state
* @param attestation
* @return
* @see
* <a>https://github.com/ethereum/eth2.0-specs/blob/v0.8.0/specs/core/0_beacon-chain.md#get_indexed_attestation</a>
*/
public IndexedAttestation getIndexedAttestation(BeaconState state, Attestation attestation) {
List<Integer> attesting_indices = getAttestingIndices(state, attestation.getData(), attestation.getAggregationBits());
final IndexedAttestationSchema indexedAttestationSchema = schemaDefinitions.getIndexedAttestationSchema();
return indexedAttestationSchema.create(attesting_indices.stream().sorted().map(UInt64::valueOf).collect(indexedAttestationSchema.getAttestingIndicesSchema().collectorUnboxed()), attestation.getData(), attestation.getAggregateSignature());
}
use of tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema in project teku by ConsenSys.
the class DataStructureUtil method randomIndexedAttestation.
public IndexedAttestation randomIndexedAttestation(final UInt64... attestingIndices) {
final IndexedAttestationSchema indexedAttestationSchema = spec.getGenesisSchemaDefinitions().getIndexedAttestationSchema();
SszUInt64List attesting_indices = indexedAttestationSchema.getAttestingIndicesSchema().of(attestingIndices);
return indexedAttestationSchema.create(attesting_indices, randomAttestationData(), randomSignature());
}
use of tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema in project teku by ConsenSys.
the class ForkChoiceTest method applyAttestationFromValidator.
private UInt64 applyAttestationFromValidator(final UInt64 validatorIndex, final SignedBlockAndState targetBlock) {
// Note this attestation is wildly invalid but we're going to shove it straight into fork choice
// as pre-validated.
final UInt64 updatedAttestationSlot = UInt64.valueOf(20);
final ValidateableAttestation updatedVote = ValidateableAttestation.from(spec, attestationSchema.create(attestationSchema.getAggregationBitsSchema().ofBits(16), new AttestationData(updatedAttestationSlot, UInt64.ONE, targetBlock.getRoot(), recentChainData.getStore().getJustifiedCheckpoint(), new Checkpoint(spec.computeEpochAtSlot(updatedAttestationSlot), targetBlock.getRoot())), dataStructureUtil.randomSignature()));
final IndexedAttestationSchema indexedAttestationSchema = spec.atSlot(updatedAttestationSlot).getSchemaDefinitions().getIndexedAttestationSchema();
updatedVote.setIndexedAttestation(indexedAttestationSchema.create(indexedAttestationSchema.getAttestingIndicesSchema().of(validatorIndex), updatedVote.getData(), updatedVote.getAttestation().getAggregateSignature()));
forkChoice.applyIndexedAttestations(List.of(updatedVote));
return updatedAttestationSlot;
}
use of tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema in project teku by ConsenSys.
the class BeaconBlockBodySchemaPhase0Test method create_mainnet.
@Test
public void create_mainnet() {
final Spec spec = TestSpecFactory.createMainnetPhase0();
final SpecConfig specConfig = spec.getGenesisSpecConfig();
final BeaconBlockBodySchemaPhase0 specA = BeaconBlockBodySchemaPhase0.create(specConfig, new AttesterSlashingSchema(new IndexedAttestationSchema(specConfig)));
final BeaconBlockBodySchemaPhase0 specB = BeaconBlockBodySchemaPhase0.create(specConfig, new AttesterSlashingSchema(new IndexedAttestationSchema(specConfig)));
assertThat(specA).isEqualTo(specB);
}
use of tech.pegasys.teku.spec.datastructures.operations.IndexedAttestation.IndexedAttestationSchema in project teku by ConsenSys.
the class BeaconBlockBodySchemaPhase0Test method create_minimal.
@Test
public void create_minimal() {
final Spec spec = TestSpecFactory.createMinimalPhase0();
final SpecConfig specConfig = spec.getGenesisSpecConfig();
final BeaconBlockBodySchemaPhase0 specA = BeaconBlockBodySchemaPhase0.create(specConfig, new AttesterSlashingSchema(new IndexedAttestationSchema(specConfig)));
final BeaconBlockBodySchemaPhase0 specB = BeaconBlockBodySchemaPhase0.create(specConfig, new AttesterSlashingSchema(new IndexedAttestationSchema(specConfig)));
assertThat(specA).isEqualTo(specB);
}
Aggregations