mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Add attester/proposer slashing endpoints (#856)
* Remove deprecated api_spec.yaml * add prototype for proposer slashing * remove clippy warnings * Add proposer_slashing API * Prototype for attester slashing API call * Fix logic error in operation pool * Finish test for attester_slashing api call * Clean proposer_slashing test * Cargo fmt * Remove useless to_string after format! macro * Cargo fmt * Update book with new api calls * Re-enable proposer slashing verification * Update book with appropriate test example * Fix proposer_slashing test * Update comments and tests for clearer code * Remove extraneous comments * Fix test * Minor fix * Address reviewer comments Co-authored-by: pscott <30843220+pscott@users.noreply.github.com>
This commit is contained in:
@@ -14,8 +14,8 @@ use ssz::Encode;
|
||||
use std::marker::PhantomData;
|
||||
use std::time::Duration;
|
||||
use types::{
|
||||
Attestation, BeaconBlock, BeaconState, CommitteeIndex, Epoch, EthSpec, Fork, Hash256,
|
||||
PublicKey, Signature, SignedBeaconBlock, Slot,
|
||||
Attestation, AttesterSlashing, BeaconBlock, BeaconState, CommitteeIndex, Epoch, EthSpec, Fork,
|
||||
Hash256, ProposerSlashing, PublicKey, Signature, SignedBeaconBlock, Slot,
|
||||
};
|
||||
use url::Url;
|
||||
|
||||
@@ -500,6 +500,38 @@ impl<E: EthSpec> Beacon<E> {
|
||||
client.json_get(url, vec![("epoch".into(), format!("{}", epoch.as_u64()))])
|
||||
})
|
||||
}
|
||||
|
||||
pub fn proposer_slashing(
|
||||
&self,
|
||||
proposer_slashing: ProposerSlashing,
|
||||
) -> impl Future<Item = bool, Error = Error> {
|
||||
let client = self.0.clone();
|
||||
|
||||
self.url("proposer_slashing")
|
||||
.into_future()
|
||||
.and_then(move |url| {
|
||||
client
|
||||
.json_post::<_>(url, proposer_slashing)
|
||||
.and_then(|response| error_for_status(response).map_err(Error::from))
|
||||
.and_then(|mut success| success.json().map_err(Error::from))
|
||||
})
|
||||
}
|
||||
|
||||
pub fn attester_slashing(
|
||||
&self,
|
||||
attester_slashing: AttesterSlashing<E>,
|
||||
) -> impl Future<Item = bool, Error = Error> {
|
||||
let client = self.0.clone();
|
||||
|
||||
self.url("attester_slashing")
|
||||
.into_future()
|
||||
.and_then(move |url| {
|
||||
client
|
||||
.json_post::<_>(url, attester_slashing)
|
||||
.and_then(|response| error_for_status(response).map_err(Error::from))
|
||||
.and_then(|mut success| success.json().map_err(Error::from))
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
/// Provides the functions on the `/spec` endpoint of the node.
|
||||
|
||||
Reference in New Issue
Block a user