Ejemplo n.º 1
0
        // def get_valid_attestation(spec, state, slot=None, index=None, signed=False):
        public static Attestation GetValidAttestation(IServiceProvider testServiceProvider, BeaconState state, Slot slot, CommitteeIndex index, bool signed)
        {
            BeaconStateAccessor beaconStateAccessor = testServiceProvider.GetService <BeaconStateAccessor>();

            if (slot == Slot.None)
            {
                slot = state.Slot;
            }
            if (index == CommitteeIndex.None)
            {
                index = new CommitteeIndex(0);
            }

            AttestationData attestationData = BuildAttestationData(testServiceProvider, state, slot, index);

            IReadOnlyList <ValidatorIndex> beaconCommittee = beaconStateAccessor.GetBeaconCommittee(state, attestationData.Slot, attestationData.Index);

            int         committeeSize   = beaconCommittee.Count;
            BitArray    aggregationBits = new BitArray(committeeSize);
            Attestation attestation     = new Attestation(aggregationBits, attestationData, BlsSignature.Zero);

            FillAggregateAttestation(state, attestation, beaconStateAccessor);

            if (signed)
            {
                SignAttestation(testServiceProvider, state, attestation);
            }

            return(attestation);
        }
Ejemplo n.º 2
0
        private static void FillAggregateAttestation(BeaconState state, Attestation attestation,
                                                     BeaconStateAccessor beaconStateAccessor)
        {
            var beaconCommittee = beaconStateAccessor.GetBeaconCommittee(state, attestation.Data.Slot, attestation.Data.Index);

            for (var i = 0; i < beaconCommittee.Count; i++)
            {
                attestation.AggregationBits[i] = true;
            }
        }
Ejemplo n.º 3
0
        private static void FillAggregateAttestation(BeaconState state, Attestation attestation,
                                                     BeaconStateAccessor beaconStateAccessor)
        {
            IReadOnlyList <ValidatorIndex> beaconCommittee = beaconStateAccessor.GetBeaconCommittee(state, attestation.Data.Slot, attestation.Data.Index);

            for (int i = 0; i < beaconCommittee.Count; i++)
            {
                attestation.AggregationBits[i] = true;
            }
        }