merge with unstable

This commit is contained in:
realbigsean
2022-11-01 13:18:00 -04:00
143 changed files with 4773 additions and 1876 deletions

View File

@@ -114,6 +114,7 @@ pub struct Timeouts {
pub sync_duties: Duration,
pub get_beacon_blocks_ssz: Duration,
pub get_debug_beacon_states: Duration,
pub get_deposit_snapshot: Duration,
}
impl Timeouts {
@@ -128,6 +129,7 @@ impl Timeouts {
sync_duties: timeout,
get_beacon_blocks_ssz: timeout,
get_debug_beacon_states: timeout,
get_deposit_snapshot: timeout,
}
}
}
@@ -934,6 +936,20 @@ impl BeaconNodeHttpClient {
Ok(())
}
/// `GET beacon/deposit_snapshot`
pub async fn get_deposit_snapshot(&self) -> Result<Option<types::DepositTreeSnapshot>, Error> {
use ssz::Decode;
let mut path = self.eth_path(V1)?;
path.path_segments_mut()
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
.push("beacon")
.push("deposit_snapshot");
self.get_bytes_opt_accept_header(path, Accept::Ssz, self.timeouts.get_deposit_snapshot)
.await?
.map(|bytes| DepositTreeSnapshot::from_ssz_bytes(&bytes).map_err(Error::InvalidSsz))
.transpose()
}
/// `POST validator/contribution_and_proofs`
pub async fn post_validator_contribution_and_proofs<T: EthSpec>(
&self,

View File

@@ -6,7 +6,10 @@ mod block_rewards;
use crate::{
ok_or_error,
types::{BeaconState, ChainSpec, Epoch, EthSpec, GenericResponse, ValidatorId},
types::{
BeaconState, ChainSpec, DepositTreeSnapshot, Epoch, EthSpec, FinalizedExecutionBlock,
GenericResponse, ValidatorId,
},
BeaconNodeHttpClient, DepositData, Error, Eth1Data, Hash256, StateId, StatusCode,
};
use proto_array::core::ProtoArray;
@@ -331,6 +334,19 @@ impl Eth1Block {
}
}
impl From<Eth1Block> for FinalizedExecutionBlock {
fn from(eth1_block: Eth1Block) -> Self {
Self {
deposit_count: eth1_block.deposit_count.unwrap_or(0),
deposit_root: eth1_block
.deposit_root
.unwrap_or_else(|| DepositTreeSnapshot::default().deposit_root),
block_hash: eth1_block.hash,
block_height: eth1_block.number,
}
}
}
#[derive(Debug, Serialize, Deserialize)]
pub struct DatabaseInfo {
pub schema_version: u64,