Commit Graph

47 Commits

Author SHA1 Message Date
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
Reisen af00a3c02a Use trace! inside solitaire
Change-Id: Ic26fcabbb6d6000b306d190aab306307ab9cda7f
2021-07-01 09:35:03 +00:00
Reisen 18e52aafe6 Add tracing log macro that defaults to noop
Change-Id: I5ae1cf9e539a08aa9d820e3bf643a311b2f9080e
2021-07-01 09:35:03 +00:00
Reisen 21c7399d55 Return errors in Data peeling
Change-Id: I3e0ae581e83ebbcf0d343b758dff033ddc9b362e
2021-07-01 06:16:59 +00:00
Stan Drozd 5e7e4d4e48 Solitaire: Enforce the "client" feature in dependees
Change-Id: I55da10bde41f84e91c5754a89eb4239967117e67
2021-06-29 15:35:14 +00:00
Stan Drozd 79d82d1226 Solitaire: use "client" as superset of "no-entrypoint", logging
Change-Id: Ie846b9abd783fe041f2cfa9aeda962003ffe1441
2021-06-28 13:01:43 +02:00
Stan Drozd 60a1acf351 solitaire: Wrap for Info, auto Wrap for data_wrapper()
Change-Id: I5cc0ba7870e140a2acf77b8fc8814ee953f56b51
2021-06-28 13:00:41 +02:00
Hendrik Hofstadt d677311d70 Fix build caching and initial devnet setup steps
Change-Id: I6df841c90f93585f0146b0de65883dd101e45bc9
2021-06-23 17:06:11 +02:00
Reisen 16f7e156ae Fix Derivation issues for PostVAA accounts.
Change-Id: Ia08003dc8aadfe3963598c81745813e6e09e5d3a
2021-06-23 11:02:42 +00:00
Reisen a28540de0d Test VerifySignatures.
Change-Id: I430b4676706371bbcf61368a83ff4946d9db2202
2021-06-23 11:02:42 +00:00
Reisen c2c2e7f13d Integration Test for PostVAA without working Signatures
Change-Id: Ib5c93986cdac88678657b254522422ab5231a856
2021-06-23 11:02:42 +00:00
Reisen 146b368fc0 Fix accounts required for calling Initialize/PostMessage
Change-Id: Ide3fa8401bac6b1b05bc4c5ec1f552a98178ad06
2021-06-23 11:02:42 +00:00
Hendrik Hofstadt aa909c218f Restructure workspace
This will make is easier to separate modules and solitaire in the future.
We also get rid of the old bridge code.

Change-Id: I4d663c36739dfec77cd5d3f1ed6b51f422fe0c91
2021-06-21 10:24:52 +02:00