Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

SingleAttestation implementation #6488

Open
wants to merge 101 commits into
base: unstable
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
25feedf
First pass
pawanjay176 Aug 29, 2024
4dc6e65
Add restrictions to RuntimeVariableList api
pawanjay176 Aug 30, 2024
a9cb329
Use empty_uninitialized and fix warnings
pawanjay176 Aug 30, 2024
60100fc
Fix some todos
pawanjay176 Aug 30, 2024
13f9bba
Merge branch 'unstable' into max-blobs-preset
pawanjay176 Sep 3, 2024
e71020e
Fix take impl on RuntimeFixedList
pawanjay176 Sep 4, 2024
52bb581
cleanup
pawanjay176 Sep 4, 2024
d37733b
Fix test compilations
pawanjay176 Sep 4, 2024
12c6ef1
Fix some more tests
pawanjay176 Sep 4, 2024
2fcb293
Fix test from unstable
pawanjay176 Sep 7, 2024
21ecb58
Merge branch 'unstable' into max-blobs-preset
pawanjay176 Oct 21, 2024
366bed3
SingleAttestation
eserilev Dec 4, 2024
68292ad
Add post attestation v2 endpoint logic to attestation service
eserilev Dec 13, 2024
5a4cd3b
Merge branch 'unstable' of https://github.com/sigp/lighthouse into si…
eserilev Dec 13, 2024
9d5a3af
Implement "Bugfix and more withdrawal tests"
michaelsproul Dec 19, 2024
f892849
Implement "Add missed exit checks to consolidation processing"
michaelsproul Dec 19, 2024
f27216f
Implement "Update initial earliest_exit_epoch calculation"
michaelsproul Dec 19, 2024
c31f1cc
Implement "Limit consolidating balance by validator.effective_balance"
michaelsproul Dec 20, 2024
282eefb
Implement "Use 16-bit random value in validator filter"
michaelsproul Dec 20, 2024
52e602d
Implement "Do not change creds type on consolidation"
michaelsproul Dec 20, 2024
f56083d
some tests and fixed attestqtion calc
eserilev Dec 20, 2024
44d15a9
Merge branch 'unstable' of https://github.com/sigp/lighthouse into si…
eserilev Dec 23, 2024
293db28
Rename PendingPartialWithdraw index field to validator_index
eserilev Jan 2, 2025
9b8a25f
Skip slots to get test to pass and add TODO
eserilev Jan 2, 2025
23d331b
Implement "Synchronously check all transactions to have non-zero length"
eserilev Jan 2, 2025
0c2c8c4
Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
michaelsproul Jan 6, 2025
de01f92
Remove footgun function
michaelsproul Jan 6, 2025
1095d60
Minor simplifications
michaelsproul Jan 6, 2025
2e86585
Move from preset to config
michaelsproul Jan 6, 2025
32483d3
Fix typo
michaelsproul Jan 6, 2025
88bedf0
Revert "Remove footgun function"
michaelsproul Jan 6, 2025
063b79c
Try fixing tests
michaelsproul Jan 6, 2025
251bca7
Implement "bump minimal preset MAX_BLOB_COMMITMENTS_PER_BLOCK and KZG…
eserilev Jan 6, 2025
e4bfe71
Thread through ChainSpec
michaelsproul Jan 6, 2025
f66e179
Fix release tests
michaelsproul Jan 6, 2025
440e854
Move RuntimeFixedVector into module and rename
michaelsproul Jan 6, 2025
04b3743
Add test
michaelsproul Jan 6, 2025
4700ef9
Merge branch 'unstable' of https://github.com/sigp/lighthouse into si…
eserilev Jan 6, 2025
c7ef72d
Added more test coverage, simplified Attestation conversion, and othe…
eserilev Jan 6, 2025
9945079
Removed unusued codepaths
eserilev Jan 6, 2025
12e442c
Fix failing test
eserilev Jan 6, 2025
3d3bc6d
Implement "Remove post-altair `initialize_beacon_state_from_eth1` fro…
eserilev Jan 6, 2025
2dbd3b7
Update preset YAML
michaelsproul Jan 7, 2025
0cd263f
Remove empty RuntimeVarList awefullness
pawanjay176 Jan 7, 2025
3b788bf
Make max_blobs_per_block a config parameter (#6329)
michaelsproul Jan 7, 2025
7c215f8
Fix tests
pawanjay176 Jan 7, 2025
0f26408
Implement max_blobs_per_block_electra
michaelsproul Jan 7, 2025
d65e821
Fix config issues
michaelsproul Jan 7, 2025
26c409c
Simplify BlobSidecarListFromRoot
michaelsproul Jan 7, 2025
eee9218
Disable PeerDAS tests
michaelsproul Jan 7, 2025
e95f003
Cleanup single attestation imports
eserilev Jan 7, 2025
823ddf5
Fix some single attestation network plumbing
eserilev Jan 7, 2025
07c039c
Merge remote-tracking branch 'origin/unstable' into max-blobs-preset
michaelsproul Jan 9, 2025
d4e152c
Bump quota to account for new target (6)
michaelsproul Jan 9, 2025
a73ecb5
Remove clone
michaelsproul Jan 9, 2025
f13bdfc
Fix issue from review
pawanjay176 Jan 9, 2025
70917f7
Try to remove ugliness
pawanjay176 Jan 10, 2025
22b7fcb
Merge branch 'unstable' into max-blobs-preset
pawanjay176 Jan 10, 2025
9e972b1
Merge remote-tracking branch 'origin/unstable' into electra-alpha10
michaelsproul Jan 10, 2025
bb59e7a
Merge commit '04b3743ec1e0b650269dd8e58b540c02430d1c0d' into electra-…
michaelsproul Jan 10, 2025
1d4dc59
Merge remote-tracking branch 'pawan/max-blobs-preset' into electra-al…
michaelsproul Jan 10, 2025
bba7310
Update tests to v1.5.0-beta.0
michaelsproul Jan 10, 2025
8c96c35
Merge remote-tracking branch 'origin/electra-alpha10' into single_att…
michaelsproul Jan 10, 2025
d7a69e4
Fix some tests
michaelsproul Jan 10, 2025
ce488b2
Cargo fmt
michaelsproul Jan 10, 2025
b42cc84
lint
eserilev Jan 10, 2025
7bd174e
fmt
eserilev Jan 10, 2025
ef13f0f
Resolve merge conflicts
eserilev Jan 10, 2025
40f65bb
Merge branch 'electra-alpha10' of https://github.com/sigp/lighthouse …
eserilev Jan 10, 2025
fe3d5de
lint
eserilev Jan 10, 2025
72bcc8a
Linting
eserilev Jan 10, 2025
344ba2b
fmt
eserilev Jan 10, 2025
eb5d3eb
Merge branch 'electra-alpha10' of https://github.com/sigp/lighthouse …
eserilev Jan 10, 2025
fdf9af8
Fmt
eserilev Jan 10, 2025
a45c0f0
Fix test and add TODO
eserilev Jan 10, 2025
f4fe1b8
Gracefully handle slashed proposers in fork choice tests
michaelsproul Jan 13, 2025
1205d83
Merge remote-tracking branch 'origin/unstable' into electra-alpha10
michaelsproul Jan 13, 2025
3b17732
Keep latest changes from max_blobs_per_block PR in codec.rs
michaelsproul Jan 13, 2025
e2ff440
Revert a few more regressions and add a comment
michaelsproul Jan 13, 2025
6cc798a
Merge branch 'electra-alpha10' of https://github.com/sigp/lighthouse …
eserilev Jan 13, 2025
7df6560
Disable more DAS tests
michaelsproul Jan 13, 2025
4fbca37
Improve validator monitor test a little
michaelsproul Jan 13, 2025
e821e62
Make test more robust
michaelsproul Jan 13, 2025
0b36d60
Fix sync test that didn't understand blobs
michaelsproul Jan 13, 2025
4f08ac7
Fill out cropped comment
michaelsproul Jan 13, 2025
11c1949
Merge remote-tracking branch 'origin/electra-alpha10' into single_att…
michaelsproul Jan 14, 2025
e76322e
Merge remote-tracking branch 'origin/unstable' into single_attestation
michaelsproul Jan 14, 2025
d8f32de
Merge remote-tracking branch 'origin/unstable' into single_attestation
michaelsproul Jan 14, 2025
fb5e378
Merge branch 'unstable' of https://github.com/sigp/lighthouse into si…
eserilev Jan 14, 2025
2d61b65
publish_attestations should accept Either<Attestation,SingleAttestation>
eserilev Jan 14, 2025
b6d80eb
log an error when failing to convert to SingleAttestation
eserilev Jan 14, 2025
86ce323
Use Cow to avoid clone
michaelsproul Jan 15, 2025
8cc43c1
Avoid reconverting to SingleAttestation
michaelsproul Jan 15, 2025
e900bb8
Tweak VC error message
michaelsproul Jan 15, 2025
72da039
update comments
eserilev Jan 15, 2025
b9b9b99
update comments
eserilev Jan 15, 2025
4f2182e
pass in single attestation as ref to subnetid calculation method
eserilev Jan 15, 2025
aa66b06
Improved API, new error variants and other minor tweaks
eserilev Jan 15, 2025
54844b3
Fix single_attestation event topic boilerplate
eserilev Jan 15, 2025
f7a0b37
fix sse event failure
eserilev Jan 15, 2025
42c01c6
Add single_attestation event topic test coverage
eserilev Jan 16, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

13 changes: 12 additions & 1 deletion beacon_node/beacon_chain/src/attestation_verification.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use tree_hash::TreeHash;
use types::{
Attestation, AttestationRef, BeaconCommittee, BeaconStateError::NoCommitteeFound, ChainSpec,
CommitteeIndex, Epoch, EthSpec, Hash256, IndexedAttestation, SelectionProof,
SignedAggregateAndProof, Slot, SubnetId,
SignedAggregateAndProof, SingleAttestation, Slot, SubnetId,
};

pub use batch::{batch_verify_aggregated_attestations, batch_verify_unaggregated_attestations};
Expand Down Expand Up @@ -317,12 +317,22 @@ pub struct VerifiedUnaggregatedAttestation<'a, T: BeaconChainTypes> {
attestation: AttestationRef<'a, T::EthSpec>,
indexed_attestation: IndexedAttestation<T::EthSpec>,
subnet_id: SubnetId,
validator_index: usize,
}

impl<T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'_, T> {
pub fn into_indexed_attestation(self) -> IndexedAttestation<T::EthSpec> {
self.indexed_attestation
}

eserilev marked this conversation as resolved.
Show resolved Hide resolved
pub fn single_attestation(&self) -> Option<SingleAttestation> {
Some(SingleAttestation {
committee_index: self.attestation.committee_index()? as usize,
attester_index: self.validator_index,
data: self.attestation.data().clone(),
signature: self.attestation.signature().clone(),
})
}
}

/// Custom `Clone` implementation is to avoid the restrictive trait bounds applied by the usual derive
Expand Down Expand Up @@ -1035,6 +1045,7 @@ impl<'a, T: BeaconChainTypes> VerifiedUnaggregatedAttestation<'a, T> {
attestation,
indexed_attestation,
subnet_id,
validator_index: validator_index as usize,
})
}

Expand Down
26 changes: 23 additions & 3 deletions beacon_node/beacon_chain/src/beacon_chain.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2035,10 +2035,30 @@ impl<T: BeaconChainTypes> BeaconChain<T> {
|v| {
// This method is called for API and gossip attestations, so this covers all unaggregated attestation events
if let Some(event_handler) = self.event_handler.as_ref() {
if event_handler.has_single_attestation_subscribers() {
let current_fork = self
.spec
.fork_name_at_slot::<T::EthSpec>(v.attestation().data().slot);
if current_fork.electra_enabled() {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it necessary to check the fork now? Can we have single attestations before electra?

// I don't see a situation where this could return None. The upstream unaggregated attestation checks
// should have already verified that this is an attestation with a single committee bit set.
if let Some(single_attestation) = v.single_attestation() {
event_handler.register(EventKind::SingleAttestation(Box::new(
single_attestation,
)));
}
}
}

if event_handler.has_attestation_subscribers() {
event_handler.register(EventKind::Attestation(Box::new(
v.attestation().clone_as_attestation(),
)));
let current_fork = self
.spec
.fork_name_at_slot::<T::EthSpec>(v.attestation().data().slot);
if !current_fork.electra_enabled() {
event_handler.register(EventKind::Attestation(Box::new(
v.attestation().clone_as_attestation(),
)));
}
}
}
metrics::inc_counter(&metrics::UNAGGREGATED_ATTESTATION_PROCESSING_SUCCESSES);
Expand Down
15 changes: 15 additions & 0 deletions beacon_node/beacon_chain/src/events.rs
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ const DEFAULT_CHANNEL_CAPACITY: usize = 16;

pub struct ServerSentEventHandler<E: EthSpec> {
attestation_tx: Sender<EventKind<E>>,
single_attestation_tx: Sender<EventKind<E>>,
block_tx: Sender<EventKind<E>>,
blob_sidecar_tx: Sender<EventKind<E>>,
finalized_tx: Sender<EventKind<E>>,
Expand Down Expand Up @@ -37,6 +38,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {

pub fn new_with_capacity(log: Logger, capacity: usize) -> Self {
let (attestation_tx, _) = broadcast::channel(capacity);
let (single_attestation_tx, _) = broadcast::channel(capacity);
let (block_tx, _) = broadcast::channel(capacity);
let (blob_sidecar_tx, _) = broadcast::channel(capacity);
let (finalized_tx, _) = broadcast::channel(capacity);
Expand All @@ -56,6 +58,7 @@ impl<E: EthSpec> ServerSentEventHandler<E> {

Self {
attestation_tx,
single_attestation_tx,
block_tx,
blob_sidecar_tx,
finalized_tx,
Expand Down Expand Up @@ -90,6 +93,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
.attestation_tx
.send(kind)
.map(|count| log_count("attestation", count)),
EventKind::SingleAttestation(_) => self
.single_attestation_tx
.send(kind)
.map(|count| log_count("single_attestation", count)),
EventKind::Block(_) => self
.block_tx
.send(kind)
Expand Down Expand Up @@ -164,6 +171,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
self.attestation_tx.subscribe()
}

pub fn subscribe_single_attestation(&self) -> Receiver<EventKind<E>> {
self.single_attestation_tx.subscribe()
}

pub fn subscribe_block(&self) -> Receiver<EventKind<E>> {
self.block_tx.subscribe()
}
Expand Down Expand Up @@ -232,6 +243,10 @@ impl<E: EthSpec> ServerSentEventHandler<E> {
self.attestation_tx.receiver_count() > 0
}

pub fn has_single_attestation_subscribers(&self) -> bool {
self.single_attestation_tx.receiver_count() > 0
}

pub fn has_block_subscribers(&self) -> bool {
self.block_tx.receiver_count() > 0
}
Expand Down
Loading
Loading