mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-17 11:52:42 +00:00
Merge remote-tracking branch 'origin/unstable' into tree-states
This commit is contained in:
@@ -518,22 +518,32 @@ pub mod deposit_methods {
|
||||
pub struct HttpJsonRpc {
|
||||
pub client: Client,
|
||||
pub url: SensitiveUrl,
|
||||
pub execution_timeout_multiplier: u32,
|
||||
auth: Option<Auth>,
|
||||
}
|
||||
|
||||
impl HttpJsonRpc {
|
||||
pub fn new(url: SensitiveUrl) -> Result<Self, Error> {
|
||||
pub fn new(
|
||||
url: SensitiveUrl,
|
||||
execution_timeout_multiplier: Option<u32>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
client: Client::builder().build()?,
|
||||
url,
|
||||
execution_timeout_multiplier: execution_timeout_multiplier.unwrap_or(1),
|
||||
auth: None,
|
||||
})
|
||||
}
|
||||
|
||||
pub fn new_with_auth(url: SensitiveUrl, auth: Auth) -> Result<Self, Error> {
|
||||
pub fn new_with_auth(
|
||||
url: SensitiveUrl,
|
||||
auth: Auth,
|
||||
execution_timeout_multiplier: Option<u32>,
|
||||
) -> Result<Self, Error> {
|
||||
Ok(Self {
|
||||
client: Client::builder().build()?,
|
||||
url,
|
||||
execution_timeout_multiplier: execution_timeout_multiplier.unwrap_or(1),
|
||||
auth: Some(auth),
|
||||
})
|
||||
}
|
||||
@@ -590,7 +600,11 @@ impl std::fmt::Display for HttpJsonRpc {
|
||||
impl HttpJsonRpc {
|
||||
pub async fn upcheck(&self) -> Result<(), Error> {
|
||||
let result: serde_json::Value = self
|
||||
.rpc_request(ETH_SYNCING, json!([]), ETH_SYNCING_TIMEOUT)
|
||||
.rpc_request(
|
||||
ETH_SYNCING,
|
||||
json!([]),
|
||||
ETH_SYNCING_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await?;
|
||||
|
||||
/*
|
||||
@@ -614,7 +628,7 @@ impl HttpJsonRpc {
|
||||
self.rpc_request(
|
||||
ETH_GET_BLOCK_BY_NUMBER,
|
||||
params,
|
||||
ETH_GET_BLOCK_BY_NUMBER_TIMEOUT,
|
||||
ETH_GET_BLOCK_BY_NUMBER_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await
|
||||
}
|
||||
@@ -625,8 +639,12 @@ impl HttpJsonRpc {
|
||||
) -> Result<Option<ExecutionBlock>, Error> {
|
||||
let params = json!([block_hash, RETURN_FULL_TRANSACTION_OBJECTS]);
|
||||
|
||||
self.rpc_request(ETH_GET_BLOCK_BY_HASH, params, ETH_GET_BLOCK_BY_HASH_TIMEOUT)
|
||||
.await
|
||||
self.rpc_request(
|
||||
ETH_GET_BLOCK_BY_HASH,
|
||||
params,
|
||||
ETH_GET_BLOCK_BY_HASH_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn get_block_by_hash_with_txns<T: EthSpec>(
|
||||
@@ -634,8 +652,12 @@ impl HttpJsonRpc {
|
||||
block_hash: ExecutionBlockHash,
|
||||
) -> Result<Option<ExecutionBlockWithTransactions<T>>, Error> {
|
||||
let params = json!([block_hash, true]);
|
||||
self.rpc_request(ETH_GET_BLOCK_BY_HASH, params, ETH_GET_BLOCK_BY_HASH_TIMEOUT)
|
||||
.await
|
||||
self.rpc_request(
|
||||
ETH_GET_BLOCK_BY_HASH,
|
||||
params,
|
||||
ETH_GET_BLOCK_BY_HASH_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await
|
||||
}
|
||||
|
||||
pub async fn new_payload_v1<T: EthSpec>(
|
||||
@@ -645,7 +667,11 @@ impl HttpJsonRpc {
|
||||
let params = json!([JsonExecutionPayloadV1::from(execution_payload)]);
|
||||
|
||||
let response: JsonPayloadStatusV1 = self
|
||||
.rpc_request(ENGINE_NEW_PAYLOAD_V1, params, ENGINE_NEW_PAYLOAD_TIMEOUT)
|
||||
.rpc_request(
|
||||
ENGINE_NEW_PAYLOAD_V1,
|
||||
params,
|
||||
ENGINE_NEW_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(response.into())
|
||||
@@ -658,7 +684,11 @@ impl HttpJsonRpc {
|
||||
let params = json!([JsonPayloadIdRequest::from(payload_id)]);
|
||||
|
||||
let response: JsonExecutionPayloadV1<T> = self
|
||||
.rpc_request(ENGINE_GET_PAYLOAD_V1, params, ENGINE_GET_PAYLOAD_TIMEOUT)
|
||||
.rpc_request(
|
||||
ENGINE_GET_PAYLOAD_V1,
|
||||
params,
|
||||
ENGINE_GET_PAYLOAD_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await?;
|
||||
|
||||
Ok(response.into())
|
||||
@@ -678,7 +708,7 @@ impl HttpJsonRpc {
|
||||
.rpc_request(
|
||||
ENGINE_FORKCHOICE_UPDATED_V1,
|
||||
params,
|
||||
ENGINE_FORKCHOICE_UPDATED_TIMEOUT,
|
||||
ENGINE_FORKCHOICE_UPDATED_TIMEOUT * self.execution_timeout_multiplier,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -695,7 +725,8 @@ impl HttpJsonRpc {
|
||||
.rpc_request(
|
||||
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_V1,
|
||||
params,
|
||||
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_V1_TIMEOUT,
|
||||
ENGINE_EXCHANGE_TRANSITION_CONFIGURATION_V1_TIMEOUT
|
||||
* self.execution_timeout_multiplier,
|
||||
)
|
||||
.await?;
|
||||
|
||||
@@ -732,13 +763,13 @@ mod test {
|
||||
let echo_auth =
|
||||
Auth::new(JwtKey::from_slice(&DEFAULT_JWT_SECRET).unwrap(), None, None);
|
||||
(
|
||||
Arc::new(HttpJsonRpc::new_with_auth(rpc_url, rpc_auth).unwrap()),
|
||||
Arc::new(HttpJsonRpc::new_with_auth(echo_url, echo_auth).unwrap()),
|
||||
Arc::new(HttpJsonRpc::new_with_auth(rpc_url, rpc_auth, None).unwrap()),
|
||||
Arc::new(HttpJsonRpc::new_with_auth(echo_url, echo_auth, None).unwrap()),
|
||||
)
|
||||
} else {
|
||||
(
|
||||
Arc::new(HttpJsonRpc::new(rpc_url).unwrap()),
|
||||
Arc::new(HttpJsonRpc::new(echo_url).unwrap()),
|
||||
Arc::new(HttpJsonRpc::new(rpc_url, None).unwrap()),
|
||||
Arc::new(HttpJsonRpc::new(echo_url, None).unwrap()),
|
||||
)
|
||||
};
|
||||
|
||||
|
||||
@@ -1,9 +1,8 @@
|
||||
use super::*;
|
||||
use serde::{Deserialize, Serialize};
|
||||
use ssz_types::FixedVector;
|
||||
use types::{
|
||||
EthSpec, ExecutionBlockHash, ExecutionPayloadHeader, Transaction, Unsigned, VariableList,
|
||||
};
|
||||
use strum::EnumString;
|
||||
use types::{EthSpec, ExecutionBlockHash, Transaction, Unsigned, VariableList};
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[serde(rename_all = "camelCase")]
|
||||
@@ -314,8 +313,9 @@ impl From<JsonForkChoiceStateV1> for ForkChoiceState {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq, Serialize, Deserialize)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Serialize, Deserialize, EnumString)]
|
||||
#[serde(rename_all = "SCREAMING_SNAKE_CASE")]
|
||||
#[strum(serialize_all = "SCREAMING_SNAKE_CASE")]
|
||||
pub enum JsonPayloadStatusV1Status {
|
||||
Valid,
|
||||
Invalid,
|
||||
|
||||
Reference in New Issue
Block a user