mirror of
https://github.com/sigp/lighthouse.git
synced 2026-04-26 09:13:41 +00:00
Refactor/stream vc vote publishing (#8880)
Changes four `ValidatorStore` batch signing methods to return `impl Stream` instead of `Future`. Services consume the stream and publish each batch as it arrives. No behavioral change for lh since `LighthouseValidatorStore` wraps everything in `stream::once` Also replaces anonymous tuples in method signatures with named structs Co-Authored-By: shane-moore <skm1790@gmail.com> Co-Authored-By: Michael Sproul <michaelsproul@users.noreply.github.com> Co-Authored-By: Mac L <mjladson@pm.me>
This commit is contained in:
@@ -25,6 +25,7 @@ mod tests {
|
||||
use eth2_keystore::KeystoreBuilder;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use fixed_bytes::FixedBytesExtended;
|
||||
use futures::StreamExt;
|
||||
use initialized_validators::{
|
||||
InitializedValidators, load_pem_certificate, load_pkcs12_identity,
|
||||
};
|
||||
@@ -50,7 +51,7 @@ mod tests {
|
||||
use types::{attestation::AttestationBase, *};
|
||||
use url::Url;
|
||||
use validator_store::{
|
||||
Error as ValidatorStoreError, SignedBlock, UnsignedBlock, ValidatorStore,
|
||||
AttestationToSign, Error as ValidatorStoreError, SignedBlock, UnsignedBlock, ValidatorStore,
|
||||
};
|
||||
|
||||
/// If the we are unable to reach the Web3Signer HTTP API within this time out then we will
|
||||
@@ -654,13 +655,14 @@ mod tests {
|
||||
.await
|
||||
.assert_signatures_match("attestation", |pubkey, validator_store| async move {
|
||||
let attestation = get_attestation();
|
||||
validator_store
|
||||
.sign_attestations(vec![(0, pubkey, 0, attestation)])
|
||||
.await
|
||||
.unwrap()
|
||||
.pop()
|
||||
.unwrap()
|
||||
.1
|
||||
let stream = validator_store.sign_attestations(vec![AttestationToSign {
|
||||
validator_index: 0,
|
||||
pubkey,
|
||||
validator_committee_index: 0,
|
||||
attestation,
|
||||
}]);
|
||||
tokio::pin!(stream);
|
||||
stream.next().await.unwrap().unwrap().pop().unwrap().1
|
||||
})
|
||||
.await
|
||||
.assert_signatures_match("signed_aggregate", |pubkey, validator_store| async move {
|
||||
@@ -879,22 +881,28 @@ mod tests {
|
||||
.await
|
||||
.assert_signatures_match("first_attestation", |pubkey, validator_store| async move {
|
||||
let attestation = first_attestation();
|
||||
validator_store
|
||||
.sign_attestations(vec![(0, pubkey, 0, attestation)])
|
||||
.await
|
||||
.unwrap()
|
||||
.pop()
|
||||
.unwrap()
|
||||
.1
|
||||
let stream = validator_store.sign_attestations(vec![AttestationToSign {
|
||||
validator_index: 0,
|
||||
pubkey,
|
||||
validator_committee_index: 0,
|
||||
attestation,
|
||||
}]);
|
||||
tokio::pin!(stream);
|
||||
stream.next().await.unwrap().unwrap().pop().unwrap().1
|
||||
})
|
||||
.await
|
||||
.assert_slashable_attestation_should_sign(
|
||||
"double_vote_attestation",
|
||||
move |pubkey, validator_store| async move {
|
||||
let attestation = double_vote_attestation();
|
||||
validator_store
|
||||
.sign_attestations(vec![(0, pubkey, 0, attestation)])
|
||||
.await
|
||||
let stream = validator_store.sign_attestations(vec![AttestationToSign {
|
||||
validator_index: 0,
|
||||
pubkey,
|
||||
validator_committee_index: 0,
|
||||
attestation,
|
||||
}]);
|
||||
tokio::pin!(stream);
|
||||
stream.next().await.unwrap()
|
||||
},
|
||||
slashable_message_should_sign,
|
||||
)
|
||||
@@ -903,9 +911,14 @@ mod tests {
|
||||
"surrounding_attestation",
|
||||
move |pubkey, validator_store| async move {
|
||||
let attestation = surrounding_attestation();
|
||||
validator_store
|
||||
.sign_attestations(vec![(0, pubkey, 0, attestation)])
|
||||
.await
|
||||
let stream = validator_store.sign_attestations(vec![AttestationToSign {
|
||||
validator_index: 0,
|
||||
pubkey,
|
||||
validator_committee_index: 0,
|
||||
attestation,
|
||||
}]);
|
||||
tokio::pin!(stream);
|
||||
stream.next().await.unwrap()
|
||||
},
|
||||
slashable_message_should_sign,
|
||||
)
|
||||
@@ -914,9 +927,14 @@ mod tests {
|
||||
"surrounded_attestation",
|
||||
move |pubkey, validator_store| async move {
|
||||
let attestation = surrounded_attestation();
|
||||
validator_store
|
||||
.sign_attestations(vec![(0, pubkey, 0, attestation)])
|
||||
.await
|
||||
let stream = validator_store.sign_attestations(vec![AttestationToSign {
|
||||
validator_index: 0,
|
||||
pubkey,
|
||||
validator_committee_index: 0,
|
||||
attestation,
|
||||
}]);
|
||||
tokio::pin!(stream);
|
||||
stream.next().await.unwrap()
|
||||
},
|
||||
slashable_message_should_sign,
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user