Skip to content
This repository has been archived by the owner on Nov 15, 2023. It is now read-only.

introduce errors with info #1834

Merged
merged 65 commits into from
Oct 27, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
65 commits
Select commit Hold shift + click to select a range
980a360
add sub errors to SubSystemError
drahnr Oct 21, 2020
f8ea7d8
step 2
drahnr Oct 21, 2020
172d88f
step 3
drahnr Oct 21, 2020
00aed75
step 4
drahnr Oct 21, 2020
ae0d715
nits
drahnr Oct 22, 2020
1cdb5b7
fixes
drahnr Oct 22, 2020
1fe0d65
wrap subsystem errors
drahnr Oct 22, 2020
e95d950
more steps
drahnr Oct 22, 2020
3927413
make subsystem errors more specific
drahnr Oct 22, 2020
48ac8ae
avail-dist: expressive errors
drahnr Oct 22, 2020
3acbe56
fixup cargo lock
drahnr Oct 22, 2020
a46f907
Update node/subsystem/src/lib.rs
drahnr Oct 23, 2020
d139597
Update node/subsystem/src/errors.rs
drahnr Oct 23, 2020
73c17e7
Update node/overseer/src/lib.rs
drahnr Oct 23, 2020
c7f8f9e
Update node/overseer/Cargo.toml
drahnr Oct 23, 2020
f1844c8
Update node/subsystem/src/lib.rs
drahnr Oct 23, 2020
9ba05a5
Update node/overseer/src/lib.rs
drahnr Oct 23, 2020
73067cf
chore format
drahnr Oct 23, 2020
727fcf1
chore add #![deny(..)] to most files.
drahnr Oct 23, 2020
8a42dfd
make the erasure wrapper use thiserror
drahnr Oct 23, 2020
597b7c2
remove derive_from where possible, unify version to 0.99.11
drahnr Oct 23, 2020
2170598
Update node/core/chain-api/src/lib.rs
drahnr Oct 23, 2020
6b6f38c
rewrap
drahnr Oct 26, 2020
d16efd7
undo whitespace madness
drahnr Oct 26, 2020
8988421
Merge remote-tracking branch 'origin/master' into bernhard-errors-wit…
drahnr Oct 26, 2020
e65b342
erasure coding error message fix
drahnr Oct 26, 2020
931558e
merge fallout
drahnr Oct 26, 2020
6516cca
add missing #[error] annotations
drahnr Oct 26, 2020
73f6ee3
chore extra spaces between #[from] and wrapped error
drahnr Oct 26, 2020
574d93f
chore: cleanup unused dependencies
drahnr Oct 26, 2020
ce334f9
moar
drahnr Oct 26, 2020
2b4a0fc
chore
drahnr Oct 26, 2020
86c5a43
service is too much pain for the gain
drahnr Oct 26, 2020
64a95ba
fallout
drahnr Oct 26, 2020
722aa4d
chore
drahnr Oct 26, 2020
4e730cd
fixes from cargo b --workspace
drahnr Oct 26, 2020
1753724
fixup core-backing
drahnr Oct 26, 2020
199a682
fixup bitfield-signing
drahnr Oct 26, 2020
b7268a3
fixup provisioner
drahnr Oct 26, 2020
0e6a1f7
fix subsys-test-helpers, fixup bitfield-distribution
drahnr Oct 26, 2020
ce9ef22
fixup av-store
drahnr Oct 26, 2020
6de2908
fixup chain-api
drahnr Oct 26, 2020
c07b2ef
Update node/subsystem-util/Cargo.toml
drahnr Oct 26, 2020
317ab57
Update validation/src/error.rs
drahnr Oct 26, 2020
37ade03
Update erasure-coding/src/lib.rs
drahnr Oct 26, 2020
6cacc59
Update erasure-coding/src/lib.rs
drahnr Oct 26, 2020
5ef5f8c
fixup pov-distribution
drahnr Oct 26, 2020
12293b3
fixup candidate-validation
drahnr Oct 26, 2020
5297f8c
chore: tabs vs spaces
drahnr Oct 26, 2020
e358347
fixup candidate selection
drahnr Oct 26, 2020
b6b436e
fixup availability distribution
drahnr Oct 26, 2020
36cbf66
fixup runtime-api
drahnr Oct 26, 2020
acdcc3b
fixup statement-distribution
drahnr Oct 26, 2020
8086835
fixup provisioner
drahnr Oct 26, 2020
59bb59d
fixup subsystem-util
drahnr Oct 26, 2020
0b0237a
fixup availability distr
drahnr Oct 26, 2020
3f3cc02
finalize fixups
drahnr Oct 26, 2020
60cee2c
Merge remote-tracking branch 'origin/master' into bernhard-errors-wit…
drahnr Oct 26, 2020
576ff06
chore: spaces vs tabs
drahnr Oct 26, 2020
3dc8e30
review comments.
drahnr Oct 26, 2020
9723752
3 -> 3u32
drahnr Oct 26, 2020
4d93bfb
update substrate to d766e229466d63afadd19097e277d85146fee3c9"
drahnr Oct 26, 2020
755f919
add u32 type annotations
drahnr Oct 26, 2020
72e8426
Merge branch 'master' into bernhard-errors-with-info
ordian Oct 26, 2020
8eea3b8
avoid the pain with cli for now
drahnr Oct 27, 2020
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
348 changes: 58 additions & 290 deletions Cargo.lock

Large diffs are not rendered by default.

13 changes: 3 additions & 10 deletions cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,12 @@ wasm-opt = false
crate-type = ["cdylib", "rlib"]

[dependencies]
log = "0.4.8"
futures = { version = "0.3.4", features = ["compat"] }
structopt = "0.3.8"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
log = "0.4.11"
structopt = { version = "0.3.8", optional = true }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-runtime = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-db = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-executor = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-tracing = { git = "https://github.com/paritytech/substrate", branch = "master" }
service = { package = "polkadot-service", path = "../node/service", default-features = false, optional = true }

tokio = { version = "0.2.13", features = ["rt-threaded"], optional = true }
frame-benchmarking-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-cli = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
sc-service = { git = "https://github.com/paritytech/substrate", branch = "master", optional = true }
Expand All @@ -46,7 +39,7 @@ default = [ "wasmtime", "db", "cli", "full-node", "trie-memory-tracker" ]
wasmtime = [ "sc-cli/wasmtime" ]
db = [ "service/db" ]
cli = [
"tokio",
"structopt",
"sc-cli",
"sc-service",
"frame-benchmarking-cli",
Expand Down
1 change: 0 additions & 1 deletion cli/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,6 @@
//! Polkadot CLI library.

#![warn(missing_docs)]
#![warn(unused_extern_crates)]

#[cfg(feature = "browser")]
mod browser;
Expand Down
2 changes: 1 addition & 1 deletion erasure-coding/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,4 @@ reed_solomon = { package = "reed-solomon-erasure", version = "4.0.2"}
codec = { package = "parity-scale-codec", version = "1.3.4", default-features = false, features = ["derive"] }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
trie = { package = "sp-trie", git = "https://github.com/paritytech/substrate", branch = "master" }
derive_more = "0.15.0"
thiserror = "1.0.21"
21 changes: 15 additions & 6 deletions erasure-coding/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ use primitives::v0::{self, Hash as H256, BlakeTwo256, HashT};
use primitives::v1;
use sp_core::Blake2Hasher;
use trie::{EMPTY_PREFIX, MemoryDB, Trie, TrieMut, trie_types::{TrieDBMut, TrieDB}};
use thiserror::Error;

use self::wrapped_shard::WrappedShard;

Expand All @@ -39,35 +40,43 @@ mod wrapped_shard;
const MAX_VALIDATORS: usize = <galois_16::Field as reed_solomon::Field>::ORDER;

/// Errors in erasure coding.
#[derive(Debug, Clone, PartialEq, derive_more::Display)]
#[derive(Debug, Clone, PartialEq, Error)]
pub enum Error {
/// Returned when there are too many validators.
#[error("There are too many validators")]
TooManyValidators,
/// Cannot encode something for no validators
#[error("Validator set is empty")]
EmptyValidators,
/// Cannot reconstruct: wrong number of validators.
#[error("Validator count mismatches between encoding and decoding")]
WrongValidatorCount,
/// Not enough chunks present.
#[error("Not enough chunks to reconstruct message")]
NotEnoughChunks,
/// Too many chunks present.
#[error("Too many chunks present")]
TooManyChunks,
/// Chunks not of uniform length or the chunks are empty.
#[error("Chunks are not unform, mismatch in length or are zero sized")]
NonUniformChunks,
/// An uneven byte-length of a shard is not valid for GF(2^16) encoding.
#[error("Uneven length is not valid for field GF(2^16)")]
UnevenLength,
/// Chunk index out of bounds.
#[display(fmt = "Chunk is out of bounds: {} {}", _0, _1)]
ChunkIndexOutOfBounds(usize, usize),
#[error("Chunk is out of bounds: {chunk_index} not included in 0..{n_validators}")]
ChunkIndexOutOfBounds{ chunk_index: usize, n_validators: usize },
/// Bad payload in reconstructed bytes.
#[error("Reconstructed payload invalid")]
BadPayload,
/// Invalid branch proof.
#[error("Invalid branch proof")]
InvalidBranchProof,
/// Branch out of bounds.
#[error("Branch is out of bounds")]
BranchOutOfBounds,
}

impl std::error::Error for Error { }

#[derive(Debug, PartialEq)]
struct CodeParams {
data_shards: usize,
Expand Down Expand Up @@ -206,7 +215,7 @@ fn reconstruct<'a, I: 'a, T: Decode>(n_validators: usize, chunks: I) -> Result<T
let mut shard_len = None;
for (chunk_data, chunk_idx) in chunks.into_iter().take(n_validators) {
if chunk_idx >= n_validators {
return Err(Error::ChunkIndexOutOfBounds(chunk_idx, n_validators));
return Err(Error::ChunkIndexOutOfBounds{ chunk_index: chunk_idx, n_validators });
}

let shard_len = shard_len.get_or_insert_with(|| chunk_data.len());
Expand Down
2 changes: 1 addition & 1 deletion node/collation-generation/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
derive_more = "0.99.9"
futures = "0.3.5"
log = "0.4.8"
polkadot-erasure-coding = { path = "../../erasure-coding" }
Expand All @@ -14,6 +13,7 @@ polkadot-node-subsystem = { path = "../subsystem" }
polkadot-node-subsystem-util = { path = "../subsystem-util" }
polkadot-primitives = { path = "../../primitives" }
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
thiserror = "1.0.21"

[dev-dependencies]
polkadot-node-subsystem-test-helpers = { path = "../subsystem-test-helpers" }
23 changes: 12 additions & 11 deletions node/collation-generation/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
// You should have received a copy of the GNU General Public License
// along with Polkadot. If not, see <http://www.gnu.org/licenses/>.

use thiserror::Error;

#[derive(Debug, derive_more::From)]
#[derive(Debug, Error)]
pub enum Error {
#[from]
Subsystem(polkadot_node_subsystem::SubsystemError),
#[from]
OneshotRecv(futures::channel::oneshot::Canceled),
#[from]
Runtime(polkadot_node_subsystem::errors::RuntimeApiError),
#[from]
Util(polkadot_node_subsystem_util::Error),
#[from]
Erasure(polkadot_erasure_coding::Error),
#[error(transparent)]
Subsystem(#[from] polkadot_node_subsystem::SubsystemError),
#[error(transparent)]
OneshotRecv(#[from] futures::channel::oneshot::Canceled),
#[error(transparent)]
Runtime(#[from] polkadot_node_subsystem::errors::RuntimeApiError),
#[error(transparent)]
Util(#[from] polkadot_node_subsystem_util::Error),
#[error(transparent)]
Erasure(#[from] polkadot_erasure_coding::Error),
}

pub type Result<T> = std::result::Result<T, Error>;
4 changes: 2 additions & 2 deletions node/core/av-store/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,12 @@ authors = ["Parity Technologies <admin@parity.io>"]
edition = "2018"

[dependencies]
derive_more = "0.99.9"
futures = "0.3.5"
futures-timer = "3.0.2"
kvdb = "0.7.0"
kvdb-rocksdb = "0.9.1"
log = "0.4.8"
log = "0.4.11"
thiserror = "1.0.21"

codec = { package = "parity-scale-codec", version = "1.3.1", features = ["derive"] }
erasure = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
Expand Down
31 changes: 16 additions & 15 deletions node/core/av-store/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ use polkadot_node_subsystem_util::metrics::{self, prometheus};
use polkadot_subsystem::messages::{
AllMessages, AvailabilityStoreMessage, ChainApiMessage, RuntimeApiMessage, RuntimeApiRequest,
};
use thiserror::Error;

const LOG_TARGET: &str = "availability";

Expand All @@ -53,22 +54,22 @@ mod columns {
pub const NUM_COLUMNS: u32 = 2;
}

#[derive(Debug, derive_more::From)]
#[derive(Debug, Error)]
enum Error {
#[from]
Chain(ChainApiError),
#[from]
Erasure(erasure::Error),
#[from]
Io(io::Error),
#[from]
Oneshot(oneshot::Canceled),
#[from]
Runtime(RuntimeApiError),
#[from]
Subsystem(SubsystemError),
#[from]
Time(SystemTimeError),
#[error(transparent)]
RuntimeAPI(#[from] RuntimeApiError),
#[error(transparent)]
ChainAPI(#[from] ChainApiError),
#[error(transparent)]
Erasure(#[from] erasure::Error),
#[error(transparent)]
Io(#[from] io::Error),
#[error(transparent)]
Oneshot(#[from] oneshot::Canceled),
#[error(transparent)]
Subsystem(#[from] SubsystemError),
#[error(transparent)]
Time(#[from] SystemTimeError),
}

/// A wrapper type for delays.
Expand Down
7 changes: 2 additions & 5 deletions node/core/backing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,16 @@ edition = "2018"

[dependencies]
futures = "0.3.5"
sp-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
sc-client-api = { git = "https://github.com/paritytech/substrate", branch = "master" }
sp-blockchain = { git = "https://github.com/paritytech/substrate", branch = "master" }
polkadot-primitives = { path = "../../../primitives" }
polkadot-node-primitives = { path = "../../primitives" }
polkadot-subsystem = { package = "polkadot-node-subsystem", path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
erasure-coding = { package = "polkadot-erasure-coding", path = "../../../erasure-coding" }
statement-table = { package = "polkadot-statement-table", path = "../../../statement-table" }
derive_more = "0.99.9"
bitvec = { version = "0.17.4", default-features = false, features = ["alloc"] }
log = "0.4.8"
log = "0.4.11"
thiserror = "1.0.21"

[dev-dependencies]
sp-core = { git = "https://github.com/paritytech/substrate", branch = "master" }
Expand Down
34 changes: 20 additions & 14 deletions node/core/backing/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@

//! Implements a `CandidateBackingSubsystem`.

#![deny(unused_crate_dependencies)]

use std::collections::{HashMap, HashSet};
use std::convert::TryFrom;
use std::pin::Pin;
Expand Down Expand Up @@ -64,22 +66,26 @@ use statement_table::{
SignedStatement as TableSignedStatement, Summary as TableSummary,
},
};
use thiserror::Error;

#[derive(Debug, derive_more::From)]
#[derive(Debug, Error)]
enum Error {
#[error("Candidate is not found")]
CandidateNotFound,
#[error("Signature is invalid")]
InvalidSignature,
StoreFailed,
#[from]
Erasure(erasure_coding::Error),
#[from]
ValidationFailed(ValidationFailed),
#[from]
Oneshot(oneshot::Canceled),
#[from]
Mpsc(mpsc::SendError),
#[from]
UtilError(util::Error),
#[error("Failed to send candidates {0:?}")]
Send(Vec<NewBackedCandidate>),
#[error("Oneshot never resolved")]
Oneshot(#[from] #[source] oneshot::Canceled),
#[error("Obtaining erasure chunks failed")]
ObtainErasureChunks(#[from] #[source] erasure_coding::Error),
#[error(transparent)]
ValidationFailed(#[from] ValidationFailed),
#[error(transparent)]
Mpsc(#[from] mpsc::SendError),
#[error(transparent)]
UtilError(#[from] util::Error),
}

/// Holds all data needed for candidate backing job operation.
Expand Down Expand Up @@ -468,7 +474,7 @@ impl CandidateBackingJob {
CandidateBackingMessage::GetBackedCandidates(_, tx) => {
let backed = self.get_backed();

tx.send(backed).map_err(|_| oneshot::Canceled)?;
tx.send(backed).map_err(|data| Error::Send(data))?;
}
}

Expand Down Expand Up @@ -640,7 +646,7 @@ impl CandidateBackingJob {
)
).await?;

rx.await?.map_err(|_| Error::StoreFailed)?;
let _ = rx.await?;

Ok(())
}
Expand Down
4 changes: 2 additions & 2 deletions node/core/bitfield-signing/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,11 @@ edition = "2018"

[dependencies]
bitvec = "0.17.4"
derive_more = "0.99.9"
futures = "0.3.5"
log = "0.4.8"
log = "0.4.11"
polkadot-primitives = { path = "../../../primitives" }
polkadot-node-subsystem = { path = "../../subsystem" }
polkadot-node-subsystem-util = { path = "../../subsystem-util" }
sp-keystore = { git = "https://github.com/paritytech/substrate", branch = "master" }
wasm-timer = "0.2.4"
thiserror = "1.0.21"
Loading