Skip to content

NDRS-149: Read the validator's secret key from disk#95

Merged
Fraser999 merged 2 commits intocasper-network:masterfrom
EdHastingsCasperAssociation:NDRS-149
Jul 17, 2020
Merged

NDRS-149: Read the validator's secret key from disk#95
Fraser999 merged 2 commits intocasper-network:masterfrom
EdHastingsCasperAssociation:NDRS-149

Conversation

@EdHastingsCasperAssociation
Copy link
Collaborator

This PR retrieves the signing key for a validator from disk for use by consensus. The consensus component did not have a config section with which to contain this value; it does now.

Additionally, to allow ease of use when running multiple nodes to test a network with, support for providing overrides for values in config files via command line is also contained in this PR. The README.md has been updated with an example of how to use this functionality.

The chainspec.toml path was being passed to the initializer as part of a tuple; the value is moved into the config file as part of this PR. Using the above mentioned configured value override functionality, the default configured value can be overridden via command line if desired.

https://casperlabs.atlassian.net/browse/NDRS-149

Note: some example pem files are included which correspond (in positional order) to example public keys contained in an example accounts.csv file; they should only be used for testing or demonstration purposes.

/// `section.key=value`
fn from_str(input: &str) -> Result<Self, Self::Err> {
let re = Regex::new(r"^([^.]+)\.([^=]+)=(.+)$").unwrap();
if let Some(captures) = re.captures(input) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could return early here:

let captures = re.captures(input).ok_or("could not parse config_ext (see README.md)")?;

match Self::ed25519_from_bytes(pem.contents) {
Ok(secret_key) => Ok(Some(secret_key)),
Err(error) => Err(error),
}
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe more concise:

Self::ed25519_from_bytes(pem.contents).map(Some)

Copy link
Contributor

@Fraser999 Fraser999 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should probably specify somewhere in the README that paths provided in the config file must either be absolute, or relative to the config file itself.

No blockers though, so optimistic approval assuming that invalid README examples are updated.

cargo run --release -- validator -p=resources/local/chainspec.toml -c=config.toml
```

If using a config file as described above, it is also possible to override and extend the values in the config file
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we changed that so it doesn't only apply when using a config file. We could update this to say something more like:

It is also possible to specify individual config file options from the command line using one or more args in the form
of `-C <section>.<key>=<value>`.  These will override values set in a config file if provided, or will override the
default values otherwise.


```
cargo run --release -- validator -p=resources/example/chainspec.toml
cargo run --release -- validator -p=resources/local/chainspec.toml
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
cargo run --release -- validator -p=resources/local/chainspec.toml
cargo run --release -- validator -c=resources/local/config.toml


As well as the [example chainspec](resources/example/chainspec.toml), there is a commented
[example config file](resources/example/config.toml) in the same folder.
As well as the [local chainspec](resources/local/chainspec.toml), there is a commented
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We can probably remove these lines altogether now, since we refer to the config file in the first example block above?


impl ConfigExt {
/// Updates toml table with updated or extended kvp.
fn update_toml_table(&self, toml_value: &mut toml::Value) -> Option<()> {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I suppose we should bring toml::value::Table into scope so we don't need to fully qualify it everywhere. And toml::Value is already in scope, so we don't need to fully qualify it everywhere in this file.

Copy link
Contributor

@fizyk20 fizyk20 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I thought that actually passing the secret key to the consensus component will fall onto me as a part of my task, but I'm happy to see that it's done here already 😄

@Fraser999 Fraser999 merged commit a2867d1 into casper-network:master Jul 17, 2020
@EdHastingsCasperAssociation EdHastingsCasperAssociation deleted the NDRS-149 branch July 29, 2020 20:11
rafal-ch pushed a commit to rafal-ch/casper-node that referenced this pull request Nov 2, 2022
SyncLeap checks, deploy buffer purge, cleanups
afck added a commit that referenced this pull request Nov 15, 2022
95: Restart current round after unpausing. r=afck a=afck

This resets `self.current_timeout` after unpausing. The effect is both that the current round's proposer immediately creates another proposal (unless they've already proposed), and that the other validators restart their timeout, so there is a chance the proposal will get accepted.

In nctl tests with block time 0 the pause mode is often activated and deactivated in quick succession, which caused a lot of proposals getting dropped. This change fixes that problem.

Closes https://github.com/casper-network/Governance/issues/342.

Co-authored-by: Andreas Fackler <andreas@casperlabs.io>
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
* split fuel-tx into parallel jobs

* fix clippy errors
rafal-ch pushed a commit that referenced this pull request Sep 11, 2024
We often need to convert directly from a panic reason to an io error,
such as when performing to/from bytes encoding - in that case, the VM
will not be intermediary to the operation and the conversion will be
performed directly.

This commit introduces a transparent conversion between the error types.
EdHastingsCasperAssociation added a commit to EdHastingsCasperAssociation/casper-node that referenced this pull request Oct 9, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants