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

Build Wasm contract with Nix #3969

Merged
merged 2 commits into from Apr 22, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
11 changes: 2 additions & 9 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,7 +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 build .#ibc-client-tendermint-cw
nix shell .#python ${{ 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.

15 changes: 14 additions & 1 deletion 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,16 +24,26 @@
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 = {
inherit
(cosmos-nix)
apalache
# apalache

celestia
cometbft
evmos
Expand Down Expand Up @@ -62,6 +73,8 @@
ibc-go-v7-wasm-simapp
;

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

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

rustWasmPlatform = nixpkgs.makeRustPlatform {
cargo = rustWithWasmTarget;
rustc = rustWithWasmTarget;
};
in
rustWasmPlatform.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
'';

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/
'';
}