Skip to content

Commit

Permalink
Use Nix to build the CosmWasm IBC client contract
Browse files Browse the repository at this point in the history
  • Loading branch information
romac committed Apr 22, 2024
1 parent 13b91a1 commit 05e67e4
Show file tree
Hide file tree
Showing 8 changed files with 4,506 additions and 15 deletions.
12 changes: 2 additions & 10 deletions .github/workflows/integration.yaml
Expand Up @@ -279,15 +279,6 @@ jobs:
toolchain: stable
- name: Install cargo-nextest
run: curl -LsSf https://get.nexte.st/latest/linux | tar zxf - -C ${CARGO_HOME:-~/.cargo}/bin
- name: Download latest IBC client CosmWasm contract
uses: actions/download-artifact@v4
with:
run-id: ${{ env.UPLOAD_WASM_RUN_ID }}
repository: cosmos/ibc-rs
pattern: tendermint-cw-*
github-token: ${{ secrets.GITHUB_TOKEN }}
- name: Relocate CosmWasm contract
run: mv tendermint-cw-*/ibc_client_tendermint_cw.wasm tools/integration-test/fixtures/wasm/ibc_client_tendermint_cw.wasm
- name: Build tests
uses: actions-rs/cargo@v1
with:
Expand All @@ -301,8 +292,9 @@ jobs:
CHAIN_COMMAND_PATHS: ${{ matrix.chain.command }}
ACCOUNT_PREFIXES: ${{ matrix.chain.account_prefix }}
NATIVE_TOKENS: ${{ matrix.chain.native_token }}
IBC_CLIENT_WASM_FILE: ${{ github.workspace }}/result/ibc_client_tendermint_cw.wasm
run: |
nix shell .#python ${{ matrix.chain.package }} -c \
nix shell .#python .#ibc-client-tendermint-cw ${{ matrix.chain.package }} -c \
cargo nextest run -p ibc-integration-test --no-fail-fast --failure-output final --test-threads=2 \
--features wasm wasm_client
Expand Down
1 change: 0 additions & 1 deletion TO_REMOVE

This file was deleted.

71 changes: 70 additions & 1 deletion flake.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

12 changes: 12 additions & 0 deletions flake.nix
Expand Up @@ -4,6 +4,7 @@
inputs = {
nixpkgs.url = "github:nixos/nixpkgs/nixpkgs-unstable";
flake-utils.url = "github:numtide/flake-utils";
rust-overlay.url = "github:oxalica/rust-overlay";
cosmos-nix.url = "github:informalsystems/cosmos.nix";
cosmos-nix-wasm.url = "github:informalsystems/cosmos.nix/jonathan/ibc-go-wasm";
};
Expand All @@ -23,10 +24,19 @@
let
nixpkgs = import inputs.nixpkgs {
inherit system;
overlays = [
inputs.rust-overlay.overlays.default
];
};

cosmos-nix = inputs.cosmos-nix.packages.${system};
cosmos-nix-wasm = inputs.cosmos-nix-wasm.packages.${system};

ibc-client-tendermint-cw =
import ./nix/ibc-client-tendermint-cw.nix
{
inherit nixpkgs;
};
in
{
packages = {
Expand Down Expand Up @@ -62,6 +72,8 @@
ibc-go-v7-wasm-simapp
;

ibc-client-tendermint-cw = ibc-client-tendermint-cw;

python = nixpkgs.python3.withPackages (p: [
p.toml
]);
Expand Down
41 changes: 41 additions & 0 deletions nix/ibc-client-tendermint-cw.nix
@@ -0,0 +1,41 @@
{ nixpkgs }:
let
rust-bin =
nixpkgs.rust-bin.stable.latest.default.override
{
targets = [ "wasm32-unknown-unknown" ];
};
in
nixpkgs.rustPlatform.buildRustPackage {
name = "ibc-client-tendermint-cw";

src = nixpkgs.fetchFromGitHub {
owner = "cosmos";
repo = "ibc-rs";
rev = "d0f7cc41c413bdb1e801acaa566f3e7cf06c2c93";
hash = "sha256-LBuP+t7M5KL4a5tbGlALq1B0G3UV3Nqvh4r1X/BgGK0=";
};

cargoLock = {
lockFile = ./ibc-rs.Cargo.lock;
};

postPatch = ''
ln -s ${./ibc-rs.Cargo.lock} Cargo.lock
'';

nativeBuildInputs = [
rust-bin
];

doCheck = false;

buildPhase = ''
RUSTFLAGS='-C link-arg=-s' cargo build -p ibc-client-tendermint-cw --target wasm32-unknown-unknown --release --lib --locked
'';

installPhase = ''
mkdir -p $out
cp target/wasm32-unknown-unknown/release/ibc_client_tendermint_cw.wasm $out/
'';
}

0 comments on commit 05e67e4

Please sign in to comment.