Fail gracefully if AVX support is missing (#6705)

This commit is contained in:
Michael Vines 2019-11-04 11:03:39 -07:00 committed by GitHub
parent 5416c114cf
commit 5e3697807c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 59 additions and 37 deletions

View File

@ -1,42 +1,51 @@
//! The `validator` module hosts all the validator microservices. //! The `validator` module hosts all the validator microservices.
use crate::broadcast_stage::BroadcastStageType; use crate::{
use crate::cluster_info::{ClusterInfo, Node}; broadcast_stage::BroadcastStageType,
use crate::confidence::ForkConfidenceCache; cluster_info::{ClusterInfo, Node},
use crate::contact_info::ContactInfo; confidence::ForkConfidenceCache,
use crate::gossip_service::{discover_cluster, GossipService}; contact_info::ContactInfo,
use crate::poh_recorder::PohRecorder; gossip_service::{discover_cluster, GossipService},
use crate::poh_service::PohService; poh_recorder::PohRecorder,
use crate::rpc::JsonRpcConfig; poh_service::PohService,
use crate::rpc_pubsub_service::PubSubService; rpc::JsonRpcConfig,
use crate::rpc_service::JsonRpcService; rpc_pubsub_service::PubSubService,
use crate::rpc_subscriptions::RpcSubscriptions; rpc_service::JsonRpcService,
use crate::service::Service; rpc_subscriptions::RpcSubscriptions,
use crate::sigverify; service::Service,
use crate::storage_stage::StorageState; sigverify,
use crate::tpu::Tpu; storage_stage::StorageState,
use crate::tvu::{Sockets, Tvu}; tpu::Tpu,
use solana_ledger::bank_forks::{BankForks, SnapshotConfig}; tvu::{Sockets, Tvu},
use solana_ledger::blocktree::{Blocktree, CompletedSlotsReceiver}; };
use solana_ledger::blocktree_processor::{self, BankForksInfo}; use solana_ledger::{
use solana_ledger::leader_schedule_cache::LeaderScheduleCache; bank_forks::{BankForks, SnapshotConfig},
use solana_ledger::snapshot_utils; blocktree::{Blocktree, CompletedSlotsReceiver},
blocktree_processor::{self, BankForksInfo},
leader_schedule_cache::LeaderScheduleCache,
snapshot_utils,
};
use solana_metrics::datapoint_info; use solana_metrics::datapoint_info;
use solana_sdk::clock::{Slot, DEFAULT_SLOTS_PER_TURN}; use solana_sdk::{
use solana_sdk::genesis_block::GenesisBlock; clock::{Slot, DEFAULT_SLOTS_PER_TURN},
use solana_sdk::hash::Hash; genesis_block::GenesisBlock,
use solana_sdk::poh_config::PohConfig; hash::Hash,
use solana_sdk::pubkey::Pubkey; poh_config::PohConfig,
use solana_sdk::signature::{Keypair, KeypairUtil}; pubkey::Pubkey,
use solana_sdk::timing::timestamp; signature::{Keypair, KeypairUtil},
timing::timestamp,
};
use std::fs; use std::{
use std::net::{IpAddr, Ipv4Addr, SocketAddr}; fs,
use std::path::{Path, PathBuf}; net::{IpAddr, Ipv4Addr, SocketAddr},
use std::sync::atomic::{AtomicBool, Ordering}; path::{Path, PathBuf},
use std::sync::mpsc::Receiver; process,
use std::sync::{Arc, Mutex, RwLock}; sync::atomic::{AtomicBool, Ordering},
use std::thread::Result; sync::mpsc::Receiver,
sync::{Arc, Mutex, RwLock},
thread::Result,
};
#[derive(Clone, Debug)] #[derive(Clone, Debug)]
pub struct ValidatorConfig { pub struct ValidatorConfig {
@ -126,6 +135,20 @@ impl Validator {
"dis" "dis"
} }
); );
// Validator binaries built on a machine with AVX support will generate invalid opcodes
// when run on machines without AVX causing a non-obvious process abort. Instead detect
// the mismatch and error cleanly.
#[target_feature(enable = "avx")]
{
if is_x86_feature_detected!("avx") {
info!("AVX detected");
} else {
error!("Your machine does not have AVX support, please rebuild from source on your machine");
process::exit(1);
}
}
info!("entrypoint: {:?}", entrypoint_info_option); info!("entrypoint: {:?}", entrypoint_info_option);
Self::print_node_info(&node); Self::print_node_info(&node);
@ -517,8 +540,7 @@ pub fn new_banks_from_blocktree(
"Delete the ledger directory to continue: {:?}", "Delete the ledger directory to continue: {:?}",
blocktree_path blocktree_path
); );
// TODO: bubble error up to caller? process::exit(1);
std::process::exit(1);
} }
} }