Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Abstract/deployment #4

Open
wants to merge 49 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 47 commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
32d6250
Prepend packages with `abstract`
CyberHoward Jan 24, 2024
5a9a1c2
remove daemon feature on cw-orch
CyberHoward Jan 24, 2024
6161854
update description
CyberHoward Jan 24, 2024
1f130eb
Deploy (#3)
Kayanski Jan 25, 2024
ada227f
Changed version
Kayanski Jan 25, 2024
87b7269
Merge with previous deployed version
Kayanski Jan 25, 2024
349b66a
Merge
Kayanski Jan 25, 2024
d6c58f9
Added more connections publishing
Kayanski Jan 25, 2024
672587b
Updated cw-orch
Kayanski Feb 5, 2024
a03304c
Updated version
Kayanski Feb 5, 2024
c4807d9
Updated cw-orch version
Kayanski Feb 5, 2024
40b8360
Merge branch 'main' into abstract/deployment
CyberHoward Feb 7, 2024
a138a33
bump polytone package version
CyberHoward Feb 7, 2024
f5f6893
Updated to v1.1.0
Kayanski Apr 16, 2024
60392c8
Merge wasms
Kayanski Apr 16, 2024
95d7903
Updated cw-orch'
Kayanski Apr 25, 2024
8603142
Update cw-orch
Kayanski May 1, 2024
8c48372
Added harpoon<-->pion deployment
Kayanski May 21, 2024
35c2406
Published new state
Kayanski May 21, 2024
346d27d
Changed xion-pion deployment
Kayanski May 27, 2024
6ddc9b9
Updated version
Kayanski May 27, 2024
a20826c
Added juno neutron testnet
Kayanski May 30, 2024
af659c9
Updated with more deployments
Kayanski Jun 11, 2024
6c1ce7c
ABetter polytone connection API
Kayanski Jun 11, 2024
f997e99
Added better api
Kayanski Jun 11, 2024
fb1300c
Added polytone connection and format cw-orch-state
Kayanski Jun 11, 2024
a694a6e
Added conditional deployment
Kayanski Jun 11, 2024
53e97c6
Nits
Kayanski Jun 11, 2024
bb9f221
Ref
Kayanski Jun 11, 2024
34da5ba
Nit
Kayanski Jun 11, 2024
0bdec1c
Updated cw-orch to 0.23
Kayanski Jun 12, 2024
63442d9
Removed deprecated warnings
Kayanski Jun 13, 2024
cb76a86
Added starship test
Kayanski Jun 17, 2024
6eac485
Moved starship to example
Kayanski Jun 17, 2024
c51ad0d
Nit
Kayanski Jun 19, 2024
69eef02
Fix imports and scripts
Kayanski Jun 24, 2024
1a66ebc
Verifying, not dpeloying
Kayanski Jun 24, 2024
de93691
MOdifying scripts
Kayanski Jun 24, 2024
bfec32f
Removed git dep
Kayanski Jun 24, 2024
d4f9d6d
Published interface update
Kayanski Jun 27, 2024
0951b47
bump cw-orch to 0.24.0
Buckram123 Jul 10, 2024
c01895a
clippy
Buckram123 Jul 11, 2024
ff37751
oopsie incorrect version bumps
Buckram123 Jul 11, 2024
0642c0c
fix toml
Buckram123 Jul 11, 2024
ee276cd
Add helper to get list of connected polytones
Buckram123 Aug 8, 2024
02a9f8b
Merge pull request #6 from AbstractSDK/buckram/connected-polytones
CyberHoward Aug 13, 2024
4aff48d
Merge pull request #5 from AbstractSDK/update/better-api
CyberHoward Aug 13, 2024
11aec33
Bump/cw2 (#8)
Kayanski Dec 17, 2024
7e4d06b
Added xion-osmosis connection
Kayanski Dec 20, 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
1,843 changes: 1,244 additions & 599 deletions Cargo.lock

Large diffs are not rendered by default.

22 changes: 15 additions & 7 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,5 +1,10 @@
[workspace]
members = ["packages/*", "contracts/accessories/*", "contracts/main/*"]
members = [
"packages/*",
"contracts/accessories/*",
"contracts/main/*",
"scripts",
]

[workspace.package]
edition = "2021"
Expand All @@ -20,10 +25,11 @@ panic = 'abort'
rpath = false

[workspace.dependencies]
polytone = { path = "packages/polytone", version = "1.0.0" }
polytone-proxy = { path = "contracts/main/proxy", version = "1.0.0" }
polytone-note = { path = "contracts/main/note", version = "1.0.0" }
polytone-voice = { path = "contracts/main/voice", version = "1.0.0" }
polytone = { package = "abstract-polytone", path = "packages/polytone", version = "1.0.0" }
polytone-proxy = { package = "abstract-polytone-proxy", path = "contracts/main/proxy", version = "3.0.0" }
polytone-note = { package = "abstract-polytone-note", path = "contracts/main/note", version = "3.0.0" }
polytone-voice = { package = "abstract-polytone-voice", path = "contracts/main/voice", version = "3.0.0" }
cw-orch-polytone = { package = "abstract-cw-orch-polytone", path = "packages/cw-orch-polytone", version = "4.0.1" }
CyberHoward marked this conversation as resolved.
Show resolved Hide resolved

cosmwasm-schema = "1.2.1"
cosmwasm-std = { version = "1.5.0", features = ["ibc3"] }
Expand All @@ -40,7 +46,9 @@ thiserror = "1.0.31"
sha2 = "0.10.6"

# dev-dependencies

cw-orch = { version = "0.24.0" }
cw-orch-interchain = { version = "0.3.0" }

cw-multi-test = "0.16.2"
polytone-tester = { path = "tests/polytone-tester" }
anyhow = { version = "1.0.51" }
cw-orch = { version = "0.20.0" }
101 changes: 101 additions & 0 deletions DEPLOY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
# Deployment

In order to deploy a Polytone connection between 2 chains (e.g. archway and osmosis), you should follow the following steps.

> **NOTE**: Keep in min that Polytone connections go only one way. This tutorial allows you to control an account on chain `dst_chain` from `src_chain` but not the other way around!

## Prerequesistes

In order to be able to deploy polytone and create a connection, the two chains you want to link together should both include polytone contracts uploaded.

### Building the contracts

If the artifacts are not present in the repository, run the following command to build them and optimize them :

```bash
./devtools/optimize.sh
```

### Uploading all the contracts on the chain

We offer the possibility to upload all contracts to a specific chain in [`scripts/src/bin/upload_contracts.rs`](scripts/src/bin/upload_contracts.rs). Simply change the chain variable to the chain on which you want to deploy the contracts.

## Contract instantiation

We will instantiate a `note` contract on `src_chain` and a `voice` on `dst_chain`.

To do so, use [`scripts/src/bin/instantiate_chains.rs`](scripts/src/bin/instantiate_chains.rs). Change the `src_chain` and `dst_chain` variables accordingly.

You can specify optional addresses that will own the contracts migration rights with the `src_admin_addr` and `dst_admin_addr` variables.

## Channel creation

Finally you need to create a channel between the two contracts.

### Hermes setup

1. [Install hermes following the official tutorial](https://hermes.informal.systems/quick-start/installation.html)
2. If you're using mainnets, you can setup the relayer using the following command:

```bash
hermes config auto --chains archway osmosis
```

3. You need to add your mnemonics or account keys to the relayer on both chains. [Follow this tutorial to learn how to add keys](https://hermes.informal.systems/tutorials/production/setup-hermes.html#setup-accounts).
4. You might need to adjust the `key_name` variables in the `$HOME/.hermes/config.toml` file to the name of the key you created.
5. You may need to config the `max_gas` variables in the `$HOME/.hermes/config.toml` file because they are not set correctly by default (some errors in the following steps will guid you in that direct). We advise you to setup the `max_gas` paramter to `1000000` on both chains for a correct channel creation process.

### Channel command

You may now create a channel with:

```bash
hermes create channel --a-chain <src-chain-id> --a-connection <connection-id> --a-port wasm.<src-note-contract-address> --b-port wasm.<dst-voice-contract-address> --channel-version polytone-1
```

e.g.

```bash
hermes create channel --a-chain archway-1 --a-connection connection-1 --a-port wasm.archway1zla0cm4sjytmktj4skrdm00hlars6q4jgkeqz5wy0tlftzu494tsqpkhuj --b-port wasm.osmo1kju3qsgcfwfuhqdrwm623xrf7hn3lmp2scaznxn75r3mlv36x4xsc7lnz2 --channel-version polytone-1
```

In return you should get all the channel ids you need (on the `src_chain` and on the `dst_chain`).

### Testing

You can make sure everything is setup correctly by using [`scripts/src/bin/verify_deployment.rs`](scripts/src/bin/verify_deployment.rs).
This creates a transaction with empty sent messages across polytone. If the relayer is setup correctly, it should relay the packets succesfully with an `Ok` acknowledgment sent back

### Setting up hermes to relay only packets on this channel

Use the following configuration for each chain you want to relay on to limit the channel to the channel you just created.

```toml
[chains.packet_filter]
policy = "allow"
list = [
[
"wasm.<contract-address>",
"<created-channel-id>",
],
]
```

## Deploy Matrix

| From\To | Osmosis | Archway | Terra | Juno | Neutron | Stargaze | Kujira | Migaloo |
|--- |----|----|----|----|----|----|----|----|
| Osmosis | ❌ | ✅ | 🟢 | 🟢 | 🟢 | 🟢 | ✅ | 🟢 |
| Archway | ✅ | ❌ | ✅ | ✅ | ✅ | ✅ | ✅ | |
| Terra | ✅ | ✅ | ❌ | ✅ | ✅ | | ✅ | |
| Juno | 🟢 | ✅ | 🟢 | ❌ | | 🟢 | ✅ | 🟢 |
| Neutron | 🟢 | ✅ | 🟢 | | ❌ | 🟢 | ✅ | |
| Stargaze | 🟢 | ✅ | | 🟢 | 🟢 | ❌ | ✅ | 🟢 |
| Kujira | ✅ | ✅ | ✅ | ✅ | ✅ | ✅ | ❌ | |
| Migaloo | 🟢 | | | 🟢 | | 🟢 | | ❌ |

✅: Deployed by Abstract

❌: No reason to deploy

🟢: Deployed by DA0DA0
CyberHoward marked this conversation as resolved.
Show resolved Hide resolved
6 changes: 3 additions & 3 deletions contracts/accessories/listener/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cosmwasm_std::{to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult};
use cw2::set_contract_version;

use crate::error::ContractError;
Expand Down Expand Up @@ -60,11 +60,11 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::Note {} => to_binary(&NOTE.load(deps.storage)?),
QueryMsg::Note {} => to_json_binary(&NOTE.load(deps.storage)?),
QueryMsg::Result {
initiator,
initiator_msg,
} => to_binary(&ResultResponse {
} => to_json_binary(&ResultResponse {
callback: RESULTS.load(deps.storage, (initiator, initiator_msg))?,
}),
}
Expand Down
6 changes: 3 additions & 3 deletions contracts/accessories/listener/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use cosmwasm_std::{to_binary, Addr, Empty, Uint64};
use cosmwasm_std::{to_json_binary, Addr, Empty, Uint64};

use cw_multi_test::{App, Contract, ContractWrapper, Executor};
use polytone::callbacks::{Callback, CallbackMessage};
Expand Down Expand Up @@ -87,7 +87,7 @@ fn test() {
// Allows note to execute callback.
let callback = CallbackMessage {
initiator: Addr::unchecked(INITIATOR_ADDR),
initiator_msg: to_binary(INITIATOR_MSG).unwrap(),
initiator_msg: to_json_binary(INITIATOR_MSG).unwrap(),
result: Callback::Execute(Result::Err("ERROR".to_string())),
};
app.execute_contract(
Expand Down Expand Up @@ -118,7 +118,7 @@ fn test() {
listener,
&QueryMsg::Result {
initiator: INITIATOR_ADDR.to_string(),
initiator_msg: to_binary(INITIATOR_MSG).unwrap().to_string(),
initiator_msg: to_json_binary(INITIATOR_MSG).unwrap().to_string(),
},
)
.unwrap();
Expand Down
8 changes: 4 additions & 4 deletions contracts/accessories/polytone-tester/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg,
to_json_binary, Binary, Deps, DepsMut, Env, MessageInfo, Response, StdResult, WasmMsg,
};
use cw2::set_contract_version;

Expand Down Expand Up @@ -58,7 +58,7 @@ pub fn execute(
}
ExecuteMsg::RunOutOfGas {} => Ok(Response::default().add_message(WasmMsg::Execute {
contract_addr: env.contract.address.into_string(),
msg: to_binary(&ExecuteMsg::RunOutOfGas {}).unwrap(),
msg: to_json_binary(&ExecuteMsg::RunOutOfGas {}).unwrap(),
funds: vec![],
})),
}
Expand All @@ -67,10 +67,10 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::History {} => to_binary(&CallbackHistoryResponse {
QueryMsg::History {} => to_json_binary(&CallbackHistoryResponse {
history: CALLBACK_HISTORY.load(deps.storage)?,
}),
QueryMsg::HelloHistory {} => to_binary(&HelloHistoryResponse {
QueryMsg::HelloHistory {} => to_json_binary(&HelloHistoryResponse {
history: HELLO_CALL_HISTORY.load(deps.storage)?,
}),
}
Expand Down
45 changes: 22 additions & 23 deletions contracts/main/note/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
[package]
name = "polytone-note"
authors = ["ekez <[email protected]>"]
description = "Sends messages to be executed on other chains over IBC."
edition = { workspace = true }
license = { workspace = true }
name = "abstract-polytone-note"
authors = ["ekez <[email protected]>"]
description = "Sends messages to be executed on other chains over IBC."
edition = { workspace = true }
license = { workspace = true }
rust-version = { workspace = true }
repository = { workspace = true }
version = { workspace = true }
repository = { workspace = true }
version = "3.0.0"

[lib]
crate-type = ["cdylib", "rlib"]
Expand All @@ -16,31 +16,30 @@ crate-type = ["cdylib", "rlib"]
backtraces = ["cosmwasm-std/backtraces"]
# disables #[entry_point] (i.e. instantiate/execute/query) export
library = []
interface = ["dep:cw-orch"]

# This is here inspite of the warnings to make sure it is not missed
# if the contract is taken out of the workspace
[profile.release]
codegen-units = 1
debug = false
codegen-units = 1
debug = false
debug-assertions = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true # very important, do not turn these off.
panic = 'abort'
rpath = false
incremental = false
lto = true
opt-level = 3
overflow-checks = true # very important, do not turn these off.
panic = 'abort'
rpath = false

[dependencies]
cosmwasm-schema = { workspace = true }
cosmwasm-std = { workspace = true }
cosmwasm-std = { workspace = true }
cw-storage-plus = { workspace = true }
cw-utils = { workspace = true }
cw2 = { workspace = true }
thiserror = { workspace = true }
polytone = { workspace = true }
cw-orch = { workspace = true, optional = true }
cw-utils = { workspace = true }
cw2 = { workspace = true }
thiserror = { workspace = true }
polytone = { workspace = true }
cw-orch = { workspace = true }

[dev-dependencies]
cw-multi-test = { workspace = true }
anyhow = { workspace = true }
anyhow = { workspace = true }
2 changes: 1 addition & 1 deletion contracts/main/note/src/bin/schema.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_schema::write_api;

use polytone_note::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};
use abstract_polytone_note::msg::{ExecuteMsg, InstantiateMsg, QueryMsg};

fn main() {
write_api! {
Expand Down
13 changes: 7 additions & 6 deletions contracts/main/note/src/contract.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#[cfg(not(feature = "library"))]
use cosmwasm_std::entry_point;
use cosmwasm_std::{
to_binary, Binary, Deps, DepsMut, Env, IbcMsg, IbcTimeout, MessageInfo, Response, StdResult,
to_json_binary, Binary, Deps, DepsMut, Env, IbcMsg, IbcTimeout, MessageInfo, Response,
StdResult,
};
use cw2::set_contract_version;
use polytone::callbacks::CallbackRequestType;
Expand Down Expand Up @@ -106,7 +107,7 @@ pub fn execute(
.add_attribute("method", "execute")
.add_message(IbcMsg::SendPacket {
channel_id,
data: to_binary(&ibc::Packet {
data: to_json_binary(&ibc::Packet {
sender: info.sender.into_string(),
msg,
})
Expand All @@ -118,18 +119,18 @@ pub fn execute(
#[cfg_attr(not(feature = "library"), entry_point)]
pub fn query(deps: Deps, _env: Env, msg: QueryMsg) -> StdResult<Binary> {
match msg {
QueryMsg::ActiveChannel => to_binary(&CHANNEL.may_load(deps.storage)?),
QueryMsg::Pair => to_binary(&CONNECTION_REMOTE_PORT.may_load(deps.storage)?.map(
QueryMsg::ActiveChannel => to_json_binary(&CHANNEL.may_load(deps.storage)?),
QueryMsg::Pair => to_json_binary(&CONNECTION_REMOTE_PORT.may_load(deps.storage)?.map(
|(connection_id, remote_port)| Pair {
connection_id,
remote_port,
},
)),
QueryMsg::RemoteAddress { local_address } => to_binary(&accounts::query_account(
QueryMsg::RemoteAddress { local_address } => to_json_binary(&accounts::query_account(
deps.storage,
deps.api.addr_validate(&local_address)?,
)?),
QueryMsg::BlockMaxGas => to_binary(&BLOCK_MAX_GAS.load(deps.storage)?),
QueryMsg::BlockMaxGas => to_json_binary(&BLOCK_MAX_GAS.load(deps.storage)?),
}
}

Expand Down
9 changes: 4 additions & 5 deletions contracts/main/note/src/msg.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,12 +23,12 @@ pub struct InstantiateMsg {
}

#[cw_serde]
#[cfg_attr(feature = "interface", derive(cw_orch::ExecuteFns))] // cw-orch automatic
#[derive(cw_orch::ExecuteFns)] // cw-orch automatic
pub enum ExecuteMsg {
/// Performs the requested queries on the voice chain and returns
/// a callback of Vec<QuerierResult>, or ACK-FAIL if unmarshalling
/// any of the query requests fails.
#[cfg_attr(feature = "interface", fn_name("ibc_query"))]
#[cw_orch(fn_name("ibc_query"))]
Query {
msgs: Vec<QueryRequest<Empty>>,
callback: CallbackRequest,
Expand All @@ -45,7 +45,7 @@ pub enum ExecuteMsg {
/// perform no additional actions, pass an empty list to
/// `msgs`. Accounts are queryable via the `RemoteAddress {
/// local_address }` query after they have been created.
#[cfg_attr(feature = "interface", fn_name("ibc_execute"))]
#[cw_orch(fn_name("ibc_execute"))]
Execute {
msgs: Vec<CosmosMsg<Empty>>,
callback: Option<CallbackRequest>,
Expand All @@ -54,8 +54,7 @@ pub enum ExecuteMsg {
}

#[cw_serde]
#[derive(QueryResponses)]
#[cfg_attr(feature = "interface", derive(cw_orch::QueryFns))] // cw-orch automatic
#[derive(QueryResponses, cw_orch::QueryFns)] // cw-orch automatic
pub enum QueryMsg {
/// This channel this note is currently connected to, or none if
/// no channel is connected.
Expand Down
4 changes: 2 additions & 2 deletions contracts/main/note/src/tests.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use cosmwasm_std::{
testing::{mock_dependencies, mock_env, mock_info},
to_binary, Uint64, WasmMsg,
to_json_binary, Uint64, WasmMsg,
};

use crate::{
Expand Down Expand Up @@ -35,7 +35,7 @@ fn simple_note() {
on_behalf_of: None,
msgs: vec![WasmMsg::Execute {
contract_addr: "some_addr".to_string(),
msg: to_binary("some_msg").unwrap(),
msg: to_json_binary("some_msg").unwrap(),
funds: vec![],
}
.into()],
Expand Down
Loading
Loading