solana-validator now verifies its genesis blockhash against the cluster entrypoint (#5589)

This commit is contained in:
Michael Vines
2019-08-21 18:16:40 -07:00
committed by GitHub
parent 5034331131
commit e2d6f01ad3
11 changed files with 105 additions and 15 deletions

View File

@@ -14,6 +14,7 @@ use solana_drone::drone::request_airdrop_transaction;
use solana_runtime::bank::Bank;
use solana_sdk::account::Account;
use solana_sdk::fee_calculator::FeeCalculator;
use solana_sdk::hash::Hash;
use solana_sdk::pubkey::Pubkey;
use solana_sdk::signature::Signature;
use solana_sdk::transaction::{self, Transaction};
@@ -213,6 +214,7 @@ fn verify_signature(input: &str) -> Result<Signature> {
pub struct Meta {
pub request_processor: Arc<RwLock<JsonRpcRequestProcessor>>,
pub cluster_info: Arc<RwLock<ClusterInfo>>,
pub genesis_blockhash: Hash,
}
impl Metadata for Meta {}
@@ -298,6 +300,9 @@ pub trait RpcSol {
#[rpc(meta, name = "getEpochInfo")]
fn get_epoch_info(&self, _: Self::Metadata) -> Result<RpcEpochInfo>;
#[rpc(meta, name = "getGenesisBlockhash")]
fn get_genesis_blockhash(&self, _: Self::Metadata) -> Result<String>;
#[rpc(meta, name = "getLeaderSchedule")]
fn get_leader_schedule(&self, _: Self::Metadata) -> Result<Option<Vec<String>>>;
@@ -448,6 +453,11 @@ impl RpcSol for RpcSolImpl {
})
}
fn get_genesis_blockhash(&self, meta: Self::Metadata) -> Result<String> {
debug!("get_genesis_blockhash rpc request received");
Ok(meta.genesis_blockhash.to_string())
}
fn get_leader_schedule(&self, meta: Self::Metadata) -> Result<Option<Vec<String>>> {
let bank = meta.request_processor.read().unwrap().bank();
Ok(
@@ -718,6 +728,7 @@ pub mod tests {
let meta = Meta {
request_processor,
cluster_info,
genesis_blockhash: Hash::default(),
};
(io, meta, bank, blockhash, alice, leader_pubkey)
}
@@ -1060,6 +1071,7 @@ pub mod tests {
cluster_info: Arc::new(RwLock::new(ClusterInfo::new_with_invalid_keypair(
ContactInfo::default(),
))),
genesis_blockhash: Hash::default(),
};
let req =