Skip to content

Commit

Permalink
Compatibility with Cosmos SDK v0.43+ (#948)
Browse files Browse the repository at this point in the history
* Adapted proto compiler. Regenerated Rust files

* Adapt to newer namespace for apps.

* Manual fix for Staking erroneous compilation

* Workaround: disabled chain upgrade

* Added specific GRPC-web port to prevent conflict on 9091.

* Upgrade protos

* Add support for new message action strings

* Improved output for one-chain script

* CLI for chain upgrade proposal adapted to gaia v5.

* Re-generated proto files with updated proto-compiler (fmt enabled).

* Manual fix for staking::Validators erroneous compilation; added the .applications.transfer generated file

* Quick feature for parametrizing upgraded chain

* Clippy fix. Meta for params for better display.

* Adapted query_upgraded_client_state

* Adapted query_upgraded_consensus_state to ibc-go-v1

* Moved from gRPC to ABCI

* Adapted send_tx_simulate to new def of SimulateRequest

* Added parametrizable upgrade plan name

* Fix unwraps. Retain unbonding period if none specified.

* Missing post-merge bracket

* Removed register and send match arms for rpc events

* Support for new message.actions strings of ICS27

Based on discussion from
cosmos/cosmos-sdk#9139 (comment)
This is not yet tested!

* Update protos sdk(v0.43.0-rc2) & ibc-go(v1.0.0-rc3)

* Revert "Added specific GRPC-web port to prevent conflict on 9091."

This reverts commit abf6dba.

* Add missing fields in upgrade Plan

* Fix clippy warnings

* Added another action field to match intertx MsgSend

* Update protos sdk(v0.43.0) & ibc-go(v1.0.0)

* Update cosmos SDK module version requirement in compatibility.rs

* Add legacy upgrade support (#1289)

* Add legacy upgrade support

* Fix check for legacy

* Update .changelog

* Add TODO

* Apply suggestion

Co-authored-by: Adi Seredinschi <adi@informal.systems>

Co-authored-by: Adi Seredinschi <adi@informal.systems>

* Apply suggestions

* Update .changelog

* Fix .changelog entry

Co-authored-by: Adi Seredinschi <adi@informal.systems>
Co-authored-by: Shoaib Ahmed <sufialhussaini@gmail.com>
  • Loading branch information
3 people authored Aug 19, 2021
1 parent 1adea5a commit c4b6e30
Show file tree
Hide file tree
Showing 32 changed files with 1,416 additions and 385 deletions.
3 changes: 3 additions & 0 deletions .changelog/unreleased/features/1287-upgrade-legacy.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Add `--legacy | -l` flag to support upgrades for chains built with Cosmos SDK < v0.43.0 ([#1287])

[#1287]: https://github.com/informalsystems/ibc-rs/issues/1287
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
- Upgrade to Cosmos SDK proto (v0.43.0) & ibc-go proto (v1.0.0) ([#948])

- [#948]: https://github.com/informalsystems/ibc-rs/pull/948
5 changes: 5 additions & 0 deletions modules/src/application/mod.rs
Original file line number Diff line number Diff line change
@@ -1 +1,6 @@
pub mod ics20_fungible_token_transfer;

// TODO: These consts should move into the ICS27 namespace
pub const ICS27_BANK_SEND_TYPE_URL: &str = "/cosmos.bank.v1beta1.MsgSend";
pub const ICS27_SEND_TYPE_URL: &str = "/intertx.MsgSend";
pub const ICS27_REGISTER_TYPE_URL: &str = "/intertx.MsgRegister";
2 changes: 1 addition & 1 deletion modules/src/ics02_client/msgs/create_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ use crate::ics02_client::error::Error;
use crate::signer::Signer;
use crate::tx_msg::Msg;

pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient";
pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgCreateClient";

/// A type of message that triggers the creation of a new on-chain (IBC) client.
#[derive(Clone, Debug, PartialEq, Eq)]
Expand Down
2 changes: 1 addition & 1 deletion modules/src/ics02_client/msgs/update_client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ use crate::ics24_host::identifier::ClientId;
use crate::signer::Signer;
use crate::tx_msg::Msg;

pub(crate) const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient";
pub const TYPE_URL: &str = "/ibc.core.client.v1.MsgUpdateClient";

/// A type of message that triggers the update of an on-chain (IBC) client with new headers.
#[derive(Clone, Debug, PartialEq)] // TODO: Add Eq bound when possible
Expand Down
2 changes: 1 addition & 1 deletion proto-compiler/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ cargo build --locked
Run the following command to clone the Cosmos SDK and the IBC-Go repositories, and check out a specific commit:

```bash
$ cargo run -- clone --out /tmp/cosmos --sdk-commit 7648bfca45b9d0897103ec739210607dce77c4fb --ibc-go-commit 333c1f338b2a14a1928a6f8ab64c37123c0e97b6
$ cargo run -- clone --out /tmp/cosmos --sdk-commit 8cfa2c26738276d895caf9eb98b3f70616218e17 --ibc-go-commit d70f49c8f612d60f1b7e2f1d1f160f28988962e1
```

Note:
Expand Down
18 changes: 9 additions & 9 deletions proto-compiler/src/cmd/compile.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,9 @@ pub struct CompileCmd {

impl CompileCmd {
pub fn run(&self) {
let with_ibc = self.ibc.is_none();
let tmp_sdk = TempDir::new("ibc-proto-sdk").unwrap();
Self::output_version(&self.sdk, tmp_sdk.as_ref(), "COSMOS_SDK_COMMIT");
Self::compile_sdk_protos(&self.sdk, tmp_sdk.as_ref(), with_ibc);
Self::compile_sdk_protos(&self.sdk, tmp_sdk.as_ref(), self.ibc.clone());

match &self.ibc {
None => {
Expand Down Expand Up @@ -121,7 +120,7 @@ impl CompileCmd {
}
}

fn compile_sdk_protos(sdk_dir: &Path, out_dir: &Path, with_ibc: bool) {
fn compile_sdk_protos(sdk_dir: &Path, out_dir: &Path, ibc_dep: Option<PathBuf>) {
println!(
"[info ] Compiling Cosmos-SDK .proto files to Rust into '{}'...",
out_dir.display()
Expand All @@ -130,7 +129,7 @@ impl CompileCmd {
let root = env!("CARGO_MANIFEST_DIR");

// Paths
let mut proto_paths = vec![
let proto_paths = vec![
format!("{}/../proto/definitions/mock", root),
format!("{}/proto/cosmos/auth", sdk_dir.display()),
format!("{}/proto/cosmos/gov", sdk_dir.display()),
Expand All @@ -140,17 +139,18 @@ impl CompileCmd {
format!("{}/proto/cosmos/upgrade", sdk_dir.display()),
];

if with_ibc {
// Use the IBC proto files from the SDK
proto_paths.push(format!("{}/proto/ibc", sdk_dir.display()));
}

let proto_includes_paths = [
let mut proto_includes_paths = vec![
format!("{}/../proto", root),
format!("{}/proto", sdk_dir.display()),
format!("{}/third_party/proto", sdk_dir.display()),
];

if let Some(ibc_dir) = ibc_dep {
// Use the IBC proto files from the SDK
proto_includes_paths.push(format!("{}/proto", ibc_dir.display()),);
}

// List available proto files
let mut protos: Vec<PathBuf> = vec![];
for proto_path in &proto_paths {
Expand Down
1 change: 1 addition & 0 deletions proto/src/prost/COSMOS_IBC_COMMIT
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
e9f1dc2a4f8631749c72e48957848cab3eb10762
2 changes: 1 addition & 1 deletion proto/src/prost/COSMOS_SDK_COMMIT
Original file line number Diff line number Diff line change
@@ -1 +1 @@
7648bfca45b9d0897103ec739210607dce77c4fb
v0.43.0
44 changes: 38 additions & 6 deletions proto/src/prost/cosmos.auth.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,15 +36,22 @@ pub struct Params {
#[prost(uint64, tag = "5")]
pub sig_verify_cost_secp256k1: u64,
}
/// GenesisState defines the auth module's genesis state.
/// QueryAccountsRequest is the request type for the Query/Accounts RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
/// params defines all the paramaters of the module.
pub struct QueryAccountsRequest {
/// pagination defines an optional pagination for the request.
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
/// accounts are the accounts present at genesis.
#[prost(message, repeated, tag = "2")]
pub pagination: ::core::option::Option<super::super::base::query::v1beta1::PageRequest>,
}
/// QueryAccountsResponse is the response type for the Query/Accounts RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct QueryAccountsResponse {
/// accounts are the existing accounts
#[prost(message, repeated, tag = "1")]
pub accounts: ::prost::alloc::vec::Vec<::prost_types::Any>,
/// pagination defines the pagination in the response.
#[prost(message, optional, tag = "2")]
pub pagination: ::core::option::Option<super::super::base::query::v1beta1::PageResponse>,
}
/// QueryAccountRequest is the request type for the Query/Account RPC method.
#[derive(Clone, PartialEq, ::prost::Message)]
Expand Down Expand Up @@ -104,6 +111,21 @@ pub mod query_client {
let inner = tonic::client::Grpc::with_interceptor(inner, interceptor);
Self { inner }
}
#[doc = " Accounts returns all the existing accounts"]
pub async fn accounts(
&mut self,
request: impl tonic::IntoRequest<super::QueryAccountsRequest>,
) -> Result<tonic::Response<super::QueryAccountsResponse>, tonic::Status> {
self.inner.ready().await.map_err(|e| {
tonic::Status::new(
tonic::Code::Unknown,
format!("Service was not ready: {}", e.into()),
)
})?;
let codec = tonic::codec::ProstCodec::default();
let path = http::uri::PathAndQuery::from_static("/cosmos.auth.v1beta1.Query/Accounts");
self.inner.unary(request.into_request(), path, codec).await
}
#[doc = " Account returns account details based on address."]
pub async fn account(
&mut self,
Expand Down Expand Up @@ -148,3 +170,13 @@ pub mod query_client {
}
}
}
/// GenesisState defines the auth module's genesis state.
#[derive(Clone, PartialEq, ::prost::Message)]
pub struct GenesisState {
/// params defines all the paramaters of the module.
#[prost(message, optional, tag = "1")]
pub params: ::core::option::Option<Params>,
/// accounts are the accounts present at genesis.
#[prost(message, repeated, tag = "2")]
pub accounts: ::prost::alloc::vec::Vec<::prost_types::Any>,
}
3 changes: 3 additions & 0 deletions proto/src/prost/cosmos.base.query.v1beta1.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,9 @@ pub struct PageRequest {
/// is set.
#[prost(bool, tag = "4")]
pub count_total: bool,
/// reverse is set to true if results are to be returned in the descending order.
#[prost(bool, tag = "5")]
pub reverse: bool,
}
/// PageResponse is to be embedded in gRPC response messages where the
/// corresponding request message has used PageRequest.
Expand Down
Loading

0 comments on commit c4b6e30

Please sign in to comment.