Skip to content

Commit 81f852c

Browse files
chore: sync with ibc-rs (#193)
* update ibc-rs rev * new error variant for Gov * update AnyClientState and AnyConsensusState impls * refactor for new ibc-rs error types * fix deprecated warning * fix use_self * short first doc paragraph * fix redundant_clone * fix empty_line_after_outer_attr * fix needless_collect * update deps * update msrv to 1.75 for derive_more * update cargo lockfile * fmt * fix significant_drop_tightening * fix equatable_if_let * fix string_lit_as_bytes * use ok_or * fix: use missing_state everywhere storage call returns None --------- Co-authored-by: Farhad Shabani <[email protected]>
1 parent 2787a8e commit 81f852c

31 files changed

+700
-624
lines changed

Cargo.lock

+323-224
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+10-9
Original file line numberDiff line numberDiff line change
@@ -8,31 +8,32 @@ members = [ "basecoin", "basecoin/app", "basecoin/modules", "basecoin/store" ]
88
version = "0.2.0"
99
license = "Apache-2.0"
1010
edition = "2021"
11-
rust-version = "1.64"
11+
rust-version = "1.75"
1212
readme = "README.md"
1313
repository = "https://github.com/informalsystems/basecoin-rs"
1414
authors = [ "Informal Systems <[email protected]>" ]
1515

1616
[workspace.dependencies]
1717
# external dependencies
1818
base64 = { version = "0.22.1", default-features = false, features = [ "alloc" ] }
19-
cosmrs = { version = "0.18.0" }
19+
cosmrs = { version = "0.20.0" }
2020
displaydoc = { version = "0.2", default-features = false }
21-
derive_more = { version = "0.99.18", default-features = false, features = [ "from", "into", "display" ] }
21+
derive_more = { version = "1.0.0", default-features = false, features = [ "from", "into", "try_into", "display" ] }
2222
ed25519 = { version = "2.2.3", default-features = false }
23-
prost = { version = "0.13.1", default-features = false }
23+
prost = { version = "0.13.3", default-features = false }
24+
serde_derive = { version = "1.0", default-features = false }
2425
serde = "1.0"
2526
serde_json = "1.0"
2627
sha2 = "0.10.8"
27-
tonic = "0.12.1"
28-
tonic-reflection = "0.12.1"
28+
tonic = "0.12.2"
29+
tonic-reflection = "0.12.2"
2930
tracing = "0.1.40"
3031
tracing-subscriber = "0.3.18"
3132

3233
# ibc dependencies
3334
ibc = { version = "0.54.0", default-features = false, features = [ "serde" ] }
3435
ibc-query = { version = "0.54.0", default-features = false }
35-
ibc-proto = { version = "0.47.0", default-features = false }
36+
ibc-proto = { version = "0.47.1", default-features = false }
3637
ics23 = { version = "0.12", default-features = false }
3738

3839
# tendermint dependencies
@@ -45,8 +46,8 @@ tendermint-rpc = { version = "0.38", default-features = false }
4546
tower-abci = { version = "0.16" }
4647

4748
[patch.crates-io]
48-
ibc = { git = "https://github.com/cosmos/ibc-rs.git", rev = "474909d" }
49-
ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "474909d" }
49+
ibc = { git = "https://github.com/cosmos/ibc-rs.git", rev = "cfb707e" }
50+
ibc-query = { git = "https://github.com/cosmos/ibc-rs.git", rev = "cfb707e" }
5051

5152
# for tendermint 0.38
5253
tower-abci = { git = "https://github.com/informalsystems/tower-abci", rev = "0992541" }

README.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ of the ibc-rs modules.
99

1010
## Requirements
1111
So far this app has been tested with:
12-
* Rust > v1.64
12+
* Rust > v1.75
1313
* CometBFT v0.37
1414

1515
## How to integrate ibc-rs changes into basecoin

basecoin/Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -20,14 +20,14 @@ tiny-bip39 = { version = "1" }
2020
digest = { version = "0.10.7" }
2121
bitcoin = { version = "0.32.2" }
2222
hdpath = { version = "0.6.3" }
23-
clap = { version = "4.5.7", features = [ "derive", "wrap_help" ] }
23+
clap = { version = "4.5", features = [ "derive", "wrap_help" ] }
2424
prost = { workspace = true }
2525
serde = { workspace = true }
26-
serde_derive = { version = "1.0.203", default-features = false }
26+
serde_derive = { workspace = true }
2727
serde_json = { workspace = true }
28-
secp256k1 = { version = "0.29.0", features = [ "serde", "rand-std" ] }
28+
secp256k1 = { version = "0.29", features = [ "serde", "rand-std" ] }
2929
sha2 = { workspace = true }
30-
tokio = { version = "1.38", features = [ "macros", "rt-multi-thread" ] }
30+
tokio = { version = "1.40", features = [ "macros", "rt-multi-thread" ] }
3131
tonic = { workspace = true }
3232
tonic-reflection = { workspace = true }
3333
toml = { version = "0.8" }

basecoin/app/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ prost = { workspace = true }
2626
serde_json = { workspace = true }
2727
tonic = { workspace = true }
2828
tracing = { workspace = true }
29-
tower = { version = "0.4", features = [ "full" ], optional = true }
29+
tower = { version = "0.5", features = [ "full" ], optional = true }
3030

3131
# tedermint dependencies
3232
tendermint = { workspace = true }

basecoin/modules/Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ derive_more = { workspace = true }
1717
primitive-types = { version = "0.12.2", default-features = false, features = [ "serde_no_std" ] }
1818
prost = { workspace = true }
1919
serde = { workspace = true }
20-
serde_derive = { version = "1.0.203", default-features = false }
20+
serde_derive = { workspace = true }
2121
serde_json = { workspace = true }
2222
sha2 = { workspace = true }
2323
tonic = { workspace = true }

basecoin/modules/src/auth/account.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl TryFrom<BaseAccount> for AuthAccount {
6060
type Error = String;
6161

6262
fn try_from(account: BaseAccount) -> Result<Self, Self::Error> {
63-
Ok(AuthAccount {
63+
Ok(Self {
6464
address: account
6565
.address
6666
.parse()
@@ -73,7 +73,7 @@ impl TryFrom<BaseAccount> for AuthAccount {
7373

7474
impl From<AuthAccount> for BaseAccount {
7575
fn from(account: AuthAccount) -> Self {
76-
BaseAccount {
76+
Self {
7777
address: account.address.to_string(),
7878
pub_key: None,
7979
account_number: account.number,
@@ -85,7 +85,7 @@ impl From<AuthAccount> for BaseAccount {
8585
impl From<AuthAccount> for Any {
8686
fn from(account: AuthAccount) -> Self {
8787
let account = BaseAccount::from(account);
88-
Any {
88+
Self {
8989
type_url: "/cosmos.auth.v1beta1.BaseAccount".to_string(),
9090
value: account.encode_to_vec(),
9191
}

basecoin/modules/src/bank/error.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,6 @@ pub enum Error {
2121

2222
impl From<Error> for AppError {
2323
fn from(e: Error) -> Self {
24-
AppError::Bank(e)
24+
Self::Bank(e)
2525
}
2626
}

basecoin/modules/src/bank/impls.rs

+1-7
Original file line numberDiff line numberDiff line change
@@ -293,13 +293,7 @@ where
293293

294294
let account_id = AccountId::from_str(&account).unwrap();
295295
self.balance_keeper
296-
.mint_coins(
297-
account_id,
298-
balances
299-
.into_iter()
300-
.map(|b| b.into())
301-
.collect::<Vec<Coin>>(),
302-
)
296+
.mint_coins(account_id, balances.into_iter().map(|b| b.into()))
303297
.unwrap();
304298
}
305299
}

basecoin/modules/src/gov/error.rs

+5-1
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,14 @@ pub use crate::error::Error as AppError;
66
pub enum Error {
77
/// invalid proposal: `{reason}`
88
InvalidProposal { reason: String },
9+
/// failed to validate: `{reason}`
10+
ValidationFailure { reason: String },
11+
/// failed to execute: `{reason}`
12+
ExecutionFailure { reason: String },
913
}
1014

1115
impl From<Error> for AppError {
1216
fn from(e: Error) -> Self {
13-
AppError::Gov(e)
17+
Self::Gov(e)
1418
}
1519
}

basecoin/modules/src/gov/impls.rs

+19-10
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ use ibc_proto::Protobuf;
1919
use tendermint::abci::Event;
2020
use tracing::debug;
2121

22+
use super::error::Error as GovError;
2223
use super::path::ProposalPath;
2324
use super::proposal::Proposal;
2425
use super::service::GovernanceService;
@@ -78,13 +79,13 @@ where
7879
let upgrade_proposal =
7980
UpgradeProposal::decode_vec(message.content.value.as_slice()).unwrap();
8081

81-
let mut upgrade_ctx = self.upgrade_ctx.write_access();
82-
83-
let event =
84-
execute_upgrade_client_proposal(upgrade_ctx.deref_mut(), upgrade_proposal)
85-
.map_err(|e| AppError::Custom {
86-
reason: format!("Error handling upgrade proposal: {:?}", e),
87-
})?;
82+
let event = execute_upgrade_client_proposal(
83+
self.upgrade_ctx.write_access().deref_mut(),
84+
upgrade_proposal,
85+
)
86+
.map_err(|e| AppError::Custom {
87+
reason: format!("Error handling upgrade proposal: {:?}", e),
88+
})?;
8889

8990
let proposal = message.proposal(self.proposal_counter);
9091

@@ -104,8 +105,16 @@ where
104105

105106
let mut ibc_ctx = self.ibc_ctx.write_access();
106107

107-
recover_client::validate(&ibc_ctx.ctx, msg_recover_client.clone())?;
108-
recover_client::execute(&mut ibc_ctx.ctx, msg_recover_client)?;
108+
recover_client::validate(&ibc_ctx.ctx, msg_recover_client.clone()).map_err(
109+
|e| GovError::ValidationFailure {
110+
reason: format!("Error validating client recovery message: {:?}", e),
111+
},
112+
)?;
113+
recover_client::execute(&mut ibc_ctx.ctx, msg_recover_client).map_err(|e| {
114+
GovError::ValidationFailure {
115+
reason: format!("Error executing client recovery message: {:?}", e),
116+
}
117+
})?;
109118

110119
// client recovery operation does not return an event
111120
// https://github.com/cosmos/ibc-go/blob/4c1aae32/modules/light-clients/07-tendermint/light_client_module.go#L249
@@ -134,7 +143,7 @@ where
134143
let data = self
135144
.store
136145
.get(Height::Pending, &Path::from(ProposalPath::sdk_path()))
137-
.ok_or(AppError::Custom {
146+
.ok_or_else(|| AppError::Custom {
138147
reason: "Data not found".to_string(),
139148
})?;
140149

basecoin/modules/src/gov/msg.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ impl TryFrom<Any> for MsgSubmitProposal {
6363

6464
fn try_from(raw: Any) -> Result<Self, Self::Error> {
6565
match raw.type_url.as_str() {
66-
TYPE_URL => MsgSubmitProposal::decode_vec(&raw.value).map_err(|e| Error::Custom {
66+
TYPE_URL => Self::decode_vec(&raw.value).map_err(|e| Error::Custom {
6767
reason: e.to_string(),
6868
}),
6969
_ => Err(Error::Custom {

basecoin/modules/src/gov/proposal.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ impl TryFrom<RawProposal> for Proposal {
4343
})
4444
}
4545
};
46-
Ok(Proposal {
46+
Ok(Self {
4747
proposal_id: raw.proposal_id,
4848
content: raw.content.unwrap(),
4949
status,

0 commit comments

Comments
 (0)