Skip to content

Commit

Permalink
cosmwasm: Add wormchain-accounting contract (wormhole-foundation#1920)
Browse files Browse the repository at this point in the history
* sdk/rust: Move profile settings to workspace

* sdk/rust: Add serde_wormhole crate

The serde_wormhole crate implements the wormhole wire format as a serde
data format.  This will let us replace all the hand-rolled
serialization with auto-generated code, which is less error-prone and
easier to review.

* sdk/rust: Add serde-based struct defintions

Refactor the core crate to add serde-based struct definitions for the
various messages used by the different wormhole smart contracts.  This
will also make it easier to use alternate data formats (like json) for
client-side tooling.

Co-authored-by: Reisen <reisen@morphism.org>

* sdk/rust: Drop references to `de::Unexpected`

The `de::Unexpected` enum from serde has a `Float(f64)` variant.
Referencing this enum anywhere in the code will cause the compiler to
emit its `fmt::Display` impl, which includes an `f64.load` instruction
on wasm targets.  Even if this instruction is never executed, its mere
existence will cause cosmos chains to reject any cosmwasm contract that
has it.

Fix this by removing all references to `de::Unexpected`.

* cosmwasm: Use cargo resolver version "2"

Enable the new feature resolver for the entire workspace.  This
prevents features that are enabled only for dev builds from also being
enabled in normal builds.

* Move cosmwasm Dockerfile to root directory

The cosmwasm contracts now also depend on the rust sdk so the docker
build context needs to be set to the root directory rather than the
cosmwasm/ directory.

* cosmwasm: Add wormchain-accounting contract

This contract implements tokenbridge accounting specifically for the
wormchain environment.

Fixes wormhole-foundation#1880.

* cosmwasm/accounting: Drop references to `de::Unexpected`

The `de::Unexpected` enum from serde has a `Float(f64)` variant.
Referencing this enum anywhere in the code will cause the compiler to
emit its `fmt::Display` impl, which includes an `f64.load` instruction
on wasm targets.  Even if this instruction is never executed, its mere
existence will cause cosmos chains to reject any cosmwasm contracts that
contain it.

Fix this by removing references to `de::Unexpected`.

Co-authored-by: Reisen <reisen@morphism.org>
  • Loading branch information
jynnantonix and Reisen authored Dec 14, 2022
1 parent 39f5877 commit 25abafc
Show file tree
Hide file tree
Showing 25 changed files with 4,225 additions and 293 deletions.
16 changes: 9 additions & 7 deletions cosmwasm/Dockerfile → Dockerfile.cosmwasm
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
# 2. The second is an empty image with only the wasm files (useful for exporting)
# 3. The third creates a node.js environment to deploy the contracts to devnet
FROM cosmwasm/workspace-optimizer:0.12.6@sha256:e6565a5e87c830ef3e8775a9035006b38ad0aaf0a96319158c802457b1dd1d08 AS builder
COPY Cargo.lock /code/
COPY Cargo.toml /code/
COPY contracts /code/contracts
COPY packages /code/packages

COPY cosmwasm/Cargo.lock /code/
COPY cosmwasm/Cargo.toml /code/
COPY cosmwasm/contracts /code/contracts
COPY cosmwasm/packages /code/packages
COPY sdk/rust /sdk/rust

# Support additional root CAs
COPY README.md cert.pem* /certs/
Expand Down Expand Up @@ -34,9 +36,9 @@ RUN apt update && apt install netcat curl jq -y
WORKDIR /app/tools

COPY --from=artifacts / /app/artifacts
COPY ./artifacts/cw20_base.wasm /app/artifacts/
COPY ./cosmwasm/artifacts/cw20_base.wasm /app/artifacts/

COPY ./tools/package.json ./tools/package-lock.json /app/tools/
COPY ./cosmwasm/tools/package.json ./cosmwasm/tools/package-lock.json /app/tools/
RUN --mount=type=cache,uid=1000,gid=1000,target=/home/node/.npm \
npm ci
COPY ./tools /app/tools
COPY ./cosmwasm/tools /app/tools
4 changes: 2 additions & 2 deletions Tiltfile
Original file line number Diff line number Diff line change
Expand Up @@ -599,8 +599,8 @@ if terra2:

docker_build(
ref = "terra2-contracts",
context = "./cosmwasm",
dockerfile = "./cosmwasm/Dockerfile",
context = ".",
dockerfile = "./Dockerfile.cosmwasm",
)

k8s_yaml_with_ns("devnet/terra2-devnet.yaml")
Expand Down
Loading

0 comments on commit 25abafc

Please sign in to comment.