Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

VM Internal Error: MemOutOfBound with Capsule 0.9.0 #80

Open
phroi opened this issue Mar 19, 2023 · 11 comments
Open

VM Internal Error: MemOutOfBound with Capsule 0.9.0 #80

phroi opened this issue Mar 19, 2023 · 11 comments
Labels
documentation Improvements or additions to documentation

Comments

@phroi
Copy link

phroi commented Mar 19, 2023

Executing these tests shows that Capsule 0.9.0 with rustc 1.63.0 suffer from:

  • VM Internal Error: MemOutOfBound when executing any non trivial script.
  • Transaction timeout when executing always success script.

Note: creating and executing tests for these scripts will not manifest these issues without a full CKB VM environment.

The same scripts compiled with Capsule 0.7.3 don't have these issues.

Some research on these issues has been done already by Travis Lee Richardson and Jordan Mack.

Keep up the Great work 💪
Phroi

@quake
Copy link
Member

quake commented Mar 20, 2023

the tx built by capsule 0.9.0 should be running with ckb2021 edition ckb-vm, which is incompatible with old version ckb-vm, I think it will pass if you set the value of hash_type to type ( https://github.com/phroi/capsule-tests/blob/master/lumos-tests/index.js#L124 ) , you may check out rfc https://github.com/nervosnetwork/rfcs/blob/master/rfcs/0032-ckb-vm-version-selection/0032-ckb-vm-version-selection.md for more information.

@jordanmack
Copy link
Contributor

jordanmack commented Mar 20, 2023

Is there any way this error could be recognized so a more friendly error message can be provided?

@phroi
Copy link
Author

phroi commented Mar 20, 2023

@TravisLeeRichardson @jordanmack and I spent at least three days each thinking about this: we are smart and well informed on Nervos L1, but we couldn't figured it out.

What would do a new developer who is trying out Nervos L1 for the first time? He probably just give up and go away from Nervos.

@quake thanks for helping us, but please improve the error message 🙏

@quake
Copy link
Member

quake commented Mar 20, 2023

@jordanmack @phroi we'll figure out a way to display more friendly error messages, but before this issue is fixed, I'd also like to know where you saw the document of setting hash_type to data? Since we recommend using type (upgradable script) in ckb, I'd like to fix the documentation in this area first.

@phroi
Copy link
Author

phroi commented Mar 20, 2023

Great news on more friendly error messages!! 🥳

As for me I'm following the Developer Training Course and noting errors as I go. You may want to check out if the current recommended guidelines are followed in the course!

To be honest I believe there are good uses for both:

  • type for scripts that are intended to be upgradable
  • data(1) for scripts that are immutable by design

@quake
Copy link
Member

quake commented Mar 20, 2023

  • data(1) for scripts that are immutable by design

I see, in your example the always_success script using data is a reasonable scenario, let's see if there is a way to figure out how to display a better message of incompatible issue to user.

@quake
Copy link
Member

quake commented Mar 20, 2023

if you want run a script compiled by capsule v0.8.0+ on vm0 (hash_type: data), you may need to run the ckb-binary-patcher with the compiled binary, which has been removed in this pr, or you may run it on vm1 (hash_type: data1 or type) directly without this patcher.

@jordanmack could you update the https://nervos.gitbook.io/developer-training-course accordingly? I think change the lumos code from data to data1 is the simplest fix for the time being.

@phroi
Copy link
Author

phroi commented Mar 20, 2023

I already tried changing from data to data1, but the Lumos version used in the course is too old.. I guess, we'll figure something out, thanks for the help!! 🙏

@phroi
Copy link
Author

phroi commented Mar 20, 2023

@quake now basically the issue is displaying a proper error message when CKB VM 2021 binary is run in a old CKB VM, a very common mistake.

Feel free to move and rename this issue to the appropriate repository!

@jordanmack
Copy link
Contributor

@jordanmack could you update the https://nervos.gitbook.io/developer-training-course accordingly? I think change the lumos code from data to data1 is the simplest fix for the time being.

Yes, I am updating all references and will add a new section to explain data, type, and data1.

@jordanmack
Copy link
Contributor

the issue is displaying a proper error message when CKB VM 2021 binary is run in a old CKB VM, a very common mistake.

Sometimes a binary will run fine in the old CKB-VM, and sometimes it fails with a strange error. This also adds to the confusion.

@blckngm blckngm added the documentation Improvements or additions to documentation label Apr 13, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

No branches or pull requests

4 participants