feat(DCAP): use upstream mc deps (#230)
Co-authored-by: Daniel Gushchyan <39884512+dangush@users.noreply.github.com>
This commit is contained in:
parent
14a6913632
commit
3e62031528
7 changed files with 132 additions and 516 deletions
134
Cargo.lock
generated
134
Cargo.lock
generated
|
@ -547,6 +547,29 @@ version = "0.11.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d965446196e3b7decd44aa7ee49e31d630118f90ef12f97900f262eb915c951d"
|
||||
|
||||
[[package]]
|
||||
name = "bindgen"
|
||||
version = "0.66.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "f2b84e06fc203107bfbad243f4aba2af864eb7db3b1cf46ea0a023b0b433d2a7"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"cexpr",
|
||||
"clang-sys",
|
||||
"lazy_static",
|
||||
"lazycell",
|
||||
"log",
|
||||
"peeking_take_while",
|
||||
"prettyplease",
|
||||
"proc-macro2",
|
||||
"quote",
|
||||
"regex",
|
||||
"rustc-hash 1.1.0",
|
||||
"shlex",
|
||||
"syn 2.0.79",
|
||||
"which 4.4.2",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "bitflags"
|
||||
version = "1.3.2"
|
||||
|
@ -670,6 +693,12 @@ dependencies = [
|
|||
"serde",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cargo-emit"
|
||||
version = "0.2.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1582e1c9e755dd6ad6b224dcffb135d199399a4568d454bd89fe515ca8425695"
|
||||
|
||||
[[package]]
|
||||
name = "cargo-generate"
|
||||
version = "0.21.3"
|
||||
|
@ -746,6 +775,15 @@ dependencies = [
|
|||
"shlex",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cexpr"
|
||||
version = "0.6.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766"
|
||||
dependencies = [
|
||||
"nom",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "cfg-if"
|
||||
version = "1.0.0"
|
||||
|
@ -811,6 +849,17 @@ dependencies = [
|
|||
"inout",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clang-sys"
|
||||
version = "1.8.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4"
|
||||
dependencies = [
|
||||
"glob",
|
||||
"libc",
|
||||
"libloading",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "clap"
|
||||
version = "4.5.18"
|
||||
|
@ -861,7 +910,7 @@ dependencies = [
|
|||
"nix 0.28.0",
|
||||
"terminfo",
|
||||
"thiserror",
|
||||
"which",
|
||||
"which 6.0.3",
|
||||
"winapi",
|
||||
]
|
||||
|
||||
|
@ -2326,6 +2375,12 @@ dependencies = [
|
|||
"thiserror",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "glob"
|
||||
version = "0.3.1"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b"
|
||||
|
||||
[[package]]
|
||||
name = "globset"
|
||||
version = "0.4.15"
|
||||
|
@ -3028,6 +3083,12 @@ version = "1.5.0"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe"
|
||||
|
||||
[[package]]
|
||||
name = "lazycell"
|
||||
version = "1.3.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55"
|
||||
|
||||
[[package]]
|
||||
name = "libc"
|
||||
version = "0.2.159"
|
||||
|
@ -3048,6 +3109,16 @@ dependencies = [
|
|||
"pkg-config",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libloading"
|
||||
version = "0.8.5"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4"
|
||||
dependencies = [
|
||||
"cfg-if",
|
||||
"windows-targets 0.48.5",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "libredox"
|
||||
version = "0.1.3"
|
||||
|
@ -3248,7 +3319,8 @@ checksum = "0e7465ac9959cc2b1404e8e2367b43684a6d13790fe23056cc8c6c5a6b7bcb94"
|
|||
[[package]]
|
||||
name = "mc-attestation-verifier"
|
||||
version = "0.4.3"
|
||||
source = "git+https://github.com/informalsystems/attestation#ae86e2804abed218f4fd2fd4aec5e39408898cd8"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "fcf39fb1af41156ec868564ab53156d6dd75f1dc8a7a073acdfb217b6140d9e4"
|
||||
dependencies = [
|
||||
"der",
|
||||
"displaydoc",
|
||||
|
@ -3263,11 +3335,25 @@ dependencies = [
|
|||
"x509-cert",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mc-sgx-core-build"
|
||||
version = "0.11.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "94420a570e76dfc39924b4ec712c2df21a8d77e61ca5ba0857300b1c59889a5d"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cargo-emit",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mc-sgx-core-sys-types"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1c5c33323d0f2855e63efaa538bdd7094104ff79f963734b4122f23302cff581"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"cargo-emit",
|
||||
"mc-sgx-core-build",
|
||||
"serde",
|
||||
"serde_with",
|
||||
]
|
||||
|
@ -3275,7 +3361,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mc-sgx-core-types"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "1191b0bb2868ff5bdf7766d3b3e9fa9bb94c23149ae21a82485e6f5f44074106"
|
||||
dependencies = [
|
||||
"bitflags 2.6.0",
|
||||
"displaydoc",
|
||||
|
@ -3292,15 +3379,19 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mc-sgx-dcap-sys-types"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "2dd3e93a316a5c142de6fb9179970abc04ca4767732b90d118c90d531db47e89"
|
||||
dependencies = [
|
||||
"bindgen",
|
||||
"mc-sgx-core-build",
|
||||
"mc-sgx-core-sys-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "mc-sgx-dcap-types"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "42c618d93a3f9561bdc27231fa7965ebe855c8d74f5cd5467da194042e0671a9"
|
||||
dependencies = [
|
||||
"const-oid",
|
||||
"displaydoc",
|
||||
|
@ -3320,7 +3411,8 @@ dependencies = [
|
|||
[[package]]
|
||||
name = "mc-sgx-util"
|
||||
version = "0.11.0"
|
||||
source = "git+https://github.com/informalsystems/sgx#f25807776cbe10901f53d23fca548c9e4f6f284c"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "b3c237bec3e33530c4b1a171c8c078ad5d525d5fae177ac9d62e8e454b3fffb7"
|
||||
|
||||
[[package]]
|
||||
name = "memchr"
|
||||
|
@ -3723,6 +3815,12 @@ dependencies = [
|
|||
"syn 2.0.79",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "peeking_take_while"
|
||||
version = "0.1.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "19b17cddbe7ec3f8bc800887bab5e717348c95ea2ca0b1bf0837fb964dc67099"
|
||||
|
||||
[[package]]
|
||||
name = "peg"
|
||||
version = "0.8.4"
|
||||
|
@ -4305,7 +4403,7 @@ dependencies = [
|
|||
"pin-project-lite",
|
||||
"quinn-proto",
|
||||
"quinn-udp",
|
||||
"rustc-hash",
|
||||
"rustc-hash 2.0.0",
|
||||
"rustls 0.23.13",
|
||||
"socket2",
|
||||
"thiserror",
|
||||
|
@ -4322,7 +4420,7 @@ dependencies = [
|
|||
"bytes",
|
||||
"rand",
|
||||
"ring 0.17.8",
|
||||
"rustc-hash",
|
||||
"rustc-hash 2.0.0",
|
||||
"rustls 0.23.13",
|
||||
"slab",
|
||||
"thiserror",
|
||||
|
@ -4675,6 +4773,12 @@ version = "0.1.24"
|
|||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "719b953e2095829ee67db738b3bfa9fa368c94900df327b3f07fe6e794d2fe1f"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "1.1.0"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2"
|
||||
|
||||
[[package]]
|
||||
name = "rustc-hash"
|
||||
version = "2.0.0"
|
||||
|
@ -6388,6 +6492,18 @@ dependencies = [
|
|||
"rustls-pki-types",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "4.4.2"
|
||||
source = "registry+https://github.com/rust-lang/crates.io-index"
|
||||
checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7"
|
||||
dependencies = [
|
||||
"either",
|
||||
"home",
|
||||
"once_cell",
|
||||
"rustix",
|
||||
]
|
||||
|
||||
[[package]]
|
||||
name = "which"
|
||||
version = "6.0.3"
|
||||
|
|
|
@ -75,10 +75,10 @@ tendermint-light-client-detector = { version = "=0.38.1", default-features = fal
|
|||
tendermint-rpc = { version = "=0.38.1", default-features = false, features = ["http-client"] }
|
||||
|
||||
# mobilecoin
|
||||
mc-sgx-core-types = { git = "https://github.com/informalsystems/sgx", default-features = false }
|
||||
mc-sgx-dcap-types = { git = "https://github.com/informalsystems/sgx", default-features = false }
|
||||
mc-sgx-dcap-sys-types = { git = "https://github.com/informalsystems/sgx", default-features = false }
|
||||
mc-attestation-verifier = { git = "https://github.com/informalsystems/attestation", default-features = false }
|
||||
mc-sgx-core-types = { version = "0.11.0", default-features = false }
|
||||
mc-sgx-dcap-types = { version = "0.11.0", default-features = false }
|
||||
mc-sgx-dcap-sys-types = { version = "0.11.0", default-features = false }
|
||||
mc-attestation-verifier = { version = "0.4.3", default-features = false }
|
||||
|
||||
# quartz
|
||||
cw-proof = { path = "crates/contracts/cw-proof", default-features = false }
|
||||
|
|
|
@ -1,62 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 <REQUEST> <REQUEST_MSG>"
|
||||
echo " <REQUEST>: Instantiate | SessionCreate | SessionSetPubKey"
|
||||
exit 1
|
||||
}
|
||||
|
||||
DIR_QUARTZ=$(git rev-parse --show-toplevel)
|
||||
DIR_PROTO="$DIR_QUARTZ/core/quartz-proto/proto"
|
||||
|
||||
REQUEST="$1"
|
||||
REQUEST_MSG=${2:-"{}"}
|
||||
|
||||
# Use the QUARTZ_PORT environment variable if set, otherwise default to 11090
|
||||
QUARTZ_PORT="${QUARTZ_PORT:-11090}"
|
||||
|
||||
# query the gRPC quartz enclave service
|
||||
ATTESTED_MSG=$(grpcurl -plaintext -import-path "$DIR_PROTO" -proto quartz.proto -d "$REQUEST_MSG" "127.0.0.1:$QUARTZ_PORT" quartz.Core/"$REQUEST" | jq -c '.message | fromjson')
|
||||
|
||||
# parse out the quote and the message
|
||||
QUOTE=$(echo "$ATTESTED_MSG" | jq -c '.quote')
|
||||
MSG=$(echo "$ATTESTED_MSG" | jq 'del(.quote)')
|
||||
|
||||
if [ "$MOCK_SGX" ]; then
|
||||
case "$REQUEST" in
|
||||
"Instantiate")
|
||||
jq -nc --argjson msg "$MSG" --argjson "attestation" "$QUOTE" '$ARGS.named'
|
||||
;;
|
||||
"SessionCreate" | "SessionSetPubKey")
|
||||
REQUEST_KEY=$(echo "$REQUEST" | perl -pe 's/([A-Z])/_\L$1/g;s/^_//')
|
||||
jq -nc --argjson quartz "$(jq -nc --argjson "$REQUEST_KEY" "$(jq -nc \
|
||||
--argjson msg "$MSG" --argjson attestation "$QUOTE" '$ARGS.named')" \
|
||||
'$ARGS.named')" '$ARGS.named'
|
||||
;;
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
||||
exit 0
|
||||
fi
|
||||
|
||||
case "$REQUEST" in
|
||||
"Instantiate")
|
||||
jq -nc --argjson msg "$MSG" --argjson "attestation" \
|
||||
"$(jq -nc --argjson collateral "$COLLATERAL" '$ARGS.named')" \
|
||||
'$ARGS.named'
|
||||
;;
|
||||
|
||||
"SessionCreate" | "SessionSetPubKey")
|
||||
REQUEST_KEY=$(echo "$REQUEST" | perl -pe 's/([A-Z])/_\L$1/g;s/^_//')
|
||||
jq -nc --argjson quartz "$(jq -nc --argjson "$REQUEST_KEY" "$(jq -nc --argjson msg "$MSG" --argjson attestation \
|
||||
"$(jq -nc --argjson collateral "$COLLATERAL" '$ARGS.named')" \
|
||||
'$ARGS.named')" '$ARGS.named')" '$ARGS.named'
|
||||
;;
|
||||
|
||||
*)
|
||||
usage
|
||||
;;
|
||||
esac
|
|
@ -27,7 +27,7 @@ impl Handler for InitRequest {
|
|||
let config = config.as_ref();
|
||||
info!("{}", "\nPeforming Init".blue().bold());
|
||||
|
||||
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("..");
|
||||
let root_dir = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("../..");
|
||||
|
||||
let parent = self
|
||||
.name
|
||||
|
@ -50,8 +50,8 @@ impl Handler for InitRequest {
|
|||
overwrite: true,
|
||||
vcs: Some(Vcs::Git),
|
||||
template_path: TemplatePath {
|
||||
// git: Some("git@github.com:informalsystems/cycles-quartz.git".to_string()), // TODO: replace with public http address when open-sourced
|
||||
path: Some(root_dir.join("apps/transfers").display().to_string()),
|
||||
// git: Some("git@github.com:informalsystems/cycles-quartz.git".to_string()), // TODO: replace with git address when open-sourced
|
||||
path: Some(root_dir.join("examples/transfers").display().to_string()),
|
||||
..TemplatePath::default()
|
||||
},
|
||||
..GenerateArgs::default()
|
||||
|
|
|
@ -1,8 +0,0 @@
|
|||
FEATURES=
|
||||
|
||||
if [ -n "$MOCK_SGX" ]; then
|
||||
echo "MOCK_SGX is set. Adding mock-sgx feature."
|
||||
FEATURES="--features=mock-sgx"
|
||||
fi
|
||||
|
||||
RUSTFLAGS='-C link-arg=-s' cargo wasm $FEATURES
|
|
@ -1,355 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
# Color definitions
|
||||
RED='\033[0;31m'
|
||||
GREEN='\033[0;32m'
|
||||
YELLOW='\033[1;33m'
|
||||
BLUE='\033[0;34m'
|
||||
MAGENTA='\033[0;35m'
|
||||
CYAN='\033[0;36m'
|
||||
BOLD='\033[1m'
|
||||
NC='\033[0m' # No Color
|
||||
|
||||
# Function to print colored and formatted messages
|
||||
print_message() {
|
||||
local color=$1
|
||||
local message=$2
|
||||
echo -e "${color}${BOLD}${message}${NC}"
|
||||
}
|
||||
|
||||
# Function to print section headers
|
||||
print_header() {
|
||||
local message=$1
|
||||
echo -e "\n${MAGENTA}${BOLD}======== $message ========${NC}\n"
|
||||
}
|
||||
|
||||
# Function to print success messages
|
||||
print_success() {
|
||||
local message=$1
|
||||
echo -e "${GREEN}${BOLD}✅ $message${NC}"
|
||||
}
|
||||
|
||||
# Function to print error messages
|
||||
print_error() {
|
||||
local message=$1
|
||||
echo -e "${RED}${BOLD}❌ Error: $message${NC}"
|
||||
exit 1
|
||||
}
|
||||
|
||||
# Function to print waiting messages
|
||||
print_waiting() {
|
||||
local message=$1
|
||||
echo -e "${YELLOW}${BOLD}⏳ $message${NC}"
|
||||
}
|
||||
|
||||
# Function to update and display progress
|
||||
update_progress() {
|
||||
local step=$1
|
||||
local total_steps=$2
|
||||
local percentage=$((step * 100 / total_steps))
|
||||
print_message $BLUE "Progress: [$percentage%] Step $step of $total_steps"
|
||||
}
|
||||
|
||||
|
||||
# Set up variables
|
||||
ROOT=${ROOT:-$(git rev-parse --show-toplevel)}
|
||||
WASMD_HOME=${WASMD_HOME:-"$HOME/.neutrond"}
|
||||
USER_ADDR=$(neutrond keys show -a "val1" --keyring-backend test --home "$WASMD_HOME" --keyring-dir "$WASMD_HOME")
|
||||
|
||||
if [ -z "$USER_ADDR" ]; then
|
||||
print_error "User address not found. Please ensure the key exists in the keyring."
|
||||
fi
|
||||
|
||||
WASM_BIN="$1"
|
||||
INSTANTIATE_MSG="$2"
|
||||
NODE_URL=${NODE_URL:-127.0.0.1:26657}
|
||||
LABEL=${LABEL:-quartz-transfers-app}
|
||||
COUNT=${COUNT:-0}
|
||||
QUARTZ_PORT="${QUARTZ_PORT:-11090}"
|
||||
CHAIN_ID=${CHAIN_ID:-test-1}
|
||||
TXFLAG="--chain-id ${CHAIN_ID} --gas-prices 0.0025untrn --gas auto --gas-adjustment 1.3 --keyring-dir "$WASMD_HOME" --keyring-backend "test" "
|
||||
CMD="neutrond --node http://$NODE_URL"
|
||||
|
||||
|
||||
|
||||
|
||||
TOTAL_STEPS=7
|
||||
CURRENT_STEP=0
|
||||
|
||||
update_progress $((++CURRENT_STEP)) $TOTAL_STEPS
|
||||
print_header "Deploying WASM Contract"
|
||||
print_message $CYAN "Contract: ${WASM_BIN}"
|
||||
print_message $CYAN "Chain ID: ${CHAIN_ID}"
|
||||
print_message $CYAN "User Address: ${USER_ADDR}"
|
||||
print_message $CYAN "Command: $CMD"
|
||||
|
||||
print_message $BLUE "Storing WASM contract..."
|
||||
RES=$($CMD tx wasm store "$WASM_BIN" --from "$USER_ADDR" $TXFLAG -y --output json )
|
||||
TX_HASH=$(echo "$RES" | jq -r '.txhash')
|
||||
print_message $CYAN "Transaction hash: $TX_HASH"
|
||||
|
||||
print_waiting "Waiting for transaction to be included in a block..."
|
||||
ATTEMPTS=0
|
||||
MAX_ATTEMPTS=30
|
||||
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
|
||||
TX_RESULT=$($CMD query tx "$TX_HASH" --output json 2>/dev/null || echo '{"code": 1}')
|
||||
TX_CODE=$(echo "$TX_RESULT" | jq -r '.code // .tx_result.code // 1')
|
||||
if [[ $TX_CODE == "0" ]]; then
|
||||
print_success "Transaction processed successfully."
|
||||
break
|
||||
elif [[ $TX_CODE != "1" ]]; then
|
||||
print_error "Error processing transaction. Code: $TX_CODE"
|
||||
fi
|
||||
print_waiting "Transaction not yet processed. Waiting... (Attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS)"
|
||||
sleep 2
|
||||
ATTEMPTS=$((ATTEMPTS+1))
|
||||
done
|
||||
|
||||
if [ $ATTEMPTS -eq $MAX_ATTEMPTS ]; then
|
||||
print_error "Failed to retrieve transaction after $MAX_ATTEMPTS attempts."
|
||||
fi
|
||||
|
||||
print_message $BLUE "Extracting CODE_ID..."
|
||||
CODE_ID=$(echo "$TX_RESULT" | jq -r '.events[] | select(.type=="store_code") | .attributes[] | select(.key=="code_id") | .value')
|
||||
print_message $CYAN "Extracted CODE_ID: $CODE_ID"
|
||||
|
||||
if [[ -z "$CODE_ID" || "$CODE_ID" == "null" ]]; then
|
||||
print_error "Failed to extract CODE_ID."
|
||||
fi
|
||||
|
||||
update_progress $((++CURRENT_STEP)) $TOTAL_STEPS
|
||||
print_header "Instantiating Contract"
|
||||
print_message $CYAN "Label: ${LABEL}"
|
||||
print_message $CYAN "Code ID: ${CODE_ID}"
|
||||
|
||||
INSTANTIATE_MSG_PARSED=$(echo "$INSTANTIATE_MSG" | jq -r '.')
|
||||
INSTANTIATE_MSG_ONELINE=$(echo "$INSTANTIATE_MSG_PARSED" | jq '{quartz: .} + {denom: "untrn"}' )
|
||||
|
||||
|
||||
|
||||
# Print the instantiate message for debugging
|
||||
echo "Instantiate message: $INSTANTIATE_MSG_ONELINE"
|
||||
|
||||
INSTANTIATE_CMD="$CMD tx wasm instantiate $CODE_ID '$INSTANTIATE_MSG_ONELINE' --from "$USER_ADDR" $TXFLAG --label $LABEL -y --no-admin --output json"
|
||||
|
||||
print_message $BLUE "Executing instantiate command..."
|
||||
RES=$(eval "$INSTANTIATE_CMD")
|
||||
TX_HASH=$(echo "$RES" | jq -r '.txhash')
|
||||
|
||||
print_waiting "Waiting for instantiate transaction to be processed..."
|
||||
ATTEMPTS=0
|
||||
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
|
||||
TX_RESULT=$($CMD query tx "$TX_HASH" --output json 2>/dev/null || echo '{"code": 1}')
|
||||
TX_CODE=$(echo "$TX_RESULT" | jq -r '.code // .tx_result.code // 1')
|
||||
if [[ $TX_CODE == "0" ]]; then
|
||||
print_success "Instantiate transaction processed successfully."
|
||||
break
|
||||
elif [[ $TX_CODE != "1" ]]; then
|
||||
print_error "Error processing instantiate transaction. Code: $TX_CODE"
|
||||
fi
|
||||
print_waiting "Instantiate transaction not yet processed. Waiting... (Attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS)"
|
||||
sleep 2
|
||||
ATTEMPTS=$((ATTEMPTS+1))
|
||||
done
|
||||
|
||||
if [ $ATTEMPTS -eq $MAX_ATTEMPTS ]; then
|
||||
print_error "Failed to retrieve instantiate transaction after $MAX_ATTEMPTS attempts."
|
||||
fi
|
||||
|
||||
print_message $BLUE "Querying for instantiated contract..."
|
||||
RES=$($CMD query wasm list-contract-by-code "$CODE_ID" --output json)
|
||||
CONTRACT=$(echo "$RES" | jq -r '.contracts[0]')
|
||||
|
||||
if [[ -z "$CONTRACT" || "$CONTRACT" == "null" ]]; then
|
||||
print_error "Failed to retrieve contract address."
|
||||
fi
|
||||
|
||||
print_message $CYAN "CONTRACT: $CONTRACT"
|
||||
|
||||
cd $ROOT/relayer
|
||||
|
||||
update_progress $((++CURRENT_STEP)) $TOTAL_STEPS
|
||||
print_header "Executing SessionCreate on Enclave"
|
||||
export EXECUTE_CREATE=$(QUARTZ_PORT=$QUARTZ_PORT ./scripts/relay.sh SessionCreate)
|
||||
if [ -z "$EXECUTE_CREATE" ]; then
|
||||
print_error "Failed to execute SessionCreate on enclave"
|
||||
fi
|
||||
print_success "SessionCreate execution successful"
|
||||
|
||||
print_message $BLUE "Submitting SessionCreate to contract..."
|
||||
RES=$($CMD tx wasm execute "$CONTRACT" "$EXECUTE_CREATE" --from "$USER_ADDR" $TXFLAG --keyring-backend "test" --keyring-dir "$WASMD_HOME" -y --output json)
|
||||
TX_HASH=$(echo "$RES" | jq -r '.txhash')
|
||||
if [ -z "$TX_HASH" ] || [ "$TX_HASH" == "null" ]; then
|
||||
print_error "Failed to retrieve transaction hash"
|
||||
fi
|
||||
print_message $CYAN "Transaction hash: $TX_HASH"
|
||||
|
||||
print_waiting "Waiting for transaction to be included in a block..."
|
||||
ATTEMPTS=0
|
||||
MAX_ATTEMPTS=30
|
||||
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
|
||||
TX_RESULT=$($CMD query tx "$TX_HASH" --output json 2>/dev/null || echo '{"code": 1}')
|
||||
TX_CODE=$(echo "$TX_RESULT" | jq -r '.code // .tx_result.code // 1')
|
||||
if [[ $TX_CODE == "0" ]]; then
|
||||
print_success "Transaction processed successfully."
|
||||
break
|
||||
elif [[ $TX_CODE != "1" ]]; then
|
||||
print_error "Error processing transaction. Code: $TX_CODE"
|
||||
fi
|
||||
print_waiting "Transaction not yet processed. Waiting... (Attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS)"
|
||||
sleep 2
|
||||
ATTEMPTS=$((ATTEMPTS+1))
|
||||
done
|
||||
|
||||
if [ $ATTEMPTS -eq $MAX_ATTEMPTS ]; then
|
||||
print_error "Failed to retrieve transaction after $MAX_ATTEMPTS attempts."
|
||||
fi
|
||||
|
||||
|
||||
print_success "Handshake process completed"
|
||||
|
||||
update_progress $((++CURRENT_STEP)) $TOTAL_STEPS
|
||||
print_header "Setting Session PK"
|
||||
|
||||
cd $ROOT/utils/tm-prover
|
||||
export PROOF_FILE="light-client-proof.json"
|
||||
rm -f "$PROOF_FILE"
|
||||
|
||||
print_message $BLUE "Removed old $PROOF_FILE"
|
||||
|
||||
# print_waiting "Waiting for new blocks to be produced..."
|
||||
print_waiting "Waiting for transaction to be included in a block..."
|
||||
ATTEMPTS=0
|
||||
MAX_ATTEMPTS=30
|
||||
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
|
||||
TX_RESULT=$($CMD query tx "$TX_HASH" --output json 2>/dev/null || echo '{"code": 1}')
|
||||
TX_CODE=$(echo "$TX_RESULT" | jq -r '.code // .tx_result.code // 1')
|
||||
if [[ $TX_CODE == "0" ]]; then
|
||||
print_success "Transaction processed successfully."
|
||||
break
|
||||
elif [[ $TX_CODE != "1" ]]; then
|
||||
print_error "Error processing transaction. Code: $TX_CODE"
|
||||
fi
|
||||
print_waiting "Transaction not yet processed. Waiting... (Attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS)"
|
||||
sleep 2
|
||||
ATTEMPTS=$((ATTEMPTS+1))
|
||||
done
|
||||
|
||||
|
||||
print_success "Required blocks produced. Proceeding with tm-prover..."
|
||||
|
||||
cd "$ROOT/apps/transfers"
|
||||
export TRUSTED_HASH=$(cat trusted.hash)
|
||||
export TRUSTED_HEIGHT=$(cat trusted.height)
|
||||
|
||||
print_message $CYAN "Trusted hash: $TRUSTED_HASH"
|
||||
print_message $CYAN "Trusted height: $TRUSTED_HEIGHT"
|
||||
|
||||
cd $ROOT/utils/tm-prover
|
||||
export QUARTZ_SESSION=$($CMD query wasm contract-state raw $CONTRACT $(echo -n "quartz_session" | xxd -p -c 20) --node "http://$NODE_URL")
|
||||
print_message $CYAN "Quartz Session before prover: $QUARTZ_SESSION"
|
||||
|
||||
export PROOF_FILE="light-client-proof.json"
|
||||
if [ -f "$PROOF_FILE" ]; then
|
||||
rm "$PROOF_FILE"
|
||||
print_message $BLUE "Removed old $PROOF_FILE"
|
||||
fi
|
||||
|
||||
print_message $BLUE "Running prover to get light client proof..."
|
||||
cargo run -- --chain-id test-1 \
|
||||
--primary "http://$NODE_URL" \
|
||||
--witnesses "http://$NODE_URL" \
|
||||
--trusted-height $TRUSTED_HEIGHT \
|
||||
--trusted-hash $TRUSTED_HASH \
|
||||
--contract-address $CONTRACT \
|
||||
--storage-key "quartz_session" \
|
||||
--trace-file $PROOF_FILE > /dev/null 2>&1
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
print_success "Light client proof generated successfully"
|
||||
else
|
||||
print_error "Failed to generate light client proof"
|
||||
fi
|
||||
|
||||
export POP=$(cat $PROOF_FILE)
|
||||
export POP_MSG=$(jq -nc --arg message "$POP" '$ARGS.named')
|
||||
|
||||
update_progress $((++CURRENT_STEP)) $TOTAL_STEPS
|
||||
|
||||
print_header "Executing SessionSetPubKey on Enclave"
|
||||
cd $ROOT/relayer
|
||||
export EXECUTE_SETPUB=$(QUARTZ_PORT=$QUARTZ_PORT ./scripts/relay.sh SessionSetPubKey "$POP_MSG")
|
||||
|
||||
RES=$($CMD tx wasm execute "$CONTRACT" "$EXECUTE_SETPUB" --from "$USER_ADDR" $TXFLAG --keyring-backend "test" --keyring-dir "$WASMD_HOME" -y --output json)
|
||||
TX_HASH=$(echo $RES | jq -r '.txhash')
|
||||
|
||||
if [ -z "$TX_HASH" ] || [ "$TX_HASH" == "null" ]; then
|
||||
print_error "Failed to retrieve transaction hash"
|
||||
fi
|
||||
print_message $CYAN "Transaction hash: $TX_HASH"
|
||||
|
||||
print_waiting "Waiting for transaction to commit..."
|
||||
ATTEMPTS=0
|
||||
MAX_ATTEMPTS=30
|
||||
while [ $ATTEMPTS -lt $MAX_ATTEMPTS ]; do
|
||||
if $CMD query tx "$TX_HASH" &> /dev/null; then
|
||||
print_success "Transaction committed successfully"
|
||||
break
|
||||
fi
|
||||
print_waiting "Waiting for tx (Attempt $((ATTEMPTS+1))/$MAX_ATTEMPTS)"
|
||||
sleep 2
|
||||
ATTEMPTS=$((ATTEMPTS+1))
|
||||
done
|
||||
|
||||
if [ $ATTEMPTS -eq $MAX_ATTEMPTS ]; then
|
||||
print_error "Transaction failed to commit after $MAX_ATTEMPTS attempts"
|
||||
fi
|
||||
|
||||
update_progress $((++CURRENT_STEP)) $TOTAL_STEPS
|
||||
print_header "Checking Session Success"
|
||||
export NONCE_AND_KEY=$($CMD query wasm contract-state raw "$CONTRACT" $(printf '%s' "quartz_session" | hexdump -ve '/1 "%02X"') -o json | jq -r .data | base64 -d)
|
||||
# echo $NONCE_AND_KEY
|
||||
export PUBKEY=$(echo $NONCE_AND_KEY | jq -r .pub_key)
|
||||
|
||||
update_progress $TOTAL_STEPS $TOTAL_STEPS
|
||||
print_header "Deployment Summary"
|
||||
print_success "Deployment and handshake completed successfully!"
|
||||
echo -e "${CYAN}${BOLD}"
|
||||
echo "📌 Contract Details:"
|
||||
echo " • Address: ${CONTRACT}"
|
||||
echo " • Code ID: ${CODE_ID}"
|
||||
echo " • Label: ${LABEL}"
|
||||
echo " • Chain ID: ${CHAIN_ID}"
|
||||
echo
|
||||
echo "🔑 Contract Key Information:"
|
||||
echo " • Public Key: ${PUBKEY}"
|
||||
echo
|
||||
echo "🌐 Network Information:"
|
||||
echo " • Node URL: ${NODE_URL}"
|
||||
echo " • Quartz Port: ${QUARTZ_PORT}"
|
||||
echo
|
||||
echo "👤 User Information:"
|
||||
echo " • Address: ${USER_ADDR}"
|
||||
echo " • Keyring Backend: test"
|
||||
echo " • Keyring Directory: /home/peppi/.neutrond/"
|
||||
echo
|
||||
echo "🔧 Additional Settings:"
|
||||
echo " • Gas Prices: 0.0025untrn"
|
||||
echo " • Gas Adjustment: 1.3"
|
||||
echo -e "${NC}"
|
||||
|
||||
# ASCII art logo for QUARTZ
|
||||
cat << "EOF"
|
||||
|
||||
██████ ██ ██ █████ ██████ ████████ ███████
|
||||
██ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
██ ██ ██ ██ ███████ ██████ ██ ███████
|
||||
██ ▄▄ ██ ██ ██ ██ ██ ██ ██ ██ ██
|
||||
██████ ██████ ██ ██ ██ ██ ██ ███████
|
||||
▀▀
|
||||
POWERED BY INFORMAL.SYSTEMMS
|
||||
EOF
|
||||
|
||||
print_message $MAGENTA "We hope you'll enjoy developing Quartz Apps!"
|
|
@ -1,75 +0,0 @@
|
|||
#!/bin/bash
|
||||
|
||||
# Deploy the specified contract's `WASM_BIN` to the chain specified by `CHAIN_ID` using the `USER_ADDR` account.
|
||||
|
||||
set -eo pipefail
|
||||
|
||||
usage() {
|
||||
echo "Usage: $0 WASM_BIN [COUNT]"
|
||||
echo "Example: $0 artifacts/cofi_karma_game.wasm"
|
||||
exit 1
|
||||
}
|
||||
|
||||
if [ -z "$1" ]; then
|
||||
echo "❌ Error: Missing WASM_BIN parameter. Please check if all parameters were specified."
|
||||
usage
|
||||
fi
|
||||
|
||||
if [ "$#" -gt 9 ]; then
|
||||
echo "❌ Error: Incorrect number of parameters."
|
||||
usage
|
||||
fi
|
||||
|
||||
USER_ADDR=${USER_ADDR:-$(wasmd keys show -a admin)}
|
||||
WASM_BIN="$1"
|
||||
CHAIN_ID=${CHAIN_ID:-testing}
|
||||
NODE_URL=${NODE_URL:-127.0.0.1:26657}
|
||||
LABEL=${LABEL:-bisenzone-mvp}
|
||||
COUNT=${COUNT:-0}
|
||||
INSTANTIATE_MSG=${INSTANTIATE_MSG:-"null"}
|
||||
|
||||
TXFLAG="--chain-id ${CHAIN_ID} --gas-prices 0.0025ucosm --gas auto --gas-adjustment 1.3"
|
||||
|
||||
CMD="wasmd --node http://$NODE_URL"
|
||||
|
||||
echo "🚀 Deploying WASM contract '${WASM_BIN}' on chain '${CHAIN_ID}' using account '${USER_ADDR}'..."
|
||||
echo " with cmd : $CMD"
|
||||
echo "===================================================================="
|
||||
|
||||
RES=$($CMD tx wasm store "$WASM_BIN" --from "$USER_ADDR" $TXFLAG -y --output json)
|
||||
echo $RES
|
||||
TX_HASH=$(echo $RES | jq -r '.["txhash"]')
|
||||
|
||||
while ! $CMD query tx $TX_HASH &> /dev/null; do
|
||||
echo "... 🕐 waiting for contract to deploy from tx hash $TX_HASH"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
RES=$($CMD query tx "$TX_HASH" --output json)
|
||||
CODE_ID=$(echo $RES | jq -r '.logs[0].events[1].attributes[1].value')
|
||||
|
||||
echo ""
|
||||
echo "🚀 Instantiating contract with the following parameters:"
|
||||
echo "--------------------------------------------------------"
|
||||
echo "Label: ${LABEL}"
|
||||
echo "--------------------------------------------------------"
|
||||
|
||||
RES=$($CMD tx wasm instantiate "$CODE_ID" "$INSTANTIATE_MSG" --from "$USER_ADDR" --label $LABEL $TXFLAG -y --no-admin --output json)
|
||||
TX_HASH=$(echo $RES | jq -r '.["txhash"]')
|
||||
|
||||
|
||||
echo ""
|
||||
while ! $CMD query tx $TX_HASH &> /dev/null; do
|
||||
echo "... 🕐 waiting for contract to be queryable from tx hash $TX_HASH"
|
||||
sleep 1
|
||||
done
|
||||
|
||||
RES=$($CMD query wasm list-contract-by-code "$CODE_ID" --output json)
|
||||
CONTRACT=$(echo $RES | jq -r '.contracts[0]')
|
||||
|
||||
echo "🚀 Successfully deployed and instantiated contract!"
|
||||
echo "🔗 Chain ID: ${CHAIN_ID}"
|
||||
echo "🆔 Code ID: ${CODE_ID}"
|
||||
echo "📌 Contract Address: ${CONTRACT}"
|
||||
echo "🔑 Contract Key: ${KEY}"
|
||||
echo "🔖 Contract Label: ${LABEL}"
|
Loading…
Reference in a new issue