-
Notifications
You must be signed in to change notification settings - Fork 163
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Build up to date state from pruning proof (#96)
* Add BlockLevel type * Add block level to relations and ghostdag stores * calc ghostdag for each level * Add apply_proof * fixes to apply_proof * build state after pruning proof * fmt * Fix logger init error * Make mainnet concurrent test work (+various minor stuff) * Create DB with increased parallelism * Fix rebase errors * Add a Config struct which bundles up all consensus configurations * sidefix: stop p2p from rebuilding every run * Use a single lock for all relation levels * Renames to block task related structs * Remove async-std crate and use async-channel directly (+use futures-util for stream) * Add panic configuration to kaspad bin * Add panic config to simpa and use logger for prints --------- Co-authored-by: msutton <mikisiton2@gmail.com>
- Loading branch information
1 parent
8cdfff9
commit 24fa659
Showing
72 changed files
with
1,978 additions
and
622 deletions.
There are no files selected for viewing
This file contains 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
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains 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 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 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 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,5 @@ | ||
use std::sync::Arc; | ||
|
||
use crate::header::Header; | ||
|
||
pub type PruningPointProof = Vec<Vec<Arc<Header>>>; |
This file contains 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,82 @@ | ||
use std::ops::Deref; | ||
|
||
use crate::{ | ||
constants::perf::{PerfParams, PERF_PARAMS}, | ||
params::Params, | ||
}; | ||
|
||
/// Various consensus configurations all bundled up under a single struct. Use `Config::new` for directly building from | ||
/// a `Params` instance. For anything more complex it is recommended to use `ConfigBuilder`. NOTE: this struct can be | ||
/// implicitly de-refed into `Params` | ||
#[derive(Clone)] | ||
pub struct Config { | ||
/// Consensus params | ||
pub params: Params, | ||
/// Performance params | ||
pub perf: PerfParams, | ||
|
||
// | ||
// Additional consensus configuration arguments which are not consensus sensitive | ||
// | ||
pub process_genesis: bool, | ||
// TODO: | ||
// is_archival: bool, | ||
// enable_sanity_check_pruning_utxoset: bool, | ||
} | ||
|
||
impl Config { | ||
pub fn new(params: Params) -> Self { | ||
Self { params, perf: PERF_PARAMS, process_genesis: true } | ||
} | ||
} | ||
|
||
impl AsRef<Params> for Config { | ||
fn as_ref(&self) -> &Params { | ||
&self.params | ||
} | ||
} | ||
|
||
impl Deref for Config { | ||
type Target = Params; | ||
|
||
fn deref(&self) -> &Self::Target { | ||
&self.params | ||
} | ||
} | ||
|
||
pub struct ConfigBuilder { | ||
config: Config, | ||
} | ||
|
||
impl ConfigBuilder { | ||
pub fn new(params: Params) -> Self { | ||
Self { config: Config::new(params) } | ||
} | ||
|
||
pub fn set_perf_params(mut self, perf: PerfParams) -> Self { | ||
self.config.perf = perf; | ||
self | ||
} | ||
|
||
pub fn edit_consensus_params<F>(mut self, edit_func: F) -> Self | ||
where | ||
F: Fn(&mut Params), | ||
{ | ||
edit_func(&mut self.config.params); | ||
self | ||
} | ||
|
||
pub fn skip_proof_of_work(mut self) -> Self { | ||
self.config.params.skip_proof_of_work = true; | ||
self | ||
} | ||
|
||
pub fn skip_adding_genesis(mut self) -> Self { | ||
self.config.process_genesis = false; | ||
self | ||
} | ||
|
||
pub fn build(self) -> Config { | ||
self.config | ||
} | ||
} |
Oops, something went wrong.