Commit Graph

28 Commits

Author SHA1 Message Date
Chirantan Ekbote 421a030dca sdk/rust: Remove `*_with_payload` methods
The RawMessage type provides a more flexible way to handle trailing
payloads so replace all usage of the `*_with_payload` functions to use
`RawMessage` instead.

There should be no functional change.
2023-01-18 09:33:10 +09: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 e05176c9be sdk/rust: Remove `expiration_time` from `GuardianSetInfo`
This field doesn't actually appear in `GuardianSetUpgrade` governance
messages and was already being skipped by serde so just remove it
completely.  Contracts that need to keep track of this information can
encapsulate the `GuardianSetInfo` inside another struct that has an
`expiration_time` field.
2023-01-04 16:17:14 +09:00
Chirantan Ekbote 3a1dd9eccd sdk/rust: Simplify quorum calculation
Also add tests.
2023-01-04 16:17:14 +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 b400a2d51d sdk/rust: Add test for digest calculation
Add a test to ensure that calculating the digest from the structured
body, serialized data, or partial body + serialized payload all give the
same result.
2022-12-21 13:59:01 +09:00
Chirantan Ekbote 0dbeeec3d4 sdk/rust: Add `Body::with_payload`
Add the `Body::with_payload` method, which can be used to change the
type of the payload for a `Body`.  This is useful when parsing the
payload needs to be deferred until after the body is parsed.
2022-12-19 17:14:33 +09:00
Chirantan Ekbote 4ea369d7a9 sdk/rust: Implement Display for Address
This will be used later by the accounting contract.
2022-12-19 17:14:33 +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 b3d68b0db6 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`.
2022-12-14 16:33:22 +09:00
Chirantan Ekbote d157c7bf67 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>
2022-12-14 16:33:22 +09:00
Chirantan Ekbote 92cb3d28a3 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.
2022-12-14 16:33:22 +09:00
Chirantan Ekbote 6e25b6c801 sdk/rust: Move profile settings to workspace 2022-12-14 16:33:22 +09:00
Chirantan Ekbote 676d729e3a sdk/rust: Fix clippy warnings 2022-10-28 14:35:44 -04:00
Chirantan Ekbote cb20d47835 sdk/rust: Fix formatting
Also disable unstable options in the rustfmt.toml
2022-10-28 14:35:44 -04:00
Chirantan Ekbote 12459c4a2a Add a wormhole go sdk
The wormhole sdk is a new go module in the sdk/ directory.  This
initially contains the *_consts.go files from the common package in the
top-level sdk package and the entire vaa package as a sub-package.

For go reasons this needs to be in the sdk directory itself (rather than
a sdk/go subdir).  To prevent the go tooling from looking into the other
non-go subdirs, add an empty go.mod file in each one.  See
golang issue 42965 for more details on why we can't have nice
things (I'm deliberately not linking to stop github from spamming that
issue).
2022-09-15 14:35:46 +01:00
Stan Drozd 18eac4e3d3 solana: bump: Rust nightly-2022-07-12, SOL SDK v1.10.31, rust container 1.60
solana: use prebuild docker image for 1.10.31

solana: use the right rust version

from https://github.com/solana-labs/solana/blob/v1.10.31/ci/rust-version.sh

nft_bridge: TransportError -> BanksClientError

solana/Dockerfile.wasm: Use rust-toolchain instead of rustup
2022-08-17 15:30:01 +01:00
Hendrik Hofstadt ee4583099f solana: token bridge transfer with payload 2022-05-11 21:24:36 -04:00
Chirantan Ekbote e907a05b1e sdk, terra: Fix tests and add them to CI
The terra tests had bit rotted quite terribly. It seems no one has run
them in almost a year because the API changed with the 0.14 release of
cosmwasm_vm in April, 2021.

Completely remove cosmwasm_vm from dev-dependencies.  The tests aren't
doing anything that requires interacting with the wasm code and can just
test the relevant functions directly.

Once this goes in the tests should be running in the CI so hopefully no
one will be able to push any more breaking changes.

commit-id:537d95e6
2022-04-20 09:46:51 +09:00
Hendrik Hofstadt c04d25e704 Fix solana integration tests & add test for account creation
Change-Id: I222744f194f952d03bfbd3ba4469bce59c310fc0
2022-04-11 21:29:39 -04:00
Serguei 8692080c2f
Terra SDK test chage to make it pass, devnet contract address corrected, build as library feature set. (#764) 2022-03-30 07:12:15 -05:00
Serguei 087506dec6
sdk/solana: post_message: added multiple seeds. (#838) 2022-03-03 12:23:56 -06:00
Hendrik Hofstadt 7edbbd3677 Update Solana to 1.9.4
Change-Id: I9c1ce5f25b21ca81599957a7faa730558d8fc03e
2022-02-02 11:31:33 -05:00
Reisen 03aae4a48a terra: fix messenger builds for sdk
Change-Id: Id30399c6a0521621c60f8382f13bd29714e6c116
2022-01-14 14:55:40 -05:00
Reisen e561d6de02 sdk: fixes to types and builds
Change-Id: I10b753450445cc021dbeb9f28ddb0384070e9635
2022-01-14 13:09:12 +00:00
Reisen 982ce08c4a sdk: rustfmt rules for sdk
Change-Id: I43d4252facd6f0c817053e07a35bb74d874064bd
2022-01-14 13:09:12 +00:00
Reisen ee0fea0436 sdk: add underlying sdk for wormhole programs
Change-Id: I858f3e43e6458af51131de9165a63078e4bb024c
2022-01-14 13:09:12 +00:00
Reisen 97566d878a sdk: add core types for wormhole projects
Change-Id: Iabaebb7b4319d5b759044896b2b396d39bda33d7
2022-01-14 13:09:12 +00:00