Skip to content
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

On-demand calculation for Ghostdag for Higher Levels #494

Merged
merged 81 commits into from
Oct 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
81 commits
Select commit Hold shift + click to select a range
5d3b10f
Refactor pruning proof validation to many functions
coderofstuff Jun 4, 2024
40f1cc9
Use blue score as work for higher levels
coderofstuff Jun 4, 2024
4af6773
Remove pruning processor dependency on gd managers
coderofstuff Jun 4, 2024
1df5a22
Consistency renaming
coderofstuff Jun 4, 2024
d12592c
Update db version
coderofstuff Jun 4, 2024
2bea765
GD Optimizations
coderofstuff Jun 4, 2024
902b217
Remove remnant of old impl. optimize db prefixes
coderofstuff Jun 4, 2024
7f1f412
Ensure parents are in relations; Add comments
coderofstuff Jun 19, 2024
f49478a
Match depth check to block_at_depth logic
coderofstuff Jun 19, 2024
879c135
Use singular GD store for header processing
coderofstuff Jun 19, 2024
56c0b40
Relax the panic to warn when finished_headers and couldn't find suffi…
coderofstuff Jun 12, 2024
43e9f9e
Error handling for gd on higher levels
coderofstuff Jun 19, 2024
34f20ab
remove using deeper requirements in lower levels
coderofstuff Jun 15, 2024
2654b25
Fix missed references to self.ghostdag_stores in validate_pruning_poi…
coderofstuff Jun 18, 2024
ba04929
Refactoring for single GD header processing
coderofstuff Jun 19, 2024
a45b571
Add assertion to check root vs old_root
coderofstuff Jun 19, 2024
edb5cd3
Lint fix current_dag_level
coderofstuff Jun 19, 2024
e81394f
Keep DB Version at 3
coderofstuff Jun 19, 2024
0e8c788
Cleanup apply_proof logic and handle more ghostdag_stores logic
coderofstuff Jun 19, 2024
56f9dab
remove simpa changes
coderofstuff Jun 19, 2024
c5be8ad
Remove rewriting origin to primary GD
coderofstuff Jun 19, 2024
8d15e27
More refactoring to use single GD store/manager
coderofstuff Jun 19, 2024
1c6b585
Lint fixes
coderofstuff Jun 21, 2024
273aa81
warn to trace for common retry
coderofstuff Jun 21, 2024
f9b3fda
Address initial comments
coderofstuff Jun 26, 2024
ca8bb42
Remove "primary" in ghostdag store/manager references
coderofstuff Jun 26, 2024
61183fa
Add small safety margin to proof at level 0
coderofstuff Jun 27, 2024
34bc88f
Revert to only do proof rebuilding on sanity check
coderofstuff Jun 29, 2024
da1cfe3
Proper "better" proof check
coderofstuff Jun 29, 2024
a23d1dd
Update comment on find_selected_parent_header_at_level
coderofstuff Jul 5, 2024
974d200
Re-apply missed comment
coderofstuff Jul 5, 2024
6ea8328
Implement db upgrade logic from 3 to 4
coderofstuff Jul 4, 2024
f8baf69
Explain further the workaround for GD ordering.rs
coderofstuff Jul 10, 2024
4f6ad73
Minor update to Display of TempGD keys
coderofstuff Jul 10, 2024
bc56e65
Various fixes
coderofstuff Jul 10, 2024
efbb083
Revert "Various fixes"
coderofstuff Jul 14, 2024
a585be7
Revert better proof check
coderofstuff Jul 16, 2024
e7625c7
Fix: use cc gd store
coderofstuff Jul 16, 2024
0741151
When building pruning point proof ghostdag data, ignore blocks before…
someone235 Aug 18, 2024
d48e049
Merge branch 'dev' into gd-optimization
coderofstuff Aug 20, 2024
89f1701
Add trusted blocks to all relevant levels during apply_proof
coderofstuff Aug 23, 2024
3e249f9
Merge branch 'dev' into gd-optimization
coderofstuff Aug 23, 2024
fb3d1e9
Calculate headers estimate in init proof stores
coderofstuff Aug 24, 2024
c9855d3
Explain finished headers logic
coderofstuff Aug 24, 2024
a63acdb
clarify comment
coderofstuff Aug 24, 2024
46dbac3
Rename old_root to depth_based_root
coderofstuff Aug 24, 2024
bdf205e
Merge branch 'dev' into gd-optimization
coderofstuff Aug 27, 2024
4c9f997
More merge fixes
coderofstuff Aug 27, 2024
42a3030
Merge pull request #9 from someone235/gd-proof-ignore-root-past
coderofstuff Aug 27, 2024
4f2aace
Merge branch 'dev' into gd-optimization
coderofstuff Aug 27, 2024
bc2e648
Merge branch 'dev' into gd-optimization
coderofstuff Aug 28, 2024
56b4392
Refactor relations services into self
coderofstuff Aug 28, 2024
66d4ebe
Use blue_work for find_selected_parent_header_at_level
coderofstuff Aug 30, 2024
18158e6
Comment fixes and small refactor
coderofstuff Aug 30, 2024
8d042b2
Revert rename to old root
coderofstuff Sep 1, 2024
09f1443
Merge branch 'dev' into gd-optimization
coderofstuff Sep 2, 2024
2913bda
Merge branch 'dev' into gd-optimization
coderofstuff Sep 3, 2024
095a9f3
Merge branch 'dev' into gd-optimization
coderofstuff Sep 6, 2024
65948d3
Lint fix from merged code
coderofstuff Sep 6, 2024
6021a1e
Merge branch 'master' into gd-optimization
coderofstuff Sep 18, 2024
009f9a8
Merge branch 'master' into gd-optimization
coderofstuff Sep 23, 2024
a60bd8c
Merge branch 'master' into gd-optimization
coderofstuff Oct 2, 2024
f1d6904
Merge branch 'master' into gd-optimization
coderofstuff Oct 3, 2024
362e564
Merge branch 'master' into gd-optimization
coderofstuff Oct 12, 2024
7b7d659
Merge branch 'master' into gd-optimization
coderofstuff Oct 13, 2024
2e8deab
Some cleanup
coderofstuff Oct 15, 2024
4168456
remove last reference to ghostdag_primary_*
coderofstuff Oct 15, 2024
a11b135
Merge branch 'master' into gd-optimization
coderofstuff Oct 26, 2024
b6af1af
Cleaner find_selected_parent_header_at_level
coderofstuff Oct 26, 2024
dcd3f5c
Refactor for better readability and add more docs
coderofstuff Oct 23, 2024
32f890d
Smaller safety margin for all
coderofstuff Oct 26, 2024
15486f8
Lint and logic fix
coderofstuff Oct 26, 2024
6a41f26
Reduce loop depth increase on level proof retries
coderofstuff Oct 28, 2024
cf476f2
Update consensus/src/processes/pruning_proof/mod.rs
coderofstuff Oct 28, 2024
be105f9
Comment cleanup
coderofstuff Oct 28, 2024
59b1a05
Remove unnecessary clone
coderofstuff Oct 28, 2024
5cd27f3
Rename genesis_hash to root; Remove redundant filter
coderofstuff Oct 28, 2024
8e03452
Cleaner reachability_stores type
coderofstuff Oct 28, 2024
01024b1
Change failed to find sufficient root log to debug
coderofstuff Oct 29, 2024
1777b80
Bump node version to 0.15.3
coderofstuff Oct 29, 2024
f83a70f
A few minor leftovers
michaelsutton Oct 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 60 additions & 58 deletions Cargo.lock

Large diffs are not rendered by default.

112 changes: 56 additions & 56 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ members = [

[workspace.package]
rust-version = "1.81.0"
version = "0.15.2"
version = "0.15.3"
authors = ["Kaspa developers"]
license = "ISC"
repository = "https://github.com/kaspanet/rusty-kaspa"
Expand All @@ -80,61 +80,61 @@ include = [
]

[workspace.dependencies]
# kaspa-testing-integration = { version = "0.15.2", path = "testing/integration" }
kaspa-addresses = { version = "0.15.2", path = "crypto/addresses" }
kaspa-addressmanager = { version = "0.15.2", path = "components/addressmanager" }
kaspa-bip32 = { version = "0.15.2", path = "wallet/bip32" }
kaspa-cli = { version = "0.15.2", path = "cli" }
kaspa-connectionmanager = { version = "0.15.2", path = "components/connectionmanager" }
kaspa-consensus = { version = "0.15.2", path = "consensus" }
kaspa-consensus-core = { version = "0.15.2", path = "consensus/core" }
kaspa-consensus-client = { version = "0.15.2", path = "consensus/client" }
kaspa-consensus-notify = { version = "0.15.2", path = "consensus/notify" }
kaspa-consensus-wasm = { version = "0.15.2", path = "consensus/wasm" }
kaspa-consensusmanager = { version = "0.15.2", path = "components/consensusmanager" }
kaspa-core = { version = "0.15.2", path = "core" }
kaspa-daemon = { version = "0.15.2", path = "daemon" }
kaspa-database = { version = "0.15.2", path = "database" }
kaspa-grpc-client = { version = "0.15.2", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.15.2", path = "rpc/grpc/core" }
kaspa-grpc-server = { version = "0.15.2", path = "rpc/grpc/server" }
kaspa-hashes = { version = "0.15.2", path = "crypto/hashes" }
kaspa-index-core = { version = "0.15.2", path = "indexes/core" }
kaspa-index-processor = { version = "0.15.2", path = "indexes/processor" }
kaspa-math = { version = "0.15.2", path = "math" }
kaspa-merkle = { version = "0.15.2", path = "crypto/merkle" }
kaspa-metrics-core = { version = "0.15.2", path = "metrics/core" }
kaspa-mining = { version = "0.15.2", path = "mining" }
kaspa-mining-errors = { version = "0.15.2", path = "mining/errors" }
kaspa-muhash = { version = "0.15.2", path = "crypto/muhash" }
kaspa-notify = { version = "0.15.2", path = "notify" }
kaspa-p2p-flows = { version = "0.15.2", path = "protocol/flows" }
kaspa-p2p-lib = { version = "0.15.2", path = "protocol/p2p" }
kaspa-perf-monitor = { version = "0.15.2", path = "metrics/perf_monitor" }
kaspa-pow = { version = "0.15.2", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.15.2", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.15.2", path = "rpc/macros" }
kaspa-rpc-service = { version = "0.15.2", path = "rpc/service" }
kaspa-txscript = { version = "0.15.2", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.15.2", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.15.2", path = "utils" }
kaspa-utils-tower = { version = "0.15.2", path = "utils/tower" }
kaspa-utxoindex = { version = "0.15.2", path = "indexes/utxoindex" }
kaspa-wallet = { version = "0.15.2", path = "wallet/native" }
kaspa-wallet-cli-wasm = { version = "0.15.2", path = "wallet/wasm" }
kaspa-wallet-keys = { version = "0.15.2", path = "wallet/keys" }
kaspa-wallet-pskt = { version = "0.15.2", path = "wallet/pskt" }
kaspa-wallet-core = { version = "0.15.2", path = "wallet/core" }
kaspa-wallet-macros = { version = "0.15.2", path = "wallet/macros" }
kaspa-wasm = { version = "0.15.2", path = "wasm" }
kaspa-wasm-core = { version = "0.15.2", path = "wasm/core" }
kaspa-wrpc-client = { version = "0.15.2", path = "rpc/wrpc/client" }
kaspa-wrpc-proxy = { version = "0.15.2", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.15.2", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.15.2", path = "rpc/wrpc/wasm" }
kaspa-wrpc-example-subscriber = { version = "0.15.2", path = "rpc/wrpc/examples/subscriber" }
kaspad = { version = "0.15.2", path = "kaspad" }
kaspa-alloc = { version = "0.15.2", path = "utils/alloc" }
# kaspa-testing-integration = { version = "0.15.3", path = "testing/integration" }
kaspa-addresses = { version = "0.15.3", path = "crypto/addresses" }
kaspa-addressmanager = { version = "0.15.3", path = "components/addressmanager" }
kaspa-bip32 = { version = "0.15.3", path = "wallet/bip32" }
kaspa-cli = { version = "0.15.3", path = "cli" }
kaspa-connectionmanager = { version = "0.15.3", path = "components/connectionmanager" }
kaspa-consensus = { version = "0.15.3", path = "consensus" }
kaspa-consensus-core = { version = "0.15.3", path = "consensus/core" }
kaspa-consensus-client = { version = "0.15.3", path = "consensus/client" }
kaspa-consensus-notify = { version = "0.15.3", path = "consensus/notify" }
kaspa-consensus-wasm = { version = "0.15.3", path = "consensus/wasm" }
kaspa-consensusmanager = { version = "0.15.3", path = "components/consensusmanager" }
kaspa-core = { version = "0.15.3", path = "core" }
kaspa-daemon = { version = "0.15.3", path = "daemon" }
kaspa-database = { version = "0.15.3", path = "database" }
kaspa-grpc-client = { version = "0.15.3", path = "rpc/grpc/client" }
kaspa-grpc-core = { version = "0.15.3", path = "rpc/grpc/core" }
kaspa-grpc-server = { version = "0.15.3", path = "rpc/grpc/server" }
kaspa-hashes = { version = "0.15.3", path = "crypto/hashes" }
kaspa-index-core = { version = "0.15.3", path = "indexes/core" }
kaspa-index-processor = { version = "0.15.3", path = "indexes/processor" }
kaspa-math = { version = "0.15.3", path = "math" }
kaspa-merkle = { version = "0.15.3", path = "crypto/merkle" }
kaspa-metrics-core = { version = "0.15.3", path = "metrics/core" }
kaspa-mining = { version = "0.15.3", path = "mining" }
kaspa-mining-errors = { version = "0.15.3", path = "mining/errors" }
kaspa-muhash = { version = "0.15.3", path = "crypto/muhash" }
kaspa-notify = { version = "0.15.3", path = "notify" }
kaspa-p2p-flows = { version = "0.15.3", path = "protocol/flows" }
kaspa-p2p-lib = { version = "0.15.3", path = "protocol/p2p" }
kaspa-perf-monitor = { version = "0.15.3", path = "metrics/perf_monitor" }
kaspa-pow = { version = "0.15.3", path = "consensus/pow" }
kaspa-rpc-core = { version = "0.15.3", path = "rpc/core" }
kaspa-rpc-macros = { version = "0.15.3", path = "rpc/macros" }
kaspa-rpc-service = { version = "0.15.3", path = "rpc/service" }
kaspa-txscript = { version = "0.15.3", path = "crypto/txscript" }
kaspa-txscript-errors = { version = "0.15.3", path = "crypto/txscript/errors" }
kaspa-utils = { version = "0.15.3", path = "utils" }
kaspa-utils-tower = { version = "0.15.3", path = "utils/tower" }
kaspa-utxoindex = { version = "0.15.3", path = "indexes/utxoindex" }
kaspa-wallet = { version = "0.15.3", path = "wallet/native" }
kaspa-wallet-cli-wasm = { version = "0.15.3", path = "wallet/wasm" }
kaspa-wallet-keys = { version = "0.15.3", path = "wallet/keys" }
kaspa-wallet-pskt = { version = "0.15.3", path = "wallet/pskt" }
kaspa-wallet-core = { version = "0.15.3", path = "wallet/core" }
kaspa-wallet-macros = { version = "0.15.3", path = "wallet/macros" }
kaspa-wasm = { version = "0.15.3", path = "wasm" }
kaspa-wasm-core = { version = "0.15.3", path = "wasm/core" }
kaspa-wrpc-client = { version = "0.15.3", path = "rpc/wrpc/client" }
kaspa-wrpc-proxy = { version = "0.15.3", path = "rpc/wrpc/proxy" }
kaspa-wrpc-server = { version = "0.15.3", path = "rpc/wrpc/server" }
kaspa-wrpc-wasm = { version = "0.15.3", path = "rpc/wrpc/wasm" }
kaspa-wrpc-example-subscriber = { version = "0.15.3", path = "rpc/wrpc/examples/subscriber" }
kaspad = { version = "0.15.3", path = "kaspad" }
kaspa-alloc = { version = "0.15.3", path = "utils/alloc" }

# external
aes = "0.8.3"
Expand Down
19 changes: 18 additions & 1 deletion consensus/src/consensus/factory.rs
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ pub struct MultiConsensusMetadata {
version: u32,
}

const LATEST_DB_VERSION: u32 = 3;
const LATEST_DB_VERSION: u32 = 4;
impl Default for MultiConsensusMetadata {
fn default() -> Self {
Self {
Expand Down Expand Up @@ -219,6 +219,23 @@ impl MultiConsensusManagementStore {
}
}

/// Returns the current version of this database
pub fn version(&self) -> StoreResult<u32> {
match self.metadata.read() {
Ok(data) => Ok(data.version),
Err(err) => Err(err),
}
}

/// Set the database version to a different one
pub fn set_version(&mut self, version: u32) -> StoreResult<()> {
self.metadata.update(DirectDbWriter::new(&self.db), |mut data| {
data.version = version;
data
})?;
Ok(())
}

pub fn should_upgrade(&self) -> StoreResult<bool> {
match self.metadata.read() {
Ok(data) => Ok(data.version != LATEST_DB_VERSION),
Expand Down
14 changes: 7 additions & 7 deletions consensus/src/consensus/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,7 +243,7 @@ impl Consensus {
block_processors_pool,
db.clone(),
storage.statuses_store.clone(),
storage.ghostdag_primary_store.clone(),
storage.ghostdag_store.clone(),
storage.headers_store.clone(),
storage.block_transactions_store.clone(),
storage.body_tips_store.clone(),
Expand Down Expand Up @@ -500,7 +500,7 @@ impl ConsensusApi for Consensus {

fn get_virtual_merge_depth_blue_work_threshold(&self) -> BlueWorkType {
// PRUNE SAFETY: merge depth root is never close to being pruned (in terms of block depth)
self.get_virtual_merge_depth_root().map_or(BlueWorkType::ZERO, |root| self.ghostdag_primary_store.get_blue_work(root).unwrap())
self.get_virtual_merge_depth_root().map_or(BlueWorkType::ZERO, |root| self.ghostdag_store.get_blue_work(root).unwrap())
}

fn get_sink(&self) -> Hash {
Expand Down Expand Up @@ -533,7 +533,7 @@ impl ConsensusApi for Consensus {

for child in initial_children {
if visited.insert(child) {
let blue_work = self.ghostdag_primary_store.get_blue_work(child).unwrap();
let blue_work = self.ghostdag_store.get_blue_work(child).unwrap();
heap.push(Reverse(SortableBlock::new(child, blue_work)));
}
}
Expand All @@ -560,7 +560,7 @@ impl ConsensusApi for Consensus {

for child in children {
if visited.insert(child) {
let blue_work = self.ghostdag_primary_store.get_blue_work(child).unwrap();
let blue_work = self.ghostdag_store.get_blue_work(child).unwrap();
heap.push(Reverse(SortableBlock::new(child, blue_work)));
}
}
Expand Down Expand Up @@ -909,7 +909,7 @@ impl ConsensusApi for Consensus {
Some(BlockStatus::StatusInvalid) => return Err(ConsensusError::InvalidBlock(hash)),
_ => {}
};
let ghostdag = self.ghostdag_primary_store.get_data(hash).unwrap_option().ok_or(ConsensusError::MissingData(hash))?;
let ghostdag = self.ghostdag_store.get_data(hash).unwrap_option().ok_or(ConsensusError::MissingData(hash))?;
Ok((&*ghostdag).into())
}

Expand Down Expand Up @@ -985,7 +985,7 @@ impl ConsensusApi for Consensus {
Ok(self
.services
.window_manager
.block_window(&self.ghostdag_primary_store.get_data(hash).unwrap(), WindowType::SampledDifficultyWindow)
.block_window(&self.ghostdag_store.get_data(hash).unwrap(), WindowType::SampledDifficultyWindow)
.unwrap()
.deref()
.iter()
Expand Down Expand Up @@ -1024,7 +1024,7 @@ impl ConsensusApi for Consensus {
match start_hash {
Some(hash) => {
self.validate_block_exists(hash)?;
let ghostdag_data = self.ghostdag_primary_store.get_data(hash).unwrap();
let ghostdag_data = self.ghostdag_store.get_data(hash).unwrap();
// The selected parent header is used within to check for sampling activation, so we verify its existence first
if !self.headers_store.has(ghostdag_data.selected_parent).unwrap() {
return Err(ConsensusError::DifficultyError(DifficultyError::InsufficientWindowData(0)));
Expand Down
44 changes: 16 additions & 28 deletions consensus/src/consensus/services.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,8 +53,7 @@ pub struct ConsensusServices {
pub reachability_service: MTReachabilityService<DbReachabilityStore>,
pub window_manager: DbWindowManager,
pub dag_traversal_manager: DbDagTraversalManager,
pub ghostdag_managers: Arc<Vec<DbGhostdagManager>>,
pub ghostdag_primary_manager: DbGhostdagManager,
pub ghostdag_manager: DbGhostdagManager,
pub coinbase_manager: CoinbaseManager,
pub pruning_point_manager: DbPruningPointManager,
pub pruning_proof_manager: Arc<PruningProofManager>,
Expand Down Expand Up @@ -82,13 +81,13 @@ impl ConsensusServices {
let reachability_service = MTReachabilityService::new(storage.reachability_store.clone());
let dag_traversal_manager = DagTraversalManager::new(
params.genesis.hash,
storage.ghostdag_primary_store.clone(),
storage.ghostdag_store.clone(),
relations_service.clone(),
reachability_service.clone(),
);
let window_manager = DualWindowManager::new(
&params.genesis,
storage.ghostdag_primary_store.clone(),
storage.ghostdag_store.clone(),
storage.headers_store.clone(),
storage.daa_excluded_store.clone(),
storage.block_window_cache_for_difficulty.clone(),
Expand All @@ -110,27 +109,17 @@ impl ConsensusServices {
params.genesis.hash,
storage.depth_store.clone(),
reachability_service.clone(),
storage.ghostdag_primary_store.clone(),
storage.ghostdag_store.clone(),
);
let ghostdag_managers = Arc::new(
storage
.ghostdag_stores
.iter()
.cloned()
.enumerate()
.map(|(level, ghostdag_store)| {
GhostdagManager::new(
params.genesis.hash,
params.ghostdag_k,
ghostdag_store,
relations_services[level].clone(),
storage.headers_store.clone(),
reachability_service.clone(),
)
})
.collect_vec(),
let ghostdag_manager = GhostdagManager::new(
params.genesis.hash,
params.ghostdag_k,
storage.ghostdag_store.clone(),
relations_services[0].clone(),
storage.headers_store.clone(),
reachability_service.clone(),
false,
);
let ghostdag_primary_manager = ghostdag_managers[0].clone();

let coinbase_manager = CoinbaseManager::new(
params.coinbase_payload_script_public_key_max_len,
Expand Down Expand Up @@ -165,7 +154,7 @@ impl ConsensusServices {
params.finality_depth,
params.genesis.hash,
reachability_service.clone(),
storage.ghostdag_primary_store.clone(),
storage.ghostdag_store.clone(),
storage.headers_store.clone(),
storage.past_pruning_points_store.clone(),
storage.headers_selected_tip_store.clone(),
Expand All @@ -184,7 +173,7 @@ impl ConsensusServices {
&storage,
parents_manager.clone(),
reachability_service.clone(),
ghostdag_managers.clone(),
ghostdag_manager.clone(),
dag_traversal_manager.clone(),
window_manager.clone(),
params.max_block_level,
Expand All @@ -199,7 +188,7 @@ impl ConsensusServices {
params.mergeset_size_limit as usize,
reachability_service.clone(),
dag_traversal_manager.clone(),
storage.ghostdag_primary_store.clone(),
storage.ghostdag_store.clone(),
storage.selected_chain_store.clone(),
storage.headers_selected_tip_store.clone(),
storage.pruning_point_store.clone(),
Expand All @@ -213,8 +202,7 @@ impl ConsensusServices {
reachability_service,
window_manager,
dag_traversal_manager,
ghostdag_managers,
ghostdag_primary_manager,
ghostdag_manager,
coinbase_manager,
pruning_point_manager,
pruning_proof_manager,
Expand Down
25 changes: 8 additions & 17 deletions consensus/src/consensus/storage.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,7 @@ pub struct ConsensusStorage {
pub selected_chain_store: Arc<RwLock<DbSelectedChainStore>>,

// Append-only stores
pub ghostdag_stores: Arc<Vec<Arc<DbGhostdagStore>>>,
pub ghostdag_primary_store: Arc<DbGhostdagStore>,
pub ghostdag_store: Arc<DbGhostdagStore>,
pub headers_store: Arc<DbHeadersStore>,
pub block_transactions_store: Arc<DbBlockTransactionsStore>,
pub past_pruning_points_store: Arc<DbPastPruningPointsStore>,
Expand Down Expand Up @@ -193,19 +192,12 @@ impl ConsensusStorage {
children_builder.build(),
)));

let ghostdag_stores = Arc::new(
(0..=params.max_block_level)
.map(|level| {
Arc::new(DbGhostdagStore::new(
db.clone(),
level,
ghostdag_builder.downscale(level).build(),
ghostdag_compact_builder.downscale(level).build(),
))
})
.collect_vec(),
);
let ghostdag_primary_store = ghostdag_stores[0].clone();
let ghostdag_store = Arc::new(DbGhostdagStore::new(
db.clone(),
0,
ghostdag_builder.downscale(0).build(),
ghostdag_compact_builder.downscale(0).build(),
));
let daa_excluded_store = Arc::new(DbDaaStore::new(db.clone(), daa_excluded_builder.build()));
let headers_store = Arc::new(DbHeadersStore::new(db.clone(), headers_builder.build(), headers_compact_builder.build()));
let depth_store = Arc::new(DbDepthStore::new(db.clone(), header_data_builder.build()));
Expand Down Expand Up @@ -245,8 +237,7 @@ impl ConsensusStorage {
relations_stores,
reachability_relations_store,
reachability_store,
ghostdag_stores,
ghostdag_primary_store,
ghostdag_store,
pruning_point_store,
headers_selected_tip_store,
body_tips_store,
Expand Down
6 changes: 3 additions & 3 deletions consensus/src/consensus/test_consensus.rs
Original file line number Diff line number Diff line change
Expand Up @@ -118,7 +118,7 @@ impl TestConsensus {

pub fn build_header_with_parents(&self, hash: Hash, parents: Vec<Hash>) -> Header {
let mut header = header_from_precomputed_hash(hash, parents);
let ghostdag_data = self.consensus.services.ghostdag_primary_manager.ghostdag(header.direct_parents());
let ghostdag_data = self.consensus.services.ghostdag_manager.ghostdag(header.direct_parents());
header.pruning_point = self
.consensus
.services
Expand Down Expand Up @@ -201,7 +201,7 @@ impl TestConsensus {
}

pub fn ghostdag_store(&self) -> &Arc<DbGhostdagStore> {
&self.consensus.ghostdag_primary_store
&self.consensus.ghostdag_store
}

pub fn reachability_store(&self) -> &Arc<RwLock<DbReachabilityStore>> {
Expand Down Expand Up @@ -233,7 +233,7 @@ impl TestConsensus {
}

pub fn ghostdag_manager(&self) -> &DbGhostdagManager {
&self.consensus.services.ghostdag_primary_manager
&self.consensus.services.ghostdag_manager
}
}

Expand Down
Loading