solana-validator now verifies its genesis blockhash against the cluster entrypoint (#5589)
This commit is contained in:
@@ -369,7 +369,7 @@ impl RpcClient {
|
||||
let blockhash = blockhash.parse().map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetRecentBlockhash parse failure: {:?}", err),
|
||||
format!("GetRecentBlockhash hash parse failure: {:?}", err),
|
||||
)
|
||||
})?;
|
||||
Ok((blockhash, fee_calculator))
|
||||
@@ -397,6 +397,33 @@ impl RpcClient {
|
||||
))
|
||||
}
|
||||
|
||||
pub fn get_genesis_blockhash(&self) -> io::Result<Hash> {
|
||||
let response = self
|
||||
.client
|
||||
.send(&RpcRequest::GetGenesisBlockhash, None, 0)
|
||||
.map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetGenesisBlockhash request failure: {:?}", err),
|
||||
)
|
||||
})?;
|
||||
|
||||
let blockhash = serde_json::from_value::<String>(response).map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetGenesisBlockhash parse failure: {:?}", err),
|
||||
)
|
||||
})?;
|
||||
|
||||
let blockhash = blockhash.parse().map_err(|err| {
|
||||
io::Error::new(
|
||||
io::ErrorKind::Other,
|
||||
format!("GetGenesisBlockhash hash parse failure: {:?}", err),
|
||||
)
|
||||
})?;
|
||||
Ok(blockhash)
|
||||
}
|
||||
|
||||
pub fn poll_balance_with_timeout(
|
||||
&self,
|
||||
pubkey: &Pubkey,
|
||||
|
@@ -9,6 +9,7 @@ pub enum RpcRequest {
|
||||
GetAccountInfo,
|
||||
GetBalance,
|
||||
GetClusterNodes,
|
||||
GetGenesisBlockhash,
|
||||
GetNumBlocksSinceSignatureConfirmation,
|
||||
GetProgramAccounts,
|
||||
GetRecentBlockhash,
|
||||
@@ -38,6 +39,7 @@ impl RpcRequest {
|
||||
RpcRequest::GetAccountInfo => "getAccountInfo",
|
||||
RpcRequest::GetBalance => "getBalance",
|
||||
RpcRequest::GetClusterNodes => "getClusterNodes",
|
||||
RpcRequest::GetGenesisBlockhash => "getGenesisBlockhash",
|
||||
RpcRequest::GetNumBlocksSinceSignatureConfirmation => {
|
||||
"getNumBlocksSinceSignatureConfirmation"
|
||||
}
|
||||
|
Reference in New Issue
Block a user