Skip to content

Commit c52c598

Browse files
authored
Electra: Remaining Consensus Data Structures (#5712)
* Attestation superstruct changes for EIP 7549 (#5644) * update * experiment * superstruct changes * revert * superstruct changes * fix tests * indexed attestation * indexed attestation superstruct * updated TODOs * `superstruct` the `AttesterSlashing` (#5636) * `superstruct` Attester Fork Variants * Push a little further * Deal with Encode / Decode of AttesterSlashing * not so sure about this.. * Stop Encode/Decode Bounds from Propagating Out * Tons of Changes.. * More Conversions to AttestationRef * Add AsReference trait (#15) * Add AsReference trait * Fix some snafus * Got it Compiling! :D * Got Tests Building * Get beacon chain tests compiling --------- Co-authored-by: Michael Sproul <[email protected]> * Merge remote-tracking branch 'upstream/unstable' into electra_attestation_changes * Make EF Tests Fork-Agnostic (#5713) * Finish EF Test Fork Agnostic (#5714) * Superstruct `AggregateAndProof` (#5715) * Upgrade `superstruct` to `0.8.0` * superstruct `AggregateAndProof` * Merge remote-tracking branch 'sigp/unstable' into electra_attestation_changes * cargo fmt * Merge pull request #5726 from realbigsean/electra_attestation_changes Merge unstable into Electra attestation changes * EIP7549 `get_attestation_indices` (#5657) * get attesting indices electra impl * fmt * get tests to pass * fmt * fix some beacon chain tests * fmt * fix slasher test * fmt got me again * fix more tests * fix tests * Some small changes (#5739) * cargo fmt (#5740) * Sketch op pool changes * fix get attesting indices (#5742) * fix get attesting indices * better errors * fix compile * only get committee index once * Ef test fixes (#5753) * attestation related ef test fixes * delete commented out stuff * Fix Aggregation Pool for Electra (#5754) * Fix Aggregation Pool for Electra * Remove Outdated Interface * fix ssz (#5755) * Get `electra_op_pool` up to date (#5756) * fix get attesting indices (#5742) * fix get attesting indices * better errors * fix compile * only get committee index once * Ef test fixes (#5753) * attestation related ef test fixes * delete commented out stuff * Fix Aggregation Pool for Electra (#5754) * Fix Aggregation Pool for Electra * Remove Outdated Interface * fix ssz (#5755) --------- Co-authored-by: realbigsean <[email protected]> * Revert "Get `electra_op_pool` up to date (#5756)" (#5757) This reverts commit ab9e58a. * Merge branch 'electra_attestation_changes' of https://github.com/sigp/lighthouse into electra_op_pool * Compute on chain aggregate impl (#5752) * add compute_on_chain_agg impl to op pool changes * fmt * get op pool tests to pass * update the naive agg pool interface (#5760) * Fix bugs in cross-committee aggregation * Add comment to max cover optimisation * Fix assert * Merge pull request #5749 from sigp/electra_op_pool Optimise Electra op pool aggregation * update committee offset * Fix Electra Fork Choice Tests (#5764) * Subscribe to the correct subnets for electra attestations (#5782) * subscribe to the correct att subnets for electra * subscribe to the correct att subnets for electra * cargo fmt * fix slashing handling * Merge remote-tracking branch 'upstream/unstable' * Send unagg attestation based on fork * Publish all aggregates * just one more check bro plz.. * Merge pull request #5832 from ethDreamer/electra_attestation_changes_merge_unstable Merge `unstable` into `electra_attestation_changes` * Merge pull request #5835 from realbigsean/fix-validator-logic Fix validator logic * Merge pull request #5816 from realbigsean/electra-attestation-slashing-handling Electra slashing handling * Electra attestation changes rm decode impl (#5856) * Remove Crappy Decode impl for Attestation * Remove Inefficient Attestation Decode impl * Implement Schema Upgrade / Downgrade * Update beacon_node/beacon_chain/src/schema_change/migration_schema_v20.rs Co-authored-by: Michael Sproul <[email protected]> --------- Co-authored-by: Michael Sproul <[email protected]> * Fix failing attestation tests and misc electra attestation cleanup (#5810) * - get attestation related beacon chain tests to pass - observed attestations are now keyed off of data + committee index - rename op pool attestationref to compactattestationref - remove unwraps in agg pool and use options instead - cherry pick some changes from ef-tests-electra * cargo fmt * fix failing test * Revert dockerfile changes * make committee_index return option * function args shouldnt be a ref to attestation ref * fmt * fix dup imports --------- Co-authored-by: realbigsean <[email protected]> * fix some todos (#5817) * Merge branch 'unstable' of https://github.com/sigp/lighthouse into electra_attestation_changes * add consolidations to merkle calc for inclusion proof * Remove Duplicate KZG Commitment Merkle Proof Code (#5874) * Remove Duplicate KZG Commitment Merkle Proof Code * s/tree_lists/fields/ * Merge branch 'unstable' of https://github.com/sigp/lighthouse into electra_attestation_changes * fix compile * Fix slasher tests (#5906) * Fix electra tests * Add electra attestations to double vote tests * Update superstruct to 0.8 * Merge remote-tracking branch 'origin/unstable' into electra_attestation_changes * Small cleanup in slasher tests * Clean up Electra observed aggregates (#5929) * Use consistent key in observed_attestations * Remove unwraps from observed aggregates * Merge branch 'unstable' of https://github.com/sigp/lighthouse into electra_attestation_changes * De-dup attestation constructor logic * Remove unwraps in Attestation construction * Dedup match_attestation_data * Remove outdated TODO * Use ForkName Ord in fork-choice tests * Use ForkName Ord in BeaconBlockBody * Make to_electra not fallible * Remove TestRandom impl for IndexedAttestation * Remove IndexedAttestation faulty Decode impl * Drop TestRandom impl * Add PendingAttestationInElectra * Indexed att on disk (#35) * indexed att on disk * fix lints * Update slasher/src/migrate.rs Co-authored-by: ethDreamer <[email protected]> --------- Co-authored-by: Lion - dapplion <[email protected]> Co-authored-by: ethDreamer <[email protected]> * add electra fork enabled fn to ForkName impl (#36) * add electra fork enabled fn to ForkName impl * remove inadvertent file * Update common/eth2/src/types.rs Co-authored-by: ethDreamer <[email protected]> * Dedup attestation constructor logic in attester cache * Use if let Ok for committee_bits * Dedup Attestation constructor code * Diff reduction in tests * Fix beacon_chain tests * Diff reduction * Use Ord for ForkName in pubsub * Resolve into_attestation_and_indices todo * Remove stale TODO * Fix beacon_chain tests * Test spec invariant * Use electra_enabled in pubsub * Remove get_indexed_attestation_from_signed_aggregate * Use ok_or instead of if let else * committees are sorted * remove dup method `get_indexed_attestation_from_committees` * Merge pull request #5940 from dapplion/electra_attestation_changes_lionreview Electra attestations #5712 review * update default persisted op pool deserialization * ensure aggregate and proof uses serde untagged on ref * Fork aware ssz static attestation tests * Electra attestation changes from Lions review (#5971) * dedup/cleanup and remove unneeded hashset use * remove irrelevant TODOs * Merge branch 'unstable' of https://github.com/sigp/lighthouse into electra_attestation_changes * Electra attestation changes sean review (#5972) * instantiate empty bitlist in unreachable code * clean up error conversion * fork enabled bool cleanup * remove a couple todos * return bools instead of options in `aggregate` and use the result * delete commented out code * use map macros in simple transformations * remove signers_disjoint_from * get ef tests compiling * get ef tests compiling * update intentionally excluded files * Avoid changing slasher schema for Electra * Delete slasher schema v4 * Fix clippy * Fix compilation of beacon_chain tests * Update database.rs * Add electra lightclient types * Update slasher/src/database.rs * fix imports * Merge pull request #5980 from dapplion/electra-lightclient Add electra lightclient types * Merge pull request #5975 from michaelsproul/electra-slasher-no-migration Avoid changing slasher schema for Electra * Update beacon_node/beacon_chain/src/attestation_verification.rs * Update beacon_node/beacon_chain/src/attestation_verification.rs
1 parent 758b58c commit c52c598

File tree

118 files changed

+5064
-1729
lines changed

Some content is hidden

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

118 files changed

+5064
-1729
lines changed

Cargo.lock

Lines changed: 3 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ smallvec = "1.11.2"
162162
snap = "1"
163163
ssz_types = "0.6"
164164
strum = { version = "0.24", features = ["derive"] }
165-
superstruct = "0.7"
165+
superstruct = "0.8"
166166
syn = "1"
167167
sysinfo = "0.26"
168168
tempfile = "3"

beacon_node/beacon_chain/src/attestation_simulator.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,7 @@ pub fn produce_unaggregated_attestation<T: BeaconChainTypes>(
8282
// Store the unaggregated attestation in the validator monitor for later processing
8383
match chain.produce_unaggregated_attestation(current_slot, beacon_committee_index) {
8484
Ok(unaggregated_attestation) => {
85-
let data = &unaggregated_attestation.data;
85+
let data = unaggregated_attestation.data();
8686

8787
debug!(
8888
chain.log,

beacon_node/beacon_chain/src/attestation_verification.rs

Lines changed: 262 additions & 126 deletions
Large diffs are not rendered by default.

beacon_node/beacon_chain/src/attestation_verification/batch.rs

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -66,14 +66,13 @@ where
6666
.ok_or(BeaconChainError::ValidatorPubkeyCacheLockTimeout)?;
6767

6868
let mut signature_sets = Vec::with_capacity(num_indexed * 3);
69-
7069
// Iterate, flattening to get only the `Ok` values.
7170
for indexed in indexing_results.iter().flatten() {
7271
let signed_aggregate = &indexed.signed_aggregate;
7372
let indexed_attestation = &indexed.indexed_attestation;
7473
let fork = chain
7574
.spec
76-
.fork_at_epoch(indexed_attestation.data.target.epoch);
75+
.fork_at_epoch(indexed_attestation.data().target.epoch);
7776

7877
signature_sets.push(
7978
signed_aggregate_selection_proof_signature_set(
@@ -98,7 +97,7 @@ where
9897
signature_sets.push(
9998
indexed_attestation_signature_set_from_pubkeys(
10099
|validator_index| pubkey_cache.get(validator_index).map(Cow::Borrowed),
101-
&indexed_attestation.signature,
100+
indexed_attestation.signature(),
102101
indexed_attestation,
103102
&fork,
104103
chain.genesis_validators_root,
@@ -182,11 +181,11 @@ where
182181
let indexed_attestation = &partially_verified.indexed_attestation;
183182
let fork = chain
184183
.spec
185-
.fork_at_epoch(indexed_attestation.data.target.epoch);
184+
.fork_at_epoch(indexed_attestation.data().target.epoch);
186185

187186
let signature_set = indexed_attestation_signature_set_from_pubkeys(
188187
|validator_index| pubkey_cache.get(validator_index).map(Cow::Borrowed),
189-
&indexed_attestation.signature,
188+
indexed_attestation.signature(),
190189
indexed_attestation,
191190
&fork,
192191
chain.genesis_validators_root,

beacon_node/beacon_chain/src/attester_cache.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ use state_processing::state_advance::{partial_state_advance, Error as StateAdvan
1515
use std::collections::HashMap;
1616
use std::ops::Range;
1717
use types::{
18+
attestation::Error as AttestationError,
1819
beacon_state::{
1920
compute_committee_index_in_epoch, compute_committee_range_in_epoch, epoch_committee_count,
2021
},
@@ -59,6 +60,7 @@ pub enum Error {
5960
InverseRange {
6061
range: Range<usize>,
6162
},
63+
AttestationError(AttestationError),
6264
}
6365

6466
impl From<BeaconStateError> for Error {

beacon_node/beacon_chain/src/beacon_block_reward.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -202,7 +202,7 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
202202
let mut previous_epoch_participation = state.previous_epoch_participation()?.clone();
203203

204204
for attestation in block.body().attestations() {
205-
let data = &attestation.data;
205+
let data = attestation.data();
206206
let inclusion_delay = state.slot().safe_sub(data.slot)?.as_u64();
207207
// [Modified in Deneb:EIP7045]
208208
let participation_flag_indices = get_attestation_participation_flag_indices(

0 commit comments

Comments
 (0)