#77 FIX - Changed quartz.manifest.template to allow any port for the enclave (#92)

This commit is contained in:
dusterbloom 2024-07-10 23:59:26 +02:00 committed by GitHub
parent 473f9622f7
commit 83441e5089
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 17 additions and 4 deletions

View file

@ -18,6 +18,7 @@ loader.env.RA_TLS_ISV_SVN = { passthrough = true }
loader.env.RA_TLS_ISV_PROD_ID = { passthrough = true } loader.env.RA_TLS_ISV_PROD_ID = { passthrough = true }
loader.env.RA_TLS_EPID_API_KEY = { passthrough = true } loader.env.RA_TLS_EPID_API_KEY = { passthrough = true }
loader.env.MYAPP_DATA = { passthrough = true } loader.env.MYAPP_DATA = { passthrough = true }
loader.env.QUARTZ_PORT = { passthrough = true }
loader.argv = ["enclave", loader.argv = ["enclave",
"--chain-id", "testing", "--chain-id", "testing",

View file

@ -1,4 +1,4 @@
use std::net::SocketAddr; use std::{env, net::SocketAddr};
use clap::Parser; use clap::Parser;
use color_eyre::eyre::{eyre, Result}; use color_eyre::eyre::{eyre, Result};
@ -19,7 +19,7 @@ fn parse_trust_threshold(s: &str) -> Result<TrustThreshold> {
#[command(author, version, about, long_about = None)] #[command(author, version, about, long_about = None)]
pub struct Cli { pub struct Cli {
/// RPC server address /// RPC server address
#[clap(long, default_value = "127.0.0.1:11090")] #[clap(long, default_value_t = default_rpc_addr())]
pub rpc_addr: SocketAddr, pub rpc_addr: SocketAddr,
/// Identifier of the chain /// Identifier of the chain
@ -50,3 +50,9 @@ pub struct Cli {
#[clap(long, default_value = "5")] #[clap(long, default_value = "5")]
pub max_block_lag: u64, pub max_block_lag: u64,
} }
fn default_rpc_addr() -> SocketAddr {
let port = env::var("QUARTZ_PORT").unwrap_or_else(|_| "11090".to_string());
format!("127.0.0.1:{}", port).parse().expect("Invalid socket address")
}

View file

@ -5,6 +5,9 @@ ROOT=${ROOT:-$HOME}
DEFAULT_NODE="127.0.0.1:26657" DEFAULT_NODE="127.0.0.1:26657"
NODE_URL=${NODE_URL:-$DEFAULT_NODE} NODE_URL=${NODE_URL:-$DEFAULT_NODE}
# Use the QUARTZ_PORT environment variable if set, otherwise default to 11090
QUARTZ_PORT="${QUARTZ_PORT:-11090}"
if [ "$#" -eq 0 ]; then if [ "$#" -eq 0 ]; then
echo "Usage: $0 <contract_address>" echo "Usage: $0 <contract_address>"
exit 1 # Exit with a non-zero status to indicate an error exit 1 # Exit with a non-zero status to indicate an error
@ -56,7 +59,7 @@ echo "subscribe to events"
cd $ROOT/cycles-quartz/apps/transfers/enclave cd $ROOT/cycles-quartz/apps/transfers/enclave
echo "... executing transfer" echo "... executing transfer"
export UPDATE=$(grpcurl -plaintext -import-path ./proto/ -proto transfers.proto -d "$REQUEST_MSG" '127.0.0.1:11090' transfers.Settlement/Run | jq .message | jq -R 'fromjson | fromjson' | jq -c ) export UPDATE=$(grpcurl -plaintext -import-path ./proto/ -proto transfers.proto -d "$REQUEST_MSG" "127.0.0.1:$QUARTZ_PORT" transfers.Settlement/Run | jq .message | jq -R 'fromjson | fromjson' | jq -c )

View file

@ -20,11 +20,14 @@ REPORT_SIG_FILE="/tmp/${USER}_datareportsig"
REQUEST="$1" REQUEST="$1"
REQUEST_MSG=${2:-"{}"} REQUEST_MSG=${2:-"{}"}
# Use the QUARTZ_PORT environment variable if set, otherwise default to 11090
QUARTZ_PORT="${QUARTZ_PORT:-11090}"
# clear tmp files from previous runs # clear tmp files from previous runs
rm -f "$QUOTE_FILE" "$REPORT_FILE" "$REPORT_SIG_FILE" rm -f "$QUOTE_FILE" "$REPORT_FILE" "$REPORT_SIG_FILE"
# query the gRPC quartz enclave service # query the gRPC quartz enclave service
ATTESTED_MSG=$(grpcurl -plaintext -import-path "$DIR_PROTO" -proto quartz.proto -d "$REQUEST_MSG" '127.0.0.1:11090' quartz.Core/"$REQUEST" | jq -c '.message | fromjson') 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 # parse out the quote and the message
QUOTE=$(echo "$ATTESTED_MSG" | jq -c '.quote') QUOTE=$(echo "$ATTESTED_MSG" | jq -c '.quote')