Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
11 changes: 5 additions & 6 deletions cli/demo_direct_call.sh
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,6 @@ echo "Using worker-rpc-port ${RPORT}"
AMOUNTSHIELD=50000000000
AMOUNTTRANSFER=40000000000

TIMEOUT="timeout 30s "
CLIENT="./../bin/integritee-cli -p ${NPORT} -P ${RPORT}"

if [ "$READMRENCLAVE" = "file" ]
Expand All @@ -73,26 +72,26 @@ echo " Bob's incognito account = ${ICGACCOUNTBOB}"
echo ""

echo "* Issue ${AMOUNTSHIELD} tokens to Alice's incognito account"
$TIMEOUT ${CLIENT} trusted set-balance ${ICGACCOUNTALICE} ${AMOUNTSHIELD} --mrenclave ${MRENCLAVE} --direct
${CLIENT} trusted set-balance ${ICGACCOUNTALICE} ${AMOUNTSHIELD} --mrenclave ${MRENCLAVE} --direct
Comment on lines -76 to +75
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Removing the timeout means that we potentially wait forever? Or what was the motivation?

Copy link
Contributor Author

@haerdib haerdib Nov 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, that is true. But since this is used as a CI test, I think we should know if no fitting confirmation is issued by the parentchain.

Copy link
Contributor Author

@haerdib haerdib Nov 15, 2021

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So my motiviation: Wait forever such that we know something is wrong.

echo ""

echo "Get balance of Alice's incognito account"
$TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE}
${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE}
echo ""

#send funds from Alice to bobs account
echo "* Send ${AMOUNTTRANSFER} funds from Alice's incognito account to Bob's incognito account"
$TIMEOUT $CLIENT trusted transfer ${ICGACCOUNTALICE} ${ICGACCOUNTBOB} ${AMOUNTTRANSFER} --mrenclave ${MRENCLAVE} --direct
$CLIENT trusted transfer ${ICGACCOUNTALICE} ${ICGACCOUNTBOB} ${AMOUNTTRANSFER} --mrenclave ${MRENCLAVE} --direct
echo ""

echo "* Get balance of Alice's incognito account"
RESULT=$($TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE} | xargs)
RESULT=$(${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE} | xargs)
echo $RESULT
echo ""


echo "* Bob's incognito account balance"
RESULT=$($TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTBOB} --mrenclave ${MRENCLAVE} | xargs)
RESULT=$(${CLIENT} trusted balance ${ICGACCOUNTBOB} --mrenclave ${MRENCLAVE} | xargs)
echo $RESULT
echo ""

Expand Down
15 changes: 7 additions & 8 deletions cli/demo_shielding_unshielding.sh
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ AMOUNTSHIELD=50000000000
AMOUNTTRANSFER=25000000000
AMOUNTUNSHIELD=15000000000

TIMEOUT="timeout 30s "
CLIENT="./../bin/integritee-cli -p ${NPORT} -P ${RPORT}"

echo "* Query on-chain enclave registry:"
Expand Down Expand Up @@ -90,43 +89,43 @@ echo ""
sleep 10

echo "* Shield ${AMOUNTSHIELD} tokens to Alice's incognito account"
${TIMEOUT} ${CLIENT} shield-funds //Alice ${ICGACCOUNTALICE} ${AMOUNTSHIELD} ${MRENCLAVE} ${WORKERPORT}
${CLIENT} shield-funds //Alice ${ICGACCOUNTALICE} ${AMOUNTSHIELD} ${MRENCLAVE} ${WORKERPORT}
echo ""

echo "* Waiting 10 seconds"
sleep 10
echo ""

echo "Get balance of Alice's incognito account"
$TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE}
${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE}
echo ""

echo "* Get balance of Alice's on-chain account"
${CLIENT} balance "//Alice"
echo ""

echo "* Send ${AMOUNTTRANSFER} funds from Alice's incognito account to Bob's incognito account"
$TIMEOUT $CLIENT trusted transfer ${ICGACCOUNTALICE} ${ICGACCOUNTBOB} ${AMOUNTTRANSFER} --mrenclave ${MRENCLAVE}
$CLIENT trusted transfer ${ICGACCOUNTALICE} ${ICGACCOUNTBOB} ${AMOUNTTRANSFER} --mrenclave ${MRENCLAVE}
echo ""

echo "* Get balance of Alice's incognito account"
$TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE}
${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE}
echo ""

echo "* Bob's incognito account balance"
$TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTBOB} --mrenclave ${MRENCLAVE}
${CLIENT} trusted balance ${ICGACCOUNTBOB} --mrenclave ${MRENCLAVE}
echo ""

echo "* Un-shield ${AMOUNTUNSHIELD} tokens from Alice's incognito account"
$TIMEOUT ${CLIENT} trusted unshield-funds ${ICGACCOUNTALICE} //Alice ${AMOUNTUNSHIELD} ${MRENCLAVE} --mrenclave ${MRENCLAVE} --xt-signer //Alice
${CLIENT} trusted unshield-funds ${ICGACCOUNTALICE} //Alice ${AMOUNTUNSHIELD} ${MRENCLAVE} --mrenclave ${MRENCLAVE} --xt-signer //Alice
echo ""

echo "* Waiting 10 seconds"
sleep 10
echo ""

echo "Get balance of Alice's incognito account"
RESULT=$($TIMEOUT ${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE} | xargs)
RESULT=$(${CLIENT} trusted balance ${ICGACCOUNTALICE} --mrenclave ${MRENCLAVE} | xargs)
echo $RESULT

echo "* Get balance of Alice's on-chain account"
Expand Down
48 changes: 25 additions & 23 deletions cli/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -531,8 +531,11 @@ fn send_request(matches: &ArgMatches<'_>, call: TrustedCallSigned) -> Option<Vec
// send and watch extrinsic until block is executed
let block_hash =
_chain_api.send_extrinsic(xt.hex_encode(), XtStatus::InBlock).unwrap().unwrap();
info!("stf call extrinsic sent. Block Hash: {:?}", block_hash);
info!("waiting for confirmation of stf call");
info!(
"Trusted call extrinsic sent and sucessfully included in parentchain block with hash {:?}.",
block_hash
);
info!("Waiting for execution confirmation from enclave...");
let (events_in, events_out) = channel();
_chain_api.subscribe_events(events_in).unwrap();

Expand All @@ -541,19 +544,19 @@ fn send_request(matches: &ArgMatches<'_>, call: TrustedCallSigned) -> Option<Vec
decoder.register_type_size::<Hash>("H256").unwrap();

loop {
let ret: ProposedSidechainBlockArgs = _chain_api
.wait_for_event::<ProposedSidechainBlockArgs>(
let ret: ProcessedParentchainBlockArgs = _chain_api
.wait_for_event::<ProcessedParentchainBlockArgs>(
Comment on lines +547 to +548
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here we waited for BlockConfirmed args. Did block confirm change over time? If not, I am not 100% convinced that this solves the issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm honestly not 100% sure what the previous problem was, but I think it might have been partially fixed by cleaning up the Confirmations on the worker side th PR #501 and now fixing the Block listening event... But the tests pass now without a Timeout. Is that not convincing enough?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If they pass consistently, I am convinced. :D

TEEREX,
"ProposedSidechainBlock",
"ProcessedParentchainBlock",
Some(decoder.clone()),
&events_out,
)
.unwrap();
info!("ProposedSidechainBlock event received");
debug!("Expected stf block Hash: {:?}", block_hash);
debug!("Confirmed stf block Hash: {:?}", ret.payload);
if ret.payload == block_hash {
return Some(ret.payload.encode())
info!("Confirmation of ProcessedParentchainBlock received");
debug!("Expected block Hash: {:?}", block_hash);
debug!("Confirmed stf block Hash: {:?}", ret.block_hash);
if ret.block_hash == block_hash {
return Some(ret.block_hash.encode())
}
}
}
Expand Down Expand Up @@ -661,9 +664,10 @@ fn send_direct_request(

#[allow(dead_code)]
#[derive(Decode)]
struct ProposedSidechainBlockArgs {
struct ProcessedParentchainBlockArgs {
Comment on lines -664 to +667
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Small but significant change in how to read this code 😄

signer: AccountId,
payload: H256,
block_hash: H256,
merkle_root: H256,
}

fn listen(matches: &ArgMatches<'_>) {
Expand All @@ -690,24 +694,23 @@ fn listen(matches: &ArgMatches<'_>) {
let _events = Vec::<frame_system::EventRecord<Event, Hash>>::decode(&mut _er_enc);
blocks += 1;
match _events {
Ok(evts) => {
Ok(evts) =>
for evr in &evts {
println!("decoded: phase {:?} event {:?}", evr.phase, evr.event);
match &evr.event {
/* Event::balances(be) => {
Event::Balances(be) => {
println!(">>>>>>>>>> balances event: {:?}", be);
match &be {
pallet_balances::RawEvent::Transfer(transactor, dest, value, fee) => {
println!("Transactor: {:?}", transactor);
println!("Destination: {:?}", dest);
pallet_balances::Event::Transfer(from, to, value) => {
println!("From: {:?}", from);
println!("To: {:?}", to);
println!("Value: {:?}", value);
println!("Fee: {:?}", fee);
}
},
_ => {
debug!("ignoring unsupported balances event");
}
},
}
},*/
},
Event::Teerex(ee) => {
println!(">>>>>>>>>> integritee event: {:?}", ee);
count += 1;
Expand Down Expand Up @@ -767,8 +770,7 @@ fn listen(matches: &ArgMatches<'_>) {
},
_ => debug!("ignoring unsupported module event: {:?}", evr.event),
}
}
},
},
Err(_) => error!("couldn't decode event record list"),
}
}
Expand Down