Commit Graph

51 Commits

Author SHA1 Message Date
Chirantan Ekbote 72e3a103b8 cosmwasm: accounting: Identify failed transfer in batch
When we fail to handle an observation in a batch, include the transfer
key as part of the error context so that it's easier to figure out which
observation caused the error.
2023-01-05 16:24:58 +09:00
Chirantan Ekbote 5d8072e3da cosmwasm: accounting: Change error message for duplicate observation
Change the error message when handling duplicate observations from
"message already processed" -> "transfer already committed".
2023-01-04 16:17:54 +09:00
Chirantan Ekbote e3192a09b1 cosmwasm: accounting: Add query for missing observations
Add a query for guardians to check if there are any pending transfers
with missing observations.  The guardians can use this information to
trigger re-observations of those transactions.
2023-01-04 16:17:37 +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
heyitaki b7d870efcb docker: reorganize dockerfiles 2022-12-21 10:58:22 -08:00
Chirantan Ekbote d53085abec cosmwasm: accounting: Include digests in transfer queries
When querying transfer details, return the digest in addition to the
details of the tokens being transferred.
2022-12-21 13:59:01 +09:00
Chirantan Ekbote d6dadb195a cosmwasm: accounting: Remove `InstantiateMsg`
Now that we're keeping track of transfer digests, initializing any on-
chain state through the `InstantiateMsg` doesn't make a lot of sense:
any state initialized this way is unverified and this message doesn't
contain enough information to generate the transfer digests.

Rather than trying to add in the necessary fields, just drop the message
completely since it won't be used in production.  It's currently only
used to initialize on-chain state for tests but the same thing can be
accomplished through the `ModifyBalance` and `SubmitVAAs` methods.
2022-12-21 13:59:01 +09:00
Chirantan Ekbote 29d28a75c0 cosmwasm: accounting: Store transfer digests
Keep track of the digests of committed transfers so that they can be
used later when handling duplicate observations / VAAs.  When processing
an observation or VAA with the same (chain, address, sequence) tuple as
a committed transfer, return a "message already processed" error when
the digests match and a "digest mismatch" error when they don't.  The
latter implies a very serious issue because transfer details shouldn't
change once they have been observed by a quorum of guardians.
2022-12-21 13:59:01 +09:00
Chirantan Ekbote acc3ec14d8 cosmwasm: accounting: Drop dependency on the tokenbridge contract
Now that the accounting contract can handle chain registrations on
its own, there's no need to query the tokenbridge contract.  Remove
references to it from `InstantiateMsg` and the internal state.
2022-12-19 17:14:33 +09:00
Chirantan Ekbote 9a559f3fbd cosmwasm: accounting: Add support for chain registration
Add support for handling chain registration VAAs for the tokenbridge
contract.  This will let us deploy accounting without also having to
deploy the tokenbridge.
2022-12-19 17:14:33 +09:00
Nikhil Suri ee2b6d0c17 cosmwasm: wormhole: remove unecessary cast to usize 2022-12-15 14:51:54 -05:00
Chirantan Ekbote fba2f48dee cosmwasm: accounting: Fix chain registration query return type
The tokenbridge chain registration query returns a
`ChainRegistrationResponse` struct and not a `Vec<u8>`.  Use the proper
return type when sending the query.
2022-12-15 10:01:08 -05:00
Chirantan Ekbote ac9c8cd743 cosmwasm: Add backfill method for accounting
Add a mechanism to backfill missing transfer messages by submitting
signed VAAs.  This will also be used to initialize the on-chain state
as there is too much data to initialize the contract via the normal
`instantiate` mechanism.

Fixes #1883, fixes #1884.
2022-12-15 12:22:37 +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 88549b6849 cosmwasm: accounting: Add ValidateTransfer query
Add a query to validate transfers.  This can be useful for guardians to
sanity check a transfer before submitting a signed observation for it.
2022-12-15 12:21:35 +09:00
Chirantan Ekbote 7cd3e14e99 cosmwasm: accounting: Rename CommitTransferError -> TransferError
This error will also be returned by the `validate_transfer` query so
rename it.
2022-12-15 12:21:35 +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
kev1n-peters 54194b1f64
cosmwasm: Added injective mainnet verify script (#2078) 2022-12-06 16:03:44 +01:00
Chirantan Ekbote 83b473edba cosmwasm: Makefile: Separate unit and integration tests
We already run the unit tests as part of the rust-lint-and-tests CI job
so don't run them again before running the integration tests.
2022-12-02 14:45:24 +00: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
Paul Noel 8d92d23d48
cosmwasm: update verify script (#1936)
* cosmwasm: update script

* scripts: update governance script

* cosmwasm: remove commented code

* cosmwasm: redirect to stderr
2022-11-28 15:24:25 -06:00
Chirantan Ekbote aad0a2bf47 cosmwasm: Override local deps at the workspace level
Put all the local overrides at the workspace level rather than having
to specify the path in each individual crate.  This will also make it
easier for us to publish to crates.io when that time comes.
2022-11-11 09:46:33 -05:00
Chirantan Ekbote 09459fcf9e cosmwasm: tokenbridge: Add chain registration query
Add a query to get the registered emitterr address for a given chain id.
This will be used by accounting.
2022-11-07 08:21:00 -05:00
Chirantan Ekbote 8d6bf74262 cosmwasm: Fix clippy warnings 2022-10-28 14:35:44 -04:00
Chirantan Ekbote dedcea34af cosmwasm: Fix formatting
Also remove the unstable options in rustfmt.toml.  We can re-enable them
once they are stabilized.
2022-10-28 14:35:44 -04:00
Evan Gray 19d9c3a290 ci: quieter terra 2022-10-27 07:52:24 -04:00
kii fbefb3aced
tob-worm-4-panics: using options rather than unwrap & tob-worm-9: cosmwasm test build (#1672)
* tob-worm-4-panics: using options rather than unwrap

* removed mock dependencies argument

* added test to make file

* use ok or else

* fmt

* ok

* errors resolved
2022-10-26 12:39:31 -04:00
Evan Gray 6c6661f621 js: make packages comply with ci rule 2022-10-20 17:11:13 -05:00
Hendrik Hofstadt 4a2fbd923f
tilt: shorten terra block time (#1744)
Change-Id: I35cce03ae6e82b522482f2c1c40ccb6819eb51f6
2022-10-17 18:13:19 +02:00
Csongor Kiss 3877f6f3c3 tilt: register aptos on other chains 2022-10-15 15:17:36 +01:00
Evan Gray 346f2f4e0e cosmwasm: comment terra2 migration so tests pass 2022-10-12 17:20:34 -04:00
Evan Gray 3a37db8b98 cosmwasm: support natives over 8 decimals 2022-10-12 17:20:34 -04:00
bruce-riley 67f57b797e
XPLA Mainnet Deploy (#1703)
* Prepare to deploy Xpla to mainnet

* Update SDK version

* Fix messed up error message

* Allow tests to pass with no XPLA tokens

* Make deploy script support testnet

* Update token bridge addresses after redeploy
2022-10-12 16:47:03 -04:00
Chirantan Ekbote f7eb26124c cosmwasm: byte_utils: Clean up padding functions
You don't need multiple heap allocations just to left-pad or right-pad a
buffer.  Also add tests.
2022-10-07 09:41:32 +09:00
Chirantan Ekbote 7f4b0d1a09 Wormhole chain integration
This is a squashed commit of all the changes needed to integrate
wormhole chain into the main repo.
2022-10-03 17:34:42 +09:00
kev1n-peters c5d2f9d54d
sdk/js: Near refactor, added integration tests (#1648)
* near-sdk-refactor: Fix attest
                 : Fix missing function calls
                 : make near on near
                 : renamed tryHexToNativeStringNear

* near-sdk-refactor: bumped near-sdk-js version

Co-authored-by: Josh Siegel <jsiegel@jumptrading.com>
2022-09-28 08:53:15 -05:00
Paul Noel e2575550e8 cosmwasm/tools: fix tilt 2022-09-27 07:58:28 -05:00
Paul Noel eb42bc48e7 cosmwasm/test: add integration tests 2022-09-27 07:58:28 -05:00
Csongor Kiss c22d0c222b cosmwasm: Add shutdown feature flag to token bridge 2022-09-27 07:58:28 -05:00
Csongor Kiss 650beaa79a solana/terra: delete generate_governance
These are superseded by the more general script `scripts/contract-upgrade-governance.sh`
2022-08-24 16:27:04 +02:00
Csongor Kiss d10072a33e cosmwasm: Add is_vaa_redeemed query to token bridge 2022-08-22 16:30:23 +02:00
Csongor Kiss f50586ad86 cosmwasm: move chain id and fee denom to storage
Prior to this change, these values were hardcode in the contract, as
the only supported chain was terra 2. This change allows the contract to
be deployed to other cosmwasm chains without having to recompile the
contract for each one.

The migration code ensures that terra2 is upgraded appropriately.
2022-07-20 16:09:39 -04:00
claudijd 8221708ef0 Move from ADD to COPY on Dockerfiles 2022-07-13 09:27:15 -04:00
Evan Gray 3d373669e5 cosmwasm: test update foreign asset 2022-06-22 13:24:46 -04:00
Csongor Kiss c7a9d5ca8b cosmwasm: make storage key constants private 2022-06-22 13:24:46 -04:00
Csongor Kiss ea1eea99dd cosmwasm: fix sequence number in storage 2022-06-22 13:24:46 -04:00
Csongor Kiss d3a1fa99d9
cosmwasm: Add fromAddress to payload 3 (#1292)
* cosmwasm: fix some clippy warnings

* cosmwasm: remove fee and add msg.sender to payload 3

* cosmwasm: fix payload 3 parsing test

* cosmwasm: fix fixed payload 3 parsing test

* cosmwasm: fix fixed fixed payload 3 parsing test

* cosmwasm: update payload tests

Co-authored-by: Csongor Kiss <ckiss@jumptrading.com>
Co-authored-by: Evan Gray <battledingo@gmail.com>
2022-06-21 17:30:33 -04: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 13780dba51 cosmwasm: cw20_base.wasm 0.13.4 2022-06-21 10:03:57 -04:00