Skip to content
This repository has been archived by the owner on Nov 20, 2024. It is now read-only.

feat: Implement pallet-cosmwasm for runtime #34

Merged
merged 55 commits into from
Sep 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
55 commits
Select commit Hold shift + click to select a range
d59cffc
feat: Add pallet-cosmwasm to runtime
code0xff Aug 28, 2024
40036d6
refactor: directly depend on String from alloc
code0xff Aug 28, 2024
f0f30df
refactor: Remove sp-std dependencies
code0xff Aug 28, 2024
fd44945
feat: Implement MsgStoreCodeHandler
code0xff Aug 28, 2024
6686799
fix: Fix query all balances bug
code0xff Aug 28, 2024
784016e
feat: Add code_hash and code_id tuple return to do_upload
code0xff Aug 28, 2024
191d454
feat: Add decode wasm_byte_code by libflate
code0xff Aug 28, 2024
c2a7637
fix: Fix store code events
code0xff Aug 29, 2024
6fdc071
chore: Add todo to MsgStoreCode handler
code0xff Aug 29, 2024
706b406
feat: Implement MsgInstantiateContract2 handler
code0xff Aug 29, 2024
1f0d972
feat: Add Context
code0xff Aug 30, 2024
fc1213d
chore: Add todo to consume_gas
code0xff Aug 30, 2024
c57f094
chore: Add todo to MsgInstantiateContract2 handle
code0xff Aug 30, 2024
36db10e
feat: Implement MsgExecuteContractHandler
code0xff Aug 30, 2024
9540a43
fix: Add emit events to MsgExecuteContractHandler handle
code0xff Aug 30, 2024
413bfe2
refactor: Refactor address_from_bech32
code0xff Aug 30, 2024
b1e27ba
refactor: Add from_bech32 to AddressMapping
code0xff Aug 30, 2024
e7b7864
feat: Implement MsgMigrateContractHandler
code0xff Aug 30, 2024
7a66966
feat: Implement MsgUpdateAdminHandler
code0xff Aug 30, 2024
24f0d1f
fix: Fix conversion to contract account in wasm message handlers
code0xff Aug 31, 2024
cd034ff
fix: Convert admin account with pallet_cosmwasm::AccountToAddr
code0xff Sep 1, 2024
edfb0b6
feat: Add cosmwasm rpc and runtime-api packages
code0xff Sep 1, 2024
36bc6a1
refactor: Rename cosm to cosmos
code0xff Sep 1, 2024
1b6992d
feat: Implement cosmwasm qeury
code0xff Sep 1, 2024
471c762
fix: Fix implement AccountToAddr
code0xff Sep 2, 2024
7344af7
refactor: Refactor acc_address_from_bech32
code0xff Sep 2, 2024
7763864
refactor: Refactor convert weight to gas
code0xff Sep 2, 2024
226f884
docs: Fix annotations in pallet_cosmos
code0xff Sep 2, 2024
b170231
test: Add mock runtime to pallet-cosmos
code0xff Sep 2, 2024
ca0bb80
refactor: Refactor MsgFilter
code0xff Sep 2, 2024
0ba2c49
refactor: Relocate SignModeHandler and SigVerifiableTx implementation…
code0xff Sep 2, 2024
dc82918
test: Add any_match test
code0xff Sep 3, 2024
f4cb096
test: Add balances genesis state
code0xff Sep 3, 2024
7b847f4
refactor: Remove alloc dependency
code0xff Sep 3, 2024
eb096a5
refactor: Remove unused error from AddressError
code0xff Sep 3, 2024
3784157
test: Add acc_address_from_bech32_test
code0xff Sep 3, 2024
ee82443
refactor: Refactor get_std_sign_bytes
code0xff Sep 4, 2024
d4c300f
refactor: Refactor get_sign_bytes and get_signers
code0xff Sep 5, 2024
33bc852
test: Implement SelfContainedCall for RuntimeCall
code0xff Sep 5, 2024
a109fee
test: Fix origin issue
code0xff Sep 5, 2024
9c2a571
test: Add check balance test
code0xff Sep 5, 2024
dee332e
test: Add MsgSend test
code0xff Sep 6, 2024
64292ff
test: Add MsgStoreCode test
code0xff Sep 6, 2024
798b461
test: Add MsgInstantiateContract2 test
code0xff Sep 6, 2024
4286a9c
test: Add a condition to pallet_cosmos_msg_instantiate_contract2_test
code0xff Sep 6, 2024
d5ce277
test: Fix test data
code0xff Sep 6, 2024
7e48427
test: Add MsgExecuteContract test
code0xff Sep 6, 2024
c8bf2c9
test: Add cw20_base.wasm and cw20-base.json
code0xff Sep 7, 2024
b148d17
fix: Change test txs
code0xff Sep 8, 2024
959d7da
feat: Add query jsonrpc to sidecar
code0xff Sep 8, 2024
55be29d
fix: Modify query rpc parameter type from Vec<u8> to Bytes
code0xff Sep 8, 2024
ee0bc15
fix: Modify height in cosmwasm query to use the actual value
code0xff Sep 9, 2024
674b3b0
feat: Add alloc feature to cosmwasm-std base64 dependency
code0xff Sep 9, 2024
c3d5fd9
fix: Remove composable-traits
code0xff Sep 9, 2024
2be63f1
fix: Remove ibc-primitives
code0xff Sep 9, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 7 additions & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@ members = [
"frame/accounts",
"frame/cosmos",
"frame/cosmwasm",
"frame/cosmwasm/rpc",
"frame/cosmwasm/runtime-api",
"frame/cosmos/types",
"frame/cosmos/x/auth",
"frame/cosmos/x/auth/migrations",
Expand All @@ -19,24 +21,24 @@ members = [
"template/runtime",
"template/node",
"cosmwasm/std",
"composable/primitives",
"composable/vm",
"composable/vm-wasmi",
"composable/composable-support",
"composable/composable-traits",
]

[workspace.dependencies]
array-bytes = "6.2.2"
base64ct = { version = "1.6.0", default-features = false }
bech32 = { version = "0.9.1", default-features = false }
bech32 = { version = "0.11.0", default-features = false }
clap = { version = "4.5.16", features = ["derive"] }
core2 = { version = "0.4.0", default-features = false }
cosmos-sdk-proto = { version = "0.24.0", default-features = false }
futures = "0.3.28"
hex = { version = "0.4.3", default-features = false }
hex-literal = "0.4.1"
impl-trait-for-tuples = "0.2.2"
jsonrpsee = "0.22.5"
libflate = { version = "2.1.0", default-features = false }
log = { version = "0.4.21", default-features = false }
num = { version = "0.4.3", default-features = false }
parity-scale-codec = { version = "3.2.0", default-features = false }
Expand Down Expand Up @@ -96,7 +98,6 @@ sp-offchain = { git = "https://github.com/paritytech/polkadot-sdk", branch = "re
sp-runtime = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
sp-runtime-interface = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
sp-session = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
sp-std = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
sp-timestamp = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
sp-transaction-pool = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
sp-version = { git = "https://github.com/paritytech/polkadot-sdk", branch = "release-polkadot-v1.9.0", default-features = false }
Expand Down Expand Up @@ -140,11 +141,11 @@ wasmi-validation = { version = "0.5.0", default-features = false }

# Composable
pallet-cosmwasm = { path = "frame/cosmwasm", default-features = false }
ibc-primitives = { path = "composable/primitives", default-features = false }
cosmwasm-vm = { path = "composable/vm", default-features = false }
cosmwasm-vm-wasmi = { path = "composable/vm-wasmi", default-features = false }
composable-support = { path = "composable/composable-support", default-features = false }
composable-traits = { path = "composable/composable-traits", default-features = false }
cosmwasm-rpc = { path = "frame/cosmwasm/rpc", default-features = false }
cosmwasm-runtime-api = { path = "frame/cosmwasm/runtime-api", default-features = false }

[profile.release]
panic = "unwind"
Expand Down
12 changes: 6 additions & 6 deletions client/rpc/src/cosm.rs → client/rpc/src/cosmos.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,28 +32,28 @@ use std::{marker::PhantomData, sync::Arc};

#[rpc(server)]
#[async_trait]
pub trait CosmApi {
#[method(name = "cosm_broadcastTx")]
pub trait CosmosApi {
#[method(name = "cosmos_broadcastTx")]
async fn broadcast_tx(&self, tx_bytes: Bytes) -> RpcResult<H256>;

#[method(name = "cosm_simulate")]
#[method(name = "cosmos_simulate")]
async fn simulate(&self, tx_bytes: Bytes) -> RpcResult<SimulateResponse>;
}

pub struct Cosm<B: BlockT, C, P> {
pub struct Cosmos<B: BlockT, C, P> {
pool: Arc<P>,
client: Arc<C>,
_marker: PhantomData<B>,
}

impl<B: BlockT, C, P> Cosm<B, C, P> {
impl<B: BlockT, C, P> Cosmos<B, C, P> {
pub fn new(pool: Arc<P>, client: Arc<C>) -> Self {
Self { pool, client, _marker: Default::default() }
}
}

#[async_trait]
impl<Block, C, P> CosmApiServer for Cosm<Block, C, P>
impl<Block, C, P> CosmosApiServer for Cosmos<Block, C, P>
where
Block: BlockT,
C: Send + Sync + 'static,
Expand Down
4 changes: 2 additions & 2 deletions client/rpc/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,9 +18,9 @@

#![deny(unused_crate_dependencies)]

mod cosm;
mod cosmos;

pub use cosm::{Cosm, CosmApiServer};
pub use cosmos::{Cosmos, CosmosApiServer};
pub use jsonrpsee::{
core,
types::{error, ErrorObject, ErrorObjectOwned},
Expand Down
2 changes: 0 additions & 2 deletions composable/composable-support/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@ schemars = { optional = true, default-features = false, workspace = true }
frame-support = { default-features = false, workspace = true }
sp-arithmetic = { default-features = false, workspace = true }
sp-runtime = { default-features = false, workspace = true }
sp-std = { default-features = false, workspace = true }

[features]
default = ["std"]
Expand All @@ -33,6 +32,5 @@ std = [
"frame-support/std",
"sp-arithmetic/std",
"sp-runtime/std",
"sp-std/std",
"schemars/std",
]
16 changes: 0 additions & 16 deletions composable/composable-traits/Cargo.toml

This file was deleted.

19 changes: 0 additions & 19 deletions composable/composable-traits/src/cosmwasm.rs

This file was deleted.

3 changes: 0 additions & 3 deletions composable/composable-traits/src/lib.rs

This file was deleted.

26 changes: 0 additions & 26 deletions composable/primitives/Cargo.toml

This file was deleted.

129 changes: 0 additions & 129 deletions composable/primitives/src/lib.rs

This file was deleted.

4 changes: 2 additions & 2 deletions composable/vm/src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -766,7 +766,7 @@ where
(Ok((data, events)), ReplyOn::Always | ReplyOn::Success) => {
log::debug!("Commit & Reply");
vm.transaction_commit()?;
// TODO:
// TODO: Handle msg_response
SubCallContinuation::Reply(SubMsgResult::Ok(SubMsgResponse {
events,
data,
Expand Down Expand Up @@ -805,7 +805,7 @@ where
// the reply and optionally overwrite the current data with with the
// one yield by the reply.
SubCallContinuation::Reply(response) => {
// TODO: Handle data
// TODO: Handle payload and gas_used
let new_data = vm.continue_reply(
Reply {
id: submsg.id,
Expand Down
2 changes: 1 addition & 1 deletion cosmwasm/std/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ cosmwasm_2_0 = ["cosmwasm_1_4"]
cosmwasm_2_1 = ["cosmwasm_2_0"]

[dependencies]
base64 = { version = "0.22.0", default-features = false }
base64 = { version = "0.22.0", default-features = false, features = ["alloc"] }
bnum = { version = "0.11.0", default-features = false }
cosmwasm-core = { version = "2.1.3", default-features = false }
cosmwasm-derive = { version = "2.1.3", default-features = false }
Expand Down
17 changes: 6 additions & 11 deletions frame/accounts/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,14 @@ repository = "https://github.com/noirhq/horizon/"
targets = ["x86_64-unknown-linux-gnu"]

[dependencies]
parity-scale-codec = { workspace = true }
scale-info = { workspace = true }
parity-scale-codec = { workspace = true, default-features = false }
scale-info = { workspace = true, default-features = false }

# Substrate FRAME
frame-support = { workspace = true }
frame-system = { workspace = true }
frame-support = { workspace = true, default-features = false }
frame-system = { workspace = true, default-features = false }
sp-core = { workspace = true, default-features = false }

# Substrate
sp-core = { workspace = true }
sp-std = { workspace = true }

# Horizon
hp-crypto = { workspace = true }
hp-crypto = { workspace = true, default-features = false }

[features]
default = ["std"]
Expand Down
6 changes: 4 additions & 2 deletions frame/accounts/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,15 +19,17 @@
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(clippy::comparison_chain, clippy::large_enum_variant)]

extern crate alloc;

pub mod weights;

use crate::weights::WeightInfo;
use alloc::vec::Vec;
#[cfg(feature = "std")]
use frame_support::traits::BuildGenesisConfig;
use hp_crypto::EcdsaExt;
pub use pallet::*;
use sp_core::H160;
use sp_std::vec::Vec;

#[frame_support::pallet]
pub mod pallet {
Expand Down Expand Up @@ -104,7 +106,7 @@ pub mod pallet {
T::AccountId: EcdsaExt,
{
pub fn connect_account(who: &T::AccountId) -> Result<(), DispatchError> {
let address = who.to_cosm_address().ok_or(Error::<T>::DeriveFailed)?;
let address = who.to_cosmos_address().ok_or(Error::<T>::DeriveFailed)?;
Connections::<T>::insert(address, who);
Self::deposit_event(Event::<T>::Connected { address, who: who.clone() });
Ok(())
Expand Down
Loading
Loading