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

DO NOT MERGE: this is essentially just dusterbloom/neutron-testnet-websocket-url syncd with main (for testing the rust cw client) #236

Closed
wants to merge 101 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
101 commits
Select commit Hold shift + click to select a range
244804e
First set of changes from `wasm` to `neutron`
dusterbloom Sep 19, 2024
20df8a5
Changes from `admin` to `val1` / `testing` to `test-1` (chainId / admin)
dusterbloom Sep 19, 2024
117580b
wasmdClient related changes
dusterbloom Sep 19, 2024
0c2a2b1
Deploy and instantiate fixes
dusterbloom Sep 19, 2024
2e4ff48
Updates to incorported the correct `fee` with correct amount
dusterbloom Sep 19, 2024
c35502a
Minimal changes to get to instantiate / create Session
dusterbloom Sep 19, 2024
cf93fb5
Latest fixes to work on `neutrond`
dusterbloom Sep 20, 2024
c4d104c
Fixes `cargo fmt`, `clippy` + reduced logging on listener
dusterbloom Sep 20, 2024
3349152
Changes needed to be able to deploy on neutron testnet /
dusterbloom Sep 24, 2024
a794bbd
Initial changes - WIP
dusterbloom Sep 27, 2024
70ca340
Fixes to wss config
dusterbloom Sep 30, 2024
dcf3f8e
Fixes on `websocket_url` + cargo fmt
dusterbloom Sep 30, 2024
50b9d83
Adding `chain-id` and defaults to neutron `node_url` / `websocket_url`
dusterbloom Sep 30, 2024
e06106c
Fixes on `ws_handler`
dusterbloom Sep 30, 2024
4cb9dea
Fixing the `cli` args
dusterbloom Sep 30, 2024
ae4289b
Merge remote-tracking branch 'origin/main' into dusterbloom/neutron-t…
dusterbloom Sep 30, 2024
d80b26f
Exrta changes after merge commit
dusterbloom Sep 30, 2024
7b61a1d
Fix to `tx_execute`
dusterbloom Sep 30, 2024
7948738
Fix to enclave main.rs and wasmd_client lib to support neutron
dusterbloom Sep 30, 2024
2ca1887
Updates to take the `websocket_url` + fees
dusterbloom Sep 30, 2024
864f22d
More fixes
dusterbloom Sep 30, 2024
096270d
Fixes to the `WsListenerConfig`
dusterbloom Sep 30, 2024
d6b3aa9
fix on dependencies , removed pining
dusterbloom Sep 30, 2024
11bee6e
adding branch
dusterbloom Sep 30, 2024
67333f4
Updated cargo.lock for cw-tee-mtcs
dusterbloom Sep 30, 2024
9f96b44
Fix for `cosmrs` and `tonic`
dusterbloom Sep 30, 2024
32b8d1a
Fix to transfers contract Cargo.toml
dusterbloom Sep 30, 2024
7019661
fix to Cargo.lock
dusterbloom Sep 30, 2024
54466af
Adding print to enclave_start
dusterbloom Sep 30, 2024
90e0570
Fix to helpers
dusterbloom Sep 30, 2024
4a9670c
adding debug on enclave start
dusterbloom Oct 1, 2024
fe1e49a
node_url fix on encalve quartz.toml
dusterbloom Oct 1, 2024
22a57c6
Fix to add `chain_id` to gramine manifest
dusterbloom Oct 1, 2024
499482e
Fix to solve undefined on `chain_id` in quartz.manifest.template
dusterbloom Oct 1, 2024
0790a69
Attempt to get over chain_id undefined
dusterbloom Oct 1, 2024
d3286de
Fix to websocket
dusterbloom Oct 1, 2024
6398cb6
Fix on listener + update build.rs
dusterbloom Oct 1, 2024
d06df1c
print `wsurl`
dusterbloom Oct 1, 2024
ff74c1d
adding more info! on two block waitor
dusterbloom Oct 1, 2024
2d899f8
Adding more debug on server.rs
dusterbloom Oct 1, 2024
46485bd
Manifest update and more debugging
dusterbloom Oct 1, 2024
c717990
Hardcoding wss to test
dusterbloom Oct 1, 2024
c3e55fd
Imrpove error logging
dusterbloom Oct 1, 2024
20a89d4
Adding print to `serve`
dusterbloom Oct 1, 2024
c2dd6b6
eprintln instead of print
dusterbloom Oct 1, 2024
024aa53
etc and resolv.conf added to `quartz.manifest.template`
dusterbloom Oct 1, 2024
1cb29ab
hardcoding wss on enclave main to test
dusterbloom Oct 1, 2024
c9e353b
ffix
dusterbloom Oct 1, 2024
2910b0e
Debug handshakefailure
dusterbloom Oct 1, 2024
2524872
Update quartz.manifest to support DNS
dusterbloom Oct 1, 2024
7adb3dc
Revert change wss to hardocoded
dusterbloom Oct 1, 2024
943bbbd
fix
dusterbloom Oct 1, 2024
73378b4
fix typo
dusterbloom Oct 1, 2024
af35e3d
Gramine Manifest helper mounted in filesystem
dusterbloom Oct 1, 2024
74a5a68
Fixes
dusterbloom Oct 1, 2024
f3bef39
Remove sgx.trusted files related to DNS
dusterbloom Oct 1, 2024
7207f3c
Adding nsswitch.conf and etc/hosts to sgx.allowed_files
dusterbloom Oct 1, 2024
a38a1d0
fix on removing sgx.allowed_files
dusterbloom Oct 1, 2024
255b27c
TLS fix
dusterbloom Oct 1, 2024
8f282d8
Update to quartz.manifest.template adding allowed files and insecure_…
dusterbloom Oct 1, 2024
b5ae0c5
Fix
dusterbloom Oct 1, 2024
4afc165
Further edit
dusterbloom Oct 1, 2024
8f5eb21
Updating gas on transfer.enclave listener
dusterbloom Oct 1, 2024
84185b9
Increase sgx.max_threads to 16
dusterbloom Oct 1, 2024
85ac4ad
Update to add neutrond to gramine manifest template
dusterbloom Oct 1, 2024
c01603d
Adding usr/lib to gramine.manifest
dusterbloom Oct 1, 2024
0e9d0be
Fix
dusterbloom Oct 1, 2024
e2842dd
neutrond added to trusted_files
dusterbloom Oct 1, 2024
559a7f0
fix
dusterbloom Oct 1, 2024
83da022
Fix to usr/lib
dusterbloom Oct 1, 2024
c4859ae
Adding pal_internal_mem_size to gramine
dusterbloom Oct 1, 2024
c7cfc61
double enclave size
dusterbloom Oct 1, 2024
c2bf042
SGX size to 16GB
dusterbloom Oct 1, 2024
726ac64
enclave size to 4GB
dusterbloom Oct 1, 2024
fb6e769
Adding root ~/.neutrond to gramine trusted_files
dusterbloom Oct 1, 2024
3bcae24
Changing `neutrond` path / adding `tmp` folder
dusterbloom Oct 2, 2024
32bd886
typo fix
dusterbloom Oct 2, 2024
f8e0e7c
Removing root from manifest
dusterbloom Oct 2, 2024
212ff0c
Adding .neutrond to `allowed_files` on quartz.manifest.template
dusterbloom Oct 2, 2024
7298fa6
Adding a tmp wasm_dir to wslisterner transfer handler / updated manif…
dusterbloom Oct 2, 2024
ccbf90f
fix
dusterbloom Oct 2, 2024
cc09c0d
Fix the timestamp to be set at enclave start
dusterbloom Oct 2, 2024
f65eed1
Adding `defer`
dusterbloom Oct 2, 2024
a4c2897
Adding import
dusterbloom Oct 2, 2024
7209f97
Fix to wslistener + debugging
dusterbloom Oct 2, 2024
3fd8fbf
Adding tokio semaphore / websocket pool etc - might break
dusterbloom Oct 2, 2024
ded64d3
Restore old listener/main
dusterbloom Oct 2, 2024
a549de0
test on checking lock file at enclaave start
dusterbloom Oct 2, 2024
035f873
Fix to enclave_start lock_file
dusterbloom Oct 2, 2024
9baabcd
Another test
dusterbloom Oct 2, 2024
625079a
More fixes
dusterbloom Oct 2, 2024
055cdc1
Changing NEUTRON_WASM_DIR
dusterbloom Oct 2, 2024
67e5fe1
fix
dusterbloom Oct 2, 2024
a2623f8
fix
dusterbloom Oct 2, 2024
eb6c7c6
removing timestamp to wasmd_dir
dusterbloom Oct 2, 2024
7814310
Fixes to tmp folder
dusterbloom Oct 2, 2024
965bab8
Removing wasmvm from manifest-template
dusterbloom Oct 2, 2024
cf4e778
adding back wasmvm
dusterbloom Oct 2, 2024
84a1e36
Merge branch 'main' into hu55a1n1/neutron-testnet-websocket-url
hu55a1n1 Oct 2, 2024
1c941d4
Fix merge
hu55a1n1 Oct 2, 2024
81f85eb
Add mistakenly deleted Cargo.locks
hu55a1n1 Oct 2, 2024
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
4 changes: 4 additions & 0 deletions .cursorignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
# Add directories or file patterns to ignore during indexing (e.g. foo/ or *.csv)
.js
node_modules/
target/
39 changes: 28 additions & 11 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ k256 = { version = "0.13.2", default-features = false, features = [
] }
num-bigint = { version = "0.4.4", default-features = false }
p256 = { version = "0.13.2", default-features = false }
prost = { version = "0.13.1", default-features = false }
prost = { version = "0.13", default-features = false }
rand = { version = "0.8.5", default-features = false, features = ["getrandom"] }
rand_core = { version = "0.6", default-features = false, features = ["std"] }
reqwest = { version = "0.12.2", default-features = false, features = [
Expand Down
1 change: 1 addition & 0 deletions crates/cli/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ toml = "0.8.19"
figment = { version = "0.10.19", features = ["env", "toml"] }
clearscreen = "3.0.0"
cargo_metadata = "0.18.1"
fs2 ="0.4.3"

# cosmos
cosmrs.workspace = true
Expand Down
10 changes: 10 additions & 0 deletions crates/cli/src/cli.rs
Original file line number Diff line number Diff line change
Expand Up @@ -125,6 +125,11 @@ pub struct HandshakeArgs {
#[serde(skip_serializing_if = "Option::is_none")]
pub node_url: Option<String>,

/// <host>:<port> to tendermint rpc interface for this chain
#[arg(long)]
#[serde(skip_serializing_if = "Option::is_none")]
pub websocket_url: Option<String>,

/// RPC interface for the Quartz enclave
#[arg(long)]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down Expand Up @@ -192,6 +197,11 @@ pub struct EnclaveStartArgs {
#[arg(long)]
pub unsafe_trust_latest: bool,

/// <host>:<port> to tendermint rpc interface for this chain
#[arg(long)]
#[serde(skip_serializing_if = "Option::is_none")]
pub websocket_url: Option<String>,

/// FMSPC (Family-Model-Stepping-Platform-Custom SKU); required if `MOCK_SGX` is not set
#[arg(long)]
#[serde(skip_serializing_if = "Option::is_none")]
Expand Down
15 changes: 12 additions & 3 deletions crates/cli/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,10 @@ pub struct Config {
#[serde(default = "default_node_url")]
pub node_url: String,

/// Full WebSocket URL for this chain
#[serde(default = "default_websocket_url")]
pub websocket_url: String,

/// RPC interface for the Quartz enclave
#[serde(default = "default_rpc_addr")]
pub enclave_rpc_addr: String,
Expand Down Expand Up @@ -53,15 +57,19 @@ fn default_rpc_addr() -> String {
}

fn default_node_url() -> String {
"127.0.0.1:26657".to_string()
"https://rpc-falcron.pion-1.ntrn.tech".to_string()
}

fn default_websocket_url() -> String {
"wss://rpc-falcron.pion-1.ntrn.tech/websocket".to_string()
}

fn default_tx_sender() -> String {
String::from("admin")
String::from("val1")
}

fn default_chain_id() -> ChainId {
"testing".parse().expect("default chain_id failed")
"pion-1".parse().expect("default chain_id failed")
}

fn default_port() -> u16 {
Expand All @@ -79,6 +87,7 @@ impl Default for Config {
tx_sender: default_tx_sender(),
chain_id: default_chain_id(),
node_url: default_node_url(),
websocket_url: default_websocket_url(),
enclave_rpc_addr: default_rpc_addr(),
enclave_rpc_port: default_port(),
app_dir: default_app_dir(),
Expand Down
57 changes: 46 additions & 11 deletions crates/cli/src/handler/contract_deploy.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,10 +9,7 @@ use serde_json::json;
use tendermint_rpc::HttpClient;
use tracing::{debug, info};

use super::utils::{
helpers::block_tx_commit,
types::{Log, WasmdTxResponse},
};
use super::utils::{helpers::block_tx_commit, types::WasmdTxResponse};
use crate::{
config::Config,
error::Error,
Expand Down Expand Up @@ -68,9 +65,9 @@ async fn deploy(
args: ContractDeployRequest,
config: &Config,
) -> Result<(u64, String), anyhow::Error> {
let httpurl = Url::parse(&format!("http://{}", config.node_url))?;
let httpurl = Url::parse(&config.node_url)?;
let tmrpc_client = HttpClient::new(httpurl.as_str())?;
let cw_client = CliWasmdClient::new(Url::parse(httpurl.as_str())?);
let cw_client = CliWasmdClient::new(httpurl);

info!("🚀 Deploying {} Contract", args.label);
let code_id = if config.contract_has_changed(wasm_bin_path).await? {
Expand All @@ -79,10 +76,32 @@ async fn deploy(
&config.tx_sender,
wasm_bin_path.display().to_string(),
)?)?;
let res = block_tx_commit(&tmrpc_client, deploy_output.txhash).await?;
info!("Deploy output: {:?}", deploy_output);

let log: Vec<Log> = serde_json::from_str(&res.tx_result.log)?;
let code_id: u64 = log[0].events[1].attributes[1].value.parse()?;
let res = block_tx_commit(&tmrpc_client, deploy_output.txhash).await?;
// info!("Deploy response {:?}", res);
info!("TX result log: {}", res.tx_result.log);

// let log: Vec<Log> = serde_json::from_str(&res.tx_result.log)?;
// let code_id: u64 = log[0].events[1].attributes[1].value.parse()?;
// config.save_codeid_to_cache(wasm_bin_path, code_id).await?;

// Find the 'code_id' attribute
let code_id = res
.tx_result
.events
.iter()
.find(|event| event.kind == "store_code")
.and_then(|event| {
event
.attributes
.iter()
.find(|attr| attr.key_str().unwrap_or("") == "code_id")
})
.and_then(|attr| attr.value_str().ok().and_then(|v| v.parse().ok()))
.ok_or_else(|| anyhow::anyhow!("Failed to find code_id in the transaction result"))?;

info!("Code ID: {}", code_id);
config.save_codeid_to_cache(wasm_bin_path, code_id).await?;

code_id
Expand All @@ -108,8 +127,24 @@ async fn deploy(
)?)?;
let res = block_tx_commit(&tmrpc_client, init_output.txhash).await?;

let log: Vec<Log> = serde_json::from_str(&res.tx_result.log)?;
let contract_addr: &String = &log[0].events[1].attributes[0].value;
// info!("Init response: {:?}", res);

// Find the '_contract_address' attribute
let contract_addr: String = res
.tx_result
.events
.iter()
.find(|event| event.kind == "instantiate")
.and_then(|event| {
event
.attributes
.iter()
.find(|attr| attr.key_str().unwrap_or("") == "_contract_address")
})
.and_then(|attr| attr.value_str().ok().and_then(|v| v.parse().ok()))
.ok_or_else(|| {
anyhow::anyhow!("Failed to find contract_address in the transaction result")
})?;

info!("🚀 Successfully deployed and instantiated contract!");
info!("🆔 Code ID: {}", code_id);
Expand Down
Loading
Loading