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

multiple parentchain handlers #1420

Merged
merged 100 commits into from
Sep 8, 2023
Merged
Show file tree
Hide file tree
Changes from 83 commits
Commits
Show all changes
100 commits
Select commit Hold shift + click to select a range
c2663d1
[enclave-runtime/initialization] lift some code out of the innermost …
clangenb Aug 17, 2023
b866e92
[enclave-runtime/initialization] rename `EnclaveIndirectExecutor` to …
clangenb Aug 17, 2023
2de2e2a
[enclave-runtime/initialization] rename stuff that is only for the pr…
clangenb Aug 17, 2023
4b9b51b
[enclave-runtime/initialization] naively add second set of components…
clangenb Aug 17, 2023
0f10edc
[enclave-runtime/initialization] introduce second nonce cache for the…
clangenb Aug 17, 2023
a678568
[enclave-runtime/initialization/global_components] fix wrong type arg
clangenb Aug 17, 2023
f8a0b3e
[indirect-calls-executor] fix `DenyAll` implementation
clangenb Aug 17, 2023
1cb32dc
[enclave-runtime/initialization] code compiles for instantiating a se…
clangenb Aug 17, 2023
7e2dd91
[enclave-runtime/initialization] fmt
clangenb Aug 17, 2023
4cdc78c
[enclave-runtime/initialization] add second set of solochain parentch…
clangenb Aug 17, 2023
2d45de6
[enclave-runtime/initialization] extend parentchain init params with …
clangenb Aug 17, 2023
2b3e2b9
[enclave-runtime/initialization] add second light-client seal
clangenb Aug 17, 2023
ba29650
change parentchain init params enum, and add full code for initializa…
clangenb Aug 17, 2023
65fa713
fix some comments and naming
clangenb Aug 17, 2023
36a225b
[service] add cli options for the secondary node
clangenb Aug 26, 2023
cd5ed0a
extract `init_parentchain` function in service and add `parentchain_i…
clangenb Aug 26, 2023
5c5912f
rename `get_node_metadata_repository_from_solo_or_parachain` to `get_…
clangenb Aug 26, 2023
62baa76
[enclave-runtime] `set_nonce` takes into account the parentchain id now
clangenb Aug 26, 2023
b6214be
fix test compilation
clangenb Aug 26, 2023
49b1f68
add complete code for secondary parentchain
clangenb Aug 28, 2023
ae363c8
[service/config] fix cli naming
clangenb Aug 28, 2023
05be779
[service] indicate in logs that they are for the secondary parentchain
clangenb Aug 28, 2023
f5776b2
[service] fix clippy
clangenb Aug 28, 2023
f56dd03
[service] fix tests
clangenb Aug 29, 2023
54fce6f
Merge branch 'master' into cl/multiple-parentchain-handlers
clangenb Aug 29, 2023
e4c247d
[enclave-runtime] fix: don't initialize second light client seal on t…
clangenb Aug 29, 2023
8852fc9
[service/setup] fix purging second light client db.
clangenb Aug 29, 2023
e87763f
[service] print block number at which the enclave registered.
clangenb Aug 29, 2023
bc35b96
[parentchain] remove some unnecessary trait bounds (simplify error me…
clangenb Aug 29, 2023
22da128
[enclave-runtime] remove unused unit test
clangenb Aug 29, 2023
6a193ec
OnchainOcallApi does not take a paramenter such that it nows, which p…
clangenb Aug 29, 2023
9ceb679
[stf-executor] remove code that executes a state update upon before s…
clangenb Aug 29, 2023
58b0857
[service] propagate parentchain id throughout the codebase
clangenb Aug 29, 2023
2f26935
Merge branch 'master' into cl/multiple-parentchain-handlers
clangenb Aug 29, 2023
6041a19
[service] fix tests
clangenb Aug 29, 2023
54b72c9
[local-setup] prepare configs to run multiple nodes
clangenb Aug 29, 2023
62ba474
[stf-executor/executor] fix wrong import
clangenb Aug 30, 2023
9ee11ff
[local-setup] add a config that spawns two nodes
clangenb Aug 30, 2023
802fb1f
[service] remove unnecessary traitbounds
clangenb Aug 30, 2023
add0bd0
[service] minor logging fixes
clangenb Aug 30, 2023
99a8695
`sync_parentchain` and `trigger_parentchain_block_import` have the `P…
clangenb Aug 30, 2023
c4e2d74
[service/worker_onchain_ocall] log to which parentchain we want to se…
clangenb Aug 30, 2023
20470ba
[service/ocall_bridge] fix log typo
clangenb Aug 31, 2023
1373f1a
[enclave-runtime] supress clippy warning
clangenb Aug 31, 2023
808e31d
[service] fix: fund enclave on secondary parentchain
clangenb Sep 5, 2023
9a6412b
[service/worker_on_chain_ocall] improve log for extrinsic
clangenb Sep 5, 2023
f284d14
[local-setup] sleep 18 between setting up nodes, so that the logs are…
clangenb Sep 5, 2023
321147e
add new indirect calls filer, which checks for transfers to alice to …
clangenb Sep 6, 2023
e332533
[indirect-executor] use correct type in `TransferToAliceShieldsFundsF…
clangenb Sep 6, 2023
92bcd4c
[indirect-executor] better logging
clangenb Sep 6, 2023
37631f6
[local-setup/tmux_logger_two_nodes] only use three panes as the last …
clangenb Sep 6, 2023
60bd7c3
[indirect-executor] remove unused imports
clangenb Sep 6, 2023
a0b08bc
[indirect-executor/transfer_to_alice_shields_funds] fix alice account
clangenb Sep 6, 2023
3053b82
[local-setup] use trace in indirect executor
clangenb Sep 7, 2023
734c466
[cli] add `demo_shielding_unshielding_two_nodes` (working)
clangenb Sep 7, 2023
64951b1
rename `ParentchainId` enum variants to `Integritee` and `TargetA`
clangenb Sep 7, 2023
2f3401d
[node-api/metadata] format pallet_balances licence header.
clangenb Sep 7, 2023
580e4f4
[indirect-calls-executor] fix documentation
clangenb Sep 7, 2023
423409e
[indirect-calls-executor] rename `ALICE_ENCODED` to `ALICE_SEED`
clangenb Sep 7, 2023
2701a9f
[Enclave.edl] fix indents
clangenb Sep 7, 2023
d8f5a2f
rename `get_node_metadata_from_teerex_solo_or_parachain` to `get_node…
clangenb Sep 7, 2023
0ce9279
[enclave-runtime] rename error `NoTeerexParentchainAssigned` to `NoIn…
clangenb Sep 7, 2023
5775ef2
[enclave-runtime] rename error `NoSecondaryParentchainAssigned` to `N…
clangenb Sep 7, 2023
5299e0a
[itp-nonce-cache] rename caches to `INTEGRITEE_NONCE_CACHE` and `TARG…
clangenb Sep 7, 2023
8db5a9d
move nonce caches to the enclave-runtimes global components
clangenb Sep 7, 2023
7a2a2ec
[enclave-runtime] change doc comments to regular comments were suitable
clangenb Sep 7, 2023
aea91ad
[itp-settings] rename light-client db paths
clangenb Sep 7, 2023
2f0f5bb
[enclave-runtime/initialization] rename parachain.rs to integritee_pa…
clangenb Sep 7, 2023
a25a72f
[enclave-runtime/initialization] rename parachain2.rs to target_a_par…
clangenb Sep 7, 2023
3728c75
[enclave-runtime/initialization] rename solochain.rs to integritee_so…
clangenb Sep 7, 2023
34a1a31
[enclave-runtime/initialization] rename solochain2.rs to target_a_sol…
clangenb Sep 7, 2023
24c9ae1
[enclave-runtime/initialization] reflect previous changes in global c…
clangenb Sep 7, 2023
9b1ef4d
[enclave-runtime/initialization] consistent naming in global components
clangenb Sep 7, 2023
a51562d
[enclave-runtime/initialization] rename Teerex... types to Integritee…
clangenb Sep 7, 2023
d1da3e3
[enclave-runtime/initialization] rename Secondary... types to TargetA…
clangenb Sep 7, 2023
2ed6533
[enclave-runtime/initialization] better distinguish the two light-cli…
clangenb Sep 7, 2023
9657250
[enclave-runtime] some more minor renamings for new scheme
clangenb Sep 7, 2023
58a3e0c
[itp-settings] fix naming of target_a light client db path
clangenb Sep 7, 2023
875990a
[enclave-runtime/global_components] fix grammar in doc
clangenb Sep 7, 2023
3df83cb
[enclave-runtime/global_components] minor doc fixes
clangenb Sep 7, 2023
65f4739
[enclave-runtime/initialization] fix naming of light-client-db variables
clangenb Sep 7, 2023
4e498f8
[cli] rename cli args in demo scripts to be more readable and use new…
clangenb Sep 7, 2023
702b7b2
fmt
clangenb Sep 7, 2023
6a62b50
[enclave-runtime] more ergonomic code due to shorter variable names.
clangenb Sep 7, 2023
e6b9259
[indirect-calls-executor] simplify creation of alice's account id
clangenb Sep 7, 2023
275ac28
[indirect-calls-executor] add an assert_eq in the doc test
clangenb Sep 7, 2023
0352110
[service] update cli arguments to new parentchain naming
clangenb Sep 7, 2023
5a572d3
[service/config] fix missing renamings
clangenb Sep 7, 2023
ee60ca1
[service/node_api_factory] add endpoint renamings
clangenb Sep 7, 2023
34fec9e
[service/main] rename node_api to integritee_rpc_api
clangenb Sep 7, 2023
d544a01
[service/main] rename `init_parentchain` and `init_secondary_parentch…
clangenb Sep 7, 2023
d86ae9f
[service/config] fix naming
clangenb Sep 7, 2023
91c8ced
[service/main] fix moving of variables
clangenb Sep 7, 2023
246a8dc
[service] fix tests
clangenb Sep 7, 2023
be0d779
[service/bridge-api] rename error to new chain naming
clangenb Sep 7, 2023
f86a1a1
[service/ocall_bridge] rename api factories for new naming
clangenb Sep 7, 2023
ee87a92
consisten naming change remaning: target_a_chain -> target_a_parentchain
clangenb Sep 7, 2023
156cb9f
fix missing minor renamings
clangenb Sep 7, 2023
96ab015
clippy
clangenb Sep 7, 2023
272f233
[enclave-runtime/global-components] fix misallocation of `IntegriteeB…
clangenb Sep 8, 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
9 changes: 6 additions & 3 deletions app-libs/stf/src/stf_sgx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ use itp_stf_interface::{
};
use itp_stf_primitives::types::ShardIdentifier;
use itp_storage::storage_value_key;
use itp_types::OpaqueCall;
use itp_types::{parentchain::ParentchainId, OpaqueCall};
use itp_utils::stringify::account_id_to_string;
use log::*;
use sp_runtime::traits::StaticLookup;
Expand Down Expand Up @@ -114,9 +114,12 @@ where
});
}

fn storage_hashes_to_update_on_block() -> Vec<Vec<u8>> {
fn storage_hashes_to_update_on_block(parentchain_id: &ParentchainId) -> Vec<Vec<u8>> {
// Get all shards that are currently registered.
vec![shards_key_hash()]
match parentchain_id {
ParentchainId::Integritee => vec![shards_key_hash()],
ParentchainId::TargetA => vec![],
}
}
}

Expand Down
27 changes: 15 additions & 12 deletions cli/demo_direct_call.sh
Original file line number Diff line number Diff line change
Expand Up @@ -27,46 +27,49 @@ while getopts ":m:p:P:t:u:V:C:" opt; do
TEST=$OPTARG
;;
m)
READMRENCLAVE=$OPTARG
READ_MRENCLAVE=$OPTARG
;;
p)
NPORT=$OPTARG
INTEGRITEE_RPC_PORT=$OPTARG
;;
P)
WORKER1PORT=$OPTARG
WORKER_1_PORT=$OPTARG
;;
u)
NODEURL=$OPTARG
INTEGRITEE_RPC_URL=$OPTARG
;;
V)
WORKER1URL=$OPTARG
WORKER_1_URL=$OPTARG
;;
C)
CLIENT_BIN=$OPTARG
;;
*)
echo "invalid arg ${OPTARG}"
exit 1
esac
done

# Using default port if none given as arguments.
NPORT=${NPORT:-9944}
NODEURL=${NODEURL:-"ws://127.0.0.1"}
INTEGRITEE_RPC_PORT=${INTEGRITEE_RPC_PORT:-9944}
INTEGRITEE_RPC_URL=${INTEGRITEE_RPC_URL:-"ws://127.0.0.1"}

WORKER1PORT=${WORKER1PORT:-2000}
WORKER1URL=${WORKER1URL:-"wss://127.0.0.1"}
WORKER_1_PORT=${WORKER_1_PORT:-2000}
WORKER_1_URL=${WORKER_1_URL:-"wss://127.0.0.1"}

CLIENT_BIN=${CLIENT_BIN:-"./../bin/integritee-cli"}

echo "Using client binary ${CLIENT_BIN}"
${CLIENT_BIN} --version
echo "Using node uri ${NODEURL}:${NPORT}"
echo "Using trusted-worker uri ${WORKER1URL}:${WORKER1PORT}"
echo "Using node uri ${INTEGRITEE_RPC_URL}:${INTEGRITEE_RPC_PORT}"
echo "Using trusted-worker uri ${WORKER_1_URL}:${WORKER_1_PORT}"
echo ""


AMOUNTSHIELD=50000000000
AMOUNTTRANSFER=40000000000

CLIENT="${CLIENT_BIN} -p ${NPORT} -P ${WORKER1PORT} -u ${NODEURL} -U ${WORKER1URL}"
CLIENT="${CLIENT_BIN} -p ${INTEGRITEE_RPC_PORT} -P ${WORKER_1_PORT} -u ${INTEGRITEE_RPC_URL} -U ${WORKER_1_URL}"
read -r MRENCLAVE <<< "$($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2; exit }')"

echo ""
Expand Down
3 changes: 3 additions & 0 deletions cli/demo_direct_call_2_workers.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,9 @@ while getopts ":p:A:B:u:W:V:C:" opt; do
C)
CLIENT_BIN=$OPTARG
;;
*)
echo "invalid arg ${OPTARG}"
exit 1
esac
done

Expand Down
37 changes: 20 additions & 17 deletions cli/demo_indirect_invocation.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,51 +8,54 @@ set -euo pipefail
while getopts ":p:A:B:u:W:V:C:" opt; do
case $opt in
p)
NPORT=$OPTARG
INTEGRITEE_RPC_PORT=$OPTARG
;;
A)
WORKER1PORT=$OPTARG
WORKER_1_PORT=$OPTARG
;;
B)
WORKER2PORT=$OPTARG
WORKER_2_PORT=$OPTARG
;;
u)
NODEURL=$OPTARG
INTEGRITEE_RPC_URL=$OPTARG
;;
V)
WORKER1URL=$OPTARG
WORKER_1_URL=$OPTARG
;;
W)
WORKER2URL=$OPTARG
WORKER_2_URL=$OPTARG
;;
C)
CLIENT_BIN=$OPTARG
;;
*)
echo "invalid arg ${OPTARG}"
exit 1
esac
done

# Using default port if none given as arguments.
NPORT=${NPORT:-9944}
NODEURL=${NODEURL:-"ws://127.0.0.1"}
INTEGRITEE_RPC_PORT=${INTEGRITEE_RPC_PORT:-9944}
INTEGRITEE_RPC_URL=${INTEGRITEE_RPC_URL:-"ws://127.0.0.1"}

WORKER1PORT=${WORKER1PORT:-2000}
WORKER1URL=${WORKER1URL:-"wss://127.0.0.1"}
WORKER_1_PORT=${WORKER_1_PORT:-2000}
WORKER_1_URL=${WORKER_1_URL:-"wss://127.0.0.1"}

WORKER2PORT=${WORKER2PORT:-3000}
WORKER2URL=${WORKER2URL:-"wss://127.0.0.1"}
WORKER_2_PORT=${WORKER_2_PORT:-3000}
WORKER_2_URL=${WORKER_2_URL:-"wss://127.0.0.1"}

CLIENT_BIN=${CLIENT_BIN:-"./../bin/integritee-cli"}

echo "Using client binary ${CLIENT_BIN}"
${CLIENT_BIN} --version
echo "Using node uri ${NODEURL}:${NPORT}"
echo "Using trusted-worker 1 uri ${WORKER1URL}:${WORKER1PORT}"
echo "Using trusted-worker 2 uri ${WORKER2URL}:${WORKER2PORT}"
echo "Using node uri ${INTEGRITEE_RPC_URL}:${INTEGRITEE_RPC_PORT}"
echo "Using trusted-worker 1 uri ${WORKER_1_URL}:${WORKER_1_PORT}"
echo "Using trusted-worker 2 uri ${WORKER_2_URL}:${WORKER_2_PORT}"
echo ""

SCRIPT_DIR=$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)

"${SCRIPT_DIR}"/demo_shielding_unshielding.sh -p "${NPORT}" -u "${NODEURL}" -V "${WORKER1URL}" -P "${WORKER1PORT}" -C "${CLIENT_BIN}" -t first
"${SCRIPT_DIR}"/demo_shielding_unshielding.sh -p "${NPORT}" -u "${NODEURL}" -V "${WORKER2URL}" -P "${WORKER2PORT}" -C "${CLIENT_BIN}" -t second
"${SCRIPT_DIR}"/demo_shielding_unshielding.sh -p "${INTEGRITEE_RPC_PORT}" -u "${INTEGRITEE_RPC_URL}" -V "${WORKER_1_URL}" -P "${WORKER_1_PORT}" -C "${CLIENT_BIN}" -t first
"${SCRIPT_DIR}"/demo_shielding_unshielding.sh -p "${INTEGRITEE_RPC_PORT}" -u "${INTEGRITEE_RPC_URL}" -V "${WORKER_2_URL}" -P "${WORKER_2_PORT}" -C "${CLIENT_BIN}" -t second

exit 0
149 changes: 149 additions & 0 deletions cli/demo_shield_on_second_node_with_transfer_to_alice.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,149 @@
#!/bin/bash
set -euo pipefail

# Verifies that shielding from a secondary parentchain works by sending a transfer to //Alice

while getopts ":m:p:A:B:u:W:V:x:y:C:" opt; do
case $opt in
p)
INTEGRITEE_RPC_PORT=$OPTARG
;;
A)
WORKER_1_PORT=$OPTARG
;;
B)
WORKER_2_PORT=$OPTARG
;;
u)
INTEGRITEE_RPC_URL=$OPTARG
;;
V)
WORKER_1_URL=$OPTARG
;;
W)
WORKER_2_URL=$OPTARG
;;
x)
TARGET_A_CHAIN_RPC_URL=$OPTARG
;;
y)
TARGET_A_CHAIN_RPC_PORT=$OPTARG
;;
C)
CLIENT_BIN=$OPTARG
;;
*)
echo "invalid arg ${OPTARG}"
exit 1
esac
done

# Using default port if none given as arguments.
INTEGRITEE_RPC_PORT=${INTEGRITEE_RPC_PORT:-9944}
INTEGRITEE_RPC_URL=${INTEGRITEE_RPC_URL:-"ws://127.0.0.1"}
TARGET_A_CHAIN_RPC_PORT=${TARGET_A_CHAIN_RPC_PORT:-9966}
TARGET_A_CHAIN_RPC_URL=${TARGET_A_CHAIN_RPC_URL:-"ws://127.0.0.1"}

WORKER_1_PORT=${WORKER_1_PORT:-2000}
WORKER_1_URL=${WORKER_1_URL:-"wss://127.0.0.1"}

WORKER_2_PORT=${WORKER_2_PORT:-3000}
WORKER_2_URL=${WORKER_2_URL:-"wss://127.0.0.1"}

CLIENT_BIN=${CLIENT_BIN:-"./../bin/integritee-cli"}

echo "Using client binary ${CLIENT_BIN}"
${CLIENT_BIN} --version
echo "Using node uri ${INTEGRITEE_RPC_URL}:${INTEGRITEE_RPC_PORT}"
echo "Using node 2 uri ${TARGET_A_CHAIN_RPC_URL}:${TARGET_A_CHAIN_RPC_PORT}"
echo "Using trusted-worker 1 uri ${WORKER_1_URL}:${WORKER_1_PORT}"
echo "Using trusted-worker 2 uri ${WORKER_2_URL}:${WORKER_2_PORT}"
echo ""

# the parentchain token is 12 decimal
UNIT=$(( 10 ** 12 ))

# make these amounts greater than ED
AMOUNT_SHIELD=$(( 6 * UNIT ))
AMOUNT_TRANSFER=$(( 2 * UNIT ))
AMOUNT_UNSHIELD=$(( 1 * UNIT ))

CLIENT="${CLIENT_BIN} -p ${INTEGRITEE_RPC_PORT} -P ${WORKER_1_PORT} -u ${INTEGRITEE_RPC_URL} -U ${WORKER_1_URL}"
CLIENT2="${CLIENT_BIN} -p ${TARGET_A_CHAIN_RPC_PORT} -P ${WORKER_1_PORT} -u ${TARGET_A_CHAIN_RPC_URL} -U ${WORKER_1_URL}"

# interval and max rounds to wait to check the given account balance in sidechain
WAIT_INTERVAL_SECONDS=10
WAIT_ROUNDS=20

# Poll and assert the given account's state is equal to expected,
# with timeout WAIT_INTERVAL_SECONDS * WAIT_ROUNDS
# usage:
# wait_assert_state <mrenclave> <account> <state-name> <expected-state>
# the `state-name` has to be the supported subcommand, e.g. `balance`, `nonce`
function wait_assert_state()
{
for i in $(seq 1 $WAIT_ROUNDS); do
sleep $WAIT_INTERVAL_SECONDS
state=$(${CLIENT} trusted --mrenclave "$1" "$3" "$2")
if [ $state -eq "$4" ]; then
return
else
:
fi
done
echo
echo "Assert $2 $3 failed, expected = $4, actual = $state"
exit 1
}

# Do a live query and assert the given account's state is equal to expected
# usage:
# assert_state <mrenclave> <account> <state-name> <expected-state>
function assert_state()
{
state=$(${CLIENT} trusted --mrenclave "$1" "$3" "$2")
if [ -z "$state" ]; then
echo "Query $2 $3 failed"
exit 1
fi

if [ $state -eq "$4" ]; then
return
fi
echo
echo "Assert $2 $3 failed, expected = $4, actual = $state"
exit 1
}

echo "* Query on-chain enclave registry:"
${CLIENT} list-workers
echo ""

# this will always take the first MRENCLAVE found in the registry !!
read MRENCLAVE <<< $($CLIENT list-workers | awk '/ MRENCLAVE: / { print $2; exit }')
echo "Reading MRENCLAVE from worker list: ${MRENCLAVE}"

[[ -z $MRENCLAVE ]] && { echo "MRENCLAVE is empty. cannot continue" ; exit 1; }

ALICETRUSTEDACCOUNT=//Alice
echo " Alice's trusted account (same as public account) = ${ALICETRUSTEDACCOUNT}"
echo ""

# Assert the initial trusted balance of Alice incognito
TRUSTED_BALANCE_ALICE=1000000000000000
wait_assert_state ${MRENCLAVE} ${ALICETRUSTEDACCOUNT} balance ${TRUSTED_BALANCE_ALICE}


echo "* Send ${AMOUNT_SHIELD} from //Alice to //Alice on L1, which should trigger the demo shield process"
${CLIENT2} transfer //Alice ${ALICETRUSTEDACCOUNT} ${AMOUNT_SHIELD}
echo ""

echo "* Wait and assert Alice's incognito account balance, should be $(( TRUSTED_BALANCE_ALICE + AMOUNT_SHIELD ))"
wait_assert_state ${MRENCLAVE} ${ALICETRUSTEDACCOUNT} balance $(( TRUSTED_BALANCE_ALICE + AMOUNT_SHIELD ))
echo "✔ ok"

echo ""
echo "-----------------------"
echo "✔ The test passed!"
echo "-----------------------"
echo ""
29 changes: 16 additions & 13 deletions cli/demo_shielding_unshielding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,42 @@ while getopts ":m:p:P:t:u:V:C:" opt; do
TEST=$OPTARG
;;
m)
READMRENCLAVE=$OPTARG
READ_MRENCLAVE=$OPTARG
;;
p)
NPORT=$OPTARG
INTEGRITEE_RPC_PORT=$OPTARG
;;
P)
WORKER1PORT=$OPTARG
WORKER_1_PORT=$OPTARG
;;
u)
NODEURL=$OPTARG
INTEGRITEE_RPC_URL=$OPTARG
;;
V)
WORKER1URL=$OPTARG
WORKER_1_URL=$OPTARG
;;
C)
CLIENT_BIN=$OPTARG
;;
*)
echo "invalid arg ${OPTARG}"
exit 1
esac
done

# Using default port if none given as arguments.
NPORT=${NPORT:-9944}
NODEURL=${NODEURL:-"ws://127.0.0.1"}
INTEGRITEE_RPC_PORT=${INTEGRITEE_RPC_PORT:-9944}
INTEGRITEE_RPC_URL=${INTEGRITEE_RPC_URL:-"ws://127.0.0.1"}

WORKER1PORT=${WORKER1PORT:-2000}
WORKER1URL=${WORKER1URL:-"wss://127.0.0.1"}
WORKER_1_PORT=${WORKER_1_PORT:-2000}
WORKER_1_URL=${WORKER_1_URL:-"wss://127.0.0.1"}

CLIENT_BIN=${CLIENT_BIN:-"./../bin/integritee-cli"}

echo "Using client binary ${CLIENT_BIN}"
${CLIENT_BIN} --version
echo "Using node uri ${NODEURL}:${NPORT}"
echo "Using trusted-worker uri ${WORKER1URL}:${WORKER1PORT}"
echo "Using node uri ${INTEGRITEE_RPC_URL}:${INTEGRITEE_RPC_PORT}"
echo "Using trusted-worker uri ${WORKER_1_URL}:${WORKER_1_PORT}"
echo ""

# the parentchain token is 12 decimal
Expand All @@ -73,7 +76,7 @@ AMOUNT_SHIELD=$(( 6 * UNIT ))
AMOUNT_TRANSFER=$(( 2 * UNIT ))
AMOUNT_UNSHIELD=$(( 1 * UNIT ))

CLIENT="${CLIENT_BIN} -p ${NPORT} -P ${WORKER1PORT} -u ${NODEURL} -U ${WORKER1URL}"
CLIENT="${CLIENT_BIN} -p ${INTEGRITEE_RPC_PORT} -P ${WORKER_1_PORT} -u ${INTEGRITEE_RPC_URL} -U ${WORKER_1_URL}"

# offchain-worker only suppports indirect calls
CALLTYPE=
Expand Down Expand Up @@ -131,7 +134,7 @@ echo "* Query on-chain enclave registry:"
${CLIENT} list-workers
echo ""

if [ "$READMRENCLAVE" = "file" ]
if [ "$READ_MRENCLAVE" = "file" ]
then
read MRENCLAVE <<< $(cat ~/mrenclave.b58)
echo "Reading MRENCLAVE from file: ${MRENCLAVE}"
Expand Down
Loading
Loading