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

@@ -12,6 +12,7 @@ use jsonrpc_http_server::{
hyper, AccessControlAllowOrigin, DomainsValidation, RequestMiddleware, RequestMiddlewareAction,
ServerBuilder,
};
use solana_sdk::hash::Hash;
use std::net::SocketAddr;
use std::path::{Path, PathBuf};
use std::sync::mpsc::channel;
@@ -91,6 +92,7 @@ impl JsonRpcService {
config: JsonRpcConfig,
bank_forks: Arc<RwLock<BankForks>>,
ledger_path: &Path,
genesis_blockhash: Hash,
validator_exit: &Arc<RwLock<Option<ValidatorExit>>>,
) -> Self {
info!("rpc bound to {:?}", rpc_addr);
@@ -118,6 +120,7 @@ impl JsonRpcService {
ServerBuilder::with_meta_extractor(io, move |_req: &hyper::Request<hyper::Body>| Meta {
request_processor: request_processor_.clone(),
cluster_info: cluster_info.clone(),
genesis_blockhash
}).threads(4)
.cors(DomainsValidation::AllowOnly(vec![
AccessControlAllowOrigin::Any,
@@ -201,6 +204,7 @@ mod tests {
JsonRpcConfig::default(),
bank_forks,
&PathBuf::from("farf"),
Hash::default(),
&validator_exit,
);
let thread = rpc_service.thread_hdl.thread();