mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-11 18:04:18 +00:00
Standard gas limit api (#3450)
## Issue Addressed Resolves https://github.com/sigp/lighthouse/issues/3403 ## Proposed Changes Implements https://ethereum.github.io/keymanager-APIs/#/Gas%20Limit ## Additional Info N/A Co-authored-by: realbigsean <sean@sigmaprime.io>
This commit is contained in:
@@ -519,6 +519,18 @@ impl ValidatorClientHttpClient {
|
||||
Ok(url)
|
||||
}
|
||||
|
||||
fn make_gas_limit_url(&self, pubkey: &PublicKeyBytes) -> Result<Url, Error> {
|
||||
let mut url = self.server.full.clone();
|
||||
url.path_segments_mut()
|
||||
.map_err(|()| Error::InvalidUrl(self.server.clone()))?
|
||||
.push("eth")
|
||||
.push("v1")
|
||||
.push("validator")
|
||||
.push(&pubkey.to_string())
|
||||
.push("gas_limit");
|
||||
Ok(url)
|
||||
}
|
||||
|
||||
/// `GET lighthouse/auth`
|
||||
pub async fn get_auth(&self) -> Result<AuthResponse, Error> {
|
||||
let mut url = self.server.full.clone();
|
||||
@@ -598,11 +610,38 @@ impl ValidatorClientHttpClient {
|
||||
self.post_with_raw_response(url, req).await
|
||||
}
|
||||
|
||||
/// `POST /eth/v1/validator/{pubkey}/feerecipient`
|
||||
/// `DELETE /eth/v1/validator/{pubkey}/feerecipient`
|
||||
pub async fn delete_fee_recipient(&self, pubkey: &PublicKeyBytes) -> Result<Response, Error> {
|
||||
let url = self.make_fee_recipient_url(pubkey)?;
|
||||
self.delete_with_raw_response(url, &()).await
|
||||
}
|
||||
|
||||
/// `GET /eth/v1/validator/{pubkey}/gas_limit`
|
||||
pub async fn get_gas_limit(
|
||||
&self,
|
||||
pubkey: &PublicKeyBytes,
|
||||
) -> Result<GetGasLimitResponse, Error> {
|
||||
let url = self.make_gas_limit_url(pubkey)?;
|
||||
self.get(url)
|
||||
.await
|
||||
.map(|generic: GenericResponse<GetGasLimitResponse>| generic.data)
|
||||
}
|
||||
|
||||
/// `POST /eth/v1/validator/{pubkey}/gas_limit`
|
||||
pub async fn post_gas_limit(
|
||||
&self,
|
||||
pubkey: &PublicKeyBytes,
|
||||
req: &UpdateGasLimitRequest,
|
||||
) -> Result<Response, Error> {
|
||||
let url = self.make_gas_limit_url(pubkey)?;
|
||||
self.post_with_raw_response(url, req).await
|
||||
}
|
||||
|
||||
/// `DELETE /eth/v1/validator/{pubkey}/gas_limit`
|
||||
pub async fn delete_gas_limit(&self, pubkey: &PublicKeyBytes) -> Result<Response, Error> {
|
||||
let url = self.make_gas_limit_url(pubkey)?;
|
||||
self.delete_with_raw_response(url, &()).await
|
||||
}
|
||||
}
|
||||
|
||||
/// Returns `Ok(response)` if the response is a `200 OK` response or a
|
||||
|
||||
@@ -10,6 +10,13 @@ pub struct GetFeeRecipientResponse {
|
||||
pub ethaddress: Address,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct GetGasLimitResponse {
|
||||
pub pubkey: PublicKeyBytes,
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub gas_limit: u64,
|
||||
}
|
||||
|
||||
#[derive(Debug, Deserialize, Serialize, PartialEq)]
|
||||
pub struct AuthResponse {
|
||||
pub token_path: String,
|
||||
|
||||
@@ -138,3 +138,9 @@ pub struct Web3SignerValidatorRequest {
|
||||
pub struct UpdateFeeRecipientRequest {
|
||||
pub ethaddress: Address,
|
||||
}
|
||||
|
||||
#[derive(Debug, Clone, PartialEq, Deserialize, Serialize)]
|
||||
pub struct UpdateGasLimitRequest {
|
||||
#[serde(with = "eth2_serde_utils::quoted_u64")]
|
||||
pub gas_limit: u64,
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user