Skip to content
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
@moriaab

Description

@moriaab

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

  1. 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(&ethabi::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(&ethabi::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();

    }
  1. Run the test
  2. 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.

Metadata

Metadata

Assignees

Labels

bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions