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.
This commit is contained in:
guibescos 2022-09-29 15:24:47 -05:00 committed by GitHub
parent 89cc35d3a0
commit 16bdc0f4c3
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 466 additions and 31 deletions

View File

@ -36,6 +36,7 @@ RUN mv wormhole-${WORMHOLE_REV} wormhole
ADD solana solana
ADD pythnet pythnet
ADD third_party/pyth/p2w-sdk/rust third_party/pyth/p2w-sdk/rust
RUN mkdir -p /opt/solana/deps

View File

@ -191,7 +191,7 @@ if pyth:
docker_build(
ref = "p2w-attest",
context = ".",
only = ["./solana", "./third_party"],
only = ["./solana", "./third_party", "./pythnet"],
dockerfile = "./third_party/pyth/Dockerfile.p2w-attest",
ignore = ["./solana/*/target"],
)

View File

@ -95,6 +95,167 @@ dependencies = [
"alloc-no-stdlib",
]
[[package]]
name = "anchor-attribute-access-control"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "70f6ee9518f50ff4d434471ccf569186022bdd5ef65a21d14da3ea5231af944f"
dependencies = [
"anchor-syn",
"anyhow",
"proc-macro2 1.0.38",
"quote 1.0.18",
"regex",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-account"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "32c92bcf5388b52676d990f85bbfd838a8f5672393135063a50dc79b2b837c79"
dependencies = [
"anchor-syn",
"anyhow",
"bs58 0.4.0",
"proc-macro2 1.0.38",
"quote 1.0.18",
"rustversion",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-constant"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0844974ac35e8ced62056b0d63777ebcdc5807438b8b189c881e2b647450b70a"
dependencies = [
"anchor-syn",
"proc-macro2 1.0.38",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-error"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0f7467345e67a6f1d4b862b9763a4160ad89d18c247b8c902807768f7b6e23df"
dependencies = [
"anchor-syn",
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-event"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8774e4c1ac71f71a5aea7e4932fb69c30e3b8155c4fa59fd69401195434528a9"
dependencies = [
"anchor-syn",
"anyhow",
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-interface"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "90eeb6e1c80f9f94fcef93a52813f6472186200e275e83cb3fac92b801de92f7"
dependencies = [
"anchor-syn",
"anyhow",
"heck 0.3.3",
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-program"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ac515a7a5a4fea7fc768b1cec40ddb948e148ea657637c75f94f283212326cb9"
dependencies = [
"anchor-syn",
"anyhow",
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
]
[[package]]
name = "anchor-attribute-state"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "43dc667b62ff71450f19dcfcc37b0c408fd4ddd89e8650368c2b0984b110603f"
dependencies = [
"anchor-syn",
"anyhow",
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
]
[[package]]
name = "anchor-derive-accounts"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7354d583a06701d24800a8ec4c2b0491f62581a331af349205e23421e0b56643"
dependencies = [
"anchor-syn",
"anyhow",
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
]
[[package]]
name = "anchor-lang"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ff5f57ec5e12fa6874b27f3d5c1f6f44302d3ad86c1266197ff7611bf6f5d251"
dependencies = [
"anchor-attribute-access-control",
"anchor-attribute-account",
"anchor-attribute-constant",
"anchor-attribute-error",
"anchor-attribute-event",
"anchor-attribute-interface",
"anchor-attribute-program",
"anchor-attribute-state",
"anchor-derive-accounts",
"arrayref",
"base64 0.13.0",
"bincode",
"borsh",
"bytemuck",
"solana-program",
"thiserror",
]
[[package]]
name = "anchor-syn"
version = "0.25.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "55aa1e680d9471342122ed5b6bc13bf5da473b0f7e4677d41a6954e5cc8ad155"
dependencies = [
"anyhow",
"bs58 0.3.1",
"heck 0.3.3",
"proc-macro2 1.0.38",
"proc-macro2-diagnostics",
"quote 1.0.18",
"serde",
"serde_json",
"sha2 0.9.9",
"syn 1.0.94",
"thiserror",
]
[[package]]
name = "ansi_term"
version = "0.12.1"
@ -106,9 +267,9 @@ dependencies = [
[[package]]
name = "anyhow"
version = "1.0.57"
version = "1.0.65"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08f9b8508dccb7687a1d6c4ce66b2b0ecef467c94667de27d8d7fe1f8d2a9cdc"
checksum = "98161a4e3e2184da77bb14f02184cdd111e83bbbcc9979dfee3c44b9a85f5602"
[[package]]
name = "arrayref"
@ -277,7 +438,7 @@ dependencies = [
"cc",
"cfg-if",
"constant_time_eq",
"digest 0.10.3",
"digest 0.10.5",
]
[[package]]
@ -305,6 +466,12 @@ version = "0.2.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "8d696c370c750c948ada61c69a0ee2cbbb9c50b1019ddb86d9317157a99c2cae"
[[package]]
name = "boolinator"
version = "2.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "cfa8873f51c92e232f9bac4065cddef41b714152812bfc5f7672ba16d6ef8cd9"
[[package]]
name = "borsh"
version = "0.9.3"
@ -371,12 +538,29 @@ dependencies = [
"alloc-stdlib",
]
[[package]]
name = "bs58"
version = "0.3.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "476e9cd489f9e121e02ffa6014a8ef220ecb15c05ed23fc34cca13925dc283fb"
[[package]]
name = "bs58"
version = "0.4.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "771fe0050b883fcc3ea2359b1a96bcfbc090b7116eae7c3c512c7a083fdf23d3"
[[package]]
name = "bstr"
version = "0.2.17"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba3569f383e8f1598449f1a423e72e99569137b47740b1da11ef19af3d5c3223"
dependencies = [
"lazy_static",
"memchr",
"regex-automata",
]
[[package]]
name = "bumpalo"
version = "3.9.1"
@ -552,7 +736,7 @@ version = "3.1.18"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "25320346e922cffe59c0bbc5410c8d8784509efb321488971081313cb1e1a33c"
dependencies = [
"heck",
"heck 0.4.0",
"proc-macro-error",
"proc-macro2 1.0.38",
"quote 1.0.18",
@ -823,9 +1007,9 @@ dependencies = [
[[package]]
name = "digest"
version = "0.10.3"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f2fb860ca6fafa5552fb6d0e816a69c8e49f0908bf524e30a90d97c85892d506"
checksum = "adfbc57365a37acbd2ebf2b64d7e69bb766e2fea813521ed536f5d0520dcf86c"
dependencies = [
"block-buffer 0.10.2",
"crypto-common",
@ -1324,6 +1508,15 @@ dependencies = [
"ahash",
]
[[package]]
name = "heck"
version = "0.3.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6d621efb26863f0e9924c6ac577e8275e5e6b77455db64ffa6c65c904e9e132c"
dependencies = [
"unicode-segmentation",
]
[[package]]
name = "heck"
version = "0.4.0"
@ -1348,6 +1541,12 @@ dependencies = [
"serde",
]
[[package]]
name = "hex-literal"
version = "0.3.4"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7ebdb29d2ea9ed0083cd8cece49bbd968021bd99b0849edb4a9a7ee0fdf6a4e0"
[[package]]
name = "histogram"
version = "0.6.9"
@ -1370,7 +1569,7 @@ version = "0.12.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c49c37c09c17a53d937dfbb742eb3a961d65a994e6bcdcf37e7399d0cc8ab5e"
dependencies = [
"digest 0.10.3",
"digest 0.10.5",
]
[[package]]
@ -2149,7 +2348,7 @@ version = "0.10.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "271779f35b581956db91a3e55737327a03aa051e90b1c47aeb189508533adfd7"
dependencies = [
"digest 0.10.3",
"digest 0.10.5",
]
[[package]]
@ -2259,6 +2458,16 @@ dependencies = [
"uint",
]
[[package]]
name = "primitive-types"
version = "0.11.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e28720988bff275df1f51b171e1b2a18c30d194c4d2b61defdacecd625a5d94a"
dependencies = [
"fixed-hash",
"uint",
]
[[package]]
name = "proc-macro-crate"
version = "0.1.5"
@ -2320,6 +2529,19 @@ dependencies = [
"unicode-xid 0.2.3",
]
[[package]]
name = "proc-macro2-diagnostics"
version = "0.9.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4bf29726d67464d49fa6224a1d07936a8c08bb3fba727c7493f6cf1616fdaada"
dependencies = [
"proc-macro2 1.0.38",
"quote 1.0.18",
"syn 1.0.94",
"version_check",
"yansi",
]
[[package]]
name = "pyth-client"
version = "0.2.2"
@ -2444,6 +2666,19 @@ dependencies = [
"wormhole-bridge-solana",
]
[[package]]
name = "pyth2wormhole-governance"
version = "0.1.0"
dependencies = [
"anyhow",
"borsh",
"clap 3.1.18",
"hex",
"pyth2wormhole-client",
"remote-executor",
"solana-sdk",
]
[[package]]
name = "qstring"
version = "0.7.2"
@ -2682,12 +2917,28 @@ dependencies = [
"regex-syntax",
]
[[package]]
name = "regex-automata"
version = "0.1.10"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "6c230d73fb8d8c1b9c0b3135c5142a8acee3a0558fb8db5cf1cb65f8d7862132"
[[package]]
name = "regex-syntax"
version = "0.6.25"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "f497285884f3fcff424ffc933e56d7cbca511def0c9831a7f9b5f6153e3cc89b"
[[package]]
name = "remote-executor"
version = "0.1.0"
dependencies = [
"anchor-lang",
"boolinator",
"wormhole-core",
"wormhole-solana",
]
[[package]]
name = "remove_dir_all"
version = "0.5.3"
@ -3061,7 +3312,7 @@ checksum = "028f48d513f9678cda28f6e4064755b3fbb2af6acd672f2c209b62323f7aea0f"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.3",
"digest 0.10.5",
]
[[package]]
@ -3085,7 +3336,7 @@ checksum = "55deaec60f81eefe3cce0dc50bda92d6d8e88f2a27df7c5033b42afeb1ed2676"
dependencies = [
"cfg-if",
"cpufeatures",
"digest 0.10.3",
"digest 0.10.5",
]
[[package]]
@ -3102,11 +3353,11 @@ dependencies = [
[[package]]
name = "sha3"
version = "0.10.1"
version = "0.10.5"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "881bf8156c87b6301fc5ca6b27f11eeb2761224c7081e69b409d5a1951a70c86"
checksum = "e2904bea16a1ae962b483322a1c7b81d976029203aea1f461e51cd7705db7ba9"
dependencies = [
"digest 0.10.3",
"digest 0.10.5",
"keccak",
]
@ -3184,7 +3435,7 @@ dependencies = [
"Inflector",
"base64 0.13.0",
"bincode",
"bs58",
"bs58 0.4.0",
"bv",
"lazy_static",
"serde",
@ -3346,7 +3597,7 @@ dependencies = [
"async-trait",
"base64 0.13.0",
"bincode",
"bs58",
"bs58 0.4.0",
"bytes",
"clap 2.34.0",
"crossbeam-channel",
@ -3447,7 +3698,7 @@ version = "1.10.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "68f2b153f8eb8c4d22f2b739d3d31bac4122ca17376869cb717bf3a45200ea63"
dependencies = [
"bs58",
"bs58 0.4.0",
"bv",
"generic-array",
"im",
@ -3571,7 +3822,7 @@ dependencies = [
"blake3",
"borsh",
"borsh-derive",
"bs58",
"bs58 0.4.0",
"bv",
"bytemuck",
"console_error_panic_hook",
@ -3593,7 +3844,7 @@ dependencies = [
"serde_bytes",
"serde_derive",
"sha2 0.10.2",
"sha3 0.10.1",
"sha3 0.10.5",
"solana-frozen-abi",
"solana-frozen-abi-macro",
"solana-sdk-macro",
@ -3748,12 +3999,12 @@ dependencies = [
"bincode",
"bitflags",
"borsh",
"bs58",
"bs58 0.4.0",
"bytemuck",
"byteorder",
"chrono",
"derivation-path",
"digest 0.10.3",
"digest 0.10.5",
"ed25519-dalek",
"ed25519-dalek-bip32",
"generic-array",
@ -3777,7 +4028,7 @@ dependencies = [
"serde_derive",
"serde_json",
"sha2 0.10.2",
"sha3 0.10.1",
"sha3 0.10.5",
"solana-frozen-abi",
"solana-frozen-abi-macro",
"solana-logger",
@ -3794,7 +4045,7 @@ version = "1.10.31"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "275c52edaaaa86ce649a226c03f75579d570c01880a43ee1de77a973994754ce"
dependencies = [
"bs58",
"bs58 0.4.0",
"proc-macro2 1.0.38",
"quote 1.0.18",
"rustversion",
@ -3878,7 +4129,7 @@ dependencies = [
"base64 0.13.0",
"bincode",
"borsh",
"bs58",
"bs58 0.4.0",
"lazy_static",
"log",
"serde",
@ -4147,7 +4398,7 @@ version = "0.24.3"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "1e385be0d24f186b4ce2f9982191e7101bb737312ad61c1f2f984f34bcf85d59"
dependencies = [
"heck",
"heck 0.4.0",
"proc-macro2 1.0.38",
"quote 1.0.18",
"rustversion",
@ -4296,18 +4547,18 @@ checksum = "b1141d4d61095b28419e22cb0bbf02755f5e54e0526f97f1e3d1d160e60885fb"
[[package]]
name = "thiserror"
version = "1.0.31"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bd829fe32373d27f76265620b5309d0340cb8550f523c1dda251d6298069069a"
checksum = "10deb33631e3c9018b9baf9dcbbc4f737320d2b576bac10f6aefa048fa407e3e"
dependencies = [
"thiserror-impl",
]
[[package]]
name = "thiserror-impl"
version = "1.0.31"
version = "1.0.37"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0396bc89e626244658bef819e22d0cc459e795a5ebe878e6ec336d1674a8d79a"
checksum = "982d17546b47146b28f7c22e3d08465f6b8903d0ea13c1660d9d84a6e7adcdbb"
dependencies = [
"proc-macro2 1.0.38",
"quote 1.0.18",
@ -4632,6 +4883,12 @@ dependencies = [
"tinyvec",
]
[[package]]
name = "unicode-segmentation"
version = "1.10.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "0fdbf052a0783de01e944a6ce7a8cb939e295b1e7be835a1112c3b9a7f047a5a"
[[package]]
name = "unicode-width"
version = "0.1.9"
@ -4945,13 +5202,47 @@ source = "git+https://github.com/wormhole-foundation/wormhole?tag=v2.8.9#e47f9e4
dependencies = [
"borsh",
"byteorder",
"primitive-types",
"primitive-types 0.9.1",
"serde",
"sha3 0.9.1",
"solana-program",
"solitaire",
]
[[package]]
name = "wormhole-core"
version = "0.1.0"
source = "git+https://github.com/guibescos/wormhole?branch=reisen/sdk-solana#61bb2fb691a8df0aa0e42a21632e43b392ffa90f"
dependencies = [
"borsh",
"bstr",
"byteorder",
"hex",
"hex-literal",
"nom",
"primitive-types 0.11.1",
"sha3 0.10.5",
"thiserror",
]
[[package]]
name = "wormhole-solana"
version = "0.1.0"
source = "git+https://github.com/guibescos/wormhole?branch=reisen/sdk-solana#61bb2fb691a8df0aa0e42a21632e43b392ffa90f"
dependencies = [
"borsh",
"bstr",
"byteorder",
"hex",
"hex-literal",
"nom",
"primitive-types 0.11.1",
"sha3 0.10.5",
"solana-program",
"thiserror",
"wormhole-core",
]
[[package]]
name = "x509-parser"
version = "0.14.0"
@ -4988,6 +5279,12 @@ dependencies = [
"linked-hash-map",
]
[[package]]
name = "yansi"
version = "0.5.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "09041cd90cf85f7f8b2df60c646f853b7f535ce68f85244eb6731cf89fa498ec"
[[package]]
name = "yasna"
version = "0.5.0"

View File

@ -1,2 +1,2 @@
[workspace]
members = ["client", "program"]
members = ["client", "program", "governance"]

View File

@ -0,0 +1,14 @@
[package]
name = "pyth2wormhole-governance"
version = "0.1.0"
description = "CLI to generate governance payloads for the attester"
edition = "2018"
[dependencies]
anyhow = "1.0.65"
clap = {version = "3.1.18", features = ["derive"]}
solana-sdk = "=1.10.31"
pyth2wormhole-client = {path = "../client/"}
hex = "0.4.3"
remote-executor = {path = "../../../pythnet/remote-executor/programs/remote-executor/"}
borsh = "0.9.3"

View File

@ -0,0 +1,53 @@
//! CLI options
use clap::{
Parser,
Subcommand,
};
use solana_sdk::pubkey::Pubkey;
#[derive(Parser, Debug)]
#[clap(
about = "A cli for the remote executor",
author = "Pyth Network Contributors"
)]
pub struct Cli {
#[clap(subcommand)]
pub action: Action,
}
#[derive(Subcommand, Debug)]
pub enum Action {
#[clap(about = "Get set upgrade authority payload for squads-cli")]
GetSetConfig {
#[clap(long, help = "Program id")]
program_id: Pubkey,
#[clap(long, help = "Current owner")]
owner: Pubkey,
#[clap(long, help = "Payer")]
payer: Pubkey,
#[clap(long, help = "Config : New owner")]
new_owner: Pubkey,
#[clap(long, help = "Config : Wormhole program id")]
wormhole: Pubkey,
#[clap(long, help = "Config : Pyth program id")]
pyth_owner: Pubkey,
#[clap(long, help = "Config : Max batch size")]
max_batch_size: u16,
#[clap(long, help = "Config : Is active")]
is_active: bool,
#[clap(long, help = "Config : Ops owner")]
ops_owner: Option<Pubkey>,
},
#[clap(about = "Get upgrade program payload for squads-cli")]
GetSetIsActive {
#[clap(long, help = "Program id")]
program_id: Pubkey,
#[clap(long, help = "Current ops owner")]
ops_owner: Pubkey,
#[clap(long, help = "Payer")]
payer: Pubkey,
#[clap(long, help = "Config : Is active")]
is_active: bool,
},
}

View File

@ -0,0 +1,69 @@
use anyhow::Result;
use clap::Parser;
use cli::{
Action,
Cli,
};
use pyth2wormhole_client::{
get_set_config_ix,
Pyth2WormholeConfig,
};
use borsh::BorshSerialize;
use pyth2wormhole_client::get_set_is_active_ix;
use remote_executor::state::governance_payload::{
ExecutorPayload,
GovernanceHeader,
InstructionData,
};
mod cli;
fn main() -> Result<()> {
let cli = Cli::parse();
match cli.action {
Action::GetSetConfig {
program_id,
owner,
payer,
new_owner,
wormhole,
pyth_owner,
max_batch_size,
is_active,
ops_owner,
} => {
let new_config = Pyth2WormholeConfig {
owner: new_owner,
wh_prog: wormhole,
pyth_owner,
max_batch_size,
is_active,
ops_owner,
};
let ix = get_set_config_ix(&program_id, &owner, &payer, new_config).unwrap();
let payload = ExecutorPayload {
header: GovernanceHeader::executor_governance_header(),
instructions: vec![InstructionData::from(&ix)],
}
.try_to_vec()?;
println!("Set config payload : {:?}", hex::encode(payload));
Ok(())
}
Action::GetSetIsActive {
program_id,
ops_owner,
payer,
is_active,
} => {
let ix = get_set_is_active_ix(&program_id, &ops_owner, &payer, is_active).unwrap();
let payload = ExecutorPayload {
header: GovernanceHeader::executor_governance_header(),
instructions: vec![InstructionData::from(&ix)],
}
.try_to_vec()?;
println!("Set is active payload : {:?}", hex::encode(payload));
Ok(())
}
}
}

View File

@ -4,6 +4,7 @@ FROM ghcr.io/certusone/solana:1.10.31@sha256:d31e8db926a1d3fbaa9d9211d9979023692
RUN apt-get update && apt-get install -yq python3 libudev-dev ncat
RUN curl -fsSL https://deb.nodesource.com/setup_16.x | bash - && apt-get install -y nodejs
ADD pythnet/remote-executor /usr/src/pythnet/remote-executor
ADD third_party/pyth/pyth_utils.py /usr/src/pyth/pyth_utils.py
ADD third_party/pyth/p2w_autoattest.py /usr/src/pyth/p2w_autoattest.py
ADD third_party/pyth/p2w-sdk/rust /usr/src/third_party/pyth/p2w-sdk/rust