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

Incorrect GAS calculation in System.Contract.Update. #1989

Closed
fyrchik opened this issue Oct 5, 2020 · 2 comments · Fixed by #1990
Closed

Incorrect GAS calculation in System.Contract.Update. #1989

fyrchik opened this issue Oct 5, 2020 · 2 comments · Fixed by #1990

Comments

@fyrchik
Copy link
Contributor

fyrchik commented Oct 5, 2020

Describe the bug
Incorrect GAS calculation in System.Contract.Update syscall. Manifest is not taken into account if script it non-null.

To Reproduce
Call ApplicationEngine.UpdateContract with non-empty script and manifest. Set GAS limit to StoragePrice * len(script).

Expected behavior
Error because of insufficient GAS.

This line AddGas(StoragePrice * (script?.Length ?? 0 + manifest?.Length ?? 0)); should probably be written as
AddGas(StoragePrice * ((script?.Length ?? 0) + (manifest?.Length ?? 0)));

@shargon
Copy link
Member

shargon commented Oct 5, 2020

If it's not null and it's 0 it will fault here

if (script.Length == 0 || script.Length > MaxContractLength)

@roman-khimov
Copy link
Contributor

See nspcc-dev/neo-go#1456 for an example of this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants