Skip to content

Commit dfc5970

Browse files
authored
Merge branch 'unstable' into column-syncer
2 parents 00c22d0 + eec3f17 commit dfc5970

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

57 files changed

+1211
-798
lines changed

AllTests-mainnet.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -792,6 +792,7 @@ AllTests-mainnet
792792
+ Access peers by key test OK
793793
+ Acquire from empty pool OK
794794
+ Acquire/Sorting and consistency test OK
795+
+ Custom filters test OK
795796
+ Delete peer on release text OK
796797
+ Iterators test OK
797798
+ Peer lifetime test OK

ConsensusSpecPreset-mainnet.md

Lines changed: 10 additions & 75 deletions
Large diffs are not rendered by default.

ConsensusSpecPreset-minimal.md

Lines changed: 11 additions & 77 deletions
Large diffs are not rendered by default.

beacon_chain/beacon_chain_db_immutable.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ type
132132
current_sync_committee*: SyncCommittee # [New in Altair]
133133
next_sync_committee*: SyncCommittee # [New in Altair]
134134

135-
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.3/specs/bellatrix/beacon-chain.md#beaconstate
135+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/bellatrix/beacon-chain.md#beaconstate
136136
# Memory-representation-equivalent to a Bellatrix BeaconState for in-place SSZ
137137
# reading and writing
138138
BellatrixBeaconStateNoImmutableValidators* = object

beacon_chain/consensus_object_pools/attestation_pool.nim

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -507,7 +507,8 @@ proc addAttestation*(
507507

508508
template addAttToPool(_: electra.Attestation) {.used.} =
509509
let
510-
committee_index = get_committee_index_one(attestation.committee_bits).expect("TODO")
510+
committee_index = get_committee_index_one(
511+
attestation.committee_bits).expect("Gossip validation requires this")
511512
data = AttestationData(
512513
slot: attestation.data.slot,
513514
index: uint64 committee_index,
@@ -557,11 +558,10 @@ func covers*(
557558
## the existing aggregates, making it redundant
558559
## the `var` attestation pool is needed to use `withValue`, else Table becomes
559560
## unusably inefficient
560-
let candidateIdx = pool.candidateIdx(data.slot, CandidateIdxType.phase0Idx)
561-
if candidateIdx.isNone:
561+
let candidateIdx = pool.candidateIdx(data.slot, CandidateIdxType.phase0Idx).valueOr:
562562
return false
563563

564-
pool.phase0Candidates[candidateIdx.get()].withValue(
564+
pool.phase0Candidates[candidateIdx].withValue(
565565
getAttestationCandidateKey(data, Opt.none CommitteeIndex), entry):
566566
if entry[].covers(bits):
567567
return true
@@ -570,21 +570,21 @@ func covers*(
570570

571571
func covers*(
572572
pool: var AttestationPool, data: AttestationData,
573-
bits: ElectraCommitteeValidatorsBits): bool =
573+
aggregation_bits: ElectraCommitteeValidatorsBits,
574+
committee_bits: AttestationCommitteeBits): bool =
574575
## Return true iff the given attestation already is fully covered by one of
575576
## the existing aggregates, making it redundant
576577
## the `var` attestation pool is needed to use `withValue`, else Table becomes
577578
## unusably inefficient
578-
let candidateIdx = pool.candidateIdx(data.slot, CandidateIdxType.electraIdx)
579-
if candidateIdx.isNone:
579+
let candidateIdx = pool.candidateIdx(data.slot, CandidateIdxType.electraIdx).valueOr:
580580
return false
581581

582-
debugComment "foo"
583-
# needs to know more than attestationdata now
584-
#let attestation_data_root = hash_tree_root(data)
585-
#pool.electraCandidates[candidateIdx.get()].withValue(attestation_data_root, entry):
586-
# if entry[].covers(bits):
587-
# return true
582+
pool.electraCandidates[candidateIdx].withValue(
583+
getAttestationCandidateKey(
584+
data, Opt.some get_committee_index_one(
585+
committee_bits).expect("Gossip validation requires this")), entry):
586+
if entry[].covers(aggregation_bits):
587+
return true
588588

589589
false
590590

beacon_chain/el/eth1_chain.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -333,7 +333,7 @@ proc getBlockProposalData*(chain: var Eth1Chain,
333333
totalDepositsInNewBlock =
334334
withState(state):
335335
when consensusFork >= ConsensusFork.Electra:
336-
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/electra/validator.md#deposits
336+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/electra/validator.md#deposits
337337
let eth1_deposit_index_limit = min(
338338
forkyState.data.eth1_data.deposit_count,
339339
forkyState.data.deposit_requests_start_index)

beacon_chain/el/merkle_minimal.nim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
{.push raises: [].}
99

10-
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.3/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
10+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/tests/core/pyspec/eth2spec/utils/merkle_minimal.py
1111

1212
# Merkle tree helpers
1313
# ---------------------------------------------------------------

beacon_chain/gossip_processing/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,9 @@ Gossip validation is different from consensus verification in particular for blo
1111

1212
- Blocks: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#beacon_block
1313
- Attestations (aggregated): https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.0/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
14-
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.4.0/specs/phase0/p2p-interface.md#attestation-subnets
14+
- Attestations (unaggregated): https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/phase0/p2p-interface.md#attestation-subnets
1515
- Voluntary exits: https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.4/specs/phase0/p2p-interface.md#voluntary_exit
16-
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.10/specs/phase0/p2p-interface.md#proposer_slashing
16+
- Proposer slashings: https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/phase0/p2p-interface.md#proposer_slashing
1717
- Attester slashing: https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#attester_slashing
1818

1919
There are multiple consumers of validated consensus objects:

beacon_chain/gossip_processing/gossip_validation.nim

Lines changed: 24 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ func check_propagation_slot_range(
9595
return ok(msgSlot)
9696

9797
if consensusFork < ConsensusFork.Deneb:
98-
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/phase0/p2p-interface.md#configuration
98+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/phase0/p2p-interface.md#configuration
9999
# The spec value of ATTESTATION_PROPAGATION_SLOT_RANGE is 32, but it can
100100
# retransmit attestations on the cusp of being out of spec, and which by
101101
# the time they reach their destination might be out of spec.
@@ -1191,6 +1191,7 @@ proc validateAttestation*(
11911191

11921192
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.1/specs/phase0/p2p-interface.md#beacon_aggregate_and_proof
11931193
# https://github.com/ethereum/consensus-specs/blob/v1.4.0-beta.5/specs/deneb/p2p-interface.md#beacon_aggregate_and_proof
1194+
# https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/electra/p2p-interface.md#beacon_aggregate_and_proof
11941195
proc validateAggregate*(
11951196
pool: ref AttestationPool, batchCrypto: ref BatchCrypto,
11961197
signedAggregateAndProof:
@@ -1215,6 +1216,11 @@ proc validateAggregate*(
12151216
return pool.checkedReject(v.error)
12161217
v.get()
12171218

1219+
# [REJECT] aggregate.data.index == 0
1220+
when signedAggregateAndProof is electra.SignedAggregateAndProof:
1221+
if not(aggregate.data.index == 0):
1222+
return pool.checkedReject("Aggregate: Electra aggregate.data.index != 0")
1223+
12181224
# [IGNORE] aggregate.data.slot is within the last
12191225
# ATTESTATION_PROPAGATION_SLOT_RANGE slots (with a
12201226
# MAXIMUM_GOSSIP_CLOCK_DISPARITY allowance) -- i.e. aggregate.data.slot +
@@ -1279,11 +1285,13 @@ proc validateAggregate*(
12791285
# [REJECT] The committee index is within the expected range -- i.e.
12801286
# data.index < get_committee_count_per_slot(state, data.target.epoch).
12811287
let committee_index = block:
1282-
when signedAggregateAndProof is electra.SignedAggregateAndProof:
1288+
when kind(typeof(signedAggregateAndProof)) == ConsensusFork.Electra:
1289+
# [REJECT] len(committee_indices) == 1, where committee_indices =
1290+
# get_committee_indices(aggregate)
12831291
let agg_idx = get_committee_index_one(aggregate.committee_bits).valueOr:
12841292
return pool.checkedReject("Aggregate: got multiple committee bits")
12851293
let idx = shufflingRef.get_committee_index(agg_idx.uint64)
1286-
elif signedAggregateAndProof is phase0.SignedAggregateAndProof:
1294+
elif kind(typeof(signedAggregateAndProof)) == ConsensusFork.Phase0:
12871295
let idx = shufflingRef.get_committee_index(aggregate.data.index)
12881296
else:
12891297
static: doAssert false
@@ -1296,13 +1304,19 @@ proc validateAggregate*(
12961304
return pool.checkedReject(
12971305
"Aggregate: number of aggregation bits and committee size mismatch")
12981306

1299-
if checkCover and
1300-
pool[].covers(aggregate.data, aggregate.aggregation_bits):
1301-
# [IGNORE] A valid aggregate attestation defined by
1302-
# `hash_tree_root(aggregate.data)` whose `aggregation_bits` is a non-strict
1303-
# superset has _not_ already been seen.
1304-
# https://github.com/ethereum/consensus-specs/pull/2847
1305-
return errIgnore("Aggregate: already covered")
1307+
# [IGNORE] A valid aggregate attestation defined by
1308+
# `hash_tree_root(aggregate.data)` whose `aggregation_bits` is a non-strict
1309+
# superset has _not_ already been seen.
1310+
# https://github.com/ethereum/consensus-specs/pull/2847
1311+
when kind(typeof(signedAggregateAndProof)) == ConsensusFork.Electra:
1312+
if checkCover and
1313+
pool[].covers(aggregate.data, aggregate.aggregation_bits,
1314+
aggregate.committee_bits):
1315+
return errIgnore("Aggregate: already covered")
1316+
else:
1317+
if checkCover and
1318+
pool[].covers(aggregate.data, aggregate.aggregation_bits):
1319+
return errIgnore("Aggregate: already covered")
13061320

13071321
# [REJECT] aggregate_and_proof.selection_proof selects the validator as an
13081322
# aggregator for the slot -- i.e. is_aggregator(state, aggregate.data.slot,

beacon_chain/libnimbus_lc/libnimbus_lc.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -94,7 +94,7 @@ typedef struct ETHConsensusConfig ETHConsensusConfig;
9494
* based on the given `config.yaml` file content - If successful.
9595
* @return `NULL` - If the given `config.yaml` is malformed or incompatible.
9696
*
97-
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.3/configs/README.md
97+
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/configs/README.md
9898
*/
9999
ETH_RESULT_USE_CHECK
100100
ETHConsensusConfig *_Nullable ETHConsensusConfigCreateFromYaml(const char *configFileContent);
@@ -150,7 +150,7 @@ typedef struct ETHBeaconState ETHBeaconState;
150150
* @return `NULL` - If the given `sszBytes` is malformed.
151151
*
152152
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.0/specs/phase0/beacon-chain.md#beaconstate
153-
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.3/specs/altair/beacon-chain.md#beaconstate
153+
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/altair/beacon-chain.md#beaconstate
154154
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.8/specs/bellatrix/beacon-chain.md#beaconstate
155155
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.2/specs/capella/beacon-chain.md#beaconstate
156156
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.9/configs/README.md
@@ -326,7 +326,7 @@ typedef struct ETHLightClientStore ETHLightClientStore;
326326
* @see https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Beacon/getLightClientBootstrap
327327
* @see https://ethereum.github.io/beacon-APIs/?urls.primaryName=v2.4.1#/Events/eventstream
328328
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.0/specs/altair/light-client/light-client.md
329-
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-alpha.9/specs/phase0/weak-subjectivity.md#weak-subjectivity-period
329+
* @see https://github.com/ethereum/consensus-specs/blob/v1.5.0-beta.4/specs/phase0/weak-subjectivity.md#weak-subjectivity-period
330330
*/
331331
ETH_RESULT_USE_CHECK
332332
ETHLightClientStore *_Nullable ETHLightClientStoreCreateFromBootstrap(

0 commit comments

Comments
 (0)