Skip to content

Commit

Permalink
thiserror and anyhow::Error now support core::Error
Browse files Browse the repository at this point in the history
  • Loading branch information
seunlanlege committed Nov 8, 2024
1 parent e3ea582 commit a96b0b0
Show file tree
Hide file tree
Showing 17 changed files with 467 additions and 430 deletions.
825 changes: 434 additions & 391 deletions Cargo.lock

Large diffs are not rendered by default.

4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,9 @@ hash-db = { version = "0.16.0", default-features = false }
memory-db = { version = "0.32.0", default-features = false }
codec = { version = "3.1.3", package = "parity-scale-codec", default-features = false }
log = { version = "0.4.21", default-features = false }
anyhow = { version = "1.0.71", default-features = false }
anyhow = { version = "1.0", default-features = false }
derive_more = { version = "1.0", default-features = false }
thiserror = { version = "2", default-features = false }
alloy-rlp = { version = "0.3.7", default-features = false }
alloy-rlp-derive = "0.3.7"
alloy-sol-macro = "0.7.7"
Expand Down
2 changes: 1 addition & 1 deletion evm/abi/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ forge-testsuite = { workspace = true }

[dependencies]
primitive-types = { workspace = true }
anyhow = { workspace = true }
anyhow = { workspace = true, default-features = true }

ethers = { workspace = true }
ismp = { workspace = true }
Expand Down
2 changes: 1 addition & 1 deletion modules/consensus/grandpa/verifier/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
codec = { workspace = true, features = ["derive"]}
anyhow = { workspace = true }
anyhow = { workspace = true, default-features = false }
finality-grandpa = { version = "0.16.0", features = ["derive-codec"], default-features = false }
serde = { workspace = true, features = ["derive"] }
derive_more = { version = "0.99.17", default-features = false, features = ["from"] }
Expand Down
3 changes: 1 addition & 2 deletions modules/consensus/sync-committee/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ codec = { package = "parity-scale-codec", version = "3.2.2", default-features =
primitive-types = { version = "0.12.1", default-features = false, features = ["serde_no_std", "impl-codec"] }
serde = { version = "1.0.185", optional = true, features = ["derive"] }
hex = { version = "0.4.3", default-features = false, features = ["alloc"] }
anyhow = {workspace = true, default-features = false}
anyhow = { workspace = true, default-features = false}
ark-ec = { version = "0.4.2", default-features = false }
ark-bls12-381 = { version = "0.4.0", default-features = false }
bls_on_arkworks = { version = "0.2.2", default-features = false }
Expand All @@ -37,4 +37,3 @@ std = [
"serde",
"serde-hex-utils/std"
]

2 changes: 1 addition & 1 deletion modules/ismp/clients/bsc/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ publish = false

[dependencies]
log = { version = "0.4.17", default-features = false }
anyhow = { workspace = true }
anyhow = { workspace = true, default-features = false }
codec = { package = "parity-scale-codec", version = "3.1.3", default-features = false }
scale-info = { version = "2.1.1", default-features = false, features = ["derive"] }

Expand Down
10 changes: 7 additions & 3 deletions modules/ismp/core/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "ismp"
version = "0.2.1"
version = "0.2.2"
edition = "2021"
description = "Rust implementation of the interoperable state machine protocol"
authors = ["Polytope Labs <hello@polytope.technology>"]
Expand All @@ -17,10 +17,12 @@ codec = { workspace = true }
primitive-types = { workspace = true, features = ["codec", "scale-info", "serde_no_std"] }
serde = { workspace = true, features = ["derive"] }
scale-info = { workspace = true, features = ["derive"] }
derive_more = { version = "0.99.17", default-features = false, features = ["from", "into", "display"] }
derive_more = { workspace = true, default-features = false, features = ["from", "into", "display"] }
displaydoc = { version = "0.2", default-features = false }
serde_json = { version = "1.0.99", default-features = false, features = ["alloc"] }
hex = { version = "0.4.3", features = ["alloc"], default-features = false }
anyhow = {workspace = true, default-features = false}
anyhow = { workspace = true, default-features = false }
thiserror = { workspace = true, default-features = false }
serde-hex-utils = { workspace = true, default-features = false }

[features]
Expand All @@ -35,5 +37,7 @@ std = [
"hex/std",
"serde_json/std",
"serde-hex-utils/std",
"thiserror/std",
"displaydoc/std",
"anyhow/std"
]
29 changes: 9 additions & 20 deletions modules/ismp/core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -25,16 +25,20 @@ use core::time::Duration;
use scale_info::TypeInfo;

/// Errors that may be encountered by the ISMP module
#[derive(Debug, Eq, PartialEq, Encode, Decode, TypeInfo)]
#[derive(Debug, Eq, PartialEq, Encode, Decode, TypeInfo, displaydoc::Display, thiserror::Error)]
pub enum Error {
/// The unbonding period for the given consensus client has elapsed and can no longer process
/// consensus updates.
/**
* The unbonding period for the given consensus client has elapsed and can no longer
* process consensus updates.
*/
UnbondingPeriodElapsed {
/// The consensus client identifier
consensus_state_id: ConsensusStateId,
},
/// The challange period for the given consensus client has not yet elapsed and cannot process
/// new consensus updates in the mean time.
/**
* The challange period for the given consensus client has not yet elapsed and cannot
* process new consensus updates in the mean time.
*/
ChallengePeriodNotElapsed {
/// The consensus client identifier
state_machine_id: StateMachineId,
Expand Down Expand Up @@ -208,18 +212,3 @@ pub enum Error {
meta: Meta,
},
}

impl core::fmt::Display for Error {
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
write!(f, "{self:?}")
}
}

impl core::error::Error for Error {}

#[cfg(not(feature = "std"))]
impl From<Error> for anyhow::Error {
fn from(value: Error) -> Self {
anyhow::Error::msg(value)
}
}
2 changes: 1 addition & 1 deletion modules/utils/serde/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ readme = "./README.md"
# crates.io
serde = { workspace = true, features = ["derive"] }
hex = { version = "0.4.3", features = ["alloc"], default-features = false }
anyhow = {workspace = true, default-features = false }
anyhow = { workspace = true, default-features = false }

[features]
default = ["std"]
Expand Down
4 changes: 2 additions & 2 deletions tesseract/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,14 @@ authors = ["Polytope Labs <hello@polytope.technology>"]
publish = false

[build-dependencies]
anyhow = "1.0.75"
anyhow = { workspace = true }
ethers-contract-abigen = { workspace = true }


[dependencies]
reqwest = { version = "0.11", features = ["json"] }
serde = { version = "1.0.164", features = ["derive"] }
anyhow = "1.0.75"
anyhow = { workspace = true }
primitive-types = "0.12.1"
futures = "0.3.28"
async-trait = "0.1.71"
Expand Down
2 changes: 1 addition & 1 deletion tesseract/fees/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Polytope Labs <hello@polytope.technology>"]
publish = false

[dependencies]
anyhow = "1.0.75"
anyhow = { workspace = true }
async-trait = "0.1.53"
futures = "0.3.28"
tokio = { workspace = true, features = ["full"] }
Expand Down
2 changes: 1 addition & 1 deletion tesseract/fisherman/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ description = "A process that checks for malicious consensus updates"
authors = ["Polytope Labs <hello@polytope.technology>"]

[dependencies]
anyhow = "1.0.75"
anyhow = { workspace = true }
log = "0.4.17"
futures = "0.3.28"
tracing = "0.1.40"
Expand Down
2 changes: 1 addition & 1 deletion tesseract/integration-test/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ pallet-hyperbridge = { workspace = true }
pallet-ismp-demo = {workspace = true}

sc-consensus-manual-seal = { workspace = true }
anyhow = "1.0.75"
anyhow = { workspace = true }
tracing = "0.1.40"
percentage = "0.1.0"
futures = "0.3.28"
Expand Down
2 changes: 1 addition & 1 deletion tesseract/messaging/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Polytope Labs <hello@polytope.technology>"]
publish = false

[dependencies]
anyhow = "1.0.75"
anyhow = { workspace = true }
tracing = "0.1.40"
percentage = "0.1.0"
futures = "0.3.28"
Expand Down
2 changes: 1 addition & 1 deletion tesseract/relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env_logger = "0.10.0"
hex = "0.4.3"

tracing-subscriber = { version = "0.3.18", features = ["env-filter"] }
anyhow = "1.0.71"
anyhow = { workspace = true }
futures = "0.3.28"
serde = { version = "1.0.164", features = ["derive"] }
json = { version = "1.0.112", package = "serde_json" }
Expand Down
2 changes: 1 addition & 1 deletion tesseract/substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ publish = false

[dependencies]
serde = { version = "1.0.164", features = ["derive"] }
anyhow = "1.0.75"
anyhow = { workspace = true }
futures = "0.3.28"
async-trait = "0.1.71"
parking_lot = "0.12.1"
Expand Down
2 changes: 1 addition & 1 deletion tesseract/telemetry/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ serde = { version = "1.0.196", features = ["derive"] }
serde_json = "1.0.112"
tower = "0.4.13"
tower-http = { version = "0.5.1", features = ["cors"] }
anyhow = "1.0.79"
anyhow = { workspace = true }
axum = "0.7.4"
sp-core = { version = "28.0.0", features = ["full_crypto"] }
ismp.workspace = true
Expand Down

0 comments on commit a96b0b0

Please sign in to comment.