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

Add Ibc sample contract #714

Merged
merged 34 commits into from
Jan 18, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
34 commits
Select commit Hold shift + click to select a range
ed8ab41
Start ibc-reflect contract, with README
ethanfrey Jan 13, 2021
9cd4c62
Add init callback to reflect contract
ethanfrey Jan 13, 2021
78a3c6a
Start coding the ibc-reflect contract
ethanfrey Jan 13, 2021
79d9eee
Update reflect init to take callback id
ethanfrey Jan 13, 2021
66ada09
Implement all ibc except for handle packet
ethanfrey Jan 13, 2021
b394889
Finish implementing ibc handler logic
ethanfrey Jan 13, 2021
ddf3d29
Add basic tests, fail as vm does not support stargate
ethanfrey Jan 13, 2021
34e1f58
Add ibc-reflect to CI
ethanfrey Jan 13, 2021
75cd4f8
Address PR comments
ethanfrey Jan 13, 2021
8e38973
Enable stargate feature on vm for integration tests
ethanfrey Jan 14, 2021
5cd5fc1
Add some ibc handshake tests
ethanfrey Jan 14, 2021
50209cc
Add some queries to the contract
ethanfrey Jan 14, 2021
6c64232
Basic integration tests for ibc handshake
ethanfrey Jan 14, 2021
a71fe4d
Fix integration test compile errors
ethanfrey Jan 14, 2021
05df515
cargo schema
ethanfrey Jan 14, 2021
dfe1c7a
Add unit test for receiving packets
ethanfrey Jan 14, 2021
9f5b706
Integration tests for receiving packets
ethanfrey Jan 14, 2021
7bff29b
Update Cargo.lock
ethanfrey Jan 14, 2021
8f4068b
Add helpers for creating WasmMsg::*
ethanfrey Jan 14, 2021
4dd748f
Add IBC mocks (testing helpers) to cosmwasm_std
ethanfrey Jan 14, 2021
beda058
Add StargateResponse query return value
ethanfrey Jan 14, 2021
7a6100e
Minor updates to ibc return types
ethanfrey Jan 15, 2021
60a698e
cargo schema
ethanfrey Jan 15, 2021
38c5af0
Format IBC Reflect text
webmaster128 Jan 17, 2021
a445c58
Add Instance::has_ibc_entry_points
webmaster128 Jan 17, 2021
9ead5f5
Add stargate support to reflect contract
ethanfrey Jan 18, 2021
aa31c6d
Add multiple packet types to ibc-reflect
ethanfrey Jan 18, 2021
a3343ee
Add multiple IBC packet formats
ethanfrey Jan 18, 2021
b95400a
Cleanup dispatch code
ethanfrey Jan 18, 2021
23dd4dc
Address Simon's PR comments
ethanfrey Jan 18, 2021
350d8e4
Update ibc reflect readme with packet specs
ethanfrey Jan 18, 2021
9cbc21d
Update to rust 1.49, latest master
ethanfrey Jan 18, 2021
62b9fc7
Update ibc types as requested by Alex
ethanfrey Jan 18, 2021
6116a10
Update schema files
ethanfrey Jan 18, 2021
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
55 changes: 55 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ workflows:
- package_vm_cranelift
- contract_burner
- contract_hackatom
- contract_ibc_reflect
- contract_queue
- contract_reflect
- contract_staking
Expand Down Expand Up @@ -333,6 +334,60 @@ jobs:
- target/wasm32-unknown-unknown/release/deps
key: cargocache-v2-contract_hackatom-rust:1.47.0-{{ checksum "Cargo.lock" }}

contract_ibc_reflect:
docker:
- image: rust:1.47.0
environment:
RUST_BACKTRACE: 1
working_directory: ~/cosmwasm/contracts/ibc-reflect
steps:
- checkout:
path: ~/cosmwasm
- run:
name: Version information
command: rustc --version; cargo --version; rustup --version
- restore_cache:
keys:
- cargocache-v2-contract_ibc_reflect-rust:1.47.0-{{ checksum "Cargo.lock" }}
- run:
name: Add wasm32 target
command: rustup target add wasm32-unknown-unknown && rustup target list --installed
- run:
name: Build wasm binary
command: cargo wasm --locked
- run:
name: Unit tests
command: cargo unit-test --locked
- run:
name: Integration tests (cranelift backend)
command: cargo integration-test --locked
- run:
name: Integration tests (singlepass backend)
command: cargo integration-test --locked --no-default-features
- run:
name: Build and run schema generator
command: cargo schema --locked
- run:
name: Ensure schemas are up-to-date
command: |
CHANGES_IN_REPO=$(git status --porcelain)
if [[ -n "$CHANGES_IN_REPO" ]]; then
echo "Repository is dirty. Showing 'git status' and 'git --no-pager diff' for debugging now:"
git status && git --no-pager diff
exit 1
fi
- save_cache:
paths:
- /usr/local/cargo/registry
- target/debug/.fingerprint
- target/debug/build
- target/debug/deps
- target/wasm32-unknown-unknown/release/.fingerprint
- target/wasm32-unknown-unknown/release/build
- target/wasm32-unknown-unknown/release/deps
key: cargocache-v2-contract_ibc_reflect-rust:1.47.0-{{ checksum "Cargo.lock" }}


contract_queue:
docker:
- image: rust:1.47.0
Expand Down
2 changes: 2 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@ and this project adheres to
### Added

- cosmwasm-vm: Add PinnedMemoryCache. ([#696])
- cosmwasm-vm: The new `Instance::has_ibc_entry_points` tells the caller if the
contract exposes IBC entry points.

### Changed

Expand Down
30 changes: 18 additions & 12 deletions contracts/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -19,41 +19,47 @@ reason, use the following commands:
docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_burner",target=/code/contracts/burner/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.10.5 ./contracts/burner
cosmwasm/rust-optimizer:0.10.7 ./contracts/burner

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_hackatom",target=/code/contracts/hackatom/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.10.5 ./contracts/hackatom
cosmwasm/rust-optimizer:0.10.7 ./contracts/hackatom

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_ibc_reflect",target=/code/contracts/ibc-reflect/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.10.7 ./contracts/ibc-reflect

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_queue",target=/code/contracts/queue/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.10.5 ./contracts/queue
cosmwasm/rust-optimizer:0.10.7 ./contracts/queue

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_reflect",target=/code/contracts/reflect/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.10.5 ./contracts/reflect
cosmwasm/rust-optimizer:0.10.7 ./contracts/reflect

docker run --rm -v "$(pwd)":/code \
--mount type=volume,source="devcontract_cache_staking",target=/code/contracts/staking/target \
--mount type=volume,source=registry_cache,target=/usr/local/cargo/registry \
cosmwasm/rust-optimizer:0.10.5 ./contracts/staking
cosmwasm/rust-optimizer:0.10.7 ./contracts/staking
```

## Entry points

The development contracts in this folder contain a variety of different entry
points in order to demonstrate and test the flexibility we have.

| Contract | Macro | Has `query` | Has `migrate` |
| -------- | --------------------------------------------- | ----------- | ------------- |
| burner | `#[entry_point]` | no | yes |
| hackatom | [`create_entry_points_with_migration!`][cepm] | yes | yes |
| queue | mixed<sup>1</sup> | yes | yes |
| reflect | [`create_entry_points!`][cep] | yes | no |
| staking | `#[entry_point]` | yes | no |
| Contract | Macro | Has `query` | Has `migrate` |
| ----------- | --------------------------------------------- | ----------- | ------------- |
| burner | `#[entry_point]` | no | yes |
| hackatom | [`create_entry_points_with_migration!`][cepm] | yes | yes |
| ibc-reflect | `#[entry_point]` | yes | no |
| queue | mixed<sup>1</sup> | yes | yes |
| reflect | [`create_entry_points!`][cep] | yes | no |
| staking | `#[entry_point]` | yes | no |

<sup>1</sup> Because we can. Don't try this at home.

Expand Down
6 changes: 6 additions & 0 deletions contracts/ibc-reflect/.cargo/config
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[alias]
wasm = "build --release --target wasm32-unknown-unknown"
wasm-debug = "build --target wasm32-unknown-unknown"
unit-test = "test --lib"
integration-test = "test --test integration"
schema = "run --example schema"
Loading