This repository was archived by the owner on Jun 21, 2020. It is now read-only.
This repository was archived by the owner on Jun 21, 2020. It is now read-only.
System error if wrong contract address is passed to the secret contract computation #131
Open
Description
Description
Currently, when core
gets a computation for a non-existent secret contract address, it throws an error saying that's missing the "State Keys" but does not return a proper "Failed Compute" result, so that it never reaches p2p. This should be corrected.
To Reproduce
- Create the following test in /enigma-core/app/src/wasm_u/wasm.rs:
#[test]
fn non_existent_contract_address() {
let (mut db, _dir) = create_test_db();
let contract_address = generate_contract_address();
let non_existent_contract_address = generate_contract_address();
let enclave = init_enclave_wrapper().unwrap();
instantiate_encryption_key(vec![contract_address], enclave.geteid());
let (keys, shared_key, _, _) = exchange_keys(enclave.geteid());
let encrypted_construct = symmetric::encrypt("construct()".as_bytes(), &shared_key).unwrap();
let encrypted_args = symmetric::encrypt(ðabi::encode(&[]), &shared_key).unwrap();
let deploy_res = compile_and_deploy_wasm_contract(
&mut db,
enclave.geteid(),
"../../examples/eng_wasm_contracts/flip_coin",
contract_address,
&encrypted_construct,
&encrypted_args,
&keys.get_pubkey()
).unwrap_result();
let exe_code = deploy_res.output;
let (keys, shared_key, _, _) = exchange_keys(enclave.geteid());
let encrypted_callable = symmetric::encrypt("flip()".as_bytes(), &shared_key).unwrap();
let encrypted_args = symmetric::encrypt(ðabi::encode(&[]), &shared_key).unwrap();
// Execute the contract with wrong address
let result = wasm::execute(
&mut db,
enclave.geteid(),
&exe_code,
&encrypted_callable,
&encrypted_args,
&keys.get_pubkey(),
&non_existent_contract_address,
GAS_LIMIT
).expect("Execution failed").unwrap_result();
}
- Run the test
- See the system error:
Execution failed: EnclaveFailError { err: KeysError, status: SGX_SUCCESS }'
Expected behavior
Return to the user the error message about wrong contract address.