Consensys / teku

Open-source Ethereum consensus client written in Java
https://consensys.io/teku
Apache License 2.0
671 stars 283 forks source link

Update the beacon block body #8102

Closed mehdi-aouadi closed 2 months ago

mehdi-aouadi commented 7 months ago

Block proposal

Constructing the BeaconBlockBody

Attestations

The network attestation aggregates contain only the assigned committee attestations. Attestation aggregates received by the block proposer from the committee aggregators with disjoint committee_bits sets and equal AttestationData SHOULD be consolidated into a single Attestation object. The proposer should run the following function to construct an on chain final aggregate form a list of network aggregates with equal AttestationData:

def compute_on_chain_aggregate(network_aggregates: List[Attestation]) -> Attestation:
    aggregates = sorted(network_aggregates, key=lambda a: get_committee_indices(a.committee_bits)[0])

    data = aggregates[0].data
    aggregation_bits = Bitlist[MAX_VALIDATORS_PER_COMMITTEE * MAX_COMMITTEES_PER_SLOT]()
    for a in aggregates:
        for b in a.aggregation_bits:
            aggregation_bits.append(b)

    signature = bls.Aggregate([a.signature for a in aggregates])

    committee_indices = [get_committee_indices(a.committee_bits)[0] for a in aggregates]
    committee_flags = [(index in committee_indices) for index in range(0, MAX_COMMITTEES_PER_SLOT)]        
    committee_bits = Bitvector[MAX_COMMITTEES_PER_SLOT](committee_flags)

    return Attestation(aggregation_bits, data, committee_bits, signature)
mehdi-aouadi commented 2 months ago

Done