-
Notifications
You must be signed in to change notification settings - Fork 119
chore: Validator block backup and key check #2230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+398
−289
Merged
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
907a482
Move validation to member fn
sergerad 4eba8d5
Move validate block logic and test key on start
sergerad eeeafd8
Refactor validator server naming and modules (#2231)
sergerad 9c79db8
Merge branch 'next' of github.com:0xMiden/miden-node into sergerad-va…
sergerad 9fa9f7a
Add data directory enum
sergerad f056b8b
Fix doc string
sergerad 372cf35
Merge branch 'next' into sergerad-validator-startup
Mirko-von-Leipzig File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,76 @@ | ||
| use std::ops::Not; | ||
| use std::path::{Path, PathBuf}; | ||
|
|
||
| /// Represents the validator's directories and their content paths. | ||
| /// | ||
| /// Used to keep our filepath assumptions in one location. | ||
| #[derive(Clone)] | ||
| pub enum DataDirectory { | ||
| /// Runtime mode: just the data directory. | ||
| Server { data: PathBuf }, | ||
| /// Bootstrap mode: genesis block, accounts, and data directories. | ||
| Bootstrap { | ||
| genesis_block: PathBuf, | ||
| accounts: PathBuf, | ||
| data: PathBuf, | ||
| }, | ||
| } | ||
|
|
||
| impl DataDirectory { | ||
| /// Loads a data directory for use by the `start` and `migrate` commands. | ||
| pub fn load_server(data: PathBuf) -> std::io::Result<Self> { | ||
| verify_is_dir(&data)?; | ||
| Ok(Self::Server { data }) | ||
| } | ||
|
|
||
| /// Loads a data directory for use by the `bootstrap` command. | ||
| pub fn load_bootstrap( | ||
| genesis_block: PathBuf, | ||
| accounts: PathBuf, | ||
| data: PathBuf, | ||
| ) -> std::io::Result<Self> { | ||
| for dir in [&genesis_block, &accounts, &data] { | ||
| verify_is_dir(dir)?; | ||
| } | ||
| Ok(Self::Bootstrap { genesis_block, accounts, data }) | ||
| } | ||
|
|
||
| pub fn database_path(&self) -> PathBuf { | ||
| self.data().join("validator.sqlite3") | ||
| } | ||
|
|
||
| pub fn block_store_dir(&self) -> PathBuf { | ||
| self.data().join("blocks") | ||
| } | ||
|
|
||
| pub fn genesis_block_path(&self) -> Option<PathBuf> { | ||
| match self { | ||
| Self::Bootstrap { genesis_block, .. } => Some(genesis_block.join("genesis.dat")), | ||
| Self::Server { .. } => None, | ||
| } | ||
| } | ||
|
|
||
| pub fn accounts_dir(&self) -> Option<&Path> { | ||
| match self { | ||
| Self::Bootstrap { accounts, .. } => Some(accounts), | ||
| Self::Server { .. } => None, | ||
| } | ||
| } | ||
|
|
||
| pub fn display(&self) -> std::path::Display<'_> { | ||
| self.data().display() | ||
| } | ||
|
|
||
| fn data(&self) -> &PathBuf { | ||
| match self { | ||
| Self::Server { data } | Self::Bootstrap { data, .. } => data, | ||
| } | ||
| } | ||
| } | ||
|
|
||
| fn verify_is_dir(path: &PathBuf) -> std::io::Result<()> { | ||
| if fs_err::metadata(path)?.is_dir().not() { | ||
| return Err(std::io::ErrorKind::NotConnected.into()); | ||
| } | ||
| Ok(()) | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
I think we should restrict
DataDirectoryto only handle the data directory. As in, not be an enum.Account output directory and genesis output directory are a separate matter. We could simplify these into a single
--output-directoryargument? Though that would be a technically breaking change right now, so maybe we punt on that, though we can prepare for it so long by making this a single struct.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.
Can be cleaned up in a follow up PR.