scrtlabs / enigma-core

Enigma Core library. The domain: Trusted and Untrusted App in Rust.
https://enigma.co
GNU Affero General Public License v3.0
94 stars 21 forks source link

Error in invocation of the external function: Trap: Trap { kind: Host(GasLimit) } #80

Closed lacabra closed 5 years ago

lacabra commented 5 years ago

Describe the bug Core throws the following error when trying to compute a task:

Error in invocation of the external function: Trap: Trap { kind: Host(GasLimit) }

To Reproduce The error above happens when trying to execute a secret contract across the network. The relevant steps to reproduce the behavior are the following:

  1. Compile the simple_addition secret contract
  2. Deploy it successfully across the network with the following parameters (subsequently encrypted with the DH key):
    • Function = construct()
    • Parameters = (empty)
  3. Deployment succeeds, core returns the deployed bytecode.
  4. Call computeTask with the following parameters (subsequently encrypted with the DH key):
    • Function = addition(int32,int32)
    • Parameters = [ [1, 'int32'], [2, 'int32'], ]
  5. core throws the error above

Expected behavior I was expecting that the computation task would succeed, like the deploySecretContract succeeded.

Backtrace

core_1        | 05:20:41 [DEBUG] tokio_zmq::async_types::future_types: ResponseFuture: received: Some("{\"type\":\"ComputeTask\",\"input\":{\"encryptedArgs\":\"47adaf2c304434d77f2a654459cab3586a67ad2eb01aae070f423fc5a5a214b2bf866a9c6fcad6aca768d7cabf49176930ae4955764dc91ae652077860bb91718439e8631553b720ecdb6ea2cfd0cfd76b50d1d61c293902b9d7ac36afe781c6cf1a7f6f9a99f7e8ad07d231b89f83f1b19fe72e114cc273bf8aaa83996037619cdbdde0306e0faaa5b895efaa98559802bc73317bb6efea5cc90c2d9c2a\",\"encryptedFn\":\"35b47dae6b718afb14f37d23b3eb574140ace17ef0b0ea0b379f7f0ef7103107094858bf7d9a47c490e1110669a680b7ae\",\"userDHKey\":\"2ea8e4cefb78efd0725ed12b23b05079a0a433cc8a656f212accf58672fee44a20cfcaa50466237273e762e49ec912be61358d5e90bff56a53a0ed42abfe27e3\",\"gasLimit\":1544,\"contractAddress\":\"88987af7d35eabcad95915b93bfd3d2bc3308f06b7197478b0dfca268f0497dc\"},\"id\":\"7GaMwT9XmmRX\"}")
core_1        | 05:20:41 [DEBUG] enigma_core_app::db::dal: DB: Read: cf: 88987af7d35eabcad95915b93bfd3d2bc3308f06b7197478b0dfca268f0497dc, key: [3]
core_1        | 05:20:42 [DEBUG] enigma_core_app::db::dal: DB: Read: cf: 88987af7d35eabcad95915b93bfd3d2bc3308f06b7197478b0dfca268f0497dc, key: [2]
core_1        | 05:20:42 [DEBUG] enigma_core_app::db::dal: LOG DERIVE: [231, 35, 223, 50, 98, 113, 138, 164, 130, 47, 55, 131, 102, 194, 208, 201, 61, 97, 102, 31, 124, 33, 69, 179, 91, 161, 224, 134, 36, 206, 239, 184, 211, 44, 170, 23, 183, 160, 138, 219, 8, 124, 33, 81, 232, 233, 35, 95, 34, 220, 118, 164, 39, 74, 67, 130, 159, 102, 211, 2, 23, 163, 255, 228, 22, 198, 226, 135, 29, 166, 53, 37, 72, 209, 207, 206, 164, 111, 167, 53, 122, 231, 10, 165, 230, 175]
core_1        | Error in invocation of the external function: Trap: Trap { kind: Host(GasLimit) }
core_1        | 05:20:42 [DEBUG] enigma_core_app::wasm_u::wasm: LOG DERIVE: EnclaveFailError { err: WasmError, status: SGX_SUCCESS }
core_1        | 
core_1        | stack backtrace:
core_1        |    0: failure::backtrace::internal::InternalBacktrace::new::hdfd00623e65741c1 (0x5556515f7c5d)
core_1        |    1: <failure::backtrace::Backtrace as core::default::Default>::default::h2d37721f771f169f (0x5556515f7eef)
core_1        |    2: failure::backtrace::Backtrace::new::h292cfb08c74e6fd4 (0x5556515f7f28)
core_1        |    3: enigma_core_app::wasm_u::wasm::execute::h2b6fe254aa973e32 (0x55565155cddc)
core_1        |    4: enigma_core_app::networking::ipc_listener::handling::compute_task::hb4a4191638cad8c4 (0x5556515145b6)
core_1        |    5: enigma_core_app::networking::ipc_listener::handle_message::h76aceb68e20cef19 (0x555651530b58)
core_1        |    6: <futures::stream::map::Map<S, F> as futures::stream::Stream>::poll::hb23859c0ae5599c0 (0x5556514f603d)
core_1        |    7: <futures::stream::forward::Forward<T, U> as futures::future::Future>::poll::h517f7d23820e7bd1 (0x5556514fc6ba)
core_1        |    8: <futures::future::map::Map<A, F> as futures::future::Future>::poll::hf41336ca30da212b (0x5556514f268d)
core_1        |    9: <futures::future::chain::Chain<A, B, C>>::poll::h074c0659b4833248 (0x5556514fea6c)
core_1        |   10: futures::task_impl::std::set::hf18bef85e2eb6c8a (0x5556514fc431)
core_1        |   11: futures::task_impl::std::ThreadNotify::with_current::h454491fb7082bf14 (0x5556514fc290)
core_1        |   12: futures::future::Future::wait::h761e03cb75db9c71 (0x5556514f3cec)
core_1        |   13: enigma_core_app::main::h32f14e4725b4e0bb (0x5556514f4977)
core_1        |   14: std::rt::lang_start::{{closure}}::hecabd70545cbfcce (0x5556514f5232)
core_1        |   15: std::rt::lang_start_internal::{{closure}}::hdc2a896aeffb5179 (0x5556519dcee2)
core_1        |              at libstd/rt.rs:59
core_1        |       std::panicking::try::do_call::h5a4eb2ce70a501f5
core_1        |              at libstd/panicking.rs:310
core_1        |   16: __rust_maybe_catch_panic (0x5556519fdf59)
core_1        |              at libpanic_unwind/lib.rs:102
core_1        |   17: std::panicking::try::h97436c380f30f437 (0x5556519df435)
core_1        |              at libstd/panicking.rs:289
core_1        |       std::panic::catch_unwind::h9c28ef6e0c478c5d
core_1        |              at libstd/panic.rs:392
core_1        |       std::rt::lang_start_internal::h6abd6befa9748e41
core_1        |              at libstd/rt.rs:58
core_1        |   18: main (0x5556514f4c23)
core_1        |   19: __libc_start_main (0x7f5f4122bb96)
core_1        |   20: _start (0x5556514eee39)
core_1        |   21: <unknown> (0x0)
core_1        | 05:20:42 [INFO] LOG DERIVE: Err(EnclaveFailError { err: WasmError, status: SGX_SUCCESS }
core_1        | 
core_1        | stack backtrace:
core_1        |    0: failure::backtrace::internal::InternalBacktrace::new::hdfd00623e65741c1 (0x5556515f7c5d)
core_1        |    1: <failure::backtrace::Backtrace as core::default::Default>::default::h2d37721f771f169f (0x5556515f7eef)
core_1        |    2: failure::backtrace::Backtrace::new::h292cfb08c74e6fd4 (0x5556515f7f28)
core_1        |    3: enigma_core_app::wasm_u::wasm::execute::h2b6fe254aa973e32 (0x55565155cddc)
core_1        |    4: enigma_core_app::networking::ipc_listener::handling::compute_task::hb4a4191638cad8c4 (0x5556515145b6)
core_1        |    5: enigma_core_app::networking::ipc_listener::handle_message::h76aceb68e20cef19 (0x555651530b58)
core_1        |    6: <futures::stream::map::Map<S, F> as futures::stream::Stream>::poll::hb23859c0ae5599c0 (0x5556514f603d)
core_1        |    7: <futures::stream::forward::Forward<T, U> as futures::future::Future>::poll::h517f7d23820e7bd1 (0x5556514fc6ba)
core_1        |    8: <futures::future::map::Map<A, F> as futures::future::Future>::poll::hf41336ca30da212b (0x5556514f268d)
core_1        |    9: <futures::future::chain::Chain<A, B, C>>::poll::h074c0659b4833248 (0x5556514fea6c)
core_1        |   10: futures::task_impl::std::set::hf18bef85e2eb6c8a (0x5556514fc431)
core_1        |   11: futures::task_impl::std::ThreadNotify::with_current::h454491fb7082bf14 (0x5556514fc290)
core_1        |   12: futures::future::Future::wait::h761e03cb75db9c71 (0x5556514f3cec)
core_1        |   13: enigma_core_app::main::h32f14e4725b4e0bb (0x5556514f4977)
core_1        |   14: std::rt::lang_start::{{closure}}::hecabd70545cbfcce (0x5556514f5232)
core_1        |   15: std::rt::lang_start_internal::{{closure}}::hdc2a896aeffb5179 (0x5556519dcee2)
core_1        |              at libstd/rt.rs:59
core_1        |       std::panicking::try::do_call::h5a4eb2ce70a501f5
core_1        |              at libstd/panicking.rs:310
core_1        |   16: __rust_maybe_catch_panic (0x5556519fdf59)
core_1        |              at libpanic_unwind/lib.rs:102
core_1        |   17: std::panicking::try::h97436c380f30f437 (0x5556519df435)
core_1        |              at libstd/panicking.rs:289
core_1        |       std::panic::catch_unwind::h9c28ef6e0c478c5d
core_1        |              at libstd/panic.rs:392
core_1        |       std::rt::lang_start_internal::h6abd6befa9748e41
core_1        |              at libstd/rt.rs:58
core_1        |   18: main (0x5556514f4c23)
core_1        |   19: __libc_start_main (0x7f5f4122bb96)
core_1        |   20: _start (0x5556514eee39)
core_1        |   21: <unknown> (0x0))
core_1        | 05:20:42 [ERROR] Unwrapped p2p Message failed: EnclaveFailError { err: WasmError, status: SGX_SUCCESS }
core_1        | 
core_1        | stack backtrace:
core_1        |    0: failure::backtrace::internal::InternalBacktrace::new::hdfd00623e65741c1 (0x5556515f7c5d)
core_1        |    1: <failure::backtrace::Backtrace as core::default::Default>::default::h2d37721f771f169f (0x5556515f7eef)
core_1        |    2: failure::backtrace::Backtrace::new::h292cfb08c74e6fd4 (0x5556515f7f28)
core_1        |    3: enigma_core_app::wasm_u::wasm::execute::h2b6fe254aa973e32 (0x55565155cddc)
core_1        |    4: enigma_core_app::networking::ipc_listener::handling::compute_task::hb4a4191638cad8c4 (0x5556515145b6)
core_1        |    5: enigma_core_app::networking::ipc_listener::handle_message::h76aceb68e20cef19 (0x555651530b58)
core_1        |    6: <futures::stream::map::Map<S, F> as futures::stream::Stream>::poll::hb23859c0ae5599c0 (0x5556514f603d)
core_1        |    7: <futures::stream::forward::Forward<T, U> as futures::future::Future>::poll::h517f7d23820e7bd1 (0x5556514fc6ba)
core_1        |    8: <futures::future::map::Map<A, F> as futures::future::Future>::poll::hf41336ca30da212b (0x5556514f268d)
core_1        |    9: <futures::future::chain::Chain<A, B, C>>::poll::h074c0659b4833248 (0x5556514fea6c)
core_1        |   10: futures::task_impl::std::set::hf18bef85e2eb6c8a (0x5556514fc431)
core_1        |   11: futures::task_impl::std::ThreadNotify::with_current::h454491fb7082bf14 (0x5556514fc290)
core_1        |   12: futures::future::Future::wait::h761e03cb75db9c71 (0x5556514f3cec)
core_1        |   13: enigma_core_app::main::h32f14e4725b4e0bb (0x5556514f4977)
core_1        |   14: std::rt::lang_start::{{closure}}::hecabd70545cbfcce (0x5556514f5232)
core_1        |   15: std::rt::lang_start_internal::{{closure}}::hdc2a896aeffb5179 (0x5556519dcee2)
core_1        |              at libstd/rt.rs:59
core_1        |       std::panicking::try::do_call::h5a4eb2ce70a501f5
core_1        |              at libstd/panicking.rs:310
core_1        |   16: __rust_maybe_catch_panic (0x5556519fdf59)
core_1        |              at libpanic_unwind/lib.rs:102
core_1        |   17: std::panicking::try::h97436c380f30f437 (0x5556519df435)
core_1        |              at libstd/panicking.rs:289
core_1        |       std::panic::catch_unwind::h9c28ef6e0c478c5d
core_1        |              at libstd/panic.rs:392
core_1        |       std::rt::lang_start_internal::h6abd6befa9748e41
core_1        |              at libstd/rt.rs:58
core_1        |   18: main (0x5556514f4c23)
core_1        |   19: __libc_start_main (0x7f5f4122bb96)
core_1        |   20: _start (0x5556514eee39)
core_1        |   21: <unknown> (0x0)
core_1        | 05:20:42 [DEBUG] tokio_zmq::async_types::sink_stream: Called start_send
core_1        | 05:20:42 [DEBUG] tokio_zmq::async_types::sink_stream: Created sink
core_1        | 05:20:42 [DEBUG] tokio_zmq::async_types::sink_stream: Called poll_complete
core_1        | 05:20:42 [DEBUG] tokio_zmq::async_types::future_types: RequestFuture: sending: Some("{\"id\":\"7GaMwT9XmmRX\",\"type\":\"Error\",\"msg\":\"EnclaveFailError { err: WasmError, status: SGX_SUCCESS }\\n\\nstack backtrace:\\n   0: failure::backtrace::internal::InternalBacktrace::new::hdfd00623e65741c1 (0x5556515f7c5d)\\n   1: <failure::backtrace::Backtrace as core::default::Default>::default::h2d37721f771f169f (0x5556515f7eef)\\n   2: failure::backtrace::Backtrace::new::h292cfb08c74e6fd4 (0x5556515f7f28)\\n   3: enigma_core_app::wasm_u::wasm::execute::h2b6fe254aa973e32 (0x55565155cddc)\\n   4: enigma_core_app::networking::ipc_listener::handling::compute_task::hb4a4191638cad8c4 (0x5556515145b6)\\n   5: enigma_core_app::networking::ipc_listener::handle_message::h76aceb68e20cef19 (0x555651530b58)\\n   6: <futures::stream::map::Map<S, F> as futures::stream::Stream>::poll::hb23859c0ae5599c0 (0x5556514f603d)\\n   7: <futures::stream::forward::Forward<T, U> as futures::future::Future>::poll::h517f7d23820e7bd1 (0x5556514fc6ba)\\n   8: <futures::future::map::Map<A, F> as futures::future::Future>::poll::hf41336ca30da212b (0x5556514f268d)\\n   9: <futures::future::chain::Chain<A, B, C>>::poll::h074c0659b4833248 (0x5556514fea6c)\\n  10: futures::task_impl::std::set::hf18bef85e2eb6c8a (0x5556514fc431)\\n  11: futures::task_impl::std::ThreadNotify::with_current::h454491fb7082bf14 (0x5556514fc290)\\n  12: futures::future::Future::wait::h761e03cb75db9c71 (0x5556514f3cec)\\n  13: enigma_core_app::main::h32f14e4725b4e0bb (0x5556514f4977)\\n  14: std::rt::lang_start::{{closure}}::hecabd70545cbfcce (0x5556514f5232)\\n  15: std::rt::lang_start_internal::{{closure}}::hdc2a896aeffb5179 (0x5556519dcee2)\\n             at libstd/rt.rs:59\\n      std::panicking::try::do_call::h5a4eb2ce70a501f5\\n             at libstd/panicking.rs:310\\n  16: __rust_maybe_catch_panic (0x5556519fdf59)\\n             at libpanic_unwind/lib.rs:102\\n  17: std::panicking::try::h97436c380f30f437 (0x5556519df435)\\n             at libstd/panicking.rs:289\\n      std::panic::catch_unwind::h9c28ef6e0c478c5d\\n             at libstd/panic.rs:392\\n      std::rt::lang_start_internal::h6abd6befa9748e41\\n             at libstd/rt.rs:58\\n  18: main (0x5556514f4c23)\\n  19: __libc_start_main (0x7f5f4122bb96)\\n  20: _start (0x5556514eee39)\\n  21: <unknown> (0x0)\"}")
core_1        | 05:20:42 [DEBUG] tokio_zmq::async_types::sink_stream: Called poll_complete

Desktop (please complete the following information):

moriaab commented 5 years ago

@lacabra I see that the gas limit for this call is 1544. It is not enough. See gasLimit attribute here: https://github.com/enigmampc/enigma-p2p/blob/develop/docs/IPC_MESSAGES.md#computetask-message . When I tried this computation the used gas was 28023. In the case of deployment with empty constructor, I guess that gasLimit = 0 is enough, since in the current version we take gas only for the execution of the function and not for actions of deployment/computation.

lacabra commented 5 years ago

Thanks @moriaab. I tried first with gas=100 and then tried with gas=100000 and both yielded the same error. I see now the 1544 and I don't know where that came from, I set it at 100000, but I have something to investigate on my side...

Just to confirm, you are expecting an int for gas, not an hex value, correct?