Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Helloworld program and tooling #2744

Merged
merged 77 commits into from
Oct 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
77 commits
Select commit Hold shift + click to select a range
791302f
Add helloworld program
tkporter Aug 8, 2023
7568cbb
Start ripping out common router types
tkporter Aug 8, 2023
8cfc568
Still quite a mess but helloworld.rs uses the router deploy tooling
tkporter Aug 9, 2023
5aa718d
Helloworld deploy tooling
tkporter Aug 9, 2023
7aea99a
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Aug 9, 2023
f508e2d
Better file structure for hellworld program
tkporter Aug 9, 2023
eb119f9
Add ability to pay for gas in helloworld program
tkporter Aug 9, 2023
3a32a17
Deployed to rc woo
tkporter Aug 10, 2023
96eb859
ugly wip
tkporter Aug 10, 2023
515b2ca
works
tkporter Aug 10, 2023
dd7ff72
Update comment
tkporter Aug 10, 2023
e30fb4a
Playing around with things to try to get SDK/infra tooling to work we…
tkporter Aug 11, 2023
76cea2d
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Aug 16, 2023
49988bb
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 5, 2023
673e1f3
wip
tkporter Sep 5, 2023
422f475
Checker working & sealevel cli compiling
tkporter Sep 6, 2023
ca7ccab
Move helloworld checking into check-deploy.ts, able to set routers an…
tkporter Sep 7, 2023
1025f1f
wip...
tkporter Sep 12, 2023
9adcc8e
Plan to deploy rc relayer
tkporter Sep 12, 2023
5a04e9d
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 12, 2023
42d0b03
Now trying to set ism correctly
tkporter Sep 12, 2023
9185791
Some deployments
tkporter Sep 13, 2023
c3eac80
Move serde stuff
tkporter Sep 13, 2023
22786aa
Attempting to clean up artifacts
tkporter Sep 13, 2023
6cc4952
Move more into multisig_ism.rs
tkporter Sep 13, 2023
e25a57f
Add get_storage in helloworld
tkporter Sep 13, 2023
82252df
Deploy new nautilus multisig ism
tkporter Sep 13, 2023
f6d61ea
mid cleanup
tkporter Sep 13, 2023
0fd7294
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 14, 2023
8515436
Cleaning up warp_route.rs
tkporter Sep 14, 2023
49ea3e9
Cleaning up warp_route.rs
tkporter Sep 14, 2023
4e68445
Cleaning up
tkporter Sep 14, 2023
5cdde39
Add gas amount stuff back
tkporter Sep 14, 2023
9175247
mintor refactor
tkporter Sep 14, 2023
13d0d62
rm devnet environment
tkporter Sep 14, 2023
dc52b7a
rm local-e2e/helloworld
tkporter Sep 14, 2023
63abd62
Configuration for new default ISM config
tkporter Sep 15, 2023
489b84c
Progress towards getting mainnet all working
tkporter Sep 18, 2023
a34b56c
IGP checker works
tkporter Sep 18, 2023
09b0680
try to get around the celo bs
tkporter Sep 18, 2023
adc63a0
Use Celo safe tx service URL that works
tkporter Sep 19, 2023
79d8d99
rm a console.log
tkporter Sep 19, 2023
fb48f68
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 19, 2023
4f22170
Nits
tkporter Sep 19, 2023
39c0fb6
Some cleanup, set the new testnet3 default ISM in program_ids.json
tkporter Sep 19, 2023
79ce38a
Cleanup innit
tkporter Sep 19, 2023
23dc5a5
Cleanup
tkporter Sep 19, 2023
6aa48e6
Clean upppp
tkporter Sep 19, 2023
d930ba0
Owner deploy tooling, make it truly idempotent regardless of the pres…
tkporter Sep 19, 2023
e682c8a
Move to routing ISM at root
tkporter Sep 19, 2023
0836656
Deployed new default ISM on mainnet
tkporter Sep 20, 2023
29be997
Created some multisig txs
tkporter Sep 20, 2023
812e395
nits
tkporter Sep 20, 2023
05dd8ea
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 20, 2023
7d4ce34
Removing deposit-only
tkporter Sep 26, 2023
039fc89
rm duped mainnetHyperlaneDefaultIsmCache
tkporter Sep 26, 2023
5d41e82
mild cleanup - also set new ISMs as helloworld ISMs
tkporter Sep 26, 2023
5ad3176
Add new POSE router
tkporter Sep 27, 2023
35a1065
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 27, 2023
da008a3
New POSE token
tkporter Sep 27, 2023
23d7ccb
Enroll new solana routers on mainnet helloworlds
tkporter Sep 28, 2023
f315685
Add DomainRoutingIsm to verification.json
tkporter Sep 28, 2023
4dd8eb1
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Sep 28, 2023
7e4b1ab
Don't charge gas for solana helloworld either
tkporter Sep 28, 2023
92ad7f9
Address todo
tkporter Sep 28, 2023
269abfc
short circuit in routingIsm
tkporter Sep 28, 2023
737ed6d
Actually check the chain when recovering a program id
tkporter Sep 29, 2023
3bd4f9d
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Oct 2, 2023
d4fab2d
fixing lint
tkporter Oct 2, 2023
e7711de
Clippy
tkporter Oct 2, 2023
616a1f5
Fix ica fork test
tkporter Oct 2, 2023
3c937e9
fix fork core
tkporter Oct 2, 2023
215487e
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Oct 3, 2023
a3fab8d
PR comments
tkporter Oct 3, 2023
c317b36
God help me debug this
tkporter Oct 3, 2023
32ad627
Fix CI
tkporter Oct 3, 2023
a32afe7
Merge branch 'main' of github.com:abacus-network/abacus-monorepo into…
tkporter Oct 3, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions rust/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 1 addition & 0 deletions rust/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ members = [
"sealevel/libraries/serializable-account-meta",
"sealevel/libraries/test-transaction-utils",
"sealevel/libraries/test-utils",
"sealevel/programs/helloworld",
"sealevel/programs/hyperlane-sealevel-token",
"sealevel/programs/hyperlane-sealevel-token-collateral",
"sealevel/programs/hyperlane-sealevel-token-native",
Expand Down
13 changes: 9 additions & 4 deletions rust/agents/relayer/src/msg/metadata/base.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,9 +74,14 @@ impl MetadataBuilder for BaseMetadataBuilder {
ism_address: H256,
message: &HyperlaneMessage,
) -> Result<Option<Vec<u8>>> {
const CTX: &str = "When fetching module type";
let ism = self.build_ism(ism_address).await.context(CTX)?;
let module_type = ism.module_type().await.context(CTX)?;
let ism = self
.build_ism(ism_address)
.await
.context("When building ISM")?;
let module_type = ism
.module_type()
.await
.context("When fetching module type")?;
let base = self.clone_with_incremented_depth()?;

let metadata_builder: Box<dyn MetadataBuilder> = match module_type {
Expand All @@ -94,7 +99,7 @@ impl MetadataBuilder for BaseMetadataBuilder {
metadata_builder
.build(ism_address, message)
.await
.context(CTX)
.context("When building metadata")
}
}

Expand Down
13 changes: 12 additions & 1 deletion rust/hyperlane-core/src/traits/interchain_security_module.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,23 @@ use async_trait::async_trait;
use auto_impl::auto_impl;
use borsh::{BorshDeserialize, BorshSerialize};
use num_derive::FromPrimitive;
use serde::{Deserialize, Serialize};

use crate::{ChainResult, HyperlaneContract, HyperlaneMessage, U256};

/// Enumeration of all known module types
#[derive(
FromPrimitive, Clone, Debug, Default, Copy, PartialEq, Eq, BorshDeserialize, BorshSerialize,
FromPrimitive,
Clone,
Debug,
Default,
Copy,
PartialEq,
Eq,
BorshDeserialize,
BorshSerialize,
Serialize,
Deserialize,
)]
#[cfg_attr(feature = "strum", derive(strum::Display))]
pub enum ModuleType {
Expand Down
3 changes: 2 additions & 1 deletion rust/sealevel/client/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,5 @@ hyperlane-sealevel-igp = { path = "../programs/hyperlane-sealevel-igp", features
hyperlane-sealevel-token-collateral = { path = "../programs/hyperlane-sealevel-token-collateral", features = ["no-entrypoint"] }
hyperlane-sealevel-token-lib = { path = "../libraries/hyperlane-sealevel-token" }
hyperlane-sealevel-token-native = { path = "../programs/hyperlane-sealevel-token-native", features = ["no-entrypoint"] }
hyperlane-sealevel-validator-announce = { path = "../programs/validator-announce", features = ["no-entrypoint"] }
hyperlane-sealevel-validator-announce = { path = "../programs/validator-announce", features = ["no-entrypoint"] }
hyperlane-sealevel-hello-world = { path = "../programs/helloworld" }
59 changes: 59 additions & 0 deletions rust/sealevel/client/src/artifacts.rs
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
use serde::{de::DeserializeOwned, Deserialize, Serialize};

use hyperlane_core::H256;
use solana_program::pubkey::Pubkey;

use std::{fs::File, io::Write, path::Path, str::FromStr};

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct SingularProgramIdArtifact {
#[serde(with = "crate::serde::serde_pubkey")]
pub program_id: Pubkey,
}

impl From<Pubkey> for SingularProgramIdArtifact {
fn from(val: Pubkey) -> Self {
SingularProgramIdArtifact { program_id: val }
}
}

#[derive(Serialize, Deserialize)]
pub(crate) struct HexAndBase58ProgramIdArtifact {
hex: String,
base58: String,
}

impl From<H256> for HexAndBase58ProgramIdArtifact {
fn from(val: H256) -> Self {
HexAndBase58ProgramIdArtifact {
hex: format!("0x{}", hex::encode(val)),
base58: Pubkey::new_from_array(val.to_fixed_bytes()).to_string(),
}
}
}

impl From<&HexAndBase58ProgramIdArtifact> for Pubkey {
fn from(val: &HexAndBase58ProgramIdArtifact) -> Self {
Pubkey::from_str(&val.base58).unwrap()
}
}

pub(crate) fn write_json<T>(path: &Path, program_id: T)
where
T: Serialize,
{
let json = serde_json::to_string_pretty(&program_id).unwrap();
println!("Writing to file {} contents:\n{}", path.display(), json);

let mut file = File::create(path).expect("Failed to create file");
file.write_all(json.as_bytes())
.expect("Failed write JSON to file");
}

pub(crate) fn read_json<T>(path: &Path) -> T
where
T: DeserializeOwned,
{
let file = File::open(path).expect("Failed to open JSON file");
serde_json::from_reader(file).expect("Failed to read JSON file")
}
10 changes: 10 additions & 0 deletions rust/sealevel/client/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ pub(crate) struct Context {
payer_keypair: Option<PayerKeypair>,
pub commitment: CommitmentConfig,
pub initial_instructions: RefCell<Vec<InstructionWithDescription>>,
pub require_tx_approval: bool,
}

pub(crate) struct InstructionWithDescription {
Expand Down Expand Up @@ -58,13 +59,15 @@ impl Context {
payer_keypair: Option<PayerKeypair>,
commitment: CommitmentConfig,
initial_instructions: RefCell<Vec<InstructionWithDescription>>,
require_tx_approval: bool,
) -> Self {
Self {
client,
payer_pubkey,
payer_keypair,
commitment,
initial_instructions,
require_tx_approval,
}
}

Expand Down Expand Up @@ -183,6 +186,13 @@ impl<'ctx, 'rpc> TxnBuilder<'ctx, 'rpc> {
return None;
}

// Print the tx as an indication for what's about to happen
self.pretty_print_transaction();

if self.ctx.require_tx_approval {
wait_for_user_confirmation();
}

let client = self.client.unwrap_or(&self.ctx.client);

let recent_blockhash = client.get_latest_blockhash().unwrap();
Expand Down
99 changes: 18 additions & 81 deletions rust/sealevel/client/src/core.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ use solana_program::pubkey::Pubkey;
use solana_sdk::signature::Signer;

use std::collections::HashMap;
use std::{fs::File, io::Write, path::Path};
use std::{fs::File, path::Path};

use crate::{
artifacts::{read_json, write_json},
cmd_utils::{create_and_write_keypair, create_new_directory, deploy_program},
multisig_ism::deploy_multisig_ism_message_id,
Context, CoreCmd, CoreDeploy, CoreSubCmd,
};
use hyperlane_core::H256;
Expand All @@ -21,7 +23,12 @@ pub(crate) fn process_core_cmd(mut ctx: Context, cmd: CoreCmd) {
let core_dir = create_new_directory(&chain_dir, "core");
let key_dir = create_new_directory(&core_dir, "keys");

let ism_program_id = deploy_multisig_ism_message_id(&mut ctx, &core, &key_dir);
let ism_program_id = deploy_multisig_ism_message_id(
&mut ctx,
&core.built_so_dir,
core.use_existing_keys,
&key_dir,
);

let mailbox_program_id = deploy_mailbox(&mut ctx, &core, &key_dir, ism_program_id);

Expand All @@ -44,43 +51,6 @@ pub(crate) fn process_core_cmd(mut ctx: Context, cmd: CoreCmd) {
}
}

fn deploy_multisig_ism_message_id(ctx: &mut Context, cmd: &CoreDeploy, key_dir: &Path) -> Pubkey {
let (keypair, keypair_path) = create_and_write_keypair(
key_dir,
"hyperlane_sealevel_multisig_ism_message_id-keypair.json",
cmd.use_existing_keys,
);
let program_id = keypair.pubkey();

deploy_program(
ctx.payer_keypair_path(),
keypair_path.to_str().unwrap(),
cmd.built_so_dir
.join("hyperlane_sealevel_multisig_ism_message_id.so")
.to_str()
.unwrap(),
&ctx.client.url(),
);

println!(
"Deployed Multisig ISM Message ID at program ID {}",
program_id
);

// Initialize
let instruction = hyperlane_sealevel_multisig_ism_message_id::instruction::init_instruction(
program_id,
ctx.payer_pubkey,
)
.unwrap();

ctx.new_txn().add(instruction).send_with_payer();

println!("Initialized Multisig ISM Message ID ");

program_id
}

fn deploy_mailbox(
ctx: &mut Context,
core: &CoreDeploy,
Expand Down Expand Up @@ -325,55 +295,23 @@ fn deploy_igp(ctx: &mut Context, core: &CoreDeploy, key_dir: &Path) -> (Pubkey,
}

#[derive(Debug, Serialize, Deserialize)]
pub(crate) struct CoreProgramIds {
#[serde(with = "serde_pubkey")]
pub struct CoreProgramIds {
#[serde(with = "crate::serde::serde_pubkey")]
pub mailbox: Pubkey,
#[serde(with = "serde_pubkey")]
#[serde(with = "crate::serde::serde_pubkey")]
pub validator_announce: Pubkey,
#[serde(with = "serde_pubkey")]
#[serde(with = "crate::serde::serde_pubkey")]
pub multisig_ism_message_id: Pubkey,
#[serde(with = "serde_pubkey")]
#[serde(with = "crate::serde::serde_pubkey")]
pub igp_program_id: Pubkey,
#[serde(with = "serde_pubkey")]
#[serde(with = "crate::serde::serde_pubkey")]
pub overhead_igp_account: Pubkey,
#[serde(with = "serde_pubkey")]
#[serde(with = "crate::serde::serde_pubkey")]
pub igp_account: Pubkey,
}

mod serde_pubkey {
use borsh::BorshDeserialize;
use serde::{Deserialize, Deserializer, Serializer};
use solana_sdk::pubkey::Pubkey;
use std::str::FromStr;

#[derive(Deserialize)]
#[serde(untagged)]
enum RawPubkey {
String(String),
Bytes(Vec<u8>),
}

pub fn serialize<S: Serializer>(k: &Pubkey, ser: S) -> Result<S::Ok, S::Error> {
ser.serialize_str(&k.to_string())
}

pub fn deserialize<'de, D: Deserializer<'de>>(de: D) -> Result<Pubkey, D::Error> {
match RawPubkey::deserialize(de)? {
RawPubkey::String(s) => Pubkey::from_str(&s).map_err(serde::de::Error::custom),
RawPubkey::Bytes(b) => Pubkey::try_from_slice(&b).map_err(serde::de::Error::custom),
}
}
}

fn write_program_ids(core_dir: &Path, program_ids: CoreProgramIds) {
let json = serde_json::to_string_pretty(&program_ids).unwrap();
let path = core_dir.join("program-ids.json");

println!("Writing program IDs to {}:\n{}", path.display(), json);

let mut file = File::create(path).expect("Failed to create keypair file");
file.write_all(json.as_bytes())
.expect("Failed to write program IDs to file");
write_json(&core_dir.join("program-ids.json"), program_ids);
}

pub(crate) fn read_core_program_ids(
Expand All @@ -386,6 +324,5 @@ pub(crate) fn read_core_program_ids(
.join(chain)
.join("core")
.join("program-ids.json");
let file = File::open(path).expect("Failed to open program IDs file");
serde_json::from_reader(file).expect("Failed to read program IDs file")
read_json(&path)
}
Loading