Commit Graph

62 Commits

Author SHA1 Message Date
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
Ali Behjati 97617cb5ce
Solitaire: Use sysvar for rent instead of default (#1505)
* Solitaire: Use sysvar for rent instead of default

Using default has some risks such as:
- Network having a different values (such as Pythnet)
- Network changes the value

It avoids using default as fallback to have Error more explicitly
avoid exposing above risks under rare conditions
that the sysvar might return Err.

* Update comments

* Format the code
2022-09-30 15:53:02 -05:00
Chirantan Ekbote e377a75e2b solana: run `cargo fmt` 2022-09-20 23:00:47 +09: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
Stan Drozd 2092484e73 solitaire: shrink stack footprint by boxing FromAccounts::from() 2022-08-17 15:30:01 +01:00
Reisen 5da7ad0ef5 solitaire: reduce Claim complexity 2022-07-15 13:12:27 -05:00
Reisen 82ea938317 solitaire: remove recursive FromAccounts and 'c lifetime.
Solitaire parses accounts using two traits, FromAccounts and Peel. The
FromAccounts derive macro generates a function, `FromAccounts::from()`,
which calls `Peel::peel` to construct each field in the struct:

```
let example = Example {
    foo: Peel::peel(next_account_iter(accs)?),
    bar: Peel::peel(next_account_iter(accs)?),
    baz: Peel::peel(next_account_iter(accs)?),
    ...,
}
```

The FromAccounts derivation also attempts to implement Peel for the
structure itself however, which means `Example` itself is embeddable as
a field in another accounts struct. This is only used in ClaimableVAA
which is a large source of confusion and the complexity is not worth
maintaining.

This commit removes the recursion by:

1) Removing the `impl Peel` derived by FromAccounts.
2) Removes the AccountInfo iterator from Context as it is no longer needed.
3) Adds the current parsed account to Context instead, safe thanks to (2)
4) Move message out of ClaimableVAA and pass in to verify everywhere instead.
5) Removes Peel/FromAccounts from ClaimableVAA.
2022-07-15 13:12:27 -05:00
Reisen 4131381fa4 solitaire: remove unused InstructionContext 2022-06-24 13:51:50 +02:00
Reisen a8d1ed129b solitaire: remove unused client code 2022-06-24 13:51:50 +02:00
Reisen 9aad49d631 solitaire: remove unused deps 2022-06-24 13:51:50 +02:00
Csongor Kiss 2e220a6f76
Solana fix warnings (#1226)
* solana: fix all rustc warnings

* solana: fix clippy warnings

* Remove manual memcpy + other warning suppressions

Co-authored-by: Csongor Kiss <ckiss@jumptrading.com>
2022-06-10 17:59:15 +01:00
Csongor Kiss da479cf4c1 solitaire: fix initialisation check 2022-04-21 19:07:15 +01:00
Chirantan Ekbote 3fdd9ccc3e solana: Merge into single workspace
Merge all the separate solana crates into a single workspace.  This is
the same thing we do for terra and will make it easier to check / lint /
test all the crates together.
2022-04-20 09:37:30 +09:00
Csongor Kiss ff15ca3a67 Document AccountState
* Don't use option_env
* Fix 'cargo test' (it was failing on ambiguous module names)
2022-04-11 21:29:39 -04:00
Hendrik Hofstadt 2b56fcc7da solitaire: Fix prefunded accounts blocking creation
Change-Id: I8841e6595b7f8bb217991515bb9ae1ae3d4f4607
2022-04-11 21:29:39 -04:00
Csongor Kiss f60acc59ab
solitaire: Infer entry point argument type in solitaire! macro (#927)
The type of the `ix_data` binding withing the solitaire! macro expansion
is explicitly annotated with its type, which comes from the macro's
pattern binding `$kind`. However, this type annotation is entirely
optional, since `ix_data` is passed in as an argument to `$fn`, whose
type forecs `ix_data` anyway, and rust will happily infer that from the
application. So we remove the explicit annotation which makes the entry
point macro easier to use.

commit-id:d428306c
2022-03-16 18:25:41 +00:00
Stanisław Drozd 2ea41b8176
[WIP] Pr/drozdziak1/p2w batching/5e704f8b (#877)
* ethereum: p2w contract -> p2w emitter, fill in essential envs

Change-Id: I6fa9364a96738d2cc02ec829a31fedba0586d8e8

commit-id:0a56f1f8

* Add p2w-relay, a p2w-sdk integration test

commit-id:6bfab639

* p2w-sdk: Expand README

Change-Id: I17cb547d6aaddc240588923561c26d11a787df2e

commit-id:6ebd6a22

* p2w-sdk: don't build ETH contracts, only the types

Change-Id: I7cbd18328227700635d7688aa24a9671e8919fcd

commit-id:adf079f7

* p2w: configurability and sane envs

commit-id:f10fd90e

* Solitaire: Implement Option<T> support in structs

commit-id:31aa12d6

* bridge/governance.rs: Stop pestering about EMITTER_ADDRESS

commit-id:d5bd7234

* p2w-attest: price batching

This commit introduces support for multiple Pyth product/price pairs
per call. The initial maximum batch size is 5 and is enforced using a
`P2W_MAX_BATCH_SIZE` constant.

solana/pyth2wormhole/program:
* On-chain batching logic
* Batch message parsing logic

solana/pyth2wormhole/client:
* Off-chain batching logic - divides any number of symbols into
largest possible batches
* Use a multi-symbol config file instead of CLI arguments

third_party/pyth/p2w-sdk:
* Expose batch parsing logic

third_party/pyth/p2w-relay:
* Comment out target chain calls until ETH contract supports batching
* Test the batch parsing function

third_party/pyth/p2w_autoattest.py:
* Generate and use the symbol config file  with pyth2wormhole-client

third_party/pyth/pyth_publisher.py:
* Add a configurable number of mock Pyth symbols
* Adjust HTTP endpoint for multiple symbols

commit-id:73787a61

* p2w-attest: mention attestation size in batch

This commit ensures that no matter the attestation format, a batch
will never contain attestations of different sizes. This guarantee
enables forward compatibility by adding new constant-size fields at
the end of a batch at all times. An older implementation will simply
not consume the remaining newer values while respecting the stated
batch member alignment.

commit-id:210da230

* pyth2wormhole-client: use fresh blockhashes, harden batch errors

This commit makes sure we don't have to deal with expired transactions
due to stale blockhashes. The problem existed with larger symbol
configs as well as on Solana mainnet. Additionally, the attestation logic
now treats transaction errors as non-critical - a failure for a batch
does not prevent attestation attempts for batches farther in the queue

commit-id:5e704f8b
2022-02-23 19:12:16 +01:00
Hendrik Hofstadt 7edbbd3677 Update Solana to 1.9.4
Change-Id: I9c1ce5f25b21ca81599957a7faa730558d8fc03e
2022-02-02 11:31:33 -05:00
Reisen 7f1c7ec62f solitaire: expose entrypoint and relax lifetimes
The current lifetimes 'a/'b restrict the &data and &program_id lifetimes which makes the
entrypoint unusable in solana_test_program's processor!() harness, which expects the more
relaxed (but equivelent for us) type of:

    fn processor<'a, 'b: 'a, 'c, 'd>(
      program_id: &'c Pubkey,
      accounts:   &'a [AccountInfo<'b>],
      data:       &'d [u8]
    )

It has no effect on our current programs.

Change-Id: Ia657462141165064c629fdff02b5ec451aab50f0
2022-01-14 13:09:12 +00:00
Stan Drozd 7d6db92c35 pyth2wormhole-client attestation call
Change-Id: I407734b5fcf919f437a0e0a32d2b35e7ec50b999
2021-09-03 17:18:38 +02:00
Stan Drozd 5dbd3ea722 pyth2wormhole: on-chain attestation call, update Pyth-facing types
This commit takes the selected Pyth Price struct account and after
serialization places them inside a PostMessage cross-program
call to Wormhole.

Change-Id: If04123705290f4749de318c0dfaa8f1d840ed349
2021-09-03 17:17:34 +02:00
Hendrik Hofstadt 9a4af890e3 Fix warnings in generated code
Change-Id: I30c0d149b07930a4bf437b74df586ec7f50a3b6a
2021-09-01 18:48:10 +00:00
Hendrik Hofstadt 855e1d6dfa Resolve compiler warnings
Change-Id: I73c560b90ce4318d3aeb37f3dc336141dfef0e94
2021-09-01 17:56:47 +00:00
Stan Drozd f7979ee8b1 solitaire: Mention invalid value in InvalidMutability
Change-Id: I240518737243eb7dabbf8ec31bd11148b4475832
2021-08-31 12:43:58 +00:00
Hendrik Hofstadt a8a8cbe183 👿
if you like it then you should have put a box 'round it

Change-Id: I504dd476f53bb5d0dd101a5278f485e83b32bd08
2021-08-25 19:49:57 +00:00
Stan Drozd 5f52dc6d76 solitaire: Implement Keyed for Mut<T: Keyed>
Change-Id: I6680315db9ac2fe913a85b01b471572047cbe658
2021-08-25 14:51:46 +00:00
Reisen d884f7be17 solitaire: force deserialization into a new stack frame
Change-Id: I5ffe4ed6b831f4ddbad4e36fad31487fcd1765cd
2021-08-24 07:08:48 +00:00
Hendrik Hofstadt a05017c043 Update rust dependencies
Change-Id: Ib587cf608255afc46dcb435a4168e0f8f8cfb8a8
2021-08-23 09:39:36 +02:00
Hendrik Hofstadt f3ef29c8fd Introduce MaybeMut
This fixes issues in places where an account is passed in multiple times both readable and writable

Change-Id: I9e75c6c273b894bf113c8d652a7dd7dcfa32b863
2021-08-12 18:41:36 +02:00
Reisen eafa7e0500 Return to trace! on Dispatch log to undo stack issue
Change-Id: Ica665e89d27585eb6ecfa7df5339413c7703b3a9
2021-08-09 16:52:56 +00:00
Reisen 2f8a73fdda Instruction symbol and error printing in prod builds
Change-Id: I3315c49272473ef3216f26b9dd21f5cfcce6e8ae
2021-08-09 12:33:59 +00:00
Reisen 05aece1f7c Add Metadata to token bridge attestations
Change-Id: Ic1a10978c25fbd916a16bd08eab0b6937c67cd59
2021-08-06 08:24:37 +00:00
Stan Drozd df5b86eded Solitaire: Say what value was passed as wrong instruction id
Change-Id: I4b79ba95ab5a43a197dfdd164b731d37b490a093
2021-07-30 14:00:35 +00:00
Reisen 108a4a2ff9 Remove InstructionContext::verify. Verify in handlers
Change-Id: I661308951de261bff572398b6834523563906907
2021-07-30 13:09:44 +00:00
Hendrik Hofstadt f9eb8a2c0a Implement wasm client for the bridge core
Change-Id: I7931eef27d8b10eaeec00833ab3dc28a57257cdf
2021-07-29 17:27:45 +02:00
Hendrik Hofstadt d33738e179 Make the token bridge work
Change-Id: Ic34f87c09dfaa91d7bf5793e83da9f06abd2fa3f
2021-07-29 17:21:17 +02:00
Reisen db4c0f8f74 Handle Invalid Instructions
Change-Id: I8a6a15b7744e69c7eab88ef50295480bc5fb96ae
2021-07-26 16:09:01 +00:00
Hendrik Hofstadt 80244ae0f3 Drop persistence options on Solana
Change-Id: Ia96672f3f80ec5daa0cce71ffbb69e2c059b3494
2021-07-20 21:00:42 +02:00
Stan Drozd 2f4517e45a Initial pyth2wormhole skeleton with access verification
Change-Id: I5a9d73144797a2f8e091e91ded744fff7d4e370b
2021-07-20 15:05:00 +00:00
Reisen 1cc90e54db Deserialize only the discriminant in the entrypoint.
It would seem that Borsh, when deserializing an enum will consume a
large amount of stack space proportional to the number of discriminants.
This causes the entrypoint to trigger stack frame access violations
during the initial deserialization.

This change uses an enum represented by a u8 instead, and removes the
association between the discriminant and the data. Deserializing the
associated data is now pushed down to within the entrypoint match arms
instead.

Change-Id: I2dcb466bf7820b3344e175ad92988bb89f30cb15
2021-07-20 11:11:28 +00:00
Hendrik Hofstadt af4e29978d Add commitment level to VAAs
This allows requesting attestations for various commitment/confirmation levels. This is helpful for low-latency applications like Pyth.

Change-Id: Ib49ace163365106b227613d2f66b787b3e5f5461
2021-07-19 07:11:45 +00:00
Stanislaw Drozd 844a303b5b Revert "Solitaire: Extend Peel to support CPI re-wrapping"
Revert submission 693

Reason for revert: Moving away from CPI abstraction
Reverted Changes:
I8c252e137:bridge, token_bridge: Use Many<T>
I6a721e8a8:Solitaire: Add an explicit Many<T> type for nested...
Ibdc94b4c6:Solitaire: Serialize CPI accounts as an AccountMet...
Iefa59f5d4:Solitaire: Extend Peel to support CPI re-wrapping

Change-Id: Iab567aea6dca5be1a7bf7efd4b86e0be05d2753c
2021-07-15 13:22:50 +00:00
Stanislaw Drozd cbc5ae3ed1 Revert "Solitaire: Serialize CPI accounts as an AccountMeta vect..."
Revert submission 693

Reason for revert: Moving away from CPI abstraction
Reverted Changes:
I8c252e137:bridge, token_bridge: Use Many<T>
I6a721e8a8:Solitaire: Add an explicit Many<T> type for nested...
Ibdc94b4c6:Solitaire: Serialize CPI accounts as an AccountMet...
Iefa59f5d4:Solitaire: Extend Peel to support CPI re-wrapping

Change-Id: I01733d16862aeac79ad76dff4f58386641488b3e
2021-07-15 13:22:50 +00:00
Stanislaw Drozd f2490339de Revert "Solitaire: Add an explicit Many<T> type for nested structs"
Revert submission 693

Reason for revert: Moving away from CPI abstraction
Reverted Changes:
I8c252e137:bridge, token_bridge: Use Many<T>
I6a721e8a8:Solitaire: Add an explicit Many<T> type for nested...
Ibdc94b4c6:Solitaire: Serialize CPI accounts as an AccountMet...
Iefa59f5d4:Solitaire: Extend Peel to support CPI re-wrapping

Change-Id: I4455479e4a19007893d4cdaac06eece70abfa797
2021-07-15 13:22:50 +00:00
Stan Drozd 6868cc7177 Solitaire: Add an explicit Many<T> type for nested structs
Change-Id: I6a721e8a88652f807f2317cfe4d82be9d629a849
2021-07-14 17:49:56 +02:00
Stan Drozd ee96b6b793 Solitaire: Serialize CPI accounts as an AccountMeta vector from Iter
Change-Id: Ibdc94b4c6359ffef78d3e2313bfee12eef93acc7
2021-07-14 17:41:19 +02:00
Stan Drozd 5827ba7b30 Solitaire: Extend Peel to support CPI re-wrapping
Change-Id: Iefa59f5d4fe36c9f9e2cd0fa997490eba0a1bb44
2021-07-14 17:41:08 +02:00
Reisen 387fcc48c0 Add Mut layer to accounts in bridge program.
Change-Id: I78dfb4568eaec4f597a6d0e1ac10a0f698bb5a61
2021-07-06 12:08:25 +00:00
Reisen 76066c8cc6 Add peel mutability checks for accounts.
Change-Id: Ic6a6fadd13a2b41d60a0c98f3b5d80d23ac263a6
2021-07-06 11:40:13 +00:00
Hendrik Hofstadt cc08a9753c reformat and fix client
Change-Id: Ie99d2b7cc2ed9890432c38661f1035a473cc5ac1
2021-07-02 11:48:48 +00:00