From 57f47f2770d86888064f56af7b784d3521869028 Mon Sep 17 00:00:00 2001 From: Farhad Shabani Date: Wed, 21 Feb 2024 06:16:39 -0800 Subject: [PATCH] feat: re-structure `basecoin-rs` (#156) * feat: split out modules * feat: re-organize repo with focus on ibc-testkit integration * fix: make clippy happy + rename main.rs to basecoin.rs * fix: allow unused imports * fix: use rpc_addr for querying ugprade plan * chore: bump Hermes to v1.8.0 * fix: update hermes-config.toml * fix: introduce cometbft version info * fix issue with upgrade-client test * fix: apply review comments * fix: adding checksums * fix: keep upgrade-client script as is * use gaia 7.1.1 on ci * code optimization --------- Co-authored-by: Rano | Ranadeep --- .../breaking-changes/155-restructure-repo.md | 2 + .github/workflows/integration.yml | 6 +- .github/workflows/rust.yml | 2 +- .github/workflows/test.yml | 2 +- Cargo.lock | 122 +++++++++++------- Cargo.toml | 58 ++++++--- README.md | 25 ++-- basecoin/Cargo.toml | 40 ++++++ basecoin/app/Cargo.toml | 41 ++++++ {crates => basecoin}/app/src/abci/mod.rs | 0 .../app/src/abci/v0_37/impls.rs | 67 +++------- .../app/src/abci/v0_37/mod.rs | 0 .../app/src/abci/v0_37/tower_abci.rs | 21 +-- .../app/src/abci/v0_38/mod.rs | 0 .../app/src/abci/v0_38/tendermint.rs | 37 +++--- {crates => basecoin}/app/src/builder.rs | 67 +--------- .../macros.rs => basecoin/app/src/error.rs | 5 +- {crates => basecoin}/app/src/lib.rs | 13 +- {crates => basecoin}/app/src/service.rs | 73 +++++------ basecoin/modules/Cargo.toml | 41 ++++++ .../modules/src}/auth/account.rs | 9 +- .../modules/src}/auth/context.rs | 0 .../modules/src}/auth/impls.rs | 27 ++-- .../modules/src}/auth/mod.rs | 0 .../modules/src}/auth/service.rs | 23 ++-- .../modules/src}/bank/context.rs | 3 +- .../modules/src}/bank/error.rs | 4 +- .../modules/src}/bank/impls.rs | 31 +++-- .../modules/src}/bank/mod.rs | 0 .../modules/src}/bank/service.rs | 25 ++-- .../modules/src}/bank/util.rs | 8 +- .../modules/src}/context.rs | 10 +- .../types => basecoin/modules/src}/error.rs | 7 +- .../modules/src}/gov/error.rs | 3 +- .../modules/src}/gov/impls.rs | 32 +++-- .../modules/src}/gov/mod.rs | 0 .../modules/src}/gov/msg.rs | 9 +- .../modules/src}/gov/path.rs | 0 .../modules/src}/gov/proposal.rs | 6 +- .../modules/src}/gov/service.rs | 28 ++-- .../modules/src}/ibc/client_contexts.rs | 5 +- .../modules/src}/ibc/error.rs | 2 +- .../modules/src}/ibc/impls.rs | 105 +++++++-------- .../modules/src}/ibc/mod.rs | 0 .../modules/src}/ibc/router.rs | 11 +- .../modules/src}/ibc/transfer.rs | 19 +-- basecoin/modules/src/lib.rs | 20 +++ .../modules/src}/staking/impls.rs | 3 +- .../modules/src}/staking/mod.rs | 0 .../modules/src}/staking/service.rs | 31 ++--- basecoin/modules/src/types.rs | 18 +++ .../modules/src}/upgrade/impls.rs | 37 +++--- .../modules/src}/upgrade/mod.rs | 0 .../modules/src}/upgrade/path.rs | 0 .../modules/src}/upgrade/query.rs | 9 +- .../modules/src}/upgrade/service.rs | 23 +--- .../main.rs => basecoin/src/bin/basecoin.rs | 15 +-- {crates/app => basecoin}/src/cli/command.rs | 0 {crates/app => basecoin}/src/cli/mod.rs | 0 .../app/src/types => basecoin/src}/config.rs | 5 +- basecoin/src/helper.rs | 58 +++++++++ basecoin/src/lib.rs | 30 +++++ {crates/app => basecoin}/src/runner.rs | 25 ++-- {crates => basecoin}/store/Cargo.toml | 13 +- .../store/src/avl/as_bytes.rs | 0 {crates => basecoin}/store/src/avl/mod.rs | 0 {crates => basecoin}/store/src/avl/node.rs | 6 +- {crates => basecoin}/store/src/avl/proof.rs | 0 {crates => basecoin}/store/src/avl/tests.rs | 11 +- {crates => basecoin}/store/src/avl/tree.rs | 27 ++-- {crates => basecoin}/store/src/context.rs | 7 +- .../store/src/impls/growing.rs | 8 +- .../store/src/impls/in_memory.rs | 9 +- {crates => basecoin}/store/src/impls/mod.rs | 0 .../store/src/impls/revertible.rs | 8 +- .../store/src/impls/shared.rs | 9 +- {crates => basecoin}/store/src/lib.rs | 0 .../store/src/types/height.rs | 0 .../store/src/types/identifier.rs | 6 +- {crates => basecoin}/store/src/types/mod.rs | 0 {crates => basecoin}/store/src/types/path.rs | 8 +- {crates => basecoin}/store/src/types/store.rs | 4 +- {crates => basecoin}/store/src/utils/codec.rs | 4 +- {crates => basecoin}/store/src/utils/mod.rs | 0 {crates => basecoin}/store/src/utils/sync.rs | 0 ci/Dockerfile | 4 +- ci/hermes-config.toml | 31 +++-- crates/app/Cargo.toml | 57 -------- crates/app/src/modules/mod.rs | 8 -- crates/app/src/modules/types.rs | 11 -- crates/app/src/types/mod.rs | 5 - crates/app/src/types/query.rs | 6 - crates/app/src/utils/mod.rs | 1 - rustfmt.toml | 5 + 94 files changed, 782 insertions(+), 729 deletions(-) create mode 100644 .changelog/unreleased/breaking-changes/155-restructure-repo.md create mode 100644 basecoin/Cargo.toml create mode 100644 basecoin/app/Cargo.toml rename {crates => basecoin}/app/src/abci/mod.rs (100%) rename {crates => basecoin}/app/src/abci/v0_37/impls.rs (82%) rename {crates => basecoin}/app/src/abci/v0_37/mod.rs (100%) rename {crates => basecoin}/app/src/abci/v0_37/tower_abci.rs (89%) rename {crates => basecoin}/app/src/abci/v0_38/mod.rs (100%) rename {crates => basecoin}/app/src/abci/v0_38/tendermint.rs (89%) rename {crates => basecoin}/app/src/builder.rs (64%) rename crates/app/src/utils/macros.rs => basecoin/app/src/error.rs (99%) rename {crates => basecoin}/app/src/lib.rs (63%) rename {crates => basecoin}/app/src/service.rs (62%) create mode 100644 basecoin/modules/Cargo.toml rename {crates/app/src/modules => basecoin/modules/src}/auth/account.rs (96%) rename {crates/app/src/modules => basecoin/modules/src}/auth/context.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/auth/impls.rs (86%) rename {crates/app/src/modules => basecoin/modules/src}/auth/mod.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/auth/service.rs (78%) rename {crates/app/src/modules => basecoin/modules/src}/bank/context.rs (96%) rename {crates/app/src/modules => basecoin/modules/src}/bank/error.rs (92%) rename {crates/app/src/modules => basecoin/modules/src}/bank/impls.rs (95%) rename {crates/app/src/modules => basecoin/modules/src}/bank/mod.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/bank/service.rs (79%) rename {crates/app/src/modules => basecoin/modules/src}/bank/util.rs (94%) rename {crates/app/src/modules => basecoin/modules/src}/context.rs (98%) rename {crates/app/src/types => basecoin/modules/src}/error.rs (73%) rename {crates/app/src/modules => basecoin/modules/src}/gov/error.rs (83%) rename {crates/app/src/modules => basecoin/modules/src}/gov/impls.rs (91%) rename {crates/app/src/modules => basecoin/modules/src}/gov/mod.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/gov/msg.rs (90%) rename {crates/app/src/modules => basecoin/modules/src}/gov/path.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/gov/proposal.rs (94%) rename {crates/app/src/modules => basecoin/modules/src}/gov/service.rs (64%) rename {crates/app/src/modules => basecoin/modules/src}/ibc/client_contexts.rs (99%) rename {crates/app/src/modules => basecoin/modules/src}/ibc/error.rs (79%) rename {crates/app/src/modules => basecoin/modules/src}/ibc/impls.rs (94%) rename {crates/app/src/modules => basecoin/modules/src}/ibc/mod.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/ibc/router.rs (88%) rename {crates/app/src/modules => basecoin/modules/src}/ibc/transfer.rs (96%) create mode 100644 basecoin/modules/src/lib.rs rename {crates/app/src/modules => basecoin/modules/src}/staking/impls.rs (99%) rename {crates/app/src/modules => basecoin/modules/src}/staking/mod.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/staking/service.rs (76%) create mode 100644 basecoin/modules/src/types.rs rename {crates/app/src/modules => basecoin/modules/src}/upgrade/impls.rs (95%) rename {crates/app/src/modules => basecoin/modules/src}/upgrade/mod.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/upgrade/path.rs (100%) rename {crates/app/src/modules => basecoin/modules/src}/upgrade/query.rs (70%) rename {crates/app/src/modules => basecoin/modules/src}/upgrade/service.rs (76%) rename crates/app/src/bin/basecoin/main.rs => basecoin/src/bin/basecoin.rs (75%) rename {crates/app => basecoin}/src/cli/command.rs (100%) rename {crates/app => basecoin}/src/cli/mod.rs (100%) rename {crates/app/src/types => basecoin/src}/config.rs (97%) create mode 100644 basecoin/src/helper.rs create mode 100644 basecoin/src/lib.rs rename {crates/app => basecoin}/src/runner.rs (92%) rename {crates => basecoin}/store/Cargo.toml (63%) rename {crates => basecoin}/store/src/avl/as_bytes.rs (100%) rename {crates => basecoin}/store/src/avl/mod.rs (100%) rename {crates => basecoin}/store/src/avl/node.rs (97%) rename {crates => basecoin}/store/src/avl/proof.rs (100%) rename {crates => basecoin}/store/src/avl/tests.rs (97%) rename {crates => basecoin}/store/src/avl/tree.rs (95%) rename {crates => basecoin}/store/src/context.rs (99%) rename {crates => basecoin}/store/src/impls/growing.rs (96%) rename {crates => basecoin}/store/src/impls/in_memory.rs (98%) rename {crates => basecoin}/store/src/impls/mod.rs (100%) rename {crates => basecoin}/store/src/impls/revertible.rs (96%) rename {crates => basecoin}/store/src/impls/shared.rs (99%) rename {crates => basecoin}/store/src/lib.rs (100%) rename {crates => basecoin}/store/src/types/height.rs (100%) rename {crates => basecoin}/store/src/types/identifier.rs (88%) rename {crates => basecoin}/store/src/types/mod.rs (100%) rename {crates => basecoin}/store/src/types/path.rs (99%) rename {crates => basecoin}/store/src/types/store.rs (98%) rename {crates => basecoin}/store/src/utils/codec.rs (97%) rename {crates => basecoin}/store/src/utils/mod.rs (100%) rename {crates => basecoin}/store/src/utils/sync.rs (100%) delete mode 100644 crates/app/Cargo.toml delete mode 100644 crates/app/src/modules/mod.rs delete mode 100644 crates/app/src/modules/types.rs delete mode 100644 crates/app/src/types/mod.rs delete mode 100644 crates/app/src/types/query.rs delete mode 100644 crates/app/src/utils/mod.rs create mode 100644 rustfmt.toml diff --git a/.changelog/unreleased/breaking-changes/155-restructure-repo.md b/.changelog/unreleased/breaking-changes/155-restructure-repo.md new file mode 100644 index 00000000..84439d76 --- /dev/null +++ b/.changelog/unreleased/breaking-changes/155-restructure-repo.md @@ -0,0 +1,2 @@ +- Restructure repository with the focus on `ibc-testkit` integration + ([#155](https://github.com/informalsystems/basecoin-rs/issues/155)) diff --git a/.github/workflows/integration.yml b/.github/workflows/integration.yml index 364af922..430ca4f4 100644 --- a/.github/workflows/integration.yml +++ b/.github/workflows/integration.yml @@ -12,14 +12,14 @@ jobs: - uses: rokroskar/workflow-run-cleanup-action@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' }} ibc-integration: runs-on: ubuntu-latest env: COMETBFT_VERSION: 0.37.1 - GAIA_VERSION: 6.0.0 - HERMES_VERSION: 1.4.0 + GAIA_VERSION: 7.1.1 + HERMES_VERSION: 1.8.0 GRPCURL_VERSION: 1.8.7 RUST_VERSION: 1.65 IBC_COMMITISH: master diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 87771488..acab25b5 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -12,7 +12,7 @@ jobs: - uses: rokroskar/workflow-run-cleanup-action@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' }} fmt: runs-on: ubuntu-latest diff --git a/.github/workflows/test.yml b/.github/workflows/test.yml index 613944f3..55a100e1 100644 --- a/.github/workflows/test.yml +++ b/.github/workflows/test.yml @@ -12,7 +12,7 @@ jobs: - uses: rokroskar/workflow-run-cleanup-action@master env: GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" - if: "!startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master'" + if: ${{ !startsWith(github.ref, 'refs/tags/') && github.ref != 'refs/heads/master' }} test: runs-on: ubuntu-latest diff --git a/Cargo.lock b/Cargo.lock index 3b83a159..851f875d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -200,13 +200,53 @@ version = "1.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "8c3c1a368f70d6cf7302d78f8f7093da241fb8e8807c05cc9e51a125895a6d5b" +[[package]] +name = "basecoin" +version = "0.1.0" +dependencies = [ + "basecoin-app", + "basecoin-modules", + "basecoin-store", + "clap", + "ibc-proto", + "serde", + "serde_derive", + "tendermint-abci", + "tendermint-rpc", + "tokio", + "toml 0.8.10", + "tonic", + "tonic-reflection", + "tower-abci", + "tracing", + "tracing-subscriber", +] + [[package]] name = "basecoin-app" version = "0.1.0" +dependencies = [ + "basecoin-modules", + "basecoin-store", + "cosmrs", + "ibc-proto", + "prost", + "serde_json", + "tendermint", + "tendermint-abci", + "tendermint-proto", + "tonic", + "tower", + "tower-abci", + "tracing", +] + +[[package]] +name = "basecoin-modules" +version = "0.1.0" dependencies = [ "base64", "basecoin-store", - "clap", "cosmrs", "derive_more", "displaydoc", @@ -221,17 +261,9 @@ dependencies = [ "serde_json", "sha2 0.10.8", "tendermint", - "tendermint-abci", - "tendermint-proto", "tendermint-rpc", - "tokio", - "toml 0.8.9", "tonic", - "tonic-reflection", - "tower", - "tower-abci", "tracing", - "tracing-subscriber", ] [[package]] @@ -363,9 +395,9 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" [[package]] name = "clap" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "1e578d6ec4194633722ccf9544794b71b1385c3c027efe0c55db226fc880865c" +checksum = "80c21025abd42669a92efc996ef13cfb2c5c627858421ea58d5c3b331a6c134f" dependencies = [ "clap_builder", "clap_derive", @@ -373,9 +405,9 @@ dependencies = [ [[package]] name = "clap_builder" -version = "4.4.18" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4df4df40ec50c46000231c914968278b1eb05098cf8f1b3a518a95030e71d1c7" +checksum = "458bf1f341769dfcf849846f65dffdf9146daa56bcd2a47cb4e1de9915567c99" dependencies = [ "anstream", "anstyle", @@ -386,9 +418,9 @@ dependencies = [ [[package]] name = "clap_derive" -version = "4.4.7" +version = "4.5.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "cf9804afaaf59a91e75b022a30fb7229a7901f60c755489cc61c9b423b836442" +checksum = "307bc0538d5f0f83b8248db3087aa92fe504e4691294d0c96c0eabc33f47ba47" dependencies = [ "heck", "proc-macro2", @@ -398,9 +430,9 @@ dependencies = [ [[package]] name = "clap_lex" -version = "0.6.0" +version = "0.7.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "702fc72eb24e5a1e48ce58027a675bc24edd52096d5397d4aea7c6dd9eca0bd1" +checksum = "98cc8fbded0c607b7ba9dd60cd98df59af97e84d24e49c8557331cfc26d301ce" [[package]] name = "colorchoice" @@ -618,9 +650,9 @@ dependencies = [ [[package]] name = "either" -version = "1.9.0" +version = "1.10.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a26ae43d7bcc3b814de94796a5e736d4029efb0ee900c12e2d54c993ad1a1e07" +checksum = "11157ac094ffbdde99aa67b23417ebdd801842852b500e395a45a9c0aac03e4a" [[package]] name = "elliptic-curve" @@ -1507,9 +1539,9 @@ checksum = "b1a46d1a171d865aa5f83f92695765caa047a9b4cbae2cbf37dbd613a793fd4c" [[package]] name = "js-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "9a1d36f1235bc969acba30b7f5990b864423a6068a10f7c90ae8f0112e3a59d1" +checksum = "406cda4b368d531c842222cf9d2600a9a4acce8d29423695379c6868a143a9ee" dependencies = [ "wasm-bindgen", ] @@ -1630,9 +1662,9 @@ dependencies = [ [[package]] name = "num-traits" -version = "0.2.17" +version = "0.2.18" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "39e3200413f237f41ab11ad6d161bc7239c84dcb631773ccd7de3dfe4b5c267c" +checksum = "da0df0e5185db44f69b44f26786fe401b6c293d1907744beaa7fa62b2e5a517a" dependencies = [ "autocfg", ] @@ -2313,9 +2345,9 @@ checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] name = "strsim" -version = "0.10.0" +version = "0.11.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "73473c0e59e6d5812c5dfe2a064a6444949f089e20eec9a2e5506596494e4623" +checksum = "5ee073c9e4cd00e28217186dbe12796d692868f432bf2e97ee73bed0c56dfa01" [[package]] name = "subtle" @@ -2691,9 +2723,9 @@ dependencies = [ [[package]] name = "toml" -version = "0.8.9" +version = "0.8.10" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "c6a4b9e8023eb94392d3dca65d717c53abc5dad49c07cb65bb8fcd87115fa325" +checksum = "9a9aad4a3066010876e8dcf5a8a06e70a558751117a145c6ce2b82c2e2054290" dependencies = [ "serde", "serde_spanned", @@ -2712,9 +2744,9 @@ dependencies = [ [[package]] name = "toml_edit" -version = "0.21.1" +version = "0.22.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6a8534fd7f78b5405e860340ad6575217ce99f38d4d5c8f2442cb5ecb50090e1" +checksum = "0c9ffdf896f8daaabf9b66ba8e77ea1ed5ed0f72821b398aba62352e95062951" dependencies = [ "indexmap 2.2.2", "serde", @@ -2986,9 +3018,9 @@ checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] name = "wasm-bindgen" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b1223296a201415c7fad14792dbefaace9bd52b62d33453ade1c5b5f07555406" +checksum = "c1e124130aee3fb58c5bdd6b639a0509486b0338acaaae0c84a5124b0f588b7f" dependencies = [ "cfg-if", "wasm-bindgen-macro", @@ -2996,9 +3028,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-backend" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "fcdc935b63408d58a32f8cc9738a0bffd8f05cc7c002086c6ef20b7312ad9dcd" +checksum = "c9e7e1900c352b609c8488ad12639a311045f40a35491fb69ba8c12f758af70b" dependencies = [ "bumpalo", "log", @@ -3011,9 +3043,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-futures" -version = "0.4.40" +version = "0.4.41" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bde2032aeb86bdfaecc8b261eef3cba735cc426c1f3a3416d1e0791be95fc461" +checksum = "877b9c3f61ceea0e56331985743b13f3d25c406a7098d45180fb5f09bc19ed97" dependencies = [ "cfg-if", "js-sys", @@ -3023,9 +3055,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3e4c238561b2d428924c49815533a8b9121c664599558a5d9ec51f8a1740a999" +checksum = "b30af9e2d358182b5c7449424f017eba305ed32a7010509ede96cdc4696c46ed" dependencies = [ "quote", "wasm-bindgen-macro-support", @@ -3033,9 +3065,9 @@ dependencies = [ [[package]] name = "wasm-bindgen-macro-support" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bae1abb6806dc1ad9e560ed242107c0f6c84335f1749dd4e8ddb012ebd5e25a7" +checksum = "642f325be6301eb8107a83d12a8ac6c1e1c54345a7ef1a9261962dfefda09e66" dependencies = [ "proc-macro2", "quote", @@ -3046,15 +3078,15 @@ dependencies = [ [[package]] name = "wasm-bindgen-shared" -version = "0.2.90" +version = "0.2.91" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4d91413b1c31d7539ba5ef2451af3f0b833a005eb27a631cec32bc0635a8602b" +checksum = "4f186bd2dcf04330886ce82d6f33dd75a7bfcf69ecf5763b89fcde53b6ac9838" [[package]] name = "web-sys" -version = "0.3.67" +version = "0.3.68" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "58cd2333b6e0be7a39605f0e255892fd7418a682d8da8fe042fe25128794d2ed" +checksum = "96565907687f7aceb35bc5fc03770a8a0471d82e479f25832f54a0e3f4b28446" dependencies = [ "js-sys", "wasm-bindgen", @@ -3225,9 +3257,9 @@ checksum = "dff9641d1cd4be8d1a070daf9e3773c5f67e78b4d9d42263020c057706765c04" [[package]] name = "winnow" -version = "0.5.37" +version = "0.5.39" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7cad8365489051ae9f054164e459304af2e7e9bb407c958076c8bf4aef52da5" +checksum = "5389a154b01683d28c77f8f68f49dea75f0a4da32557a58f68ee51ebba472d29" dependencies = [ "memchr", ] diff --git a/Cargo.toml b/Cargo.toml index aa47a0f8..497f4a66 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -3,27 +3,47 @@ resolver = "2" members = [ - "crates/app", - "crates/store", + "basecoin", + "basecoin/app", + "basecoin/modules", + "basecoin/store", ] +[workspace.package] +version = "0.1.0" +license = "Apache-2.0" +edition = "2021" +rust-version = "1.64" +readme = "README.md" +repository = "https://github.com/informalsystems/basecoin-rs" +authors = ["Informal Systems "] + [workspace.dependencies] -base64 = { version = "0.21.6", default-features = false, features = ["alloc"] } -displaydoc = { version = "0.2", default-features = false } -derive_more = { version = "0.99.17", default-features = false, features = ["from", "into", "display"] } -ed25519 = { version = "2.1.0", default-features = false } -ibc = { git = "https://github.com/cosmos/ibc-rs", rev = "4769bd7", default-features = false, features = ["serde"] } -ibc-query = { git = "https://github.com/cosmos/ibc-rs", rev = "4769bd7", default-features = false } -ibc-proto = { version = "0.41.0", default-features = false } -ics23 = { version = "0.11", default-features = false } -prost = { version = "0.12", default-features = false } -serde = "1.0" -serde_json = "1.0" -sha2 = "0.10.2" -tendermint = "0.34" -tendermint-abci = "0.34" -tendermint-proto = "0.34" -tendermint-rpc = "0.34" -tracing = "0.1.26" +# external dependencies +base64 = { version = "0.21.6", default-features = false, features = ["alloc"] } +cosmrs = { version = "0.15.0" } +displaydoc = { version = "0.2", default-features = false } +derive_more = { version = "0.99.17", default-features = false, features = ["from", "into", "display"] } +ed25519 = { version = "2.1.0", default-features = false } +prost = { version = "0.12", default-features = false } +serde = "1.0" +serde_json = "1.0" +sha2 = "0.10.2" +tonic = "0.10" +tonic-reflection = "0.10" +tracing = "0.1.26" +tracing-subscriber = "0.3.16" + +# ibc dependencies +ibc = { git = "https://github.com/cosmos/ibc-rs", rev = "4769bd7", default-features = false, features = ["serde"] } +ibc-query = { git = "https://github.com/cosmos/ibc-rs", rev = "4769bd7", default-features = false } +ibc-proto = { version = "0.41.0", default-features = false } +ics23 = { version = "0.11", default-features = false } + +# tendermint dependencies +tendermint = { version = "0.34", default-features = false } +tendermint-abci = { version = "0.34", default-features = false } +tendermint-proto = { version = "0.34", default-features = false } +tendermint-rpc = { version = "0.34", default-features = false } diff --git a/README.md b/README.md index 2ae7dc78..25afe510 100644 --- a/README.md +++ b/README.md @@ -5,11 +5,11 @@ It is a rudimentary Tendermint ABCI application that implements the following fu * `ibc` - enables support for IBC (clients, connections & channels) Its main use-cases are serving as a testing ground and mock implementation for verifying the correctness and behaviour -of the ibc-rs modules. +of the ibc-rs modules. ## Requirements So far this app has been tested with: -* Rust >v1.52.1 +* Rust > v1.64 * CometBFT v0.37 ## How to integrate ibc-rs changes into basecoin @@ -43,7 +43,7 @@ See the module documentation for more details - * [Ibc module](docs/modules/ibc.md) ### Step 4: Run the basecoin app and CometBFT -```shell +```console # See all supported CLI options $ cargo run -- --help basecoin 0.1.0 @@ -51,18 +51,17 @@ basecoin 0.1.0 USAGE: basecoin [FLAGS] [OPTIONS] -FLAGS: - --help Prints help information - -q, --quiet Suppress all output logging (overrides --verbose) - -V, --version Prints version information - -v, --verbose Increase output logging verbosity to DEBUG level +Commands: + start + query Query a state of Basecoin application from the store + help Prints this message or the help of the given subcommand(s) OPTIONS: - -g, --grpc-port Bind the gRPC server to this port [default: 9093] - -h, --host Bind the TCP server to this host [default: 127.0.0.1] - -p, --port Bind the TCP server to this port [default: 26658] - -r, --read-buf-size The default server read buffer size, in bytes, for each incoming client - connection [default: 1048576] + --config The path to the configuration file [default: config.toml] + --verbose Increase output logging verbosity to DEBUG level + --quiet Suppress all output logging (overrides --verbose) + -h --help Prints help information + -V, --version Prints version information # Run the ABCI application (from this repo) # The -v is to enable trace-level logging diff --git a/basecoin/Cargo.toml b/basecoin/Cargo.toml new file mode 100644 index 00000000..f7d6911e --- /dev/null +++ b/basecoin/Cargo.toml @@ -0,0 +1,40 @@ +[package] +name = "basecoin" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +readme = { workspace = true } +repository = { workspace = true } +authors = { workspace = true } +description = """ + Contains the basecoin daemon and CLI that integrates with ibc-rs, making + use of tendermint-rs. +""" + +[features] +default = ["v0_37"] +v0_37 = ["basecoin-app/v0_37", "dep:tower-abci"] +v0_38 = ["basecoin-app/v0_38", "dep:tendermint-abci"] + +[dependencies] +# external dependencies +clap = { version = "4.3.0", features = ["derive", "wrap_help"] } +ibc-proto = { workspace = true, features = ["server", "proto-descriptor", "serde"] } +serde = { workspace = true } +serde_derive = { version = "1.0.104", default-features = false } +tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } +tonic = { workspace = true } +tonic-reflection = { workspace = true } +toml = { version = "0.8" } +tracing = { workspace = true } +tracing-subscriber = { workspace = true } +tower-abci = { version = "0.11", optional = true } + +# tendermint dependencies +tendermint-abci = { workspace = true, optional = true } +tendermint-rpc = { workspace = true , features = ["http-client"] } + +# internal dependencies +basecoin-store = { path = "./store" } +basecoin-modules = { path = "./modules" } +basecoin-app = { path = "./app", default-features = false } diff --git a/basecoin/app/Cargo.toml b/basecoin/app/Cargo.toml new file mode 100644 index 00000000..ee4c5278 --- /dev/null +++ b/basecoin/app/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "basecoin-app" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +readme = { workspace = true } +repository = { workspace = true } +authors = { workspace = true } +description = """ + Contains a simple implementation of the Tendermint ABCI application. +""" + +[features] +default = ["v0_37"] + +# Makes the application compatible with CometBFT v0.37 +v0_37 = ["dep:tower-abci", "dep:tower"] + +# Makes the application compatible with CometBFT v0.38 +# (WIP) methods are not yet implemented +v0_38 = ["dep:tendermint-abci"] + +[dependencies] +# external dependencies +cosmrs = { workspace = true } +ibc-proto = { workspace = true, features = ["server", "proto-descriptor", "serde"] } +prost = { workspace = true } +serde_json = { workspace = true } +tonic = { workspace = true } +tracing = { workspace = true } +tower-abci = { version = "0.11", optional = true } +tower = { version = "0.4", features = ["full"], optional = true } + +# tedermint dependencies +tendermint = { workspace = true } +tendermint-abci = { workspace = true, optional = true } +tendermint-proto = { workspace = true } + +# internal dependencies +basecoin-store = { path = "../store" } +basecoin-modules = { path = "../modules" } diff --git a/crates/app/src/abci/mod.rs b/basecoin/app/src/abci/mod.rs similarity index 100% rename from crates/app/src/abci/mod.rs rename to basecoin/app/src/abci/mod.rs diff --git a/crates/app/src/abci/v0_37/impls.rs b/basecoin/app/src/abci/v0_37/impls.rs similarity index 82% rename from crates/app/src/abci/v0_37/impls.rs rename to basecoin/app/src/abci/v0_37/impls.rs index f86a6a7a..a3de146f 100644 --- a/crates/app/src/abci/v0_37/impls.rs +++ b/basecoin/app/src/abci/v0_37/impls.rs @@ -1,59 +1,32 @@ //! Contains methods specifically implemented for use with the Tower ABCI //! interface, compatible with CometBFT version 0.37 -use basecoin_store::context::ProvableStore; -use basecoin_store::context::Store; -use basecoin_store::types::Height; -use basecoin_store::types::Path; +use std::fmt::{Debug, Write}; + +use basecoin_modules::auth::ACCOUNT_PREFIX; +use basecoin_modules::error::Error; +use basecoin_modules::types::IdentifiedModule; +use basecoin_store::context::{ProvableStore, Store}; +use basecoin_store::types::{Height, Path}; use basecoin_store::utils::SharedRwExt; -use cosmrs::tx::SignerInfo; -use cosmrs::tx::SignerPublicKey; +use cosmrs::tx::{SignerInfo, SignerPublicKey}; use cosmrs::Tx; -use ibc::primitives::proto::Any; +use ibc_proto::google::protobuf::Any; use prost::Message; use serde_json::Value; -use std::fmt::{Debug, Write}; +use tendermint::merkle::proof::{ProofOp, ProofOps}; +use tendermint_proto::v0_37::abci::{ + response_process_proposal, Event as ProtoEvent, RequestApplySnapshotChunk, RequestBeginBlock, + RequestCheckTx, RequestDeliverTx, RequestEcho, RequestEndBlock, RequestInfo, RequestInitChain, + RequestLoadSnapshotChunk, RequestOfferSnapshot, RequestPrepareProposal, RequestProcessProposal, + RequestQuery, ResponseApplySnapshotChunk, ResponseBeginBlock, ResponseCheckTx, ResponseCommit, + ResponseDeliverTx, ResponseEcho, ResponseEndBlock, ResponseInfo, ResponseInitChain, + ResponseListSnapshots, ResponseLoadSnapshotChunk, ResponseOfferSnapshot, + ResponsePrepareProposal, ResponseProcessProposal, ResponseQuery, +}; use tracing::{debug, info}; -use tendermint_proto::v0_37::abci::response_process_proposal; -use tendermint_proto::v0_37::abci::Event as ProtoEvent; -use tendermint_proto::v0_37::abci::RequestApplySnapshotChunk; -use tendermint_proto::v0_37::abci::RequestBeginBlock; -use tendermint_proto::v0_37::abci::RequestCheckTx; -use tendermint_proto::v0_37::abci::RequestDeliverTx; -use tendermint_proto::v0_37::abci::RequestEcho; -use tendermint_proto::v0_37::abci::RequestEndBlock; -use tendermint_proto::v0_37::abci::RequestInfo; -use tendermint_proto::v0_37::abci::RequestInitChain; -use tendermint_proto::v0_37::abci::RequestLoadSnapshotChunk; -use tendermint_proto::v0_37::abci::RequestOfferSnapshot; -use tendermint_proto::v0_37::abci::RequestPrepareProposal; -use tendermint_proto::v0_37::abci::RequestProcessProposal; -use tendermint_proto::v0_37::abci::RequestQuery; -use tendermint_proto::v0_37::abci::ResponseApplySnapshotChunk; -use tendermint_proto::v0_37::abci::ResponseBeginBlock; -use tendermint_proto::v0_37::abci::ResponseCheckTx; -use tendermint_proto::v0_37::abci::ResponseCommit; -use tendermint_proto::v0_37::abci::ResponseDeliverTx; -use tendermint_proto::v0_37::abci::ResponseEcho; -use tendermint_proto::v0_37::abci::ResponseEndBlock; -use tendermint_proto::v0_37::abci::ResponseInfo; -use tendermint_proto::v0_37::abci::ResponseInitChain; -use tendermint_proto::v0_37::abci::ResponseListSnapshots; -use tendermint_proto::v0_37::abci::ResponseLoadSnapshotChunk; -use tendermint_proto::v0_37::abci::ResponseOfferSnapshot; -use tendermint_proto::v0_37::abci::ResponsePrepareProposal; -use tendermint_proto::v0_37::abci::ResponseProcessProposal; -use tendermint_proto::v0_37::abci::ResponseQuery; - -use tendermint::merkle::proof::ProofOp; -use tendermint::merkle::proof::ProofOps; - -use crate::modules::auth::ACCOUNT_PREFIX; -use crate::modules::types::IdentifiedModule; -use crate::utils::macros::ResponseFromErrorExt; - -use crate::types::error::Error; +use crate::error::ResponseFromErrorExt; use crate::BaseCoinApp; pub fn echo( diff --git a/crates/app/src/abci/v0_37/mod.rs b/basecoin/app/src/abci/v0_37/mod.rs similarity index 100% rename from crates/app/src/abci/v0_37/mod.rs rename to basecoin/app/src/abci/v0_37/mod.rs diff --git a/crates/app/src/abci/v0_37/tower_abci.rs b/basecoin/app/src/abci/v0_37/tower_abci.rs similarity index 89% rename from crates/app/src/abci/v0_37/tower_abci.rs rename to basecoin/app/src/abci/v0_37/tower_abci.rs index 4bbe42a2..65b76781 100644 --- a/crates/app/src/abci/v0_37/tower_abci.rs +++ b/basecoin/app/src/abci/v0_37/tower_abci.rs @@ -8,29 +8,20 @@ use std::task::{Context, Poll}; use basecoin_store::context::ProvableStore; use tendermint::v0_37::abci::response::Response as AbciResponse; use tendermint::v0_37::abci::Request as AbciRequest; - -use tendermint_proto::v0_37::abci::RequestApplySnapshotChunk; -use tendermint_proto::v0_37::abci::RequestBeginBlock; -use tendermint_proto::v0_37::abci::RequestCheckTx; -use tendermint_proto::v0_37::abci::RequestDeliverTx; -use tendermint_proto::v0_37::abci::RequestEcho; -use tendermint_proto::v0_37::abci::RequestEndBlock; -use tendermint_proto::v0_37::abci::RequestInfo; -use tendermint_proto::v0_37::abci::RequestInitChain; -use tendermint_proto::v0_37::abci::RequestLoadSnapshotChunk; -use tendermint_proto::v0_37::abci::RequestOfferSnapshot; -use tendermint_proto::v0_37::abci::RequestQuery; - +use tendermint_proto::v0_37::abci::{ + RequestApplySnapshotChunk, RequestBeginBlock, RequestCheckTx, RequestDeliverTx, RequestEcho, + RequestEndBlock, RequestInfo, RequestInitChain, RequestLoadSnapshotChunk, RequestOfferSnapshot, + RequestQuery, +}; use tower::Service; use tower_abci::BoxError; -use crate::BaseCoinApp; - use super::impls::{ apply_snapshot_chunk, begin_block, check_tx, commit, deliver_tx, echo, end_block, info, init_chain, list_snapshots, load_snapshot_chunk, offer_snapshot, prepare_proposal, process_proposal, query, }; +use crate::BaseCoinApp; /// We have to create this type since the compiler doesn't think that /// `dyn Future> + Send` diff --git a/crates/app/src/abci/v0_38/mod.rs b/basecoin/app/src/abci/v0_38/mod.rs similarity index 100% rename from crates/app/src/abci/v0_38/mod.rs rename to basecoin/app/src/abci/v0_38/mod.rs diff --git a/crates/app/src/abci/v0_38/tendermint.rs b/basecoin/app/src/abci/v0_38/tendermint.rs similarity index 89% rename from crates/app/src/abci/v0_38/tendermint.rs rename to basecoin/app/src/abci/v0_38/tendermint.rs index dbfbaf18..dbe396ad 100644 --- a/crates/app/src/abci/v0_38/tendermint.rs +++ b/basecoin/app/src/abci/v0_38/tendermint.rs @@ -1,30 +1,23 @@ -use prost::Message; -use serde_json::Value; use std::convert::TryInto; use std::fmt::Debug; -use tendermint_proto::abci::RequestFinalizeBlock; -use tendermint_proto::abci::ResponseFinalizeBlock; -use tracing::{debug, info}; -use tendermint_abci::Application; -use tendermint_proto::abci::RequestInfo; -use tendermint_proto::abci::RequestInitChain; -use tendermint_proto::abci::RequestQuery; -use tendermint_proto::abci::ResponseCommit; -use tendermint_proto::abci::ResponseInfo; -use tendermint_proto::abci::ResponseInitChain; -use tendermint_proto::abci::ResponseQuery; - -use tendermint::merkle::proof::ProofOp; -use tendermint::merkle::proof::ProofOps; - -use crate::builder::BaseCoinApp; -use crate::macros::ResponseFromErrorExt; -use crate::modules::types::IdentifiedModule; -use crate::types::error::Error; +use basecoin_modules::error::Error; +use basecoin_modules::types::IdentifiedModule; use basecoin_store::context::{ProvableStore, Store}; use basecoin_store::types::{Height, Path}; use basecoin_store::utils::SharedRwExt; +use prost::Message; +use serde_json::Value; +use tendermint::merkle::proof::{ProofOp, ProofOps}; +use tendermint_abci::Application; +use tendermint_proto::abci::{ + RequestFinalizeBlock, RequestInfo, RequestInitChain, RequestQuery, ResponseCommit, + ResponseFinalizeBlock, ResponseInfo, ResponseInitChain, ResponseQuery, +}; +use tracing::{debug, info}; + +use crate::builder::BaseCoinApp; +use crate::error::ResponseFromErrorExt; impl Application for BaseCoinApp { fn info(&self, request: RequestInfo) -> ResponseInfo { @@ -56,7 +49,7 @@ impl Application for BaseCoinApp { let mut modules = self.modules.write_access(); - for IdentifiedModule { module, id } in modules.iter_mut() { + for IdentifiedModule { module, .. } in modules.iter_mut() { module.init(app_state.clone()); } diff --git a/crates/app/src/builder.rs b/basecoin/app/src/builder.rs similarity index 64% rename from crates/app/src/builder.rs rename to basecoin/app/src/builder.rs index 76dcc371..445a76ab 100644 --- a/crates/app/src/builder.rs +++ b/basecoin/app/src/builder.rs @@ -1,26 +1,15 @@ -use crate::modules::auth::AuthAccountKeeper; -use crate::modules::auth::AuthAccountReader; -use crate::modules::bank::Bank; -use crate::modules::context::prefix; -use crate::modules::context::Identifiable; -use crate::modules::context::Module; -use crate::modules::ibc::Ibc; -use crate::modules::types::IdentifiedModule; -use crate::modules::types::ModuleList; -use crate::modules::types::ModuleStore; -use crate::types::error::Error; +use std::fmt::Debug; +use std::sync::{Arc, RwLock}; +use basecoin_modules::context::Module; +use basecoin_modules::error::Error; +use basecoin_modules::types::{IdentifiedModule, ModuleList, ModuleStore}; use basecoin_store::context::ProvableStore; -use basecoin_store::impls::RevertibleStore; -use basecoin_store::impls::SharedStore; -use basecoin_store::types::Identifier; -use basecoin_store::types::MainStore; +use basecoin_store::impls::{RevertibleStore, SharedStore}; +use basecoin_store::types::{Identifier, MainStore}; use basecoin_store::utils::{SharedRw, SharedRwExt}; - use cosmrs::AccountId; use ibc_proto::google::protobuf::Any; -use std::fmt::Debug; -use std::sync::{Arc, RwLock}; use tendermint::abci::Event; use tracing::error; @@ -117,46 +106,4 @@ impl BaseCoinApp { Err(Error::NotHandled) } } - - /// Gives access to the IBC module. - pub fn ibc(&self) -> Ibc> { - let modules = self.modules.read_access(); - - modules - .iter() - .find(|m| m.id == prefix::Ibc {}.identifier()) - .and_then(|m| { - m.module - .as_any() - .downcast_ref::>>() - .cloned() - }) - .expect("IBC module not found") - } - - /// Gives access to the Bank module. - pub fn bank( - &self, - ) -> Bank< - RevertibleStore, - AuthAccountReader>, - AuthAccountKeeper>, - > { - let modules = self.modules.read_access(); - - modules - .iter() - .find(|m| m.id == prefix::Bank {}.identifier()) - .and_then(|m| { - m.module - .as_any() - .downcast_ref::, - AuthAccountReader>, - AuthAccountKeeper>, - >>() - .cloned() - }) - .expect("Bank module not found") - } } diff --git a/crates/app/src/utils/macros.rs b/basecoin/app/src/error.rs similarity index 99% rename from crates/app/src/utils/macros.rs rename to basecoin/app/src/error.rs index c508be6e..957259ae 100644 --- a/crates/app/src/utils/macros.rs +++ b/basecoin/app/src/error.rs @@ -1,8 +1,7 @@ -#[cfg(all(feature = "v0_37", not(feature = "v0_38")))] -use tendermint_proto::v0_37::abci::{ResponseCheckTx, ResponseDeliverTx, ResponseQuery}; - #[cfg(any(feature = "v0_38", not(feature = "v0_37")))] use tendermint_proto::abci::{ResponseCheckTx, ResponseQuery}; +#[cfg(all(feature = "v0_37", not(feature = "v0_38")))] +use tendermint_proto::v0_37::abci::{ResponseCheckTx, ResponseDeliverTx, ResponseQuery}; pub(crate) trait ResponseFromErrorExt { fn from_error(code: u32, log: impl ToString) -> Self; diff --git a/crates/app/src/lib.rs b/basecoin/app/src/lib.rs similarity index 63% rename from crates/app/src/lib.rs rename to basecoin/app/src/lib.rs index 5764dd5f..30a4ee62 100644 --- a/crates/app/src/lib.rs +++ b/basecoin/app/src/lib.rs @@ -1,4 +1,5 @@ //! The basecoin ABCI application. +#![forbid(unsafe_code)] #![deny( warnings, trivial_numeric_casts, @@ -6,18 +7,10 @@ unused_qualifications, rust_2018_idioms )] -#![forbid(unsafe_code)] + pub mod abci; -pub mod cli; -pub mod modules; +mod error; pub mod service; -pub mod types; -mod utils; mod builder; pub use builder::{BaseCoinApp, Builder}; - -mod runner; -pub use runner::default_app_runner; - -pub(crate) const CHAIN_REVISION_NUMBER: u64 = 0; diff --git a/crates/app/src/service.rs b/basecoin/app/src/service.rs similarity index 62% rename from crates/app/src/service.rs rename to basecoin/app/src/service.rs index d37f069f..16843b4d 100644 --- a/crates/app/src/service.rs +++ b/basecoin/app/src/service.rs @@ -1,43 +1,23 @@ -use ibc_proto::cosmos::base::tendermint::v1beta1::service_server::Service as HealthService; -use ibc_proto::cosmos::base::tendermint::v1beta1::AbciQueryRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::AbciQueryResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetBlockByHeightRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetBlockByHeightResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetLatestBlockRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetLatestBlockResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetLatestValidatorSetRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetLatestValidatorSetResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetNodeInfoRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetNodeInfoResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetSyncingRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetSyncingResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetValidatorSetByHeightRequest; -use ibc_proto::cosmos::base::tendermint::v1beta1::GetValidatorSetByHeightResponse; -use ibc_proto::cosmos::base::tendermint::v1beta1::Module as VersionInfoModule; -use ibc_proto::cosmos::base::tendermint::v1beta1::VersionInfo; -use ibc_proto::cosmos::tx::v1beta1::service_server::Service as TxService; -use ibc_proto::cosmos::tx::v1beta1::BroadcastTxRequest; -use ibc_proto::cosmos::tx::v1beta1::BroadcastTxResponse; -use ibc_proto::cosmos::tx::v1beta1::GetBlockWithTxsRequest; -use ibc_proto::cosmos::tx::v1beta1::GetBlockWithTxsResponse; -use ibc_proto::cosmos::tx::v1beta1::GetTxRequest; -use ibc_proto::cosmos::tx::v1beta1::GetTxResponse; -use ibc_proto::cosmos::tx::v1beta1::GetTxsEventRequest; -use ibc_proto::cosmos::tx::v1beta1::GetTxsEventResponse; -use ibc_proto::cosmos::tx::v1beta1::SimulateRequest; -use ibc_proto::cosmos::tx::v1beta1::SimulateResponse; -use ibc_proto::cosmos::tx::v1beta1::TxDecodeAminoRequest; -use ibc_proto::cosmos::tx::v1beta1::TxDecodeAminoResponse; -use ibc_proto::cosmos::tx::v1beta1::TxDecodeRequest; -use ibc_proto::cosmos::tx::v1beta1::TxDecodeResponse; -use ibc_proto::cosmos::tx::v1beta1::TxEncodeAminoRequest; -use ibc_proto::cosmos::tx::v1beta1::TxEncodeAminoResponse; -use ibc_proto::cosmos::tx::v1beta1::TxEncodeRequest; -use ibc_proto::cosmos::tx::v1beta1::TxEncodeResponse; +use std::convert::TryInto; use basecoin_store::context::ProvableStore; use cosmrs::Tx; -use std::convert::TryInto; +use ibc_proto::cosmos::base::tendermint::v1beta1::service_server::Service as HealthService; +use ibc_proto::cosmos::base::tendermint::v1beta1::{ + AbciQueryRequest, AbciQueryResponse, GetBlockByHeightRequest, GetBlockByHeightResponse, + GetLatestBlockRequest, GetLatestBlockResponse, GetLatestValidatorSetRequest, + GetLatestValidatorSetResponse, GetNodeInfoRequest, GetNodeInfoResponse, GetSyncingRequest, + GetSyncingResponse, GetValidatorSetByHeightRequest, GetValidatorSetByHeightResponse, + Module as VersionInfoModule, VersionInfo, +}; +use ibc_proto::cosmos::tx::v1beta1::service_server::Service as TxService; +use ibc_proto::cosmos::tx::v1beta1::{ + BroadcastTxRequest, BroadcastTxResponse, GetBlockWithTxsRequest, GetBlockWithTxsResponse, + GetTxRequest, GetTxResponse, GetTxsEventRequest, GetTxsEventResponse, SimulateRequest, + SimulateResponse, TxDecodeAminoRequest, TxDecodeAminoResponse, TxDecodeRequest, + TxDecodeResponse, TxEncodeAminoRequest, TxEncodeAminoResponse, TxEncodeRequest, + TxEncodeResponse, +}; use tendermint_proto::p2p::DefaultNodeInfo; use tonic::{Request, Response, Status}; use tracing::debug; @@ -66,12 +46,19 @@ impl HealthService for BaseCoinApp { name: "basecoin-rs".to_string(), app_name: "basecoind".to_string(), version: "0.1.0".to_string(), - git_commit: "209afef7e99ebcb814b25b6738d033aa5e1a932c".to_string(), - build_deps: vec![VersionInfoModule { - path: "github.com/cosmos/cosmos-sdk".to_string(), - version: "v0.47.0".to_string(), - sum: "h1:ps1QWfvaX6VLNcykA7wzfii/5IwBfYgTIik6NOVDq/c=".to_string(), - }], + git_commit: "44bae428392201d541cc2811de4369ea664c5762".to_string(), + build_deps: vec![ + VersionInfoModule { + path: "github.com/cometbft/cometbft".to_string(), + version: "v0.37.1".to_string(), + sum: "h1:KLxkQTK2hICXYq21U2hn1W5hOVYUdQgDQ1uB+90xPIg=".to_string(), + }, + VersionInfoModule { + path: "github.com/cosmos/cosmos-sdk".to_string(), + version: "v0.47.0".to_string(), + sum: "h1:GKYtBpvjwuDEVix1vdnQpq7PuEOnItuEK0vdAL2cZ5g=".to_string(), + }, + ], ..VersionInfo::default() }), })) diff --git a/basecoin/modules/Cargo.toml b/basecoin/modules/Cargo.toml new file mode 100644 index 00000000..4443e376 --- /dev/null +++ b/basecoin/modules/Cargo.toml @@ -0,0 +1,41 @@ +[package] +name = "basecoin-modules" +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +readme = { workspace = true } +repository = { workspace = true } +authors = { workspace = true } +description = """ + Contains simple implementations of various modules for the Basecoin application. +""" + +[dependencies] +# external dependencies +base64 = { workspace = true } +cosmrs = { workspace = true } +displaydoc = { workspace = true } +derive_more = { workspace = true } +primitive-types = { version = "0.12.0", default-features = false, features = ["serde_no_std"] } +prost = { workspace = true } +serde = { workspace = true } +serde_derive = { version = "1.0.104", default-features = false } +serde_json = { workspace = true } +sha2 = { workspace = true } +tonic = { workspace = true } +tracing = { workspace = true } + +# ibc dependencies +ibc = { workspace = true } +ibc-proto = { workspace = true, features = ["server", "proto-descriptor", "serde"] } +ibc-query = { workspace = true } +ics23 = { workspace = true, features = ["host-functions"] } + +# tendermint dependencies +tendermint = { workspace = true } +tendermint-rpc = { workspace = true , features = ["http-client"] } + +# internal dependencies +basecoin-store = { path = "../store" } + + diff --git a/crates/app/src/modules/auth/account.rs b/basecoin/modules/src/auth/account.rs similarity index 96% rename from crates/app/src/modules/auth/account.rs rename to basecoin/modules/src/auth/account.rs index 74a45e8b..efda7f22 100644 --- a/crates/app/src/modules/auth/account.rs +++ b/basecoin/modules/src/auth/account.rs @@ -1,11 +1,12 @@ -use super::context::Account; +use std::convert::{TryFrom, TryInto}; use basecoin_store::types::Path; -use ibc_proto::{cosmos::auth::v1beta1::BaseAccount, google::protobuf::Any}; - use cosmrs::AccountId; +use ibc_proto::cosmos::auth::v1beta1::BaseAccount; +use ibc_proto::google::protobuf::Any; use prost::Message; -use std::convert::{TryFrom, TryInto}; + +use super::context::Account; /// Address of the account that the relayer uses to sign basecoin transactions. /// This is hardcoded as we don't verify signatures currently. diff --git a/crates/app/src/modules/auth/context.rs b/basecoin/modules/src/auth/context.rs similarity index 100% rename from crates/app/src/modules/auth/context.rs rename to basecoin/modules/src/auth/context.rs diff --git a/crates/app/src/modules/auth/impls.rs b/basecoin/modules/src/auth/impls.rs similarity index 86% rename from crates/app/src/modules/auth/impls.rs rename to basecoin/modules/src/auth/impls.rs index 39bbeec4..351af322 100644 --- a/crates/app/src/modules/auth/impls.rs +++ b/basecoin/modules/src/auth/impls.rs @@ -1,25 +1,24 @@ -use crate::modules::auth::account::AccountsPath; -use crate::modules::auth::account::AuthAccount; -use crate::modules::auth::context::{Account, AccountKeeper, AccountReader}; -use crate::modules::auth::service::AuthService; -use crate::modules::bank::Denom; -use crate::{modules::context::Module, types::error::Error as AppError}; +use std::collections::HashMap; +use std::str::FromStr; use basecoin_store::context::{ProvableStore, Store}; use basecoin_store::impls::SharedStore; -use basecoin_store::types::Height; -use basecoin_store::types::{ProtobufStore, TypedStore}; - +use basecoin_store::types::{Height, ProtobufStore, TypedStore}; use cosmrs::AccountId; -use ibc_proto::{ - cosmos::auth::v1beta1::{query_server::QueryServer, BaseAccount}, - google::protobuf::Any, -}; +use ibc_proto::cosmos::auth::v1beta1::query_server::QueryServer; +use ibc_proto::cosmos::auth::v1beta1::BaseAccount; +use ibc_proto::google::protobuf::Any; use serde_json::Value; -use std::{collections::HashMap, str::FromStr}; use tendermint::abci::Event; use tracing::{debug, trace}; +use crate::auth::account::{AccountsPath, AuthAccount}; +use crate::auth::context::{Account, AccountKeeper, AccountReader}; +use crate::auth::service::AuthService; +use crate::bank::Denom; +use crate::context::Module; +use crate::error::Error as AppError; + #[derive(Clone)] pub struct Auth { store: SharedStore, diff --git a/crates/app/src/modules/auth/mod.rs b/basecoin/modules/src/auth/mod.rs similarity index 100% rename from crates/app/src/modules/auth/mod.rs rename to basecoin/modules/src/auth/mod.rs diff --git a/crates/app/src/modules/auth/service.rs b/basecoin/modules/src/auth/service.rs similarity index 78% rename from crates/app/src/modules/auth/service.rs rename to basecoin/modules/src/auth/service.rs index 8a5c2faf..39f6b537 100644 --- a/crates/app/src/modules/auth/service.rs +++ b/basecoin/modules/src/auth/service.rs @@ -1,20 +1,21 @@ -use super::impls::AuthAccountReader; -use crate::modules::auth::{account::RELAYER_ACCOUNT, context::AccountReader}; - use basecoin_store::context::ProvableStore; +use ibc_proto::cosmos::auth::v1beta1::query_server::Query; use ibc_proto::cosmos::auth::v1beta1::{ - query_server::Query, AddressBytesToStringRequest, AddressBytesToStringResponse, - AddressStringToBytesRequest, AddressStringToBytesResponse, Bech32PrefixRequest, - Bech32PrefixResponse, QueryAccountAddressByIdRequest, QueryAccountAddressByIdResponse, - QueryAccountInfoRequest, QueryAccountInfoResponse, QueryAccountRequest, QueryAccountResponse, - QueryAccountsRequest, QueryAccountsResponse, QueryModuleAccountByNameRequest, - QueryModuleAccountByNameResponse, QueryModuleAccountsRequest, QueryModuleAccountsResponse, - QueryParamsRequest, QueryParamsResponse, + AddressBytesToStringRequest, AddressBytesToStringResponse, AddressStringToBytesRequest, + AddressStringToBytesResponse, Bech32PrefixRequest, Bech32PrefixResponse, + QueryAccountAddressByIdRequest, QueryAccountAddressByIdResponse, QueryAccountInfoRequest, + QueryAccountInfoResponse, QueryAccountRequest, QueryAccountResponse, QueryAccountsRequest, + QueryAccountsResponse, QueryModuleAccountByNameRequest, QueryModuleAccountByNameResponse, + QueryModuleAccountsRequest, QueryModuleAccountsResponse, QueryParamsRequest, + QueryParamsResponse, }; - use tonic::{Request, Response, Status}; use tracing::debug; +use super::impls::AuthAccountReader; +use crate::auth::account::RELAYER_ACCOUNT; +use crate::auth::context::AccountReader; + pub struct AuthService { pub account_reader: AuthAccountReader, } diff --git a/crates/app/src/modules/bank/context.rs b/basecoin/modules/src/bank/context.rs similarity index 96% rename from crates/app/src/modules/bank/context.rs rename to basecoin/modules/src/bank/context.rs index 89145a17..bc441081 100644 --- a/crates/app/src/modules/bank/context.rs +++ b/basecoin/modules/src/bank/context.rs @@ -1,4 +1,5 @@ -use std::{fmt::Debug, str::FromStr}; +use std::fmt::Debug; +use std::str::FromStr; use basecoin_store::types::Height; diff --git a/crates/app/src/modules/bank/error.rs b/basecoin/modules/src/bank/error.rs similarity index 92% rename from crates/app/src/modules/bank/error.rs rename to basecoin/modules/src/bank/error.rs index 555b7d12..b8af9b51 100644 --- a/crates/app/src/modules/bank/error.rs +++ b/basecoin/modules/src/bank/error.rs @@ -1,8 +1,8 @@ -pub use crate::types::error::Error as AppError; - use cosmrs::AccountId; pub use displaydoc::Display; +pub use crate::error::Error as AppError; + #[derive(Debug, Display)] pub enum Error { /// failed to decode message diff --git a/crates/app/src/modules/bank/impls.rs b/basecoin/modules/src/bank/impls.rs similarity index 95% rename from crates/app/src/modules/bank/impls.rs rename to basecoin/modules/src/bank/impls.rs index c70c7d78..3abf5d7a 100644 --- a/crates/app/src/modules/bank/impls.rs +++ b/basecoin/modules/src/bank/impls.rs @@ -1,27 +1,30 @@ -use super::context::{BankKeeper, BankReader}; -use super::error::Error; -use super::service::BankService; -use super::util::{Balances, BalancesPath, Coin, Denom}; -use crate::modules::auth::AccountKeeper; -use crate::modules::auth::AccountReader; -use crate::modules::auth::{AuthAccount, ACCOUNT_PREFIX}; -use crate::modules::context::Module; -use crate::types::error::Error as AppError; -use crate::types::QueryResult; +use std::collections::HashMap; +use std::convert::TryInto; +use std::fmt::Debug; +use std::str::FromStr; use basecoin_store::context::{ProvableStore, Store}; use basecoin_store::impls::SharedStore; use basecoin_store::types::{Height, JsonStore, Path, TypedStore}; use basecoin_store::utils::{Async, Codec, JsonCodec}; - -use cosmrs::{bank::MsgSend, proto, AccountId}; -use ibc_proto::{cosmos::bank::v1beta1::query_server::QueryServer, google::protobuf::Any}; +use cosmrs::bank::MsgSend; +use cosmrs::{proto, AccountId}; +use ibc_proto::cosmos::bank::v1beta1::query_server::QueryServer; +use ibc_proto::google::protobuf::Any; use primitive_types::U256; use prost::Message; -use std::{collections::HashMap, convert::TryInto, fmt::Debug, str::FromStr}; use tendermint::abci::Event; use tracing::{debug, trace}; +use super::context::{BankKeeper, BankReader}; +use super::error::Error; +use super::service::BankService; +use super::util::{Balances, BalancesPath, Coin, Denom}; +use crate::auth::{AccountKeeper, AccountReader, AuthAccount, ACCOUNT_PREFIX}; +use crate::context::Module; +pub use crate::error::Error as AppError; +use crate::types::QueryResult; + #[derive(Clone)] pub struct BankBalanceReader { balance_store: JsonStore, BalancesPath, Balances>, diff --git a/crates/app/src/modules/bank/mod.rs b/basecoin/modules/src/bank/mod.rs similarity index 100% rename from crates/app/src/modules/bank/mod.rs rename to basecoin/modules/src/bank/mod.rs diff --git a/crates/app/src/modules/bank/service.rs b/basecoin/modules/src/bank/service.rs similarity index 79% rename from crates/app/src/modules/bank/service.rs rename to basecoin/modules/src/bank/service.rs index 6b7e05f1..72f72390 100644 --- a/crates/app/src/modules/bank/service.rs +++ b/basecoin/modules/src/bank/service.rs @@ -1,24 +1,21 @@ use basecoin_store::context::ProvableStore; -use ibc_proto::cosmos::{ - bank::v1beta1::{ - query_server::Query, QueryAllBalancesRequest, QueryAllBalancesResponse, - QueryBalanceRequest, QueryBalanceResponse, QueryDenomMetadataRequest, - QueryDenomMetadataResponse, QueryDenomOwnersRequest, QueryDenomOwnersResponse, - QueryDenomsMetadataRequest, QueryDenomsMetadataResponse, QueryParamsRequest, - QueryParamsResponse, QuerySendEnabledRequest, QuerySendEnabledResponse, - QuerySpendableBalanceByDenomRequest, QuerySpendableBalanceByDenomResponse, - QuerySpendableBalancesRequest, QuerySpendableBalancesResponse, QuerySupplyOfRequest, - QuerySupplyOfResponse, QueryTotalSupplyRequest, QueryTotalSupplyResponse, - }, - base::v1beta1::Coin as RawCoin, +use ibc_proto::cosmos::bank::v1beta1::query_server::Query; +use ibc_proto::cosmos::bank::v1beta1::{ + QueryAllBalancesRequest, QueryAllBalancesResponse, QueryBalanceRequest, QueryBalanceResponse, + QueryDenomMetadataRequest, QueryDenomMetadataResponse, QueryDenomOwnersRequest, + QueryDenomOwnersResponse, QueryDenomsMetadataRequest, QueryDenomsMetadataResponse, + QueryParamsRequest, QueryParamsResponse, QuerySendEnabledRequest, QuerySendEnabledResponse, + QuerySpendableBalanceByDenomRequest, QuerySpendableBalanceByDenomResponse, + QuerySpendableBalancesRequest, QuerySpendableBalancesResponse, QuerySupplyOfRequest, + QuerySupplyOfResponse, QueryTotalSupplyRequest, QueryTotalSupplyResponse, }; +use ibc_proto::cosmos::base::v1beta1::Coin as RawCoin; use tonic::{Request, Response, Status}; - -use crate::modules::bank::util::Denom; use tracing::debug; use super::context::BankReader; use super::impls::BankBalanceReader; +use crate::bank::util::Denom; pub struct BankService { pub bank_reader: BankBalanceReader, diff --git a/crates/app/src/modules/bank/util.rs b/basecoin/modules/src/bank/util.rs similarity index 94% rename from crates/app/src/modules/bank/util.rs rename to basecoin/modules/src/bank/util.rs index 39b946d8..c266a460 100644 --- a/crates/app/src/modules/bank/util.rs +++ b/basecoin/modules/src/bank/util.rs @@ -1,12 +1,12 @@ -use crate::types::error::Error; - use basecoin_store::types::Path; -use ibc_proto::{cosmos::base::v1beta1::Coin as ProtoCoin, Protobuf}; - use cosmrs::{AccountId, Coin as MsgCoin}; +use ibc_proto::cosmos::base::v1beta1::Coin as ProtoCoin; +use ibc_proto::Protobuf; use primitive_types::U256; use serde::{Deserialize, Serialize}; +use crate::error::Error; + #[derive(Serialize, Deserialize, Debug, Default, PartialEq, Clone, Hash, Eq)] #[serde(transparent)] pub struct Denom(pub String); diff --git a/crates/app/src/modules/context.rs b/basecoin/modules/src/context.rs similarity index 98% rename from crates/app/src/modules/context.rs rename to basecoin/modules/src/context.rs index 5aa7d451..66d44695 100644 --- a/crates/app/src/modules/context.rs +++ b/basecoin/modules/src/context.rs @@ -1,13 +1,14 @@ +use std::any::Any as StdAny; + use basecoin_store::impls::SharedStore; use basecoin_store::types::{Height, Identifier as StoreIdentifier, Path}; use cosmrs::AccountId; use ibc_proto::google::protobuf::Any; -use std::any::Any as StdAny; use tendermint::abci::Event; use tendermint::block::Header; -use crate::types::error::Error; -use crate::types::query::QueryResult; +use crate::error::Error; +use crate::types::QueryResult; pub trait Module: Send + Sync + AsAny { /// The module's store type. @@ -89,9 +90,10 @@ pub trait Identifiable { } pub mod prefix { - use super::Identifiable; use basecoin_store::types::Identifier as StoreIdentifier; + use super::Identifiable; + /// Bank module prefix #[derive(Clone)] pub struct Bank; diff --git a/crates/app/src/types/error.rs b/basecoin/modules/src/error.rs similarity index 73% rename from crates/app/src/types/error.rs rename to basecoin/modules/src/error.rs index 9dd71eda..05176b87 100644 --- a/crates/app/src/types/error.rs +++ b/basecoin/modules/src/error.rs @@ -1,8 +1,9 @@ -use crate::modules::bank::Error as BankError; -use crate::modules::gov::Error as GovError; -use crate::modules::ibc::Error as IbcError; use displaydoc::Display; +use crate::bank::Error as BankError; +use crate::gov::Error as GovError; +use crate::ibc::Error as IbcError; + #[derive(Debug, Display)] pub enum Error { /// no module could handle specified message diff --git a/crates/app/src/modules/gov/error.rs b/basecoin/modules/src/gov/error.rs similarity index 83% rename from crates/app/src/modules/gov/error.rs rename to basecoin/modules/src/gov/error.rs index d5581805..dcab388e 100644 --- a/crates/app/src/modules/gov/error.rs +++ b/basecoin/modules/src/gov/error.rs @@ -1,6 +1,7 @@ -pub use crate::types::error::Error as AppError; pub use displaydoc::Display; +pub use crate::error::Error as AppError; + #[derive(Debug, Display)] pub enum Error { /// invalid proposal: `{reason}` diff --git a/crates/app/src/modules/gov/impls.rs b/basecoin/modules/src/gov/impls.rs similarity index 91% rename from crates/app/src/modules/gov/impls.rs rename to basecoin/modules/src/gov/impls.rs index e6d11cc5..b4409b40 100644 --- a/crates/app/src/modules/gov/impls.rs +++ b/basecoin/modules/src/gov/impls.rs @@ -1,31 +1,29 @@ -use super::path::ProposalPath; -use super::proposal::Proposal; -use super::service::GovernanceService; -use crate::modules::context::Module; -use crate::modules::gov::msg::MsgSubmitProposal; -use crate::modules::upgrade::Upgrade; -use crate::types::error::Error as AppError; -use crate::types::QueryResult; +use std::fmt::Debug; +use std::marker::PhantomData; +use std::ops::DerefMut; +use std::sync::{Arc, RwLock}; use basecoin_store::context::Store; use basecoin_store::impls::SharedStore; use basecoin_store::types::{Height, Path, ProtobufStore, TypedStore}; use basecoin_store::utils::{SharedRw, SharedRwExt}; - -use ibc::cosmos_host::upgrade_proposal::upgrade_client_proposal_handler; -use ibc::cosmos_host::upgrade_proposal::UpgradeProposal; +use cosmrs::AccountId; +use ibc::cosmos_host::upgrade_proposal::{upgrade_client_proposal_handler, UpgradeProposal}; use ibc_proto::cosmos::gov::v1beta1::query_server::QueryServer; use ibc_proto::google::protobuf::Any; use ibc_proto::Protobuf; - -use cosmrs::AccountId; -use std::fmt::Debug; -use std::marker::PhantomData; -use std::ops::DerefMut; -use std::sync::{Arc, RwLock}; use tendermint::abci::Event; use tracing::debug; +use super::path::ProposalPath; +use super::proposal::Proposal; +use super::service::GovernanceService; +use crate::context::Module; +pub use crate::error::Error as AppError; +use crate::gov::msg::MsgSubmitProposal; +use crate::types::QueryResult; +use crate::upgrade::Upgrade; + #[derive(Clone)] pub struct Governance where diff --git a/crates/app/src/modules/gov/mod.rs b/basecoin/modules/src/gov/mod.rs similarity index 100% rename from crates/app/src/modules/gov/mod.rs rename to basecoin/modules/src/gov/mod.rs diff --git a/crates/app/src/modules/gov/msg.rs b/basecoin/modules/src/gov/msg.rs similarity index 90% rename from crates/app/src/modules/gov/msg.rs rename to basecoin/modules/src/gov/msg.rs index dddf17fa..3d54e8b7 100644 --- a/crates/app/src/modules/gov/msg.rs +++ b/basecoin/modules/src/gov/msg.rs @@ -1,14 +1,11 @@ use displaydoc::Display; - -use ibc_proto::cosmos::gov::v1beta1::MsgSubmitProposal as RawMsgSubmitProposal; -use ibc_proto::cosmos::gov::v1beta1::ProposalStatus; +use ibc_proto::cosmos::gov::v1beta1::{MsgSubmitProposal as RawMsgSubmitProposal, ProposalStatus}; use ibc_proto::google::protobuf::Any; use ibc_proto::Protobuf; -use crate::modules::bank::Coin; -use crate::types::error::Error; - use super::proposal::Proposal; +use crate::bank::Coin; +use crate::error::Error; pub(crate) const TYPE_URL: &str = "/cosmos.gov.v1beta1.MsgSubmitProposal"; diff --git a/crates/app/src/modules/gov/path.rs b/basecoin/modules/src/gov/path.rs similarity index 100% rename from crates/app/src/modules/gov/path.rs rename to basecoin/modules/src/gov/path.rs diff --git a/crates/app/src/modules/gov/proposal.rs b/basecoin/modules/src/gov/proposal.rs similarity index 94% rename from crates/app/src/modules/gov/proposal.rs rename to basecoin/modules/src/gov/proposal.rs index 6587eff4..29015858 100644 --- a/crates/app/src/modules/gov/proposal.rs +++ b/basecoin/modules/src/gov/proposal.rs @@ -1,13 +1,11 @@ //! Definition of domain `Proposal`. -use ibc_proto::cosmos::gov::v1beta1::Proposal as RawProposal; -use ibc_proto::cosmos::gov::v1beta1::ProposalStatus; -use ibc_proto::cosmos::gov::v1beta1::TallyResult; +use ibc_proto::cosmos::gov::v1beta1::{Proposal as RawProposal, ProposalStatus, TallyResult}; use ibc_proto::google::protobuf::{Any, Timestamp}; use ibc_proto::Protobuf; use super::error::Error; -use crate::modules::bank::Coin; +use crate::bank::Coin; pub(crate) const TYPE_URL: &str = "/cosmos.gov.v1beta1.Proposal"; diff --git a/crates/app/src/modules/gov/service.rs b/basecoin/modules/src/gov/service.rs similarity index 64% rename from crates/app/src/modules/gov/service.rs rename to basecoin/modules/src/gov/service.rs index 6a3e79e2..88eb6d5d 100644 --- a/crates/app/src/modules/gov/service.rs +++ b/basecoin/modules/src/gov/service.rs @@ -1,24 +1,14 @@ -use basecoin_store::context::Store; +use std::marker::PhantomData; +use basecoin_store::context::Store; use ibc_proto::cosmos::gov::v1beta1::query_server::Query as GovernanceQuery; -use ibc_proto::cosmos::gov::v1beta1::QueryDepositRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryDepositResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryDepositsRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryDepositsResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryParamsRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryParamsResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryProposalRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryProposalResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryProposalsRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryProposalsResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryTallyResultRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryTallyResultResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryVoteRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryVoteResponse; -use ibc_proto::cosmos::gov::v1beta1::QueryVotesRequest; -use ibc_proto::cosmos::gov::v1beta1::QueryVotesResponse; - -use std::marker::PhantomData; +use ibc_proto::cosmos::gov::v1beta1::{ + QueryDepositRequest, QueryDepositResponse, QueryDepositsRequest, QueryDepositsResponse, + QueryParamsRequest, QueryParamsResponse, QueryProposalRequest, QueryProposalResponse, + QueryProposalsRequest, QueryProposalsResponse, QueryTallyResultRequest, + QueryTallyResultResponse, QueryVoteRequest, QueryVoteResponse, QueryVotesRequest, + QueryVotesResponse, +}; use tonic::{Request, Response, Status}; pub struct GovernanceService(pub PhantomData); diff --git a/crates/app/src/modules/ibc/client_contexts.rs b/basecoin/modules/src/ibc/client_contexts.rs similarity index 99% rename from crates/app/src/modules/ibc/client_contexts.rs rename to basecoin/modules/src/ibc/client_contexts.rs index 4d196e42..50c800b3 100644 --- a/crates/app/src/modules/ibc/client_contexts.rs +++ b/basecoin/modules/src/ibc/client_contexts.rs @@ -1,4 +1,5 @@ -use super::impls::{AnyConsensusState, IbcContext}; +use std::fmt::Debug; + use basecoin_store::context::Store; use basecoin_store::types::Height; use ibc::clients::tendermint::client_state::ClientState as TmClientState; @@ -13,7 +14,7 @@ use ibc::core::host::types::path::{ClientConsensusStatePath, ClientStatePath, Pa use ibc::core::host::ValidationContext; use ibc::primitives::Timestamp; -use std::fmt::Debug; +use super::impls::{AnyConsensusState, IbcContext}; impl ClientValidationContext for IbcContext where diff --git a/crates/app/src/modules/ibc/error.rs b/basecoin/modules/src/ibc/error.rs similarity index 79% rename from crates/app/src/modules/ibc/error.rs rename to basecoin/modules/src/ibc/error.rs index 38b34dc2..5b9d4d3b 100644 --- a/crates/app/src/modules/ibc/error.rs +++ b/basecoin/modules/src/ibc/error.rs @@ -1,6 +1,6 @@ use ibc::core::handler::types::error::ContextError; -pub use crate::types::error::Error as AppError; +pub use crate::error::Error as AppError; pub type Error = ContextError; diff --git a/crates/app/src/modules/ibc/impls.rs b/basecoin/modules/src/ibc/impls.rs similarity index 94% rename from crates/app/src/modules/ibc/impls.rs rename to basecoin/modules/src/ibc/impls.rs index 871e1124..1c476d4d 100644 --- a/crates/app/src/modules/ibc/impls.rs +++ b/basecoin/modules/src/ibc/impls.rs @@ -1,89 +1,72 @@ -use crate::CHAIN_REVISION_NUMBER; -use crate::{ - modules::{ - bank::BankBalanceKeeper, - context::{Identifiable, Module}, - ibc::{router::IbcRouter, transfer::IbcTransferModule}, - upgrade::Upgrade, - }, - types::{error::Error as AppError, QueryResult}, -}; -use basecoin_store::{ - context::{ProvableStore, Store}, - impls::SharedStore, - types::{BinStore, Height, JsonStore, Path, ProtobufStore, TypedSet, TypedStore}, +use std::collections::HashMap; +use std::convert::{TryFrom, TryInto}; +use std::fmt::Debug; +use std::ops::Deref; +use std::sync::{Arc, RwLock}; +use std::time::Duration; + +use basecoin_store::context::{ProvableStore, Store}; +use basecoin_store::impls::SharedStore; +use basecoin_store::types::{ + BinStore, Height, JsonStore, Path, ProtobufStore, TypedSet, TypedStore, }; use cosmrs::AccountId; use derive_more::{From, TryInto}; use ibc::apps::transfer::handler::send_transfer; +use ibc::apps::transfer::types::msgs::transfer::MsgTransfer; use ibc::clients::tendermint::client_state::ClientState as TmClientState; use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState; use ibc::clients::tendermint::types::ConsensusState as ConsensusStateType; +use ibc::core::channel::types::channel::{ChannelEnd, IdentifiedChannelEnd}; +use ibc::core::channel::types::commitment::{AcknowledgementCommitment, PacketCommitment}; +use ibc::core::channel::types::error::{ChannelError, PacketError}; +use ibc::core::channel::types::packet::{PacketState, Receipt}; use ibc::core::client::context::consensus_state::ConsensusState as _; +use ibc::core::client::types::error::ClientError; use ibc::core::client::types::Height as IbcHeight; use ibc::core::commitment_types::commitment::{CommitmentPrefix, CommitmentRoot}; +use ibc::core::connection::types::error::ConnectionError; +use ibc::core::connection::types::version::Version as ConnectionVersion; +use ibc::core::connection::types::{ConnectionEnd, IdentifiedConnectionEnd}; use ibc::core::entrypoint::dispatch; use ibc::core::handler::types::error::ContextError; use ibc::core::handler::types::events::IbcEvent; use ibc::core::handler::types::msgs::MsgEnvelope; -use ibc::core::host::types::identifiers::Sequence; +use ibc::core::host::types::identifiers::{ClientId, ConnectionId, Sequence}; +use ibc::core::host::types::path::{ + AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath, ClientStatePath, + CommitmentPath, ConnectionPath, Path as IbcPath, ReceiptPath, SeqAckPath, SeqRecvPath, + SeqSendPath, +}; use ibc::core::host::{ExecutionContext, ValidationContext}; use ibc::cosmos_host::IBC_QUERY_PATH; use ibc::derive::ConsensusState; use ibc::primitives::{Signer, Timestamp}; -use ibc::{ - apps::transfer::types::msgs::transfer::MsgTransfer, - core::{ - channel::types::{ - channel::{ChannelEnd, IdentifiedChannelEnd}, - commitment::{AcknowledgementCommitment, PacketCommitment}, - error::{ChannelError, PacketError}, - packet::{PacketState, Receipt}, - }, - client::types::error::ClientError, - connection::types::{ - error::ConnectionError, - version::Version as ConnectionVersion, - {ConnectionEnd, IdentifiedConnectionEnd}, - }, - host::types::{ - identifiers::{ClientId, ConnectionId}, - path::{ - AckPath, ChannelEndPath, ClientConnectionPath, ClientConsensusStatePath, - ClientStatePath, CommitmentPath, ConnectionPath, Path as IbcPath, ReceiptPath, - SeqAckPath, SeqRecvPath, SeqSendPath, - }, - }, - }, -}; -use ibc_proto::{ - google::protobuf::Any, - ibc::core::{ - channel::v1::{query_server::QueryServer as ChannelQueryServer, Channel as RawChannelEnd}, - client::v1::query_server::QueryServer as ClientQueryServer, - connection::v1::{ - query_server::QueryServer as ConnectionQueryServer, ConnectionEnd as RawConnectionEnd, - }, - }, -}; - +use ibc_proto::google::protobuf::Any; +use ibc_proto::ibc::core::channel::v1::query_server::QueryServer as ChannelQueryServer; +use ibc_proto::ibc::core::channel::v1::Channel as RawChannelEnd; +use ibc_proto::ibc::core::client::v1::query_server::QueryServer as ClientQueryServer; +use ibc_proto::ibc::core::connection::v1::query_server::QueryServer as ConnectionQueryServer; +use ibc_proto::ibc::core::connection::v1::ConnectionEnd as RawConnectionEnd; use ibc_query::core::channel::ChannelQueryService; use ibc_query::core::client::ClientQueryService; use ibc_query::core::connection::ConnectionQueryService; use ibc_query::core::context::{ProvableContext, QueryContext}; use prost::Message; -use std::{ - collections::HashMap, - convert::{TryFrom, TryInto}, - fmt::Debug, - ops::Deref, - sync::{Arc, RwLock}, - time::Duration, -}; +use tendermint::abci::Event; +use tendermint::block::Header; use tendermint::merkle::proof::ProofOp; -use tendermint::{abci::Event, block::Header}; use tracing::debug; +use crate::bank::BankBalanceKeeper; +use crate::context::{Identifiable, Module}; +use crate::error::Error as AppError; +use crate::ibc::router::IbcRouter; +use crate::ibc::transfer::IbcTransferModule; +use crate::types::QueryResult; +use crate::upgrade::Upgrade; +use crate::CHAIN_REVISION_NUMBER; + // Note: We define `AnyConsensusState` just to showcase the use of the // derive macro. Technically, we could just use `TmConsensusState` // as the `AnyConsensusState`, since we only support this one variant. @@ -466,7 +449,7 @@ where } fn commitment_prefix(&self) -> CommitmentPrefix { - use crate::modules::context::prefix::Ibc as IbcPrefix; + use crate::context::prefix::Ibc as IbcPrefix; CommitmentPrefix::try_from(IbcPrefix {}.identifier().as_bytes().to_vec()) .expect("empty prefix") } diff --git a/crates/app/src/modules/ibc/mod.rs b/basecoin/modules/src/ibc/mod.rs similarity index 100% rename from crates/app/src/modules/ibc/mod.rs rename to basecoin/modules/src/ibc/mod.rs diff --git a/crates/app/src/modules/ibc/router.rs b/basecoin/modules/src/ibc/router.rs similarity index 88% rename from crates/app/src/modules/ibc/router.rs rename to basecoin/modules/src/ibc/router.rs index ef1015fa..6a97bc53 100644 --- a/crates/app/src/modules/ibc/router.rs +++ b/basecoin/modules/src/ibc/router.rs @@ -1,14 +1,17 @@ -use crate::modules::bank::BankBalanceKeeper; -use crate::modules::ibc::transfer::IbcTransferModule; +use std::borrow::Borrow; +use std::collections::BTreeMap; +use std::fmt::Debug; use basecoin_store::context::Store; use ibc::apps::transfer::types::MODULE_ID_STR as IBC_TRANSFER_MODULE_ID; +use ibc::core::host::types::identifiers::PortId; use ibc::core::router::module::Module as IbcModule; use ibc::core::router::router::Router; use ibc::core::router::types::error::RouterError; -use ibc::core::{host::types::identifiers::PortId, router::types::module::ModuleId}; +use ibc::core::router::types::module::ModuleId; -use std::{borrow::Borrow, collections::BTreeMap, fmt::Debug}; +use crate::bank::BankBalanceKeeper; +use crate::ibc::transfer::IbcTransferModule; #[derive(Clone, Debug)] pub struct IbcRouter diff --git a/crates/app/src/modules/ibc/transfer.rs b/basecoin/modules/src/ibc/transfer.rs similarity index 96% rename from crates/app/src/modules/ibc/transfer.rs rename to basecoin/modules/src/ibc/transfer.rs index d60f6548..7fa3da72 100644 --- a/crates/app/src/modules/ibc/transfer.rs +++ b/basecoin/modules/src/ibc/transfer.rs @@ -1,9 +1,7 @@ -use crate::modules::auth::ACCOUNT_PREFIX; -use crate::modules::bank::BankKeeper; -use crate::modules::bank::{Coin, Denom}; +use core::fmt::Debug; -use ibc::apps::transfer::context::TokenTransferExecutionContext; -use ibc::apps::transfer::context::TokenTransferValidationContext; +use cosmrs::AccountId; +use ibc::apps::transfer::context::{TokenTransferExecutionContext, TokenTransferValidationContext}; use ibc::apps::transfer::module::{ on_acknowledgement_packet_validate, on_chan_open_ack_validate, on_chan_open_confirm_validate, on_chan_open_init_execute, on_chan_open_init_validate, on_chan_open_try_execute, @@ -14,21 +12,18 @@ use ibc::apps::transfer::types::error::TokenTransferError; use ibc::apps::transfer::types::{Memo, PrefixedCoin, VERSION}; use ibc::core::channel::types::acknowledgement::Acknowledgement; use ibc::core::channel::types::channel::{Counterparty, Order}; -use ibc::core::channel::types::error::ChannelError; -use ibc::core::channel::types::error::PacketError; +use ibc::core::channel::types::error::{ChannelError, PacketError}; use ibc::core::channel::types::packet::Packet; use ibc::core::channel::types::Version as ChannelVersion; use ibc::core::handler::types::events::IbcEvent; -use ibc::core::host::types::identifiers::ChannelId; -use ibc::core::host::types::identifiers::ConnectionId; -use ibc::core::host::types::identifiers::PortId; +use ibc::core::host::types::identifiers::{ChannelId, ConnectionId, PortId}; use ibc::core::router::module::Module as IbcModule; use ibc::core::router::types::module::ModuleExtras; use ibc::cosmos_host::utils::cosmos_adr028_escrow_address; use ibc::primitives::Signer; -use core::fmt::Debug; -use cosmrs::AccountId; +use crate::auth::ACCOUNT_PREFIX; +use crate::bank::{BankKeeper, Coin, Denom}; #[derive(Clone, Debug)] pub struct IbcTransferModule diff --git a/basecoin/modules/src/lib.rs b/basecoin/modules/src/lib.rs new file mode 100644 index 00000000..506a7572 --- /dev/null +++ b/basecoin/modules/src/lib.rs @@ -0,0 +1,20 @@ +#![forbid(unsafe_code)] +#![deny( + warnings, + trivial_numeric_casts, + unused_import_braces, + unused_qualifications, + rust_2018_idioms +)] + +pub mod auth; +pub mod bank; +pub mod context; +pub mod error; +pub mod gov; +pub mod ibc; +pub mod staking; +pub mod types; +pub mod upgrade; + +pub const CHAIN_REVISION_NUMBER: u64 = 0; diff --git a/crates/app/src/modules/staking/impls.rs b/basecoin/modules/src/staking/impls.rs similarity index 99% rename from crates/app/src/modules/staking/impls.rs rename to basecoin/modules/src/staking/impls.rs index 6c3fa845..509ecc33 100644 --- a/crates/app/src/modules/staking/impls.rs +++ b/basecoin/modules/src/staking/impls.rs @@ -1,9 +1,8 @@ use std::marker::PhantomData; -use ibc_proto::cosmos::staking::v1beta1::query_server::QueryServer; - use basecoin_store::context::ProvableStore; use basecoin_store::impls::SharedStore; +use ibc_proto::cosmos::staking::v1beta1::query_server::QueryServer; use super::service::StakingService; diff --git a/crates/app/src/modules/staking/mod.rs b/basecoin/modules/src/staking/mod.rs similarity index 100% rename from crates/app/src/modules/staking/mod.rs rename to basecoin/modules/src/staking/mod.rs diff --git a/crates/app/src/modules/staking/service.rs b/basecoin/modules/src/staking/service.rs similarity index 76% rename from crates/app/src/modules/staking/service.rs rename to basecoin/modules/src/staking/service.rs index c899da3e..43926de3 100644 --- a/crates/app/src/modules/staking/service.rs +++ b/basecoin/modules/src/staking/service.rs @@ -1,24 +1,21 @@ use std::marker::PhantomData; use basecoin_store::context::ProvableStore; -use ibc_proto::{ - cosmos::staking::v1beta1::{ - query_server::Query, Params, QueryDelegationRequest, QueryDelegationResponse, - QueryDelegatorDelegationsRequest, QueryDelegatorDelegationsResponse, - QueryDelegatorUnbondingDelegationsRequest, QueryDelegatorUnbondingDelegationsResponse, - QueryDelegatorValidatorRequest, QueryDelegatorValidatorResponse, - QueryDelegatorValidatorsRequest, QueryDelegatorValidatorsResponse, - QueryHistoricalInfoRequest, QueryHistoricalInfoResponse, QueryParamsRequest, - QueryParamsResponse, QueryPoolRequest, QueryPoolResponse, QueryRedelegationsRequest, - QueryRedelegationsResponse, QueryUnbondingDelegationRequest, - QueryUnbondingDelegationResponse, QueryValidatorDelegationsRequest, - QueryValidatorDelegationsResponse, QueryValidatorRequest, QueryValidatorResponse, - QueryValidatorUnbondingDelegationsRequest, QueryValidatorUnbondingDelegationsResponse, - QueryValidatorsRequest, QueryValidatorsResponse, - }, - google::protobuf::Duration, +use ibc_proto::cosmos::staking::v1beta1::query_server::Query; +use ibc_proto::cosmos::staking::v1beta1::{ + Params, QueryDelegationRequest, QueryDelegationResponse, QueryDelegatorDelegationsRequest, + QueryDelegatorDelegationsResponse, QueryDelegatorUnbondingDelegationsRequest, + QueryDelegatorUnbondingDelegationsResponse, QueryDelegatorValidatorRequest, + QueryDelegatorValidatorResponse, QueryDelegatorValidatorsRequest, + QueryDelegatorValidatorsResponse, QueryHistoricalInfoRequest, QueryHistoricalInfoResponse, + QueryParamsRequest, QueryParamsResponse, QueryPoolRequest, QueryPoolResponse, + QueryRedelegationsRequest, QueryRedelegationsResponse, QueryUnbondingDelegationRequest, + QueryUnbondingDelegationResponse, QueryValidatorDelegationsRequest, + QueryValidatorDelegationsResponse, QueryValidatorRequest, QueryValidatorResponse, + QueryValidatorUnbondingDelegationsRequest, QueryValidatorUnbondingDelegationsResponse, + QueryValidatorsRequest, QueryValidatorsResponse, }; - +use ibc_proto::google::protobuf::Duration; use tonic::{Request, Response, Status}; use tracing::debug; diff --git a/basecoin/modules/src/types.rs b/basecoin/modules/src/types.rs new file mode 100644 index 00000000..2306b1ef --- /dev/null +++ b/basecoin/modules/src/types.rs @@ -0,0 +1,18 @@ +use basecoin_store::impls::RevertibleStore; +use basecoin_store::types::Identifier; +use tendermint::merkle::proof::ProofOp; + +use crate::context::Module; + +pub type ModuleList = Vec>; +pub type ModuleStore = RevertibleStore; + +pub struct IdentifiedModule { + pub id: Identifier, + pub module: Box>>, +} + +pub struct QueryResult { + pub data: Vec, + pub proof: Option>, +} diff --git a/crates/app/src/modules/upgrade/impls.rs b/basecoin/modules/src/upgrade/impls.rs similarity index 95% rename from crates/app/src/modules/upgrade/impls.rs rename to basecoin/modules/src/upgrade/impls.rs index 943aede4..6679ff52 100644 --- a/crates/app/src/modules/upgrade/impls.rs +++ b/basecoin/modules/src/upgrade/impls.rs @@ -1,38 +1,33 @@ -use ibc::core::client::types::error::UpgradeClientError; -use ibc::core::commitment_types::commitment::CommitmentRoot; -use ibc::core::host::types::path::UpgradeClientPath; -use ibc::cosmos_host::SDK_UPGRADE_QUERY_PATH; -use prost::Message; use std::fmt::Debug; -use tracing::debug; use basecoin_store::context::{ProvableStore, Store}; use basecoin_store::impls::SharedStore; -use basecoin_store::types::{Height, Path}; -use basecoin_store::types::{ProtobufStore, TypedStore}; - +use basecoin_store::types::{Height, Path, ProtobufStore, TypedStore}; use cosmrs::AccountId; - -use ibc_proto::cosmos::upgrade::v1beta1::query_server::QueryServer; -use ibc_proto::google::protobuf::Any; - use ibc::clients::tendermint::client_state::ClientState as TmClientState; use ibc::clients::tendermint::consensus_state::ConsensusState as TmConsensusState; use ibc::clients::tendermint::types::ConsensusState as ConsensusStateType; -use ibc::cosmos_host::upgrade_proposal::UpgradeExecutionContext; -use ibc::cosmos_host::upgrade_proposal::UpgradeValidationContext; -use ibc::cosmos_host::upgrade_proposal::{Plan, UpgradeChain}; +use ibc::core::client::types::error::UpgradeClientError; +use ibc::core::commitment_types::commitment::CommitmentRoot; +use ibc::core::host::types::path::UpgradeClientPath; +use ibc::cosmos_host::upgrade_proposal::{ + Plan, UpgradeChain, UpgradeExecutionContext, UpgradeValidationContext, +}; +use ibc::cosmos_host::SDK_UPGRADE_QUERY_PATH; +use ibc_proto::cosmos::upgrade::v1beta1::query_server::QueryServer; +use ibc_proto::google::protobuf::Any; +use prost::Message; use tendermint::abci::Event; - use tendermint::merkle::proof::ProofOp; +use tracing::debug; use super::path::UpgradePlanPath; use super::query::UPGRADE_PLAN_QUERY_PATH; use super::service::UpgradeService; -use crate::modules::context::Module; -use crate::modules::ibc::{AnyConsensusState, IbcContext}; -use crate::types::error::Error as AppError; -use crate::types::query::QueryResult; +use crate::context::Module; +use crate::error::Error as AppError; +use crate::ibc::{AnyConsensusState, IbcContext}; +use crate::types::QueryResult; #[derive(Clone)] pub struct Upgrade diff --git a/crates/app/src/modules/upgrade/mod.rs b/basecoin/modules/src/upgrade/mod.rs similarity index 100% rename from crates/app/src/modules/upgrade/mod.rs rename to basecoin/modules/src/upgrade/mod.rs diff --git a/crates/app/src/modules/upgrade/path.rs b/basecoin/modules/src/upgrade/path.rs similarity index 100% rename from crates/app/src/modules/upgrade/path.rs rename to basecoin/modules/src/upgrade/path.rs diff --git a/crates/app/src/modules/upgrade/query.rs b/basecoin/modules/src/upgrade/query.rs similarity index 70% rename from crates/app/src/modules/upgrade/query.rs rename to basecoin/modules/src/upgrade/query.rs index 72447260..4b315b79 100644 --- a/crates/app/src/modules/upgrade/query.rs +++ b/basecoin/modules/src/upgrade/query.rs @@ -1,16 +1,15 @@ use ibc::cosmos_host::upgrade_proposal::Plan; use ibc_proto::cosmos::upgrade::v1beta1::Plan as RawPlan; use ibc_proto::Protobuf; -use tendermint_rpc::{Client, HttpClient}; +use tendermint_rpc::{Client, HttpClient, Url}; use super::path::UpgradePlanPath; -use crate::types::config::CometbftConfig; -use crate::types::error::Error; +use crate::error::Error; pub(crate) const UPGRADE_PLAN_QUERY_PATH: &str = "/cosmos.upgrade.v1beta1.Query/CurrentPlan"; -pub async fn query_upgrade_plan(cfg: CometbftConfig) -> Result { - let rpc_client = HttpClient::new(cfg.rpc_addr.clone()).unwrap(); +pub async fn query_upgrade_plan(rpc_addr: Url) -> Result { + let rpc_client = HttpClient::new(rpc_addr.clone()).unwrap(); let data = UpgradePlanPath::sdk_pending_path().to_string().into_bytes(); diff --git a/crates/app/src/modules/upgrade/service.rs b/basecoin/modules/src/upgrade/service.rs similarity index 76% rename from crates/app/src/modules/upgrade/service.rs rename to basecoin/modules/src/upgrade/service.rs index 39dfe29a..5c4a76ff 100644 --- a/crates/app/src/modules/upgrade/service.rs +++ b/basecoin/modules/src/upgrade/service.rs @@ -1,25 +1,16 @@ use basecoin_store::context::Store; use basecoin_store::impls::SharedStore; -use basecoin_store::types::Height; -use basecoin_store::types::ProtobufStore; -use basecoin_store::types::TypedStore; - +use basecoin_store::types::{Height, ProtobufStore, TypedStore}; use ibc::clients::tendermint::types::ConsensusState as TmConsensusState; use ibc::core::host::types::path::UpgradeClientPath; - use ibc_proto::cosmos::upgrade::v1beta1::query_server::Query as UpgradeQuery; -use ibc_proto::cosmos::upgrade::v1beta1::QueryAppliedPlanRequest; -use ibc_proto::cosmos::upgrade::v1beta1::QueryAppliedPlanResponse; -use ibc_proto::cosmos::upgrade::v1beta1::QueryAuthorityRequest; -use ibc_proto::cosmos::upgrade::v1beta1::QueryAuthorityResponse; -use ibc_proto::cosmos::upgrade::v1beta1::QueryCurrentPlanRequest; -use ibc_proto::cosmos::upgrade::v1beta1::QueryCurrentPlanResponse; -use ibc_proto::cosmos::upgrade::v1beta1::QueryModuleVersionsRequest; -use ibc_proto::cosmos::upgrade::v1beta1::QueryModuleVersionsResponse; -use ibc_proto::cosmos::upgrade::v1beta1::QueryUpgradedConsensusStateRequest; -use ibc_proto::cosmos::upgrade::v1beta1::QueryUpgradedConsensusStateResponse; +use ibc_proto::cosmos::upgrade::v1beta1::{ + QueryAppliedPlanRequest, QueryAppliedPlanResponse, QueryAuthorityRequest, + QueryAuthorityResponse, QueryCurrentPlanRequest, QueryCurrentPlanResponse, + QueryModuleVersionsRequest, QueryModuleVersionsResponse, QueryUpgradedConsensusStateRequest, + QueryUpgradedConsensusStateResponse, +}; use ibc_proto::google::protobuf::Any; - use prost::Message; use tonic::{Request, Response, Status}; diff --git a/crates/app/src/bin/basecoin/main.rs b/basecoin/src/bin/basecoin.rs similarity index 75% rename from crates/app/src/bin/basecoin/main.rs rename to basecoin/src/bin/basecoin.rs index 22aae077..10a44efb 100644 --- a/crates/app/src/bin/basecoin/main.rs +++ b/basecoin/src/bin/basecoin.rs @@ -3,13 +3,12 @@ #![deny(warnings, missing_docs, trivial_casts, unused_qualifications)] #![forbid(unsafe_code)] -use basecoin_app::{ - cli::command::{BasecoinCli, Commands, QueryCmd, UpgradeCmd}, - default_app_runner, - modules::upgrade::query_upgrade_plan, - types::config::load_config, -}; +use std::io::Write; +use basecoin::cli::command::{BasecoinCli, Commands, QueryCmd, UpgradeCmd}; +use basecoin::config::load_config; +use basecoin::default_app_runner; +use basecoin_modules::upgrade::query_upgrade_plan; use clap::Parser; use tracing::metadata::LevelFilter; @@ -36,10 +35,10 @@ async fn main() { Commands::Query(q) => { let query_res = match q { QueryCmd::Upgrade(u) => match u { - UpgradeCmd::Plan => query_upgrade_plan(cfg.cometbft).await.unwrap(), + UpgradeCmd::Plan => query_upgrade_plan(cfg.cometbft.rpc_addr).await.unwrap(), }, }; - println!("{:?}", query_res); + let _ = write!(std::io::stdout(), "{:#?}", query_res); } }; } diff --git a/crates/app/src/cli/command.rs b/basecoin/src/cli/command.rs similarity index 100% rename from crates/app/src/cli/command.rs rename to basecoin/src/cli/command.rs diff --git a/crates/app/src/cli/mod.rs b/basecoin/src/cli/mod.rs similarity index 100% rename from crates/app/src/cli/mod.rs rename to basecoin/src/cli/mod.rs diff --git a/crates/app/src/types/config.rs b/basecoin/src/config.rs similarity index 97% rename from crates/app/src/types/config.rs rename to basecoin/src/config.rs index a8d499a9..ab5e8357 100644 --- a/crates/app/src/types/config.rs +++ b/basecoin/src/config.rs @@ -1,6 +1,7 @@ -use super::error::Error; -use serde_derive::{Deserialize, Serialize}; pub use std::path::Path; + +use basecoin_modules::error::Error; +use serde_derive::{Deserialize, Serialize}; use tendermint_rpc::Url; use tracing_subscriber::filter::LevelFilter; diff --git a/basecoin/src/helper.rs b/basecoin/src/helper.rs new file mode 100644 index 00000000..0698a656 --- /dev/null +++ b/basecoin/src/helper.rs @@ -0,0 +1,58 @@ +use std::fmt::Debug; + +use basecoin_app::BaseCoinApp; +use basecoin_modules::auth::{AuthAccountKeeper, AuthAccountReader}; +use basecoin_modules::bank::Bank; +use basecoin_modules::context::{prefix, Identifiable}; +use basecoin_modules::ibc::Ibc; +use basecoin_store::context::ProvableStore; +use basecoin_store::impls::RevertibleStore; +use basecoin_store::utils::SharedRwExt; + +/// Gives access to the IBC module. +pub fn ibc(app: BaseCoinApp) -> Ibc> +where + S: ProvableStore + Default + Debug, +{ + let modules = app.modules.read_access(); + + modules + .iter() + .find(|m| m.id == prefix::Ibc {}.identifier()) + .and_then(|m| { + m.module + .as_any() + .downcast_ref::>>() + .cloned() + }) + .expect("IBC module not found") +} + +/// Gives access to the Bank module. +pub fn bank( + app: BaseCoinApp, +) -> Bank< + RevertibleStore, + AuthAccountReader>, + AuthAccountKeeper>, +> +where + S: ProvableStore + Default + Debug, +{ + let modules = app.modules.read_access(); + + modules + .iter() + .find(|m| m.id == prefix::Bank {}.identifier()) + .and_then(|m| { + m.module + .as_any() + .downcast_ref::, + AuthAccountReader>, + AuthAccountKeeper>, + >>() + .cloned() + }) + .expect("Bank module not found") +} diff --git a/basecoin/src/lib.rs b/basecoin/src/lib.rs new file mode 100644 index 00000000..a8ab9134 --- /dev/null +++ b/basecoin/src/lib.rs @@ -0,0 +1,30 @@ +#![forbid(unsafe_code)] +#![deny( + warnings, + trivial_numeric_casts, + unused_import_braces, + unused_qualifications, + rust_2018_idioms +)] + +pub mod cli; +pub mod config; +pub mod helper; +mod runner; + +pub use runner::default_app_runner; + +/// Re-exports Basecoin's store types and implementations. +pub mod store { + pub use basecoin_store::*; +} + +/// Re-exports Basecoin's modules types and implementations. +pub mod modules { + pub use basecoin_modules::*; +} + +/// Re-exports Basecoin's ABCI application types and implementations. +pub mod app { + pub use basecoin_app::*; +} diff --git a/crates/app/src/runner.rs b/basecoin/src/runner.rs similarity index 92% rename from crates/app/src/runner.rs rename to basecoin/src/runner.rs index 84cc5fa6..54454130 100644 --- a/crates/app/src/runner.rs +++ b/basecoin/src/runner.rs @@ -1,24 +1,21 @@ +use basecoin_app::Builder; +use basecoin_modules::auth::Auth; +use basecoin_modules::bank::Bank; +use basecoin_modules::context::{prefix, Identifiable}; +use basecoin_modules::gov::Governance; +use basecoin_modules::ibc::Ibc; +use basecoin_modules::staking::Staking; +use basecoin_modules::upgrade::Upgrade; use basecoin_store::impls::{GrowingStore, InMemoryStore}; use ibc_proto::cosmos::base::tendermint::v1beta1::service_server::ServiceServer as HealthServer; use ibc_proto::cosmos::tx::v1beta1::service_server::ServiceServer as TxServer; - -use crate::builder::Builder; -use crate::modules::auth::Auth; -use crate::modules::bank::Bank; -use crate::modules::context::prefix; -use crate::modules::context::Identifiable; -use crate::modules::gov::Governance; -use crate::modules::ibc::Ibc; -use crate::modules::staking::Staking; -use crate::modules::upgrade::Upgrade; -use crate::types::config::ServerConfig; - #[cfg(all(feature = "v0_38", not(feature = "v0_37")))] use tendermint_abci::ServerBuilder; - #[cfg(all(feature = "v0_37", not(feature = "v0_38")))] use tower_abci::v037::split; +use crate::config::ServerConfig; + pub async fn default_app_runner(server_cfg: ServerConfig) { // instantiate the application with a KV store implementation of choice let app_builder = Builder::new(GrowingStore::::default()); @@ -60,8 +57,6 @@ pub async fn default_app_runner(server_cfg: ServerConfig) { .add_module(prefix::Upgrade {}.identifier(), upgrade.clone()) .build(); - let _ibc = app.ibc(); - #[cfg(all(feature = "v0_38", not(feature = "v0_37")))] { tracing::info!("Starting Tendermint ABCI server"); diff --git a/crates/store/Cargo.toml b/basecoin/store/Cargo.toml similarity index 63% rename from crates/store/Cargo.toml rename to basecoin/store/Cargo.toml index 11d65ab0..7bab0e5c 100644 --- a/crates/store/Cargo.toml +++ b/basecoin/store/Cargo.toml @@ -1,12 +1,11 @@ [package] name = "basecoin-store" -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" -readme = "README.md" -categories = ["cryptography::cryptocurrencies", "iavl"] -repository = "https://github.com/informalsystems/basecoin-rs" -authors = ["Informal Systems "] +version = { workspace = true } +edition = { workspace = true } +license = { workspace = true } +readme = { workspace = true } +repository = { workspace = true } +authors = { workspace = true } description = """ A simple implementation of an AVL store tailored for the basecoin application. """ diff --git a/crates/store/src/avl/as_bytes.rs b/basecoin/store/src/avl/as_bytes.rs similarity index 100% rename from crates/store/src/avl/as_bytes.rs rename to basecoin/store/src/avl/as_bytes.rs diff --git a/crates/store/src/avl/mod.rs b/basecoin/store/src/avl/mod.rs similarity index 100% rename from crates/store/src/avl/mod.rs rename to basecoin/store/src/avl/mod.rs diff --git a/crates/store/src/avl/node.rs b/basecoin/store/src/avl/node.rs similarity index 97% rename from crates/store/src/avl/node.rs rename to basecoin/store/src/avl/node.rs index ab2e9e71..776dc0f8 100644 --- a/crates/store/src/avl/node.rs +++ b/basecoin/store/src/avl/node.rs @@ -1,9 +1,11 @@ -use std::{borrow::Borrow, mem}; +use std::borrow::Borrow; +use std::mem; use sha2::{Digest, Sha256}; use tendermint::hash::Hash; -use crate::avl::{as_bytes::AsBytes, proof, HASH_ALGO}; +use crate::avl::as_bytes::AsBytes; +use crate::avl::{proof, HASH_ALGO}; pub type NodeRef = Option>>; diff --git a/crates/store/src/avl/proof.rs b/basecoin/store/src/avl/proof.rs similarity index 100% rename from crates/store/src/avl/proof.rs rename to basecoin/store/src/avl/proof.rs diff --git a/crates/store/src/avl/tests.rs b/basecoin/store/src/avl/tests.rs similarity index 97% rename from crates/store/src/avl/tests.rs rename to basecoin/store/src/avl/tests.rs index 2d23ff88..9b229a2d 100644 --- a/crates/store/src/avl/tests.rs +++ b/basecoin/store/src/avl/tests.rs @@ -1,13 +1,12 @@ //! # Test suite of tendermock AVL Tree. -use ics23::{commitment_proof::Proof, verify_membership, HostFunctionsManager}; +use ics23::commitment_proof::Proof; +use ics23::{verify_membership, HostFunctionsManager}; use sha2::{Digest, Sha256}; -use crate::avl::{ - node::{as_node_ref, NodeRef}, - tree::AvlTree, - *, -}; +use crate::avl::node::{as_node_ref, NodeRef}; +use crate::avl::tree::AvlTree; +use crate::avl::*; #[test] fn insert() { diff --git a/crates/store/src/avl/tree.rs b/basecoin/store/src/avl/tree.rs similarity index 95% rename from crates/store/src/avl/tree.rs rename to basecoin/store/src/avl/tree.rs index ff2eb5b4..a260f0d8 100644 --- a/crates/store/src/avl/tree.rs +++ b/basecoin/store/src/avl/tree.rs @@ -1,22 +1,15 @@ -use core::{ - borrow::Borrow, - cmp::{Ord, Ordering}, - marker::Sized, - option::{ - Option, - Option::{None, Some}, - }, -}; - -use ics23::{ - commitment_proof::Proof, CommitmentProof, ExistenceProof, HashOp, InnerOp, LeafOp, LengthOp, -}; +use core::borrow::Borrow; +use core::cmp::{Ord, Ordering}; +use core::marker::Sized; +use core::option::Option; +use core::option::Option::{None, Some}; + +use ics23::commitment_proof::Proof; +use ics23::{CommitmentProof, ExistenceProof, HashOp, InnerOp, LeafOp, LengthOp}; use tendermint::hash::Hash; -use crate::avl::{ - node::{as_node_ref, NodeRef}, - proof, AsBytes, -}; +use crate::avl::node::{as_node_ref, NodeRef}; +use crate::avl::{proof, AsBytes}; /// An AVL Tree that supports `get` and `insert` operation and can be used to prove existence of a /// given key-value couple. diff --git a/crates/store/src/context.rs b/basecoin/store/src/context.rs similarity index 99% rename from crates/store/src/context.rs rename to basecoin/store/src/context.rs index 351e7545..aa70144a 100644 --- a/crates/store/src/context.rs +++ b/basecoin/store/src/context.rs @@ -1,8 +1,9 @@ -use crate::types::{Height, Path, RawHeight}; -use crate::utils::Async; +use std::fmt::Debug; use ics23::CommitmentProof; -use std::fmt::Debug; + +use crate::types::{Height, Path, RawHeight}; +use crate::utils::Async; /// Store trait - maybe provableStore or privateStore pub trait Store: Async + Clone { diff --git a/crates/store/src/impls/growing.rs b/basecoin/store/src/impls/growing.rs similarity index 96% rename from crates/store/src/impls/growing.rs rename to basecoin/store/src/impls/growing.rs index 952be0b4..0c98340e 100644 --- a/crates/store/src/impls/growing.rs +++ b/basecoin/store/src/impls/growing.rs @@ -1,10 +1,8 @@ -use crate::context::ProvableStore; -use crate::context::Store; -use crate::types::Height; -use crate::types::Path; - use ics23::CommitmentProof; +use crate::context::{ProvableStore, Store}; +use crate::types::{Height, Path}; + /// GrowingStore does not prune any path. /// If the path is set to v, the stored value is v /// If the path is deleted, the stored value is [] diff --git a/crates/store/src/impls/in_memory.rs b/basecoin/store/src/impls/in_memory.rs similarity index 98% rename from crates/store/src/impls/in_memory.rs rename to basecoin/store/src/impls/in_memory.rs index f1e34c83..2602762b 100644 --- a/crates/store/src/impls/in_memory.rs +++ b/basecoin/store/src/impls/in_memory.rs @@ -1,11 +1,12 @@ +use ics23::CommitmentProof; +use tendermint::hash::Algorithm; +use tendermint::Hash; +use tracing::trace; + use crate::avl::{AsBytes, AvlTree}; use crate::context::{ProvableStore, Store}; use crate::types::{Height, Path, State}; -use ics23::CommitmentProof; -use tendermint::{hash::Algorithm, Hash}; -use tracing::trace; - /// An in-memory store backed by an AvlTree. #[derive(Clone, Debug)] pub struct InMemoryStore { diff --git a/crates/store/src/impls/mod.rs b/basecoin/store/src/impls/mod.rs similarity index 100% rename from crates/store/src/impls/mod.rs rename to basecoin/store/src/impls/mod.rs diff --git a/crates/store/src/impls/revertible.rs b/basecoin/store/src/impls/revertible.rs similarity index 96% rename from crates/store/src/impls/revertible.rs rename to basecoin/store/src/impls/revertible.rs index 34aec72b..0b5ea7a3 100644 --- a/crates/store/src/impls/revertible.rs +++ b/basecoin/store/src/impls/revertible.rs @@ -1,11 +1,9 @@ -use crate::context::ProvableStore; -use crate::context::Store; -use crate::types::Height; -use crate::types::Path; - use ics23::CommitmentProof; use tracing::trace; +use crate::context::{ProvableStore, Store}; +use crate::types::{Height, Path}; + /// A wrapper store that implements rudimentary `apply()`/`reset()` support for other stores #[derive(Clone, Debug)] pub struct RevertibleStore { diff --git a/crates/store/src/impls/shared.rs b/basecoin/store/src/impls/shared.rs similarity index 99% rename from crates/store/src/impls/shared.rs rename to basecoin/store/src/impls/shared.rs index 110f0a03..c5eb95ed 100644 --- a/crates/store/src/impls/shared.rs +++ b/basecoin/store/src/impls/shared.rs @@ -1,11 +1,12 @@ +use std::ops::{Deref, DerefMut}; +use std::sync::{Arc, RwLock}; + +use ics23::CommitmentProof; + use crate::context::{ProvableStore, Store}; use crate::types::{Height, Path, RawHeight}; use crate::utils::{SharedRw, SharedRwExt}; -use ics23::CommitmentProof; -use std::ops::{Deref, DerefMut}; -use std::sync::{Arc, RwLock}; - /// Wraps a store to make it shareable by cloning #[derive(Clone, Debug)] pub struct SharedStore(SharedRw); diff --git a/crates/store/src/lib.rs b/basecoin/store/src/lib.rs similarity index 100% rename from crates/store/src/lib.rs rename to basecoin/store/src/lib.rs diff --git a/crates/store/src/types/height.rs b/basecoin/store/src/types/height.rs similarity index 100% rename from crates/store/src/types/height.rs rename to basecoin/store/src/types/height.rs diff --git a/crates/store/src/types/identifier.rs b/basecoin/store/src/types/identifier.rs similarity index 88% rename from crates/store/src/types/identifier.rs rename to basecoin/store/src/types/identifier.rs index 50f011b4..d53d0e18 100644 --- a/crates/store/src/types/identifier.rs +++ b/basecoin/store/src/types/identifier.rs @@ -1,7 +1,5 @@ -use std::{ - fmt::{Debug, Display, Formatter}, - ops::Deref, -}; +use std::fmt::{Debug, Display, Formatter}; +use std::ops::Deref; /// A new type representing a valid ICS024 identifier. /// Implements `Deref`. diff --git a/crates/store/src/types/mod.rs b/basecoin/store/src/types/mod.rs similarity index 100% rename from crates/store/src/types/mod.rs rename to basecoin/store/src/types/mod.rs diff --git a/crates/store/src/types/path.rs b/basecoin/store/src/types/path.rs similarity index 99% rename from crates/store/src/types/path.rs rename to basecoin/store/src/types/path.rs index 8c73e225..a74803e6 100644 --- a/crates/store/src/types/path.rs +++ b/basecoin/store/src/types/path.rs @@ -1,9 +1,11 @@ -use super::Identifier; -use crate::avl::{AsBytes, ByteSlice}; -use displaydoc::Display as DisplayDoc; use std::fmt::{Display, Formatter}; use std::str::{from_utf8, FromStr, Utf8Error}; +use displaydoc::Display as DisplayDoc; + +use super::Identifier; +use crate::avl::{AsBytes, ByteSlice}; + #[derive(Debug, DisplayDoc)] pub enum Error { /// path isn't a valid string: `{error}` diff --git a/crates/store/src/types/store.rs b/basecoin/store/src/types/store.rs similarity index 98% rename from crates/store/src/types/store.rs rename to basecoin/store/src/types/store.rs index 79635c7c..37e4c80e 100644 --- a/crates/store/src/types/store.rs +++ b/basecoin/store/src/types/store.rs @@ -1,10 +1,12 @@ +use std::fmt::Debug; +use std::marker::PhantomData; + use crate::avl::AvlTree; use crate::context::Store; use crate::impls::{RevertibleStore, SharedStore}; use crate::types::{Height, Path, RawHeight}; use crate::utils::codec::{BinCodec, JsonCodec, NullCodec, ProtobufCodec}; use crate::utils::Codec; -use std::{fmt::Debug, marker::PhantomData}; // A state type that represents a snapshot of the store at every block. // The value is a `Vec` to allow stored types to choose their own serde. diff --git a/crates/store/src/utils/codec.rs b/basecoin/store/src/utils/codec.rs similarity index 97% rename from crates/store/src/utils/codec.rs rename to basecoin/store/src/utils/codec.rs index 38626319..35f84a4f 100644 --- a/crates/store/src/utils/codec.rs +++ b/basecoin/store/src/utils/codec.rs @@ -1,6 +1,8 @@ -use serde::{de::DeserializeOwned, Serialize}; use std::marker::PhantomData; +use serde::de::DeserializeOwned; +use serde::Serialize; + /// A trait that defines how types are decoded/encoded. pub trait Codec { type Value; diff --git a/crates/store/src/utils/mod.rs b/basecoin/store/src/utils/mod.rs similarity index 100% rename from crates/store/src/utils/mod.rs rename to basecoin/store/src/utils/mod.rs diff --git a/crates/store/src/utils/sync.rs b/basecoin/store/src/utils/sync.rs similarity index 100% rename from crates/store/src/utils/sync.rs rename to basecoin/store/src/utils/sync.rs diff --git a/ci/Dockerfile b/ci/Dockerfile index 210c48ab..b369848f 100644 --- a/ci/Dockerfile +++ b/ci/Dockerfile @@ -1,6 +1,6 @@ ARG COMETBFT_VERSION=0.37.1 -ARG GAIA_VERSION=6.0.0 -ARG HERMES_VERSION=1.7.0 +ARG GAIA_VERSION=7.1.1 +ARG HERMES_VERSION=1.8.0 ARG RUST_VERSION=1.65 FROM cometbft/cometbft:v${COMETBFT_VERSION} AS cometbft diff --git a/ci/hermes-config.toml b/ci/hermes-config.toml index efcd6211..81fb77df 100644 --- a/ci/hermes-config.toml +++ b/ci/hermes-config.toml @@ -1,37 +1,48 @@ [global] -log_level = 'trace' +log_level = 'debug' [[chains]] id = 'ibc-0' rpc_addr = 'http://127.0.0.1:26657' grpc_addr = 'http://127.0.0.1:9090' -websocket_addr = 'ws://localhost:26657/websocket' +event_source = { mode = 'push', url = 'ws://127.0.0.1:26557/websocket', batch_delay = '500ms' } rpc_timeout = '10s' +trusted_node = false account_prefix = 'cosmos' key_name = 'testkey' store_prefix = 'ibc' +default_gas = 100000 +max_gas = 4000000 gas_price = { price = 0.001, denom = 'stake' } +gas_multiplier = 1.1 +max_msg_num = 30 +max_tx_size = 2097152 clock_drift = '5s' # `trusting_period` default value is '14days', but for the purpose of testing -# the consensus state pruning mechanism of Tendermint client it is set to '3m' +# the consensus state pruning mechanism of Tendermint client, it is set to '3m' trusting_period = '3m' - -[chains.trust_threshold] -numerator = '1' -denominator = '3' +trust_threshold = '2/3' +address_type = { derivation = 'cosmos' } [[chains]] id = 'basecoin-0' rpc_addr = 'http://127.0.0.1:26357' grpc_addr = 'http://127.0.0.1:9093' -websocket_addr = 'ws://localhost:26357/websocket' +event_source = { mode = 'push', url = 'ws://127.0.0.1:26357/websocket', batch_delay = '500ms' } rpc_timeout = '10s' +trusted_node = false account_prefix = 'cosmos' key_name = 'testkey' store_prefix = 'ibc' +default_gas = 100000 +max_gas = 4000000 gas_price = { price = 0.001, denom = 'basecoin' } +gas_multiplier = 1.1 +max_msg_num = 30 +max_tx_size = 2097152 clock_drift = '5s' trusting_period = '3m' +address_type = { derivation = 'cosmos' } proof_specs = ''' [ { @@ -74,8 +85,6 @@ proof_specs = ''' } ] ''' +trust_threshold = '2/3' -[chains.trust_threshold] -numerator = '1' -denominator = '3' diff --git a/crates/app/Cargo.toml b/crates/app/Cargo.toml deleted file mode 100644 index f77ade30..00000000 --- a/crates/app/Cargo.toml +++ /dev/null @@ -1,57 +0,0 @@ -[package] -name = "basecoin-app" -version = "0.1.0" -edition = "2021" -license = "Apache-2.0" -readme = "README.md" -categories = ["cryptography::cryptocurrencies"] -repository = "https://github.com/informalsystems/basecoin-rs" -authors = ["Informal Systems "] -description = """ - An example Tendermint ABCI application that integrates with ibc-rs, making - use of tendermint-rs. -""" - -default-run = "basecoin" - - -[features] -default = ["v0_37"] - -# Makes the application compatible with CometBFT v0.37 -v0_37 = ["dep:tower-abci", "dep:tower"] - -# Makes the application compatible with CometBFT v0.38 -# (WIP) methods are not yet implemented -v0_38 = ["dep:tendermint-abci"] - -[dependencies] -basecoin-store = { path = "../store" } -base64 = { workspace = true } -clap = { version = "4.3.0", features = ["derive", "wrap_help"] } -cosmrs = "0.15.0" -displaydoc = { workspace = true } -derive_more = { workspace = true } -ibc = { workspace = true } -ibc-proto = { workspace = true, features = ["server", "proto-descriptor", "serde"] } -ibc-query = { workspace = true } -ics23 = { workspace = true, features = ["host-functions"] } -primitive-types = { version = "0.12.0", default-features = false, features = ["serde_no_std"] } -prost = { workspace = true } -serde = { workspace = true } -serde_derive = { version = "1.0.104", default-features = false } -serde_json = { workspace = true } -sha2 = { workspace = true } -tendermint = { workspace = true } -tendermint-abci = { workspace = true, optional = true } -tendermint-proto ={ workspace = true } -tendermint-rpc = { workspace = true , features = ["http-client"] } -toml = "0.8" -tokio = { version = "1.0", features = ["macros", "rt-multi-thread"] } -tonic = "0.10" -tonic-reflection = "0.10" -tracing = { workspace = true } -tracing-subscriber = "0.3.16" -tower-abci = { version = "0.11", optional = true } -tower = { version = "0.4", features = ["full"], optional = true } - diff --git a/crates/app/src/modules/mod.rs b/crates/app/src/modules/mod.rs deleted file mode 100644 index 61ff7b3c..00000000 --- a/crates/app/src/modules/mod.rs +++ /dev/null @@ -1,8 +0,0 @@ -pub mod auth; -pub mod bank; -pub mod context; -pub mod gov; -pub mod ibc; -pub mod staking; -pub mod types; -pub mod upgrade; diff --git a/crates/app/src/modules/types.rs b/crates/app/src/modules/types.rs deleted file mode 100644 index f61ce8ac..00000000 --- a/crates/app/src/modules/types.rs +++ /dev/null @@ -1,11 +0,0 @@ -use crate::modules::context::Module; -use basecoin_store::impls::RevertibleStore; -use basecoin_store::types::Identifier; - -pub(crate) type ModuleList = Vec>; -pub(crate) type ModuleStore = RevertibleStore; - -pub struct IdentifiedModule { - pub id: Identifier, - pub module: Box>>, -} diff --git a/crates/app/src/types/mod.rs b/crates/app/src/types/mod.rs deleted file mode 100644 index e9fd2577..00000000 --- a/crates/app/src/types/mod.rs +++ /dev/null @@ -1,5 +0,0 @@ -pub mod config; -pub mod error; -pub mod query; - -pub use query::QueryResult; diff --git a/crates/app/src/types/query.rs b/crates/app/src/types/query.rs deleted file mode 100644 index 5bc61300..00000000 --- a/crates/app/src/types/query.rs +++ /dev/null @@ -1,6 +0,0 @@ -use tendermint::merkle::proof::ProofOp; - -pub struct QueryResult { - pub data: Vec, - pub proof: Option>, -} diff --git a/crates/app/src/utils/mod.rs b/crates/app/src/utils/mod.rs deleted file mode 100644 index 24c0ad7b..00000000 --- a/crates/app/src/utils/mod.rs +++ /dev/null @@ -1 +0,0 @@ -pub(crate) mod macros; diff --git a/rustfmt.toml b/rustfmt.toml new file mode 100644 index 00000000..e9e7427c --- /dev/null +++ b/rustfmt.toml @@ -0,0 +1,5 @@ +reorder_imports = true + +# unstable features +group_imports = "StdExternalCrate" +imports_granularity = "Module"