Skip to content

Commit

Permalink
Merge pull request #57 from olisystems/merge-upstream
Browse files Browse the repository at this point in the history
Merge upstream
  • Loading branch information
clangenb authored Sep 13, 2023
2 parents 2d79833 + 9f63a25 commit 363e4fa
Show file tree
Hide file tree
Showing 82 changed files with 2,824 additions and 744 deletions.
10 changes: 7 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,13 @@ 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![],
ParentchainId::TargetB => 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
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
46 changes: 23 additions & 23 deletions cli/demo_sidechain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,68 +20,68 @@
#
# usage:
# export RUST_LOG_LOG=integritee-cli=info,ita_stf=info
# demo_sidechain.sh -p <NODEPORT> -A <WORKER1PORT> -B <WORKER2PORT> -m file
# demo_sidechain.sh -p <NODEPORT> -A <WORKER_1_PORT> -B <WORKER_2_PORT> -m file
#
# TEST_BALANCE_RUN is either "first" or "second"
# if -m file is set, the mrenclave will be read from file.

while getopts ":m:p:A:B:t:u:W:V:C:" opt; do
case $opt in
t)
TEST=$OPTARG
;;
m)
READMRENCLAVE=$OPTARG
READ_MRENCLAVE=$OPTARG
;;
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}"

INITIALFUNDS=50000000000
AMOUNTTRANSFER=20000000000

CLIENTWORKER1="${CLIENT_BIN} -p ${NPORT} -P ${WORKER1PORT} -u ${NODEURL} -U ${WORKER1URL}"
CLIENTWORKER2="${CLIENT_BIN} -p ${NPORT} -P ${WORKER2PORT} -u ${NODEURL} -U ${WORKER2URL}"
CLIENTWORKER1="${CLIENT_BIN} -p ${INTEGRITEE_RPC_PORT} -P ${WORKER_1_PORT} -u ${INTEGRITEE_RPC_URL} -U ${WORKER_1_URL}"
CLIENTWORKER2="${CLIENT_BIN} -p ${INTEGRITEE_RPC_PORT} -P ${WORKER_2_PORT} -u ${INTEGRITEE_RPC_URL} -U ${WORKER_2_URL}"

if [ "$READMRENCLAVE" = "file" ]
if [ "$READ_MRENCLAVE" = "file" ]
then
read MRENCLAVE <<< $(cat ~/mrenclave.b58)
echo "Reading MRENCLAVE from file: ${MRENCLAVE}"
Expand Down
27 changes: 15 additions & 12 deletions cli/demo_smart_contract.sh
Original file line number Diff line number Diff line change
Expand Up @@ -13,25 +13,28 @@

# usage:
# export RUST_LOG_LOG=integritee-cli=info,ita_stf=info
# demo_smart_contract.sh -p <NODEPORT> -P <WORKERPORT>
# demo_smart_contract.sh -p <NODEPORT> -P <WORKER_PORT>

while getopts ":p:A:u:V:C:" opt; do
case $opt in
p)
NPORT=$OPTARG
INTEGRITEE_RPC_PORT=$OPTARG
;;
A)
WORKERPORT=$OPTARG
WORKER_PORT=$OPTARG
;;
u)
NODEURL=$OPTARG
INTEGRITEE_RPC_URL=$OPTARG
;;
V)
WORKERURL=$OPTARG
WORKER_URL=$OPTARG
;;
C)
CLIENT_BIN=$OPTARG
;;
*)
echo "invalid arg ${OPTARG}"
exit 1
esac
done

Expand All @@ -43,21 +46,21 @@ ADDFUNCTION="1003e2d200000000000000000000000000000000000000000000000000000000000


# 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"}

WORKERPORT=${WORKERPORT:-2000}
WORKERURL=${WORKERURL:-"wss://127.0.0.1"}
WORKER_PORT=${WORKER_PORT:-2000}
WORKER_URL=${WORKER_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 ${WORKERURL}:${WORKERPORT}"
echo "Using node uri ${INTEGRITEE_RPC_URL}:${INTEGRITEE_RPC_PORT}"
echo "Using trusted-worker uri ${WORKER_URL}:${WORKER_PORT}"

CLIENTWORKER="${CLIENT_BIN} -p ${NPORT} -P ${WORKERPORT} -u ${NODEURL} -U ${WORKERURL}"
CLIENTWORKER="${CLIENT_BIN} -p ${INTEGRITEE_RPC_PORT} -P ${WORKER_PORT} -u ${INTEGRITEE_RPC_URL} -U ${WORKER_URL}"


# this will always take the first MRENCLAVE found in the registry !!
Expand Down
Loading

0 comments on commit 363e4fa

Please sign in to comment.