Process exits and slashings off the network (#1253)

* Process exits and slashings off the network

* Fix rest_api tests

* Add op verification tests

* Add tests for pruning of slashings in the op pool

* Address Paul's review comments
This commit is contained in:
Michael Sproul
2020-06-18 21:06:34 +10:00
committed by GitHub
parent 3199b1a6f2
commit bcb6afa0aa
27 changed files with 956 additions and 273 deletions

View File

@@ -19,7 +19,7 @@ pub struct PersistedOperationPool<T: EthSpec> {
// be difficult to make that roundtrip due to eager aggregation.
attestations: Vec<(AttestationId, Vec<Attestation<T>>)>,
/// Attester slashings.
attester_slashings: Vec<AttesterSlashing<T>>,
attester_slashings: Vec<(AttesterSlashing<T>, ForkVersion)>,
/// Proposer slashings.
proposer_slashings: Vec<ProposerSlashing>,
/// Voluntary exits.
@@ -40,7 +40,7 @@ impl<T: EthSpec> PersistedOperationPool<T> {
.attester_slashings
.read()
.iter()
.map(|(_, slashing)| slashing.clone())
.cloned()
.collect();
let proposer_slashings = operation_pool
@@ -66,19 +66,9 @@ impl<T: EthSpec> PersistedOperationPool<T> {
}
/// Reconstruct an `OperationPool`.
pub fn into_operation_pool(self, state: &BeaconState<T>, spec: &ChainSpec) -> OperationPool<T> {
pub fn into_operation_pool(self) -> OperationPool<T> {
let attestations = RwLock::new(self.attestations.into_iter().collect());
let attester_slashings = RwLock::new(
self.attester_slashings
.into_iter()
.map(|slashing| {
(
OperationPool::attester_slashing_id(&slashing, state, spec),
slashing,
)
})
.collect(),
);
let attester_slashings = RwLock::new(self.attester_slashings.into_iter().collect());
let proposer_slashings = RwLock::new(
self.proposer_slashings
.into_iter()