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

Sanity Checker: store/load Arguments #114

Open
anton-trunov opened this issue Aug 29, 2024 · 2 comments
Open

Sanity Checker: store/load Arguments #114

anton-trunov opened this issue Aug 29, 2024 · 2 comments

Comments

@anton-trunov
Copy link

Summary
Some kind of interval analysis for bit-width arguments would be nice to have, although the most frequent case is by far when it's just an integer literal or a constant.

Context
A frequent case is when due to a typo people put incorrect amount for bit width of some date they store in a builder or parse from a slice. For instance, I've seen contracts with an attempt to store 0 bits.

Some functions from @stdlib/std/cells.tact:

  • storeInt(self: Builder, value: Int, bits: Int) must have its 3d argument bits to be in the range [1; 257];
  • storeUint(self: Builder, value: Int, bits: Int) must have its 3d argument bits to be in the range [1; 256];
  • loadBits(self: Slice, l: Int) must have the l argument to be at least non-zero;

Examples

fun send(params: SendParameters) {
    let b: Builder = beginCell();
    b = b.storeInt(1, 0);
    ...
}

Use instead:

fun send(params: SendParameters) {
    let b: Builder = beginCell();
    b = b.storeInt(1, <non-zero-amount-of-bits>);
    ...
}
@jubnzv
Copy link
Member

jubnzv commented Aug 29, 2024

It looks useful to have. I think the linter should support only a specified set of the Func standard library functions and process all the native Tact functions that are aliased to them.

@jubnzv
Copy link
Member

jubnzv commented Oct 15, 2024

Related to the implementation of #20.

Another related issue: what if the user is trying to store a reference to the same cell multiple times?

@jubnzv jubnzv changed the title Parsing or storing incorrect amount of bits for integers or slices Sanity Checker: store/load Arguments Oct 15, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants