Skip to content

Commit

Permalink
Update webb-rs to v0.5.13 (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
salman01zp authored Feb 1, 2023
1 parent c5bdec8 commit 7b7bbe2
Show file tree
Hide file tree
Showing 22 changed files with 671 additions and 238 deletions.
807 changes: 625 additions & 182 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion crates/event-watcher-traits/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sled = { version = "^0.34" }
futures = { version = "^0.3", default-features = false }
backoff = { version = "0.4.0", features = ["tokio"] }
tokio = { version = "^1", features = ["full"] }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/proposal-signing-backends/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ sled = { version = "^0.34" }
futures = { version = "^0.3", default-features = false }
tokio = { version = "^1", features = ["full"] }
hex = { version = "0.4", default-features = false }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-context/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ edition = "2021"
webb-relayer-config = { path = "../relayer-config"}
webb-relayer-utils = { path = "../relayer-utils"}
tokio = { version = "^1", features = ["full"] }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }

Expand Down
2 changes: 1 addition & 1 deletion crates/relayer-handler-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ edition = "2021"
serde = { version = "^1", default-features = false, features = ["derive"] }
tokio = { version = "^1", features = ["full"] }
webb-relayer-tx-relay-utils = { path = "../tx-relay-utils" }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
2 changes: 1 addition & 1 deletion crates/relayer-handlers/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ tokio = { version = "^1", features = ["full"] }
tokio-stream = { version = "^0.1" }
warp = { version = "0.3.3", default-features = false, features = ["websocket", "tls"] }
serde_json = { version = "^1", default-features = false }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
6 changes: 2 additions & 4 deletions crates/relayer-handlers/src/routes/encrypted_outputs.rs
Original file line number Diff line number Diff line change
Expand Up @@ -97,8 +97,7 @@ pub async fn handle_encrypted_outputs_cache_evm(
return Ok(warp::reply::with_status(
warp::reply::json(&UnsupportedFeature {
message: format!(
"Unsupported Contract: {} for chaind : {}",
contract, chain_id
"Unsupported Contract: {contract} for chaind : {chain_id}"
),
}),
warp::http::StatusCode::BAD_REQUEST,
Expand All @@ -111,8 +110,7 @@ pub async fn handle_encrypted_outputs_cache_evm(
return Ok(warp::reply::with_status(
warp::reply::json(&UnsupportedFeature {
message: format!(
"Enbable data query for contract : ({})",
contract
"Enbable data query for contract : ({contract})"
),
}),
warp::http::StatusCode::FORBIDDEN,
Expand Down
6 changes: 2 additions & 4 deletions crates/relayer-handlers/src/routes/leaves.rs
Original file line number Diff line number Diff line change
Expand Up @@ -101,8 +101,7 @@ pub async fn handle_leaves_cache_evm(
return Ok(warp::reply::with_status(
warp::reply::json(&UnsupportedFeature {
message: format!(
"Unsupported Contract: {} for chaind : {}",
contract, chain_id
"Unsupported Contract: {contract} for chaind : {chain_id}"
),
}),
warp::http::StatusCode::BAD_REQUEST,
Expand All @@ -115,8 +114,7 @@ pub async fn handle_leaves_cache_evm(
return Ok(warp::reply::with_status(
warp::reply::json(&UnsupportedFeature {
message: format!(
"Enbable data query for contract : ({})",
contract
"Enbable data query for contract : ({contract})"
),
}),
warp::http::StatusCode::FORBIDDEN,
Expand Down
4 changes: 2 additions & 2 deletions crates/relayer-store/src/sled.rs
Original file line number Diff line number Diff line change
Expand Up @@ -639,11 +639,11 @@ mod tests {

match block {
Ok(b) => {
println!("retrieved block {:?}", block);
println!("retrieved block {block:?}");
assert_eq!(b, 20u64);
}
Err(e) => {
println!("Error encountered {:?}", e);
println!("Error encountered {e:?}");
}
}
}
Expand Down
9 changes: 3 additions & 6 deletions crates/relayer-types/src/mnemonic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,8 +42,7 @@ impl<'de> Deserialize<'de> for Mnemonic {
let str_value = if value.starts_with("0x") {
// hex value
return Err(serde::de::Error::custom(format!(
"got {} but expected a 12/24 word list ",
value
"got {value} but expected a 12/24 word list "
)));
} else if value.starts_with('>') {
todo!("Implement command execution to extract the mnemonic")
Expand All @@ -53,8 +52,7 @@ impl<'de> Deserialize<'de> for Mnemonic {
tracing::trace!("Reading {} from env", var);
std::env::var(var).map_err(|e| {
serde::de::Error::custom(format!(
"error while loading this env {}: {}",
var, e,
"error while loading this env {var}: {e}",
))
})?
} else {
Expand All @@ -63,8 +61,7 @@ impl<'de> Deserialize<'de> for Mnemonic {
BipMnemonic::from_phrase(&str_value, Language::English).map_err(
|_| {
serde::de::Error::custom(format!(
"Cannot get the mnemonic from string: {}",
value
"Cannot get the mnemonic from string: {value}"
))
},
)
Expand Down
6 changes: 2 additions & 4 deletions crates/relayer-types/src/private_key.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,7 @@ impl<'de> Deserialize<'de> for PrivateKey {
tracing::trace!("Reading {} from env", var);
let val = std::env::var(var).map_err(|e| {
serde::de::Error::custom(format!(
"error while loading this env {}: {}",
var, e,
"error while loading this env {var}: {e}",
))
})?;
let maybe_hex = Secret::from_str(&val);
Expand All @@ -78,8 +77,7 @@ impl<'de> Deserialize<'de> for PrivateKey {
let val =
std::fs::read_to_string(file_path).map_err(|e| {
serde::de::Error::custom(format!(
"error while reading file path {} : {}",
file_path, e
"error while reading file path {file_path} : {e}"
))
})?;
if val.starts_with("0x") {
Expand Down
15 changes: 7 additions & 8 deletions crates/relayer-types/src/rpc_url.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,28 +17,28 @@ impl std::fmt::Display for RpcUrl {
// Display the inner url, not the wrapper.
// with all the parts, scheme, host, port, path, query, fragment.
let scheme = self.0.scheme();
write!(f, "{}", scheme)?;
write!(f, "{scheme}")?;
if let Some(host) = self.0.host_str() {
write!(f, "://{}", host)?;
write!(f, "://{host}")?;
}
if let Some(port) = self.0.port_or_known_default() {
write!(f, ":{}", port)?;
write!(f, ":{port}")?;
}
write!(f, "{}", self.0.path())?;

if let Some(query) = self.0.query() {
write!(f, "?{}", query)?;
write!(f, "?{query}")?;
}
if let Some(fragment) = self.0.fragment() {
write!(f, "#{}", fragment)?;
write!(f, "#{fragment}")?;
}
Ok(())
}
}

impl std::fmt::Debug for RpcUrl {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
write!(f, "{}", self)?;
write!(f, "{self}")?;
Ok(())
}
}
Expand Down Expand Up @@ -91,8 +91,7 @@ impl<'de> Deserialize<'de> for RpcUrl {
tracing::trace!("Reading {} from env", var);
let val = std::env::var(var).map_err(|e| {
serde::de::Error::custom(format!(
"error while loading this env {}: {}",
var, e,
"error while loading this env {var}: {e}",
))
})?;
let maybe_rpc_url = url::Url::parse(&val);
Expand Down
3 changes: 1 addition & 2 deletions crates/relayer-types/src/suri.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,7 @@ impl<'de> Deserialize<'de> for Suri {
tracing::trace!("Reading {} from env", var);
let val = std::env::var(var).map_err(|e| {
serde::de::Error::custom(format!(
"error while loading this env {}: {}",
var, e,
"error while loading this env {var}: {e}",
))
})?;
let maybe_pair =
Expand Down
14 changes: 6 additions & 8 deletions crates/relayer-utils/src/metric.rs
Original file line number Diff line number Diff line change
Expand Up @@ -183,24 +183,22 @@ impl Metrics {
let resource_hex = hex::encode(resource_id.to_bytes().as_ref());
// Total gas fee spent on particular resource.
let total_gas_spent_counter = register_counter!(
format!("resource_{}_total_gas_spent", resource_hex),
format!("resource_{resource_hex}_total_gas_spent"),
format!(
"The total number of gas spent on resource : {}",
resource_hex
"The total number of gas spent on resource : {resource_hex}"
)
);
// Total fee earned on particular resource.
let total_fee_earned_counter = register_counter!(
format!("resource_{}_total_fees_earned", resource_hex),
format!("resource_{resource_hex}_total_fees_earned"),
format!(
"The total number of fees earned on resource : {}",
resource_hex
"The total number of fees earned on resource : {resource_hex}"
)
);
// Account Balance
let account_balance_counter = register_gauge!(
format!("resource_{}_account_balance", resource_hex),
format!("Total account balance : {}", resource_hex)
format!("resource_{resource_hex}_account_balance"),
format!("Total account balance : {resource_hex}")
);

ResourceMetric {
Expand Down
2 changes: 1 addition & 1 deletion crates/tx-queue/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ futures = { version = "^0.3", default-features = false }
backoff = { version = "0.4.0", features = ["tokio"] }
tokio = { version = "^1", features = ["full"] }
rand = { version = "0.8", default-features = false, features = ["getrandom"] }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
ethereum-types = "0.13.1"
Expand Down
2 changes: 1 addition & 1 deletion crates/tx-relay-utils/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,6 @@ edition = "2021"

[dependencies]
serde = { version = "^1", default-features = false, features = ["derive"] }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
2 changes: 1 addition & 1 deletion crates/tx-relay/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ webb-relayer-utils = { path = "../relayer-utils"}
tracing = { version = "^0.1", features = ["log"] }
futures = { version = "^0.3", default-features = false }
tokio = { version = "^1", features = ["full"] }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
2 changes: 1 addition & 1 deletion event-watchers/dkg/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ tracing = { version = "^0.1", features = ["log"] }
sled = { version = "^0.34" }
tokio = { version = "^1", features = ["full"] }
hex = { version = "0.4", default-features = false }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
2 changes: 1 addition & 1 deletion event-watchers/evm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ sled = { version = "^0.34" }
tokio = { version = "^1", features = ["full"] }
serde_json = { version = "^1", default-features = false }
hex = { version = "0.4", default-features = false }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
2 changes: 1 addition & 1 deletion event-watchers/substrate/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ tracing = { version = "^0.1", features = ["log"] }
sled = { version = "^0.34" }
tokio = { version = "^1", features = ["full"] }
hex = { version = "0.4", default-features = false }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down
15 changes: 9 additions & 6 deletions event-watchers/substrate/src/signature_bridge_watcher.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ use std::borrow::Cow;
use webb::substrate::scale::Encode;
use webb_relayer_types::dynamic_payload::WebbDynamicTxPayload;
use webb_relayer_utils::metric;
use webb::substrate::protocol_substrate_runtime::api::runtime_types::sp_core::bounded::bounded_vec::BoundedVec;

/// A SignatureBridge contract events & commands watcher.
#[derive(Copy, Clone, Debug, Default)]
Expand Down Expand Up @@ -154,7 +155,8 @@ where
.storage()
.fetch(&current_maintainer_addrs, None)
.await?
.unwrap();
.unwrap()
.0;

// Verify proposal signature
let is_signature_valid = validate_ecdsa_signature(
Expand Down Expand Up @@ -189,8 +191,8 @@ where
// Enqueue transaction call data in protocol-substrate transaction queue
let execute_proposal_call = ExecuteProposal {
src_id: typed_chain_id.chain_id(),
proposal_data: proposal_data.clone(),
signature: signature.clone(),
proposal_data: BoundedVec(proposal_data.clone()),
signature: BoundedVec(signature.clone()),
};
// webb dynamic payload
let execute_proposal_tx = WebbDynamicTxPayload {
Expand Down Expand Up @@ -238,7 +240,8 @@ where
.storage()
.fetch(&current_maintainer_addrs, None)
.await?
.unwrap();
.unwrap()
.0;
// we need to do some checks here:
// 1. convert the public key to address and check it is not the same as the current maintainer.
// 2. check if the nonce is greater than the current nonce.
Expand Down Expand Up @@ -283,8 +286,8 @@ where
);

let set_maintainer_call = SetMaintainer {
message: new_maintainer.clone(),
signature: signature.clone(),
message: BoundedVec(new_maintainer.clone()),
signature: BoundedVec(signature.clone()),
};

// webb dynamic payload
Expand Down
2 changes: 1 addition & 1 deletion services/webb-relayer/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ warp-real-ip = "0.2"
config = { version = "0.11", default-features = false, features = ["toml", "json"] }
serde_json = { version = "^1", default-features = false }
paw = { version = "^1.0", optional = true }
webb = { version = "0.5.11", default-features = false }
webb = { version = "0.5.13", default-features = false }
# Used by ethers (but we need it to be vendored with the lib).
native-tls = { version = "^0.2", features = ["vendored"], optional = true }
webb-proposals = { version = "0.5.4", default-features = false, features = ["scale"] }
Expand Down

0 comments on commit 7b7bbe2

Please sign in to comment.