Skip to content

Commit

Permalink
Keep a record of the works done so far as a release v.0.1.0 (#69)
Browse files Browse the repository at this point in the history
* Add changelog

* Fix clippy catches

* Fix errors by clippy 1.67.0

* cargo fmt

* Set version to 0.1.0
  • Loading branch information
Farhad-Shabani authored Feb 2, 2023
1 parent c5744f4 commit b63ad47
Show file tree
Hide file tree
Showing 10 changed files with 36 additions and 28 deletions.
10 changes: 10 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# CHANGELOG

## 0.1.0

*Feb 1st, 2023*

This is the initial release of the `basecoin-rs` project. This version serves as
a development reference for interacting with Hermes IBC relayer and performing
handy tests with specific versions of the `ibc-rs` (v0.16.0) and `tendermint-rs`
(v0.23.7).
2 changes: 1 addition & 1 deletion 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 Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "tendermint-basecoin"
version = "0.2.0"
version = "0.1.0"
edition = "2018"
license = "Apache-2.0"
readme = "README.md"
Expand Down
2 changes: 1 addition & 1 deletion ci/Dockerfile
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
ARG TENDERMINT_VERSION=0.34.11
ARG GAIA_VERSION=5.0.5
ARG RUST_VERSION=1.62
ARG RUST_VERSION=1.65

FROM tendermint/tendermint:v${TENDERMINT_VERSION} AS tendermint
FROM cephalopodequipment/gaiad:${GAIA_VERSION} AS gaia
Expand Down
12 changes: 5 additions & 7 deletions src/app/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -247,21 +247,21 @@ impl<S: Default + ProvableStore + 'static> Application for BaseCoinApp<S> {
// responded to by this module, so try with next module
Err(Error(ErrorDetail::NotHandled(_), _)) => continue,
// Other error - return immediately
Err(e) => return ResponseQuery::from_error(1, format!("query error: {:?}", e)),
Err(e) => return ResponseQuery::from_error(1, format!("query error: {e:?}")),
}
}
ResponseQuery::from_error(1, "query msg not handled")
}

fn deliver_tx(&self, request: RequestDeliverTx) -> ResponseDeliverTx {
debug!("Got deliverTx request: {:?}", request);
debug!("Got deliverTx request: {request:?}");

let tx: Tx = match request.tx.as_slice().try_into() {
Ok(tx) => tx,
Err(err) => {
return ResponseDeliverTx::from_error(
1,
format!("failed to decode incoming tx bytes: {}", err),
format!("failed to decode incoming tx bytes: {err}"),
);
}
};
Expand Down Expand Up @@ -311,7 +311,7 @@ impl<S: Default + ProvableStore + 'static> Application for BaseCoinApp<S> {
self.store.write().unwrap().reset();
return ResponseDeliverTx::from_error(
2,
format!("deliver failed with error: {}", e),
format!("deliver failed with error: {e}"),
);
}
}
Expand Down Expand Up @@ -342,9 +342,7 @@ impl<S: Default + ProvableStore + 'static> Application for BaseCoinApp<S> {
info!(
"Committed height {} with hash({})",
state.current_height() - 1,
data.iter()
.map(|b| format!("{:02X}", b))
.collect::<String>()
data.iter().map(|b| format!("{b:02X}")).collect::<String>()
);
ResponseCommit {
data,
Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/bank.rs
Original file line number Diff line number Diff line change
Expand Up @@ -232,11 +232,11 @@ impl<S: Store> BankKeeper for BankBalanceKeeper<S> {
self.balance_store
.set(src_balance_path, Balances(src_balances))
.map(|_| ())
.map_err(|e| Error::store(format!("{:?}", e)))?;
.map_err(|e| Error::store(format!("{e:?}")))?;
self.balance_store
.set(dst_balance_path, Balances(dst_balances))
.map(|_| ())
.map_err(|e| Error::store(format!("{:?}", e)))?;
.map_err(|e| Error::store(format!("{e:?}")))?;

Ok(())
}
Expand Down Expand Up @@ -275,7 +275,7 @@ impl<S: Store> BankKeeper for BankBalanceKeeper<S> {
self.balance_store
.set(balance_path, Balances(balances))
.map(|_| ())
.map_err(|e| Error::store(format!("{:?}", e)))?;
.map_err(|e| Error::store(format!("{e:?}")))?;

Ok(())
}
Expand Down Expand Up @@ -306,7 +306,7 @@ impl<S: Store> BankKeeper for BankBalanceKeeper<S> {
self.balance_store
.set(balance_path, Balances(balances))
.map(|_| ())
.map_err(|e| Error::store(format!("{:?}", e)))?;
.map_err(|e| Error::store(format!("{e:?}")))?;

Ok(())
}
Expand Down Expand Up @@ -370,7 +370,7 @@ where
fn deliver(&mut self, message: Any, _signer: &AccountId) -> Result<Vec<Event>, ModuleError> {
let message: MsgSend = Self::decode::<proto::cosmos::bank::v1beta1::MsgSend>(message)?
.try_into()
.map_err(|e| Error::msg_validation_failure(format!("{:?}", e)))?;
.map_err(|e| Error::msg_validation_failure(format!("{e:?}")))?;

let _ = self
.account_reader
Expand Down Expand Up @@ -464,7 +464,7 @@ impl<S: ProvableStore + 'static> Query for BankService<S> {
.get_ref()
.address
.parse()
.map_err(|e| Status::invalid_argument(format!("{}", e)))?;
.map_err(|e| Status::invalid_argument(format!("{e}")))?;
let denom = Denom(request.get_ref().denom.clone());
let balances = self.bank_reader.get_all_balances(account_id);

Expand Down
12 changes: 6 additions & 6 deletions src/app/modules/ibc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -434,7 +434,7 @@ impl<S: Store> ClientReader for Ibc<S> {
client_id: &ClientId,
height: IbcHeight,
) -> Result<Option<AnyConsensusState>, ClientError> {
let path = format!("clients/{}/consensusStates", client_id)
let path = format!("clients/{client_id}/consensusStates")
.try_into()
.unwrap(); // safety - path must be valid since ClientId and height are valid Identifiers

Expand Down Expand Up @@ -464,7 +464,7 @@ impl<S: Store> ClientReader for Ibc<S> {
client_id: &ClientId,
height: IbcHeight,
) -> Result<Option<AnyConsensusState>, ClientError> {
let path = format!("clients/{}/consensusStates", client_id)
let path = format!("clients/{client_id}/consensusStates")
.try_into()
.unwrap(); // safety - path must be valid since ClientId and height are valid Identifiers

Expand Down Expand Up @@ -808,7 +808,7 @@ impl<S: Store> ChannelReader for Ibc<S> {
}

fn hash(&self, value: Vec<u8>) -> Vec<u8> {
sha2::Sha256::digest(&value).to_vec()
sha2::Sha256::digest(value).to_vec()
}

fn host_height(&self) -> IbcHeight {
Expand Down Expand Up @@ -1085,7 +1085,7 @@ impl<S: ProvableStore + 'static> ClientQuery for IbcClientService<S> {
let path = "clients"
.to_owned()
.try_into()
.map_err(|e| Status::invalid_argument(format!("{}", e)))?;
.map_err(|e| Status::invalid_argument(format!("{e}")))?;

let client_state_paths = |path: Path| -> Option<path::ClientStatePath> {
match path.try_into() {
Expand Down Expand Up @@ -1130,7 +1130,7 @@ impl<S: ProvableStore + 'static> ClientQuery for IbcClientService<S> {

let path = format!("clients/{}/consensusStates", request.get_ref().client_id)
.try_into()
.map_err(|e| Status::invalid_argument(format!("{}", e)))?;
.map_err(|e| Status::invalid_argument(format!("{e}")))?;

let keys = self.consensus_state_store.get_keys(&path);
let consensus_states = keys
Expand Down Expand Up @@ -1267,7 +1267,7 @@ impl<S: ProvableStore + 'static> ConnectionQuery for IbcConnectionService<S> {
.get_ref()
.client_id
.parse()
.map_err(|e| Status::invalid_argument(format!("{}", e)))?;
.map_err(|e| Status::invalid_argument(format!("{e}")))?;
let path = path::ClientConnectionsPath(client_id);
let connection_ids = self
.connection_ids_store
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/avl/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ fn check_integrity<T: Ord, V>(node_ref: &NodeRef<T, V>) -> bool {
println!("[AVL] Balance factor >= 2");
return false;
}
let bonus_height = if is_leaf { 0 } else { 1 };
let bonus_height = u32::from(!is_leaf);
if node.height != std::cmp::max(left_height, right_height) + bonus_height {
println!("[AVL] Heights are inconsistent");
return false;
Expand Down
2 changes: 1 addition & 1 deletion src/app/store/avl/tree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -209,7 +209,7 @@ where
}

#[allow(dead_code)]
fn get_keys_rec<'a, 'b>(node_ref: &'a NodeRef<K, V>, keys: &'b mut Vec<&'a K>) {
fn get_keys_rec<'a>(node_ref: &'a NodeRef<K, V>, keys: &mut Vec<&'a K>) {
if let Some(node) = node_ref {
Self::get_keys_rec(&node.left, keys);
keys.push(&node.key);
Expand Down
8 changes: 4 additions & 4 deletions src/app/store/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -637,7 +637,7 @@ mod tests {

(0..=len)
.map(|_| loop {
let c = rng.sample::<char, _>(Standard) as char;
let c = rng.sample::<char, _>(Standard);

if c.is_ascii() && !VALID_CHARS.contains(&c) {
return c;
Expand All @@ -649,13 +649,13 @@ mod tests {
proptest! {
#[test]
fn validate_method_doesnt_crash(s in "\\PC*") {
let _ = Identifier::validate(&s);
let _ = Identifier::validate(s);
}

#[test]
fn valid_identifier_is_ok(l in 1usize..=10) {
let id = gen_valid_identifier(l);
let validated = Identifier::validate(&id);
let validated = Identifier::validate(id);

assert!(validated.is_ok())
}
Expand All @@ -664,7 +664,7 @@ mod tests {
#[ignore]
fn invalid_identifier_errors(l in 1usize..=10) {
let id = gen_invalid_identifier(l);
let validated = Identifier::validate(&id);
let validated = Identifier::validate(id);

assert!(validated.is_err())
}
Expand Down

0 comments on commit b63ad47

Please sign in to comment.