Commit Graph

20 Commits

Author SHA1 Message Date
Steve 821a6e8752
Add ibc-translator contract to the cosmwasm workspace and it's governance packet to the rust sdk. (#3174)
* Add ibc-translator contract and it's governance packet to the rust sdk.

* Remove unnecessary cargo script

* rustfmt and clippy fixes

* Address review comments

* Use WormholeQuery instead of contract to verify vaa, remove wormhole
core contract dependency, remove feature flag on anybuf.

* Add cw20 token metadata to tokenfactory metadata

* Change Simple/ContractControlled payloads to
GatewayTransfer/GatewayTransferWithPayload

* Change display and scaled denom to ensure x/bank conformance.
2023-08-10 07:08:22 -07:00
Nikhil Suri 892274ffa4
cosmwasm: ibc contracts (#2591)
* cosmwasm: add wormchain-ibc-receiver and wormhole-ibc contracts

* Address review comments from jynnantonix and hendrikhofstadt

* Fix lint errors and test failures

* Update naming to reflect new mapping of channelId -> chainId

* Return errors in ibc handlers that should never be called

* Remove contract name and version logic from migration handlers

* Add query handlers to wormhole-ibc contract

* Add wormchain channel id whitelisting to wormhole-ibc contract

* Increase packet timeout to 1 year

* Rebase on main, update imports to new names

* Add governance replay protection to both contracts

* wormhole_ibc SubmitUpdateChannelChain should only handle a single VAA

* better error messages

* Better logging and strip null characters from channel_id from governance VAA

* add brackets back for empty query methods

* Update Cargo.lock

* Only send wormhole wasm event attributes via IBC and add attribute whitelist on the receiver end

* tilt: fix terra2 deploy

* Update based on comments from jynnantonix

---------

Co-authored-by: Evan Gray <battledingo@gmail.com>
2023-05-18 07:34:15 -04:00
Nikhil Suri 842462fd78
cosmwasm: remove terraswap dependency (#2739)
* cosmwasm: remove terraswap dependency

* add test to ensure serialization is the same
2023-05-04 07:56:01 -07:00
Nikhil Suri d7b6be7358
Cosmwasm package naming updates (#2641)
* sdk: update wormhole-core to wormhole-sdk and fix lib name to be wormhole_sdk

* cosmwasm: update wormhole and token bridge cosmwasm package/lib names

* Fix terra2 deployment script with new artifact names
2023-04-18 09:31:38 -07:00
Nikhil Suri 8837a9af50
cosmwasm: bump k256 dependency to 0.11 (#2630)
* cosmwasm: add test for keys_equal

* cosmwasm: bump k256 from 0.9.4 to 0.11

* Update bad_signature tests to use new error messages
2023-04-14 15:04:49 -05:00
Nikhil Suri 56b847c41d
cosmwasm: clean up unused dependencies (#2629) 2023-04-13 12:34:08 +01:00
Conor Patrick 7c5bdb1863 accountant: remove double keccak for submitting observations 2023-02-27 08:52:42 -06:00
Chirantan Ekbote dd95954fc3 cosmwasm: Rename accounting -> accountant
Also change wormchain -> global.
2023-01-23 16:42:47 -05:00
Chirantan Ekbote 1f8055adfa cosmwasm: accounting: Use hex-encoding for TokenAddress
Use hex rather than base64 when serializing / deserializing
`TokenAddress` so that it's more consistent with the other address
types.
2023-01-23 14:27:08 -05:00
Chirantan Ekbote 3c6702b6f7 sdk/rust: Add serde_wormhole::RawMessage
Add a RawMessage type that can be used to defer parsing parts of a
payload, similar to the `json.RawMessage` from Go.  The implementation
is inspired by `serde_json::RawValue`, which does a similar thing.

When serializing, RawMessage will serialize to a base64-encoded string
if it detects that the data format is human readable (like JSON).
Otherwise it will simply forward the raw bytes to the serializer.

RawMessage has both borrowed and boxed versions.  The borrowed version
is the most efficient as it enables zero-copy handling of the input data
but also requires that the input data already contains raw bytes and is
not suitable when dealing with human-readable formats like JSON.

The boxed version is more flexible as it supports byte slices, base64-
encoded strings, and byte sequences but is slightly less efficient as it
requires copying or decoding the input data.
2023-01-18 09:29:05 +09:00
Chirantan Ekbote 8777c22d32 cosmwasm: accounting: Use cw_transcode for events
Use cw_transcode to ensure that event attribute values are always
encoded as proper json, making it easier for clients to parse them back
into structured data.

This also lets us reuse the input messages for the events, reducing the
number of different structs that we need to track.
2023-01-16 09:28:43 +09:00
Chirantan Ekbote 3c914c725a cosmwasm: Add cw_transcode crate
The cw_transcode crate provides a way to transcode any arbitrary rust
struct into a `cosmwasm_std::Event` via that struct's `Serialize` impl,
ensuring that the event attribute values are encoded as proper json.

This will make it easier for client code to parse the event back into
structured data without having to write custom parsing code for each
individual event type.
2023-01-12 10:29:29 +09:00
Chirantan Ekbote ab172b4da5 sdk/rust: Ensure chain conversions are isomorphic
Ensure that converting `Chain` to/from a u16 or to/from a string is
always isomorphic.  This requires changing the `FromStr` impl so that in
can handle strings like "Unknown(27)".
2023-01-04 16:17:14 +09:00
Chirantan Ekbote 16b22a8cfc cosmwasm: wormhole-bindings: Use the Signature type from the SDK
Use the `Signature` type from the core SDK to avoid unnecessary
type conversions.  Cosmwasm requires its message types to implement
`JsonSchema` so also derive that impl for the `Signature` type behind a
feature flag.

This change uncovered a separate issue where the fake `WormholeKeeper`
was using regular ecdsa signatures rather than recoverable signatures
so fix the signing and verification methods to use the recoverable
signatures.
2022-12-15 12:22:37 +09:00
Chirantan Ekbote 25abafc753
cosmwasm: Add wormchain-accounting contract (#1920)
* 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 #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>
2022-12-14 12:06:45 -05:00
Chirantan Ekbote c5925f1467 cosmwasm: Add core accounting package
The accounting package implements the reusable, chain agnostic part of
tokenbridge accounting.

Part of #1880.
2022-11-30 16:34:22 +09:00
Chirantan Ekbote b1fce660c8 cosmwasm: Add wormhole-bindings package
This package defines the bindings into the native wormhole module on
wormchain.

Part of #1880 and #1881.
2022-11-29 08:18:56 +09:00
Csongor Kiss c22d0c222b cosmwasm: Add shutdown feature flag to token bridge 2022-09-27 07:58:28 -05:00
Evan Gray db0fc219aa cosmwasm: terra2 support
Co-authored-by: Csongor Kiss <ckiss@jumptrading.com>
2022-06-21 10:03:57 -04:00
Evan Gray c7d8075555 cosmwasm: initialize 2022-06-21 10:03:57 -04:00