mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-09 11:41:51 +00:00
Update VC and BN APIs for naive aggregation (#950)
* Refactor `Attestation` production * Add constant * Start refactor for aggregation * Return early when no attesting validators * Refactor into individual functions * Tidy, add comments * Add first draft of NaiveAggregationPool * Further progress on naive aggregation pool * Fix compile errors in VC * Change locking logic for naive pool * Introduce AttesationType * Add pruning, comments * Add MAX_ATTESTATIONS_PER_SLOT restriction * Add pruning based on slot * Update BN for new aggregation fns * Fix test compile errors * Fix failing rest_api test * Move SignedAggregateAndProof into own file * Update docs, fix warning * Tidy some formatting in validator API * Remove T::default_spec from signing * Fix failing rest test * Tidy * Add test, fix bug * Improve naive pool tests * Add max attestations test * Revert changes to the op_pool * Refactor timer
This commit is contained in:
@@ -6,7 +6,7 @@ extern crate lazy_static;
|
||||
use beacon_chain::test_utils::{
|
||||
AttestationStrategy, BeaconChainHarness, BlockStrategy, HarnessType,
|
||||
};
|
||||
use beacon_chain::AttestationProcessingOutcome;
|
||||
use beacon_chain::{AttestationProcessingOutcome, AttestationType};
|
||||
use state_processing::per_slot_processing;
|
||||
use types::{
|
||||
test_utils::generate_deterministic_keypair, AggregateSignature, BitList, EthSpec, Hash256,
|
||||
@@ -56,7 +56,7 @@ fn attestation_validity() {
|
||||
.expect("should get at least one attestation");
|
||||
|
||||
assert_eq!(
|
||||
chain.process_attestation(valid_attestation.clone(), Some(false)),
|
||||
chain.process_attestation(valid_attestation.clone(), AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::Processed),
|
||||
"should accept valid attestation"
|
||||
);
|
||||
@@ -71,7 +71,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(epoch_mismatch_attestation, Some(false)),
|
||||
.process_attestation(epoch_mismatch_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::BadTargetEpoch),
|
||||
"should not accept attestation where the slot is not in the same epoch as the target"
|
||||
);
|
||||
@@ -87,7 +87,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(early_attestation, Some(false)),
|
||||
.process_attestation(early_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::FutureEpoch {
|
||||
attestation_epoch: current_epoch + 1,
|
||||
current_epoch
|
||||
@@ -122,7 +122,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(late_attestation, Some(false)),
|
||||
.process_attestation(late_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::PastEpoch {
|
||||
attestation_epoch: current_epoch - 2,
|
||||
current_epoch
|
||||
@@ -140,7 +140,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(bad_target_attestation, Some(false)),
|
||||
.process_attestation(bad_target_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::UnknownTargetRoot(
|
||||
Hash256::from_low_u64_be(42)
|
||||
)),
|
||||
@@ -157,7 +157,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(future_block_attestation, Some(false)),
|
||||
.process_attestation(future_block_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::AttestsToFutureBlock {
|
||||
block: current_slot,
|
||||
attestation: current_slot - 1
|
||||
@@ -175,7 +175,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(bad_head_attestation, Some(false)),
|
||||
.process_attestation(bad_head_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::UnknownHeadBlock {
|
||||
beacon_block_root: Hash256::from_low_u64_be(42)
|
||||
}),
|
||||
@@ -195,7 +195,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(bad_signature_attestation, Some(false)),
|
||||
.process_attestation(bad_signature_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::InvalidSignature),
|
||||
"should not accept bad_signature attestation"
|
||||
);
|
||||
@@ -211,7 +211,7 @@ fn attestation_validity() {
|
||||
assert_eq!(
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(empty_bitfield_attestation, Some(false)),
|
||||
.process_attestation(empty_bitfield_attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::EmptyAggregationBitfield),
|
||||
"should not accept empty_bitfield attestation"
|
||||
);
|
||||
@@ -259,7 +259,9 @@ fn attestation_that_skips_epochs() {
|
||||
.expect("should get at least one attestation");
|
||||
|
||||
assert_eq!(
|
||||
harness.chain.process_attestation(attestation, Some(false)),
|
||||
harness
|
||||
.chain
|
||||
.process_attestation(attestation, AttestationType::Aggregated),
|
||||
Ok(AttestationProcessingOutcome::Processed),
|
||||
"should process attestation that skips slots"
|
||||
);
|
||||
|
||||
@@ -6,7 +6,7 @@ extern crate lazy_static;
|
||||
use beacon_chain::test_utils::{
|
||||
AttestationStrategy, BeaconChainHarness, BlockStrategy, DiskHarnessType,
|
||||
};
|
||||
use beacon_chain::AttestationProcessingOutcome;
|
||||
use beacon_chain::{AttestationProcessingOutcome, AttestationType};
|
||||
use rand::Rng;
|
||||
use sloggers::{null::NullLoggerBuilder, Build};
|
||||
use std::sync::Arc;
|
||||
@@ -306,7 +306,7 @@ fn epoch_boundary_state_attestation_processing() {
|
||||
.epoch;
|
||||
let res = harness
|
||||
.chain
|
||||
.process_attestation_internal(attestation.clone(), Some(true));
|
||||
.process_attestation_internal(attestation.clone(), AttestationType::Aggregated);
|
||||
|
||||
let current_epoch = harness.chain.epoch().expect("should get epoch");
|
||||
let attestation_epoch = attestation.data.target.epoch;
|
||||
|
||||
@@ -6,7 +6,7 @@ extern crate lazy_static;
|
||||
use beacon_chain::test_utils::{
|
||||
AttestationStrategy, BeaconChainHarness, BlockStrategy, HarnessType, OP_POOL_DB_KEY,
|
||||
};
|
||||
use beacon_chain::AttestationProcessingOutcome;
|
||||
use beacon_chain::{AttestationProcessingOutcome, AttestationType};
|
||||
use operation_pool::PersistedOperationPool;
|
||||
use state_processing::{
|
||||
per_slot_processing, per_slot_processing::Error as SlotProcessingError, EpochProcessingError,
|
||||
@@ -449,7 +449,9 @@ fn attestations_with_increasing_slots() {
|
||||
|
||||
for attestation in attestations {
|
||||
let attestation_epoch = attestation.data.target.epoch;
|
||||
let res = harness.chain.process_attestation(attestation, Some(false));
|
||||
let res = harness
|
||||
.chain
|
||||
.process_attestation(attestation, AttestationType::Aggregated);
|
||||
|
||||
if attestation_epoch + 1 < current_epoch {
|
||||
assert_eq!(
|
||||
|
||||
Reference in New Issue
Block a user