Skip to content
This repository has been archived by the owner on Jun 17, 2022. It is now read-only.

Commit

Permalink
Merge pull request #55 from selendra/development
Browse files Browse the repository at this point in the history
Development
  • Loading branch information
Lay Nath authored Nov 4, 2021
2 parents f97c23c + 950372c commit 4faa8e0
Show file tree
Hide file tree
Showing 17 changed files with 313 additions and 107 deletions.
12 changes: 6 additions & 6 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion modules/parachain/test-parachains/adder/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ parachain = { package = "selendra-parachain", path = "../../", default-features
parity-scale-codec = { version = "2.3.1", default-features = false, features = ["derive"] }
sp-std = { git = "https://github.com/paritytech/substrate", default-features = false, branch = "polkadot-v0.9.10" }
tiny-keccak = { version = "2.0.2", features = ["keccak"] }
dlmalloc = { version = "0.2.1", features = [ "global" ] }
dlmalloc = { version = "0.2.2", features = [ "global" ] }

# We need to make sure the global allocator is disabled until we have support of full substrate externalities
sp-io = { git = "https://github.com/paritytech/substrate", default-features = false, features = [ "disable_allocator" ], branch = "polkadot-v0.9.10" }
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,4 @@ substrate-test-utils = { git = "https://github.com/paritytech/substrate", branch
sc-service = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }
sp-keyring = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.10" }

tokio = { version = "0.2", features = ["macros"] }
tokio = { version = "1.13.0", features = ["macros"] }
41 changes: 32 additions & 9 deletions node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,9 @@ fn query_inner<D: Decode>(
Ok(Some(res))
},
Ok(None) => Ok(None),
Err(e) => {
tracing::warn!(target: LOG_TARGET, err = ?e, "Error reading from the availability store");
Err(e.into())
Err(err) => {
tracing::warn!(target: LOG_TARGET, ?err, "Error reading from the availability store");
Err(err.into())
},
}
}
Expand Down Expand Up @@ -365,6 +365,20 @@ pub enum Error {
CustomDatabase,
}

impl Error {
/// Determine if the error is irrecoverable
/// or notifying the user via means of logging
/// is sufficient.
fn is_fatal(&self) -> bool {
match self {
Self::Io(_) => true,
Self::Oneshot(_) => true,
Self::CustomDatabase => true,
_ => false,
}
}
}

impl Error {
fn trace(&self) {
match self {
Expand Down Expand Up @@ -524,8 +538,7 @@ where
match res {
Err(e) => {
e.trace();

if let Error::Subsystem(SubsystemError::Context(_)) = e {
if e.is_fatal() {
break
}
},
Expand Down Expand Up @@ -840,8 +853,18 @@ where
let (tx, rx) = oneshot::channel();
ctx.send_message(ChainApiMessage::FinalizedBlockHash(batch_num, tx)).await;

match rx.await?? {
None => {
match rx.await? {
Err(err) => {
tracing::warn!(
target: LOG_TARGET,
batch_num,
?err,
"Failed to retrieve finalized block number.",
);

break
},
Ok(None) => {
tracing::warn!(
target: LOG_TARGET,
"Availability store was informed that block #{} is finalized, \
Expand All @@ -851,7 +874,7 @@ where

break
},
Some(h) => h,
Ok(Some(h)) => h,
}
};

Expand Down Expand Up @@ -1093,7 +1116,7 @@ fn process_message(
},
Err(e) => {
let _ = tx.send(Err(()));
return Err(e)
return Err(e.into())
},
}
},
Expand Down
56 changes: 38 additions & 18 deletions node/core/chain-selection/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -348,14 +348,11 @@ async fn run<Context, B>(
B: Backend,
{
loop {
let res = run_iteration(&mut ctx, &mut backend, &stagnant_check_interval, &*clock).await;
let res = run_until_error(&mut ctx, &mut backend, &stagnant_check_interval, &*clock).await;
match res {
Err(e) => {
e.trace();

if let Error::Subsystem(SubsystemError::Context(_)) = e {
break
}
break
},
Ok(()) => {
tracing::info!(target: LOG_TARGET, "received `Conclude` signal, exiting");
Expand All @@ -370,7 +367,7 @@ async fn run<Context, B>(
//
// A return value of `Ok` indicates that an exit should be made, while non-fatal errors
// lead to another call to this function.
async fn run_iteration<Context, B>(
async fn run_until_error<Context, B>(
ctx: &mut Context,
backend: &mut B,
stagnant_check_interval: &StagnantCheckInterval,
Expand Down Expand Up @@ -440,32 +437,50 @@ async fn fetch_finalized(
ctx: &mut impl SubsystemContext,
) -> Result<Option<(Hash, BlockNumber)>, Error> {
let (number_tx, number_rx) = oneshot::channel();
let (hash_tx, hash_rx) = oneshot::channel();

ctx.send_message(ChainApiMessage::FinalizedBlockNumber(number_tx)).await;

let number = number_rx.await??;
let number = match number_rx.await? {
Ok(number) => number,
Err(err) => {
tracing::warn!(target: LOG_TARGET, ?err, "Fetching finalized number failed");
return Ok(None)
},
};

let (hash_tx, hash_rx) = oneshot::channel();

ctx.send_message(ChainApiMessage::FinalizedBlockHash(number, hash_tx)).await;

match hash_rx.await?? {
None => {
match hash_rx.await? {
Err(err) => {
tracing::warn!(
target: LOG_TARGET,
number,
?err,
"Fetching finalized block number failed"
);
Ok(None)
},
Ok(None) => {
tracing::warn!(target: LOG_TARGET, number, "Missing hash for finalized block number");

return Ok(None)
Ok(None)
},
Some(h) => Ok(Some((h, number))),
Ok(Some(h)) => Ok(Some((h, number))),
}
}

async fn fetch_header(
ctx: &mut impl SubsystemContext,
hash: Hash,
) -> Result<Option<Header>, Error> {
let (h_tx, h_rx) = oneshot::channel();
ctx.send_message(ChainApiMessage::BlockHeader(hash, h_tx)).await;
let (tx, rx) = oneshot::channel();
ctx.send_message(ChainApiMessage::BlockHeader(hash, tx)).await;

h_rx.await?.map_err(Into::into)
Ok(rx.await?.unwrap_or_else(|err| {
tracing::warn!(target: LOG_TARGET, ?hash, ?err, "Missing hash for finalized block number");
None
}))
}

async fn fetch_block_weight(
Expand All @@ -475,7 +490,12 @@ async fn fetch_block_weight(
let (tx, rx) = oneshot::channel();
ctx.send_message(ChainApiMessage::BlockWeight(hash, tx)).await;

rx.await?.map_err(Into::into)
let res = rx.await?;

Ok(res.unwrap_or_else(|err| {
tracing::warn!(target: LOG_TARGET, ?hash, ?err, "Missing hash for finalized block number");
None
}))
}

// Handle a new active leaf.
Expand Down Expand Up @@ -590,7 +610,7 @@ fn extract_reversion_logs(header: &Header) -> Vec<BlockNumber> {
logs
}

// Handle a finalized block event.
/// Handle a finalized block event.
fn handle_finalized_block(
backend: &mut impl Backend,
finalized_hash: Hash,
Expand Down
6 changes: 3 additions & 3 deletions node/core/dispute-coordinator/src/real/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -419,7 +419,7 @@ where
tracing::warn!(
target: LOG_TARGET,
session,
"Missing info for session which has an active dispute",
"Recovering lacks info for session which has an active dispute",
);
continue
},
Expand Down Expand Up @@ -860,7 +860,7 @@ async fn handle_import_statements(
tracing::warn!(
target: LOG_TARGET,
session,
"Missing info for session which has an active dispute",
"Importing statement lacks info for session which has an active dispute",
);

return Ok(ImportStatementsResult::InvalidImport)
Expand Down Expand Up @@ -893,7 +893,7 @@ async fn handle_import_statements(
tracing::warn!(
target: LOG_TARGET,
session,
"Missing info for session which has an active dispute",
"Not seen backing vote for candidate which has an active dispute",
);
return Ok(ImportStatementsResult::InvalidImport)
},
Expand Down
2 changes: 1 addition & 1 deletion node/core/pvf/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ async-process = "1.1.0"
assert_matches = "1.4.0"
futures = "0.3.17"
futures-timer = "3.0.2"
libc = "0.2.104"
libc = "0.2.106"
slotmap = "1.0"
tracing = "0.1.29"
pin-project = "1.0.8"
Expand Down
Loading

0 comments on commit 4faa8e0

Please sign in to comment.