-
Notifications
You must be signed in to change notification settings - Fork 1.6k
CLI: Restrict os/arch for secure validators, add flag for insecure mode #7073
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||||||||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
@@ -303,6 +303,12 @@ where | |||||||||||||||||||||
return Err(Error::Other("BEEFY disallowed on production networks".to_string())) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
if cli.run.base.validator && !cli.run.insecure_validator { | ||||||||||||||||||||||
if let Err(e) = can_run_as_secure_validator() { | ||||||||||||||||||||||
return Err(Error::InsecureValidator(e)) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
set_default_ss58_version(chain_spec); | ||||||||||||||||||||||
|
||||||||||||||||||||||
let grandpa_pause = if cli.run.grandpa_pause.is_empty() { | ||||||||||||||||||||||
|
@@ -732,3 +738,17 @@ pub fn run() -> Result<()> { | |||||||||||||||||||||
} | ||||||||||||||||||||||
Ok(()) | ||||||||||||||||||||||
} | ||||||||||||||||||||||
|
||||||||||||||||||||||
/// Returns an error if a secure validator cannot be built for the target OS and architecture. | ||||||||||||||||||||||
fn can_run_as_secure_validator() -> std::result::Result<(), String> { | ||||||||||||||||||||||
#[cfg(not(target_os = "linux"))] | ||||||||||||||||||||||
let result = Err("Must be on Linux to run a validator securely.".into()); | ||||||||||||||||||||||
|
||||||||||||||||||||||
#[cfg(all(target_os = "linux", not(target_arch = "x86_64")))] | ||||||||||||||||||||||
let result = Err("Must be on x86_64 to run a validator securely.".into()); | ||||||||||||||||||||||
Comment on lines
+744
to
+748
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Maybe a little bit less jargon-y? Normal users might not necessarily know what
Suggested change
|
||||||||||||||||||||||
|
||||||||||||||||||||||
#[cfg(all(target_os = "linux", target_arch = "x86_64"))] | ||||||||||||||||||||||
let result = Ok(()); | ||||||||||||||||||||||
|
||||||||||||||||||||||
result | ||||||||||||||||||||||
} |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -57,4 +57,7 @@ pub enum Error { | |||||
|
||||||
#[error("This subcommand is only available when compiled with `{feature}`")] | ||||||
FeatureNotEnabled { feature: &'static str }, | ||||||
|
||||||
#[error("Insecure validator: {0} Run with --insecure-validator-i-know-what-i-do if you understand and accept the risks of running insecurely.")] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "Insecure validator" can be kinda vague, maybe something like this?
Suggested change
Also, I think in this case it'd be nice to maybe e.g. put a link to the docs with a longer explanation of why this is and what will be the consequences when running in unsecure mode. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Like the idea, just don't know where the doc should go. Maybe on the validators guide? |
||||||
InsecureValidator(String), | ||||||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is visible to the user in
--help
, right? In which case a slightly longer explanation would be nice. (Or as I've said in the other comment, maybe a link to somewhere where it's explained in more detail.)