dfinity / motoko

Simple high-level language for writing Internet Computer canisters
Apache License 2.0
515 stars 97 forks source link

compiler bug #3550

Open jb747 opened 2 years ago

jb747 commented 2 years ago

Reported when running make in test project:

Motoko 0.6.29 (source fjj8ynd5-n5c9760p-1kql7sph-3ml9y6vd)

Fatal error: exception "Assert_failure mo_interpreter/interpret.ml:468:17"
Raised at Mo_interpreter__Interpret.interpret_exp_mut.(fun) in file "mo_interpreter/interpret.ml", line 468, characters 17-29
Called from Mo_interpreter__Interpret.Scheduler.yield in file "mo_interpreter/interpret.ml", line 118, characters 8-23
Called from Mo_interpreter__Interpret.Scheduler.run in file "mo_interpreter/interpret.ml", line 121, characters 36-44
Called from Mo_interpreter__Interpret.interpret_lib in file "mo_interpreter/interpret.ml", line 983, characters 2-18
Called from Pipeline.interpret_libs in file "pipeline/pipeline.ml", line 441, characters 17-45
Called from Pipeline.interpret_files.(fun) in file "pipeline/pipeline.ml", line 459, characters 18-43
Called from Pipeline.run_files in file "pipeline/pipeline.ml", line 497, characters 20-55
Called from Dune__exe__Moc.process_files in file "exes/moc.ml", line 183, characters 22-48
Called from Dune__exe__Moc in file "exes/moc.ml", line 295, characters 4-23
jb747 commented 2 years ago

The code is obviously rough but it was getting close to a clean build before hitting the bug. Let me know if I can help to track it down.

jb747 commented 2 years ago

hopefully the code helps to uncover an underlying issue. Meanwhile, if someone can explain what the "derivation path" used by the ECDSA API is, then it seems that the code might simplify enough to build cleanly. The bitcoin example doesn't seem to give it much importance but perhaps it is atypical.

crusso commented 2 years ago

The reason this code fails is, I believe, due to the fact that IR requires IC features (ManagementCanister, Bitcoin API) that are not available in the interpreter nor in the wasi target you are using to run your tests. We should definitely have the wasi compiled code and interpreter fail more gracefully in such cases, but I think you need to re-write at leat part of your tests to run on a local replica instead.

I don't have an answer to your "deriviation path" question but perhaps someone on the forum will.

crusso commented 2 years ago

hopefully the code helps to uncover an underlying issue. Meanwhile, if someone can explain what the "derivation path" used by the ECDSA API is, then it seems that the code might simplify enough to build cleanly. The bitcoin example doesn't seem to give it much importance but perhaps it is atypical.

https://internetcomputer.org/docs/current/references/ic-interface-spec contains some mentions of derivation_path, if that helps any,

jb747 commented 2 years ago

Thanks for explanation of the overall failure.

This is a source which explains that the derivation path can be used to create a hierarchy of public keys: https://internetcomputer.org/docs/current/samples/t-ecdsa-sample/.