Commit Graph

70 Commits

Author SHA1 Message Date
Stanisław Drozd afd4a8be91
wormhole-attester: Add a histogram metric for tx processing duration (#434)
This adds buckets between 16ms and 65.536 seconds. In tilt, most
attestation txs fall between 256 and 1024 milliseconds.
2022-12-20 11:53:51 +01:00
Stanisław Drozd d517f11af0
[wormhole-attester] Add a healthcheck on the metrics port (#429)
* wormhole attester: Add a healthcheck on the metrics port

* pyth2wormhole healthcheck: apply review advice

- Move metrics/healthcheck counter updates to be next to each other
- Change "0-sized window disables healthcheck" into an explicit config value
- move healthcheck updates past the atomic counter updates
2022-12-15 18:29:23 +01:00
Ali Behjati 0d2f60cf28
[attester] Bump version for new release (#414) 2022-12-06 17:03:16 +01:00
Jayant Krishnamurthy 15708d552d
Fix formatting for new nightly rust (#415)
Co-authored-by: Jayant Krishnamurthy <jkrishnamurthy@jumptrading.com>
2022-12-05 10:02:58 -08:00
Ali Behjati df3297e430
[attster] Remove while true and wait instead (#411) 2022-12-05 18:34:31 +01:00
Jayant Krishnamurthy 3beffdfe46
Configure symbol groups by name (#403)
* Refactor to make this change easier

* stop mutating AttestationConfig

* get the product names also

* ok

* refactor

* cleanup

* more cleanup

* more cleanup

* comment

* i think this works

* fix stuff

* clippy

* more cleanup

* main

* main

* fix formatting

* blah

* test

* cleanup

* fix python

* config

* fix test

* grr

* grr

* comments

Co-authored-by: Jayant Krishnamurthy <jkrishnamurthy@jumptrading.com>
2022-12-02 09:35:33 -08:00
Ali Behjati 8d9a707b48
Remove seq output log and py server for that (#408)
Co-authored-by: Stanisław Drozd <stan@nexantic.com>
2022-12-01 18:30:34 +01:00
Ali Behjati 51514dcd9b
Add clippy to all rust projects (#400) 2022-11-28 18:22:48 +01:00
Stanisław Drozd bbe35df8cf
drozdziak1/pyth attester prometheus metrics (#396)
* Add prometheus to Tilt with attester metrics

* Dockerfile.prometheus: re-add after faulty merge

* p2w-attest: Clarify port number, remove subpage config

* p2w-attest/util.rs: fix warnings

* p2w-attest: typo
2022-11-25 16:35:32 +01:00
Ali Behjati becc216853
Abehjati/repo-improvement (#395)
* Use a new rustfmt file

* Run cosmwasm action only when needed

* Remove pre-commit from remote-executor action

* Fix formatting

* Run precommit for all files

As previous PR was merged without pre-commit
2022-11-25 11:16:58 +01:00
Ali Behjati d6e25d9209
Add pre-commit globally (#393)
* Add pre-commit globally

* Fix CI errors
2022-11-24 14:14:29 +01:00
Stanisław Drozd b1afaacabf
drozdziak1/pyth attester rpc timeout fix (#391)
* pyth2wormhole-client: Stagger attestation sched jobs

* pyth2wormhole-client 1.0.0-rc1

This is an initial semver release for the pyth2wormhole-client package.

* p2w_autoattest.py: Add env for atteser --timeout option

* pyth-attesster v1.0.0-rc2

* pyth-attester-v1.0.0-rc3

This fixes a typo in p2w_autoattest.py

* pyth-attester-v1.0.0
2022-11-18 14:00:44 +01:00
Stanisław Drozd 3eb2beabe7
Drozdziak1/p2w attest cont mapping reload (#330)
* pyth2wormhole-client: automatically crawl mapping based on interval

* Make the mapping crawl automation seamless

* pyth2wormhole-client: Make mapping crawling routine more robust

This change takes care of recoverable mapping crawling
errors (e.g. malformed single price on single product is no longer
dropping otherwise good different prices and products in the mapping
in favor of a warn message)

* pyth2wormhole-client: Move mapping crawl sleep near logic it affects

* pyth2wormhole-client: remove stray comment

* pyth2wormhole: Fix faulty merge with master

* pyth2wormhole-client: Fix mapping crawl price counting

* pyth2wormhole-client: split daemon/non-daemon, improve readabi[...]

...lity and remove most warnings

* pyth2wormhole-client: parts-per-thousand -> base points

* pyth2wormhole-client: inaccurate comment

* p2w-client: review advice - bp -> bps, std hasher -> sha256

* pyth2wormhole-client: reuse message queue across mapping lookups
2022-10-24 17:19:25 +02:00
Ali Behjati b05a63fe5a
[attestation-cli] Fix corner case of product with no price (#351)
* Fix corner case of product with no price
2022-10-18 16:32:44 +02:00
Stanisław Drozd 6407eaa244
pyth2wormhole-client:should_resend(): optimize interval-only batches (#338)
* pyth2wormhole-client:should_resend(): optimize interval-only batches

Most attestation conditions in prod are interval-only. This change
ensures that interval-only batches don't waste time on the on-chain
state lookup request.

* pyth2wormhole: Fix build error, redundant new_symbol_states decl

* pyth2wormhole-client: is_onchain -> needs_onchain_lookup

* pyth2wormhole-client: typo
2022-10-10 20:57:23 +02:00
Stanisław Drozd 44559109f0
p2w-client: Remove --log-level, rely on RUST_LOG, provide default (#333) 2022-10-10 13:25:19 +02:00
Stan Drozd 660160b31a
pyth2wormhole-client: Switch to multi-threaded tokio runtime 2022-10-06 19:04:31 +02:00
Stanisław Drozd ef37c86b32
p2w-client: move rpc_interval to config, test fast rate accuracy (#334) 2022-10-06 17:44:26 +02:00
Stanisław Drozd c81a420a79
pyth2wormhole/migrate: add pythnet rent adjustment (#315)
* pyth2wormhole/migrate: add pythnet rent adjustment

* p2w/migrate: leave a note about rent calculation
2022-10-04 13:13:14 +02:00
guibescos 16bdc0f4c3
Guibescos/cli for attester admin (#314)
* Add payload generators

* Executor cli no longer a lib

* Expose instructions in client

* Format

* Cli

* Fix CI

* Fix CI, second try

* Fix CI, second try

* Fix CI, third try

* Fix CI, foruth try

* Remove pythnet from dockerfile wasm

* Test

* Revert "Test"

This reverts commit ffa702b249f821aee0a781b680bdf51d038859cf.
2022-09-29 15:24:47 -05:00
guibescos c4238c7a91
Guibescos/expose attester instructions (#313)
* Add payload generators

* Executor cli no longer a lib

* Expose instructions in client

* Format
2022-09-29 09:15:42 -05:00
Stanisław Drozd c9b4a34ae4
pyth2wormhole-client: fix mapping_addr default for attestation config (#306) 2022-09-27 14:44:31 +02:00
Stanisław Drozd b59bd702c2
p2w: Monitor and realloc() + rent adjuist on cfg account size change (#305)
* p2w: Monitor and realloc() + rent adjuist on cfg account size change

* p2w/set_config: reorder data assignment and realloc()
2022-09-27 08:53:59 +02:00
Ali Behjati bc48a31576
Fixing some bugs on clap and processing logic (#299) 2022-09-22 15:04:00 +02:00
Ali Behjati 77083cf760
Attestation: Add ops owner and set-is-active ix (#295)
* Attestation: Add ops owner and set-is-active ix

* Update solana/pyth2wormhole/client/src/cli.rs

Co-authored-by: Stanisław Drozd <stan@nexantic.com>

* Fix typos

* Add a test without owner

Co-authored-by: Stanisław Drozd <stan@nexantic.com>
2022-09-21 21:14:23 +02:00
Stanisław Drozd fdafbe32a4
Drozdziak1/p2w client use mapping crawl (#294)
* p2w-client: Add attestation config merging logic

This change adds code to append new symbols to an existing attestation
config. In conjunction with the mapping crawling logic, this will aid
in hot reloading attestation configs in runtime

* pyth2wormhole-client: Use the crawled mapping symbols
2022-09-21 16:49:37 +02:00
Stanisław Drozd 163fa44f24
Drozdziak1/p2w client mapping crawl (#286)
* pyth2wormhole-client: Add a mapping crawling routine

* pyth2wormhole-client: Add mapping_addr for attestation config

* pyth2wormhole-client: cargo fmt
2022-09-21 10:38:17 +02:00
Ali Behjati bd90203cdf
Fix a bug in the id of price attestation (#273) 2022-09-07 14:57:15 +02:00
Stanisław Drozd 15f3175f91
p2w: Make commitment usage consistent (#270)
This changeset adjusts p2w_autoattest.py commitment to confirmed and
fixes a get_transaction() failure that happened due to the upstream
default finalized commitment setting (RpcClient's set value is not
used). This is fixed by using the chosen commitment explicitly via
get_transaction_with_config()
2022-09-06 16:21:02 +02:00
Stanisław Drozd 94aab8af8f
Drozdziak1/p2w init rent adjustment (#269)
* pyth2wormhole: add rent adjustment to the initialize() instruction

* pyth2wormhole migrate(): Leave a note about rent adjustment

The migrate() ix won't be called in the nearest future - it does not
make sense to bloat the program bytecode with the rent adjustment. The
note describes the what and why in detail.
2022-09-06 16:06:07 +02:00
Stanisław Drozd aa7be4d1be
Drozdziak1/p2w client error logging and docker caching (#268)
* p2w-client: Fix silent logs, restore program log printing

For some time now, p2w-client error reporting would fail to show
daemon mode errors. The logs would only mention resends without ever
showing failed attempts.

with solana-program 1.10.31 came a newer, inferior program log
reporting which only says "N program logs" instead of saying what they
are. This changeset prints errors verbatim using formatted debug
"{:#?}" syntax.

* Docker: Improve p2w-attest/solana-devnet caching

This commit speeds up caching in two ways:

1. By severing the dependency on bridge-client in
Dockerfile.p2w-attest - mainly because of unnecessary `cargo install`
builds which even with target dir caching can take ~1 minute. The
bridge/token-bridge client binaries are not useful to p2w-client anyway.

2. By attaching cargo-install commands to a target dir cache via the
--target-dir option in cargo
2022-09-05 17:00:24 +02:00
Ali Behjati 5c48dacee0
Hack the rent exempt bug (#265)
* Hack the rent exempt bug

* Fix compile bug

* Fix account resize potential problem

* Use invoke transfer instead of playing with lamports
2022-09-05 13:32:41 +02:00
Ali Behjati 19e34f5c00
Fix bugs related to P2WMessage being owned by wormhole (#266)
* Fix caused by wormhole owning P2WMessage

* Refactor the code

* Comment the integration test

It seems that solana test suite has bug,
An error occurs after tx is finished successfully. Also,
it appears as a segfault for Reisen.

* Add more comments

* Add manual check for seeds

* Add more comments

* minor comment change

* Improve comments
2022-09-05 12:36:59 +02:00
Stanisław Drozd 19047c13b4
p2w-client: add get-emitter for printing emitter address (#267)
* p2w-client: add get-emitter for printing emitter address

* Move get-emitter before CLI checks
2022-09-05 12:01:12 +02:00
Ali Behjati b4c8f2e470
Refactor our CW contract + cleanups (#262)
* Use the cw sdk

* Fix clippy warnings

* Use Addr instead of String

* Format the code (cargo +nightly fmt)

* Depend on wormhole git instead of local dependency

* Add error enum

* refactor

* Refactor errors

* certusone->wormhole-foundation rename

It will fix some compile problems

* Build wormhole contract from their repo

* remove wormhole package

* Remove memmap2 patch

It was not needed anymore with the newer
verison of solana (wormhole removed it too)

* Rename pyth-bridge to pyth-cosmwasm
2022-09-02 12:39:51 +02:00
Stanisław Drozd 6382f540db
Wormhole message reuse via post_message_unreliable (#261)
* pyth2wormhole: Implement reusable message PDAs

This changeset converts attest() to use a new PDA for
reusable/unreliable wormhole message account. Each PDA is tied to a
given attest() payer with an index that lets them rotate a number of
message accounts. Keeping the appropriate timing of the reuses is up
to the message owner, who should rotate a number of PDAs.

* pyth2wormhole-client: Add a message acc rotation impl

* p2w attest(): Integrate with bumped wormhole and fix call issues

* p2w-client: Format code, fix test_attest, refactor message index

* Dockerfile.client, Dockerfile.p2w-attest: Improve caching

The main improvement comes from running cargo-install from within a
workspace which lets us cache target/

* p2w-client: Make reusable messages configurable in yaml

* p2w on-chain: refactor to unreliable-only, adjust msg balance, nits

* p2w-client: P2WMessageIndex -> P2WMessageQueue, queue tests

* p2w-client: Add a hard limit to the message account queue
2022-09-01 18:47:24 +02:00
Stanisław Drozd a2a0f6e15b
Start depending on the upstream out-of-tree Wormhole (#258)
* Add out-of-tree dependency on wormhole v2.8.9

This lets us outsource all wormhole/solitaire code to the upstream
certusone repo

* Docker.client: Use cargo-install to install binaries from github

* p2w: fix solana-program wasm-bindgen

* pyth2wormhole: Fix code-level errors against newer solitaire

* p2w: Use upstream wormhole rust code, bump guardian to 2.8.9

* guardian: ensure solana is on, spy: bump image to 2.8.9

Co-authored-by: Reisen <reisen@morphism.org>
2022-08-29 16:18:41 +02:00
Jayant Krishnamurthy b485ef4d16
Use Confirmed confirmation level instead of Finalized (#256)
Co-authored-by: Jayant Krishnamurthy <jkrishnamurthy@jumptrading.com>
2022-08-29 11:23:17 +02:00
Stanisław Drozd 130c0522f0
pyth2wormhole: Fix a cfg migration bug, fix cfg lockout (see below) (#253)
This commit resolves a runtime problem in migrate() which occurred on devnet, as
well as invalid mutability for the old config and misuse of the
checked_sub() method.

The runtime problem came from a non-zero balance existing on
not-yet-used PDA. Effectively, this means permissionless
initialization of PDAs on Solana. Anyone can send lamports to any
account on Solana (existing or not), and it doesn't take much funds to
keep an empty account exempt. While it is possible to recover from it,
this case is relatively rare and takes a lot of code to
automate. Instead, we settle for a dumb bump of the config PDA
seed (see config.rs).

This measure is best used sparingly, as it imposes the same static
seed on all SOL networks. This will cause headaches if the attester
tooling grows a third-party user base.
2022-08-19 08:45:47 -07:00
Ali Behjati 07bf9dbee2
Abehjati/use-cw-1-for-contracts (#240)
* Bump version of cw packages from 0.16.0 to 1.0.0

* Fix build

* Update wormhole details

* Update js packages

* Update dockers, configs, to use cosmwasm 2 in tilt

* Update wormhole and pyth addresses everywhere

The migration file is probably not necessary for us.
To be deleted later.

* Update gh action name
2022-07-20 16:35:01 +02:00
Stanisław Drozd f0552e5f1b
pyth2wormhole-client: refactor into fully-async futures-based approach (#219)
* pyth2wormhole-client: refactor into fully-async futures-based approach

commit-id:2ed35045

* p2w-client: Change inconsistent rpc constructor

commit-id:cb3b2ff2

* p2w-client: Move job creation to a function, simplify comment

commit-id:35328b38

* pyth2wormhole-client: Use get_multiple_accounts

commit-id:7fc85157

* Implement a rate-limited mutex for RPC client

commit-id:1a243063

* pyth2wormhole-client: only guard beginning new requests in RLMutex

commit-id:d8251474

* pyth2wormhole-client: RLMutex: ensure the inner guard is not dropped

commit-id:c3513f5e

* pyth2wormhole-client: Clarify attestation_sched_futs comment

commit-id:97033670

* pyth2wormhole-client: Use CommitmentConfig's native FromStr parsing

commit-id:835d7125

* pyth2wormhole-client: doc comment typo

commit-id:5ee388de

* pyth2wormhole-client: move closures to their own async functions

This makes the main.rs async attestation routines easier to read.

commit-id:3565a744

* pyth2wormhole-client: fix merge typo

* pyth2wormhole-client: Apply Tom's readability advice

* pyth2wormhole-client reword attestation_sched_job() comment

* pyth2wormhole-client: expand attestation_sched_job() comment

* pyth2wormhole-client:   e  x  p  a  n  d   the comment

* Trigger CI

* p2w-client/main.rs: correct missing awaits after merge
2022-07-18 14:40:03 +02:00
Stanisław Drozd 9dbfbd4174
[WIP] p2w-client: Implement a migrate command and instruction generator (#232)
* p2w-client: Implement a migrate command and instruction generator

* Fix minor bug in gen_migrate_tx

* Fix migration test and add a test for success

Co-authored-by: Ali Behjati <bahjatia@gmail.com>
2022-07-13 15:57:16 +02:00
Stanisław Drozd bbad8fb544
pyth2wormhole: Add an is_active flag to on-chain config (#224)
* pyth2wormhole: Add an is_active flag to on-chain config

This new flag will help enable/disable attester contracts between deployments

* p2w-client: typo

* p2w-client: add is_active to init

* pyth2wormhole config.rs: mention removing old structs, reword

* pyth2wormhole: remove unused config data struct from migrate()

* pyth2wormhole migrate(): leave a note about AccountState::Uninitialized

* Update solana/pyth2wormhole/program/src/migrate.rs

Co-authored-by: Reisen <Reisen@users.noreply.github.com>

* Update solana/pyth2wormhole/program/src/migrate.rs

Co-authored-by: Reisen <Reisen@users.noreply.github.com>

* Update solana/pyth2wormhole/program/src/migrate.rs

Co-authored-by: Reisen <Reisen@users.noreply.github.com>

* p2w program: missing deref typo

Co-authored-by: Reisen <Reisen@users.noreply.github.com>
2022-06-22 13:37:15 +02:00
Stanisław Drozd c613271a93
Bump Solana to v1.10.13, bump borsh to v0.9.3, bump clap to v3.18 (#210)
* Bump Solana to v1.10.13, bump borsh to v0.9.3, bump clap to v3.18

commit-id:519b2a6d

* p2w-sdk/rust: update Cargo.lock

commit-id:b7945666
2022-05-17 08:53:30 +02:00
Stanisław Drozd c9ef5ec365
p2w-client: Implement basic unwindowed stats + change SOL commitment to Confirmed (#208)
This commit adds TPS, success/error rates and average same-batch
resend delays.

commit-id:e73abcf5
2022-05-16 13:40:30 +02:00
Stanisław Drozd 941017de4b
p2w-client: Implement additional trigger conditions (#207)
* p2w-client: Implement additional trigger conditions

From now on, we support price change by a given percentage as well as
publish time changes for triggering attestations.

commit-id:9bd145e1

* p2w-client: Harden price_pct_change for negative values

commit-id:cb679208

* p2w-client: Make sure we always update each symbol's state

commit-id:27f276dc

* p2w-client: include resend state lookups in the RPC interval setting

commit-id:68de125f

* p2w-client: Improve local symbol state handling, min interval=60s

With this change, we update local state only if we meet a
condition. Additionally, the publish_time change becomes a
configurable minimal delta.

commit-id:f8139cd6

* p2w-client: Fix a state update bug for state updates

commit-id:29f44a39
2022-05-12 14:39:49 +02:00
Stanisław Drozd 7b1dbc1938
p2w-client: Move batch state to a new module, harden status access (#205)
* p2w-client: Move batch state to a new module, harden status access

commit-id:8265cb5b

* Trigger CI

commit-id:be75d126
2022-05-11 18:02:59 +02:00
Stanisław Drozd a1e50ae636
Drozdziak1/p2w client sym groups (#199)
* pyth2wormhole-client: Implement and use daemon mode

commit-id:7001bdf7

* pyth2wormhole-client: harden CLI, simplify attestation loop

commit-id:ad5e4857

* pyth2wormhole-client: Refactor symbol config into groups

This commit implements the notion of a symbol group - a collection of
symbols that are attested according to the specified set of
condition. Currently, only an attestation frequency is supported. In
the future, this value will serve as a fallback for symbols that
rarely trip other conditions.

commit-id:cf19cc41

* p2w_autoattest.py: Use symbol groups in config

commit-id:1153c5f7

* Dockerfile.client: bump toolchain version to mitigate compiler error

The previous compiler version encountered a bug when building
pyth2wormhole-client for testing. The error message mentioned serde,
which is tested inside the `attestation_cfg.rs` module.

commit-id:61c12427

* p2w_autoattest.py: Add another test group

commit-id:2e29583c

* p2w-client: Get rid of sent_at, clarify messages, add status setter

commit-id:87653ab1
2022-05-06 18:29:47 +02:00
Stanisław Drozd 35912e874e
p2w-attest contract: disambiguate set-config types (#201)
* p2w-attest contract: disambiguate set-config types

commit-id:999f3954

* p2w-attest set-config: also print the same mismatched value

commit-id:732e2773
2022-05-05 13:40:02 +02:00
Stanisław Drozd 97ebef0c6c
pyth2wormhole-client: Implement and use daemon mode (#192)
* pyth2wormhole-client: Implement and use daemon mode

commit-id:7001bdf7

* pyth2wormhole-client: harden CLI, simplify attestation loop

commit-id:ad5e4857

* pyth2wormhole-client: Use requires_if for batch_interval/daemon

commit-id:0da03fd5
2022-05-02 13:08:03 +02:00