Skip to content
This repository was archived by the owner on Nov 15, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
d8c0d83
Introduce LightHeader and use it for tree_route(). Add lowest_common_…
seerscode Sep 22, 2019
8376f5f
Introduce HeaderCache using LightHeader. Implement get_light_header()…
seerscode Sep 22, 2019
7354ac4
Add header_cache to LightStorage. Implement get_light_header and set_…
seerscode Sep 22, 2019
1667fbf
Use lowest_common_ancestor in informant.
seerscode Sep 22, 2019
89a20f1
Use lowest_common_ancestor and new tree_route in Client.
seerscode Sep 22, 2019
9933541
Use get_light_header in in_mem.
seerscode Sep 22, 2019
6d13ab2
Use lowest_common_ancestor in is_descendent_of.
seerscode Sep 22, 2019
3004c17
Use light header in ancestry.
seerscode Sep 22, 2019
1d5645a
Forward set/get light_header for Blockchain.
seerscode Sep 22, 2019
0bd2228
Add lru crate.
seerscode Sep 22, 2019
303f2d5
Add Cargo.lock.
seerscode Sep 22, 2019
7afb9fd
Update cargo.lock
seerscode Sep 22, 2019
3dcf173
Fix compilation.
seerscode Sep 22, 2019
dc6ebb8
Fix test compilation.
seerscode Sep 22, 2019
69c846c
Fix cargo.lock
seerscode Sep 23, 2019
df7be28
Extract header metadata to own crate.
seerscode Sep 27, 2019
96c10cc
Fix tests and remove unused code.
seerscode Sep 27, 2019
c789299
Adds some docs.
seerscode Sep 27, 2019
b8b976a
Fix cargo.lock
seerscode Sep 27, 2019
004b48a
merge master
seerscode Sep 27, 2019
641755f
Fix nits.
seerscode Oct 1, 2019
5903fb5
Use same lru cache everywhere.
seerscode Oct 1, 2019
f0ecf0e
Remove TreeBackend.
seerscode Oct 1, 2019
cbc5840
Add a couple of test cases more.
seerscode Oct 2, 2019
8cb5b42
Remove functions from import lines.
seerscode Oct 2, 2019
5621af9
Fix tests.
seerscode Oct 2, 2019
a993063
Fix indent.
seerscode Oct 2, 2019
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
15 changes: 15 additions & 0 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ members = [
"core/cli",
"core/client",
"core/client/db",
"core/client/header-metadata",
"core/consensus/aura",
"core/consensus/babe",
"core/consensus/common",
Expand Down
1 change: 1 addition & 0 deletions core/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ exit-future = "0.1"
serde_json = "1.0"
panic-handler = { package = "substrate-panic-handler", path = "../../core/panic-handler" }
client = { package = "substrate-client", path = "../../core/client" }
header-metadata = { package = "substrate-header-metadata", path = "../../core/client/header-metadata" }
network = { package = "substrate-network", path = "../../core/network" }
sr-primitives = { path = "../../core/sr-primitives" }
primitives = { package = "substrate-primitives", path = "../../core/primitives" }
Expand Down
17 changes: 8 additions & 9 deletions core/cli/src/informant.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ use client::BlockchainEvents;
use futures::{Future, Stream};
use futures03::{StreamExt as _, TryStreamExt as _};
use log::{info, warn};
use sr_primitives::{generic::BlockId, traits::Header};
use sr_primitives::traits::Header;
use service::AbstractService;

mod display;
Expand All @@ -47,19 +47,18 @@ pub fn build(service: &impl AbstractService) -> impl Future<Item = (), Error = (
// detect and log reorganizations.
if let Some((ref last_num, ref last_hash)) = last_best {
if n.header.parent_hash() != last_hash && n.is_new_best {
let tree_route = ::client::blockchain::tree_route(
|id| client.header(&id)?.ok_or_else(
|| client::error::Error::UnknownBlock(format!("{:?}", id))),
BlockId::Hash(last_hash.clone()),
BlockId::Hash(n.hash),
let maybe_ancestor = header_metadata::lowest_common_ancestor(
&*client,
last_hash.clone(),
n.hash,
);

match tree_route {
Ok(ref t) if !t.retracted().is_empty() => info!(
match maybe_ancestor {
Ok(ref ancestor) if ancestor.hash != *last_hash => info!(
"Reorg from #{},{} to #{},{}, common ancestor #{},{}",
last_num, last_hash,
n.header.number(), n.hash,
t.common_block().number, t.common_block().hash,
ancestor.number, ancestor.hash,
),
Ok(_) => {},
Err(e) => warn!("Error computing tree route: {}", e),
Expand Down
2 changes: 2 additions & 0 deletions core/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,7 @@ runtime-version = { package = "sr-version", path = "../sr-version", default-feat
rstd = { package = "sr-std", path = "../sr-std", default-features = false }
inherents = { package = "substrate-inherents", path = "../inherents", default-features = false }
sr-api-macros = { path = "../sr-api-macros" }
header-metadata = { package = "substrate-header-metadata", path = "header-metadata", optional = true }

[dev-dependencies]
env_logger = "0.6"
Expand All @@ -45,6 +46,7 @@ std = [
"sr-primitives/std",
"runtime-version/std",
"hash-db/std",
"header-metadata",
"consensus",
"parking_lot",
"derive_more",
Expand Down
1 change: 1 addition & 0 deletions core/client/db/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ executor = { package = "substrate-executor", path = "../../executor" }
state_db = { package = "substrate-state-db", path = "../../state-db" }
trie = { package = "substrate-trie", path = "../../trie" }
consensus_common = { package = "substrate-consensus-common", path = "../../consensus/common" }
header_metadata = { package = "substrate-header-metadata", path = "../header-metadata" }

[dev-dependencies]
substrate-keyring = { path = "../../keyring" }
Expand Down
Loading