Skip to content
This repository has been archived by the owner on Feb 21, 2024. It is now read-only.

Commit

Permalink
Merge pull request paritytech#151 from subspace/fix-non-archival-node
Browse files Browse the repository at this point in the history
Get chain parameters from best block instead of genesis block to fix sync for non-archival nodes
  • Loading branch information
nazar-pc authored Nov 25, 2021
2 parents c877423 + adeb347 commit e0814b5
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 9 deletions.
8 changes: 4 additions & 4 deletions crates/sc-consensus-subspace-rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -185,15 +185,15 @@ where
fn get_farmer_metadata(&self) -> FutureResult<FarmerMetadata> {
let client = Arc::clone(&self.client);
Box::pin(async move {
let best_block_hash = BlockId::Hash(client.info().best_hash);
let best_block_id = BlockId::Hash(client.info().best_hash);
let runtime_api = client.runtime_api();

let farmer_metadata: Result<FarmerMetadata, ApiError> = try {
FarmerMetadata {
confirmation_depth_k: runtime_api.confirmation_depth_k(&best_block_hash)?,
record_size: runtime_api.record_size(&best_block_hash)?,
confirmation_depth_k: runtime_api.confirmation_depth_k(&best_block_id)?,
record_size: runtime_api.record_size(&best_block_id)?,
recorded_history_segment_size: runtime_api
.recorded_history_segment_size(&best_block_hash)?,
.recorded_history_segment_size(&best_block_id)?,
}
};

Expand Down
8 changes: 4 additions & 4 deletions crates/sc-consensus-subspace/src/archiver.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,19 +85,19 @@ pub fn start_subspace_archiver<Block: BlockT, Client>(
+ 'static,
Client::Api: SubspaceApi<Block>,
{
let genesis_block_id = BlockId::Number(Zero::zero());
let best_block_id = BlockId::Hash(client.info().best_hash);

let confirmation_depth_k = client
.runtime_api()
.confirmation_depth_k(&genesis_block_id)
.confirmation_depth_k(&best_block_id)
.expect("Failed to get `confirmation_depth_k` from runtime API");
let record_size = client
.runtime_api()
.record_size(&genesis_block_id)
.record_size(&best_block_id)
.expect("Failed to get `record_size` from runtime API");
let recorded_history_segment_size = client
.runtime_api()
.recorded_history_segment_size(&genesis_block_id)
.recorded_history_segment_size(&best_block_id)
.expect("Failed to get `recorded_history_segment_size` from runtime API");

let maybe_last_root_block = find_last_root_block(client.as_ref());
Expand Down
4 changes: 3 additions & 1 deletion crates/sc-consensus-subspace/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1644,9 +1644,11 @@ where
let (imported_block_notification_sender, imported_block_notification_stream) =
notification::channel("subspace_imported_block_notification_stream");

let best_block_id = BlockId::Hash(client.info().best_hash);

let confirmation_depth_k = client
.runtime_api()
.confirmation_depth_k(&BlockId::Number(Zero::zero()))
.confirmation_depth_k(&best_block_id)
.expect("Failed to get `confirmation_depth_k` from runtime API");

let link = SubspaceLink {
Expand Down

0 comments on commit e0814b5

Please sign in to comment.