Adds attestation validation to SimpleSync

This commit is contained in:
Paul Hauner 2019-03-30 19:11:52 +11:00
parent c2b6f949c0
commit 935c64deef
No known key found for this signature in database
GPG Key ID: 303E4494BB28068C
4 changed files with 12 additions and 16 deletions

View File

@ -11,7 +11,7 @@ use operation_pool::OperationPool;
use parking_lot::{RwLock, RwLockReadGuard}; use parking_lot::{RwLock, RwLockReadGuard};
use slot_clock::SlotClock; use slot_clock::SlotClock;
use ssz::ssz_encode; use ssz::ssz_encode;
pub use state_processing::per_block_processing::errors::{ use state_processing::per_block_processing::errors::{
AttestationValidationError, AttesterSlashingValidationError, DepositValidationError, AttestationValidationError, AttesterSlashingValidationError, DepositValidationError,
ExitValidationError, ProposerSlashingValidationError, TransferValidationError, ExitValidationError, ProposerSlashingValidationError, TransferValidationError,
}; };

View File

@ -13,4 +13,8 @@ pub use db;
pub use fork_choice; pub use fork_choice;
pub use parking_lot; pub use parking_lot;
pub use slot_clock; pub use slot_clock;
pub use state_processing::per_block_processing::errors::{
AttestationValidationError, AttesterSlashingValidationError, DepositValidationError,
ExitValidationError, ProposerSlashingValidationError, TransferValidationError,
};
pub use types; pub use types;

View File

@ -5,7 +5,7 @@ use beacon_chain::{
parking_lot::RwLockReadGuard, parking_lot::RwLockReadGuard,
slot_clock::SlotClock, slot_clock::SlotClock,
types::{BeaconState, ChainSpec}, types::{BeaconState, ChainSpec},
AggregationOutcome, CheckPoint, AttestationValidationError, CheckPoint,
}; };
use eth2_libp2p::rpc::HelloMessage; use eth2_libp2p::rpc::HelloMessage;
use types::{Attestation, BeaconBlock, BeaconBlockBody, BeaconBlockHeader, Epoch, Hash256, Slot}; use types::{Attestation, BeaconBlock, BeaconBlockBody, BeaconBlockHeader, Epoch, Hash256, Slot};
@ -40,7 +40,7 @@ pub trait BeaconChain: Send + Sync {
fn process_attestation( fn process_attestation(
&self, &self,
attestation: Attestation, attestation: Attestation,
) -> Result<AggregationOutcome, BeaconChainError>; ) -> Result<(), AttestationValidationError>;
fn get_block_roots( fn get_block_roots(
&self, &self,
@ -126,14 +126,9 @@ where
fn process_attestation( fn process_attestation(
&self, &self,
_attestation: Attestation, attestation: Attestation,
) -> Result<AggregationOutcome, BeaconChainError> { ) -> Result<(), AttestationValidationError> {
// Awaiting a proper operations pool before we can import attestations. self.process_attestation(attestation)
//
// Returning a useless error for now.
//
// https://github.com/sigp/lighthouse/issues/281
return Err(BeaconChainError::DBInconsistent("CANNOT PROCESS".into()));
} }
fn get_block_roots( fn get_block_roots(

View File

@ -563,12 +563,9 @@ impl SimpleSync {
"peer" => format!("{:?}", peer_id), "peer" => format!("{:?}", peer_id),
); );
// Awaiting a proper operations pool before we can import attestations.
//
// https://github.com/sigp/lighthouse/issues/281
match self.chain.process_attestation(msg) { match self.chain.process_attestation(msg) {
Ok(_) => panic!("Impossible, method not implemented."), Ok(()) => info!(self.log, "ImportedAttestation"),
Err(_) => error!(self.log, "Attestation processing not implemented!"), Err(e) => warn!(self.log, "InvalidAttestation"; "error" => format!("{:?}", e)),
} }
} }