pyth-crosschain/third_party/pyth/prepare_multisig.py

61 lines
2.5 KiB
Python
Raw Normal View History

# This script prepares a local Squads multisig deployment for use with
# the multisig-wh-message-builder
import errno
import os
import sys
from pyth_utils import *
MULTISIG_SCRIPT_CMD_PREFIX = "npm run start --".split(" ")
MULTISIG_SCRIPT_DIR = os.environ.get("MULTISIG_SCRIPT_DIR", "/root/pyth/multisig-wh-message-builder")
Repo structure refactor (#449) * Repo structure refactor This change introduces major codebase layout changes in three areas: * Tilt devnet lives in tilt-devnet/ - all k8s and docker files, scripts, local testing private keys are moved to this directory. * pyth2wormhole becomes pyth-wormhole-attester and is relocated to wormhole-attester/ - This long-needed rename will hopefully eradicate most of the confusing naming around the attester. The Rust client binary becomes pyth-wormhole-attester-client. * Target-chain code lives in target-chain/ - This leaves just the attester, third_party and pythnet-specific things at top-level. Other opportunistic changes: * Fixed rebuild trigger for Dockerfile.wasm These items are a fraction of the necessary structure changes in the repo. * cosmwasm: fix contract after faulty merge * .github: remove unused dependabot config * Fix path references in .github and .pre-commit-config.yml * .github: Rename attester references to pyth-wormhole-attester * .pre-commit-config.yaml: fix paths and run all commit hooks * p2w-relay: Fix faulty merge resolution in favor of origin/main * Dockerfile.pyth_relay: Fix Ethereum path reference * Dockerfile.solana: Trip early cache with arbitrary change * Dockerfile.pyth_relay: typo * p2w-relay: fix evm build in npm script * Dockerfile.solana: Retry invalidating cache again * near -> target-chains/near * wormhole-attester: bump on/off-chain major versions due to rename Attester packages were renamed. This possibly breaks most dependees. * Dockerfile.solana: Improve decoy-crate to have a real lib target * .github/[...]/pyth-cosmwasm-contract.yml: typo * rust-toolchain: Bump rust to stable 1.63 * rust-toolchain: use christmas nightly * empty commit to trigger build * attester-image-push.yaml: keep xc-attest image name intact * multisig-wh-message-builder: remove accidental revert
2023-01-04 05:46:42 -08:00
MESH_KEY_DIR = "/solana-secrets/squads/"
MESH_PROGRAM_ADDR = "SMPLVC8MxZ5Bf5EfF7PaMiTCxoBAcmkbM2vkrvMK8ho"
MESH_CREATE_KEY_PATH = MESH_KEY_DIR + "create_key.json"
MESH_VAULT_EXT_AUTHORITY_KEY_PATH = MESH_KEY_DIR + "external_authority.json"
ALICE_KEY_PATH = MESH_KEY_DIR + "member_alice.json"
BOB_KEY_PATH = MESH_KEY_DIR + "member_bob.json"
CAROL_KEY_PATH = MESH_KEY_DIR + "member_carol.json"
create_key_addr = sol_run_or_die("address", ["--keypair", MESH_CREATE_KEY_PATH], capture_output=True).stdout.strip()
ext_authority_addr = sol_run_or_die("address", ["--keypair", MESH_VAULT_EXT_AUTHORITY_KEY_PATH], capture_output=True).stdout.strip()
alice_addr = sol_run_or_die("address", ["--keypair", ALICE_KEY_PATH], capture_output=True).stdout.strip()
bob_addr = sol_run_or_die("address", ["--keypair", BOB_KEY_PATH], capture_output=True).stdout.strip()
carol_addr = sol_run_or_die("address", ["--keypair", CAROL_KEY_PATH], capture_output=True).stdout.strip()
# wrap run_or_die in msg builder common cli args
def msg_builder_run_or_die(args = [], debug=False, **kwargs):
"""
Message builder boilerplate in front of run_or_die()
"""
return run_or_die(
MULTISIG_SCRIPT_CMD_PREFIX + args, cwd=MULTISIG_SCRIPT_DIR, debug=debug, **kwargs)
# create a Multisig Vault
res = msg_builder_run_or_die([
"init-vault",
"-k", create_key_addr,
"-x", ext_authority_addr,
"-p", SOL_PAYER_KEYPAIR,
"-c", "localdevnet",
"-r", SOL_RPC_URL,
"-i", f"{alice_addr},{bob_addr},{carol_addr}",
"-t", "2", # 2/3 threshold
],
capture_output=True, debug=True, die=False)
if res.returncode == errno.EEXIST:
print("WARNING: Skipping vault creation and testing, received EEXIST from script", file=sys.stderr)
elif res.returncode != 0:
print(f"ERROR: unexpected failure with code {res.returncode}", file=sys.stderr)
sys.exit(res.returncode)
else:
print("Vault created, starting test routine", file=sys.stderr)
# TODO(2022-12-08): Add test scenarios
sys.stderr.flush()
readiness()