anoma / anoma-archive

Reference implementation of the Anoma protocols in Rust.
https://anoma.net
GNU General Public License v3.0
425 stars 176 forks source link

matchmaker token exchange crash #444

Open tzemanovic opened 3 years ago

tzemanovic commented 3 years ago

When I repeatedly submit the 3 intents from README to the RPC, it caused the matchmaker to crash. This seems to happen somewhere in these lines of wasm/wasm_source/src/mm_token_exch.rs:

    let cycle_intents = sort_cycle(graph, cycle_intents);
    let amounts = compute_amounts(graph, &cycle_intents);

Trace:

Message:  called `Result::unwrap()` on an `Err` value: RunnerFailed(RuntimeError(RuntimeError { source: Trap(HeapAccessOutOfBounds), wasm_trace: [FrameInfo { module_name: "<module>", func_index: 637, function_name: None, func_start: SourceLoc(212115), instr: SourceLoc(212169) }, FrameInfo { module_name: "<module>", func_index: 632, function_name: None, func_start: SourceLoc(211881), instr: SourceLoc(211905) }, FrameInfo { module_name: "<module>", func_index: 78, function_name: None, func_start: SourceLoc(59525), instr: SourceLoc(59671) }, FrameInfo { module_name: "<module>", func_index: 58, function_name: None, func_start: SourceLoc(8740), instr: SourceLoc(8772) }, FrameInfo { module_name: "<module>", func_index: 57, function_name: None, func_start: SourceLoc(8687), instr: SourceLoc(8708) }, FrameInfo { module_name: "<module>", func_index: 75, function_name: None, func_start: SourceLoc(59339), instr: SourceLoc(59349) }, FrameInfo { module_name: "<module>", func_index: 74, function_name: None, func_start: SourceLoc(11770), instr: SourceLoc(11798) }], native_trace:    0: <unknown>
   1: <unknown>
   2: <unknown>
   3: <unknown>
   4: <unknown>
   5: <unknown>
   6: <unknown>
   7: <unknown>
   8: <unknown>
   9: <unknown>
  10: <unknown>
  11: <unknown>
  12: <unknown>
  13: <unknown>
  14: <unknown>
  15: <unknown>
 }))
Location: apps/src/lib/node/gossip/intent_gossiper/matchmaker.rs:136We should be able to reproduce and find the issue via a unit test calling these functions with the same intent data (because it's tricky to debug wasm).

┆Issue is synchronized with this Asana task by Unito

Fraccaman commented 3 years ago

there is an e2e test, maybe we can use the same test and submit txs twice?

tzemanovic commented 3 years ago

there is an e2e test, maybe we can use the same test and submit txs twice?

The e2e is using the matchmaker compiled to wasm, which is harder to debug (we'll just get the same error trace as above). If we can reproduce the same issue without compiling to wasm (in e.g. a unit test), it should be easier to see where it's crashing. The matchmaker could benefit from having some unit tests anyway

cwgoes commented 2 years ago

Can we build a version of the matchmaker just natively? The WASM execution is nice but the matchmaker doesn't run in consensus anyways so it really doesn't matter that much, and native performance may be important for production cases.