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

Usage of RLP builtin #3215

Open
janezpodhostnik opened this issue Apr 3, 2024 · 1 comment
Open

Usage of RLP builtin #3215

janezpodhostnik opened this issue Apr 3, 2024 · 1 comment
Labels
Bug Something isn't working Feedback

Comments

@janezpodhostnik
Copy link
Contributor

Current Behavior

When trying to use the RLP builtin functions I got really confused.

This does not work:

import RLP
//....
RLP.decodeString("...".utf8)
//....

This also does not work:

// import RLP
//....
decodeString("...".utf8)
//....

But (confusingly) this works:

//import RLP
//....
RLP.decodeString("...".utf8)
//....

Expected Behavior

This is a bit confusing, and is not obvious from the docs: https://cadence-lang.org/docs/1.0/language/built-in-functions#rlp

Maybe add an example to the docs, or even allow the import RLP even if it is not doing anything.

IMO, the best solution might actually be so that you have to import RLP...

Steps To Reproduce

I ran this in a go test env:

import RLP

transaction(){
    prepare(signer: auth(Storage, Contracts, Keys, Inbox, Capabilities) &Account) {
        var f: fun(): Void = fun(){}
        f = fun() {
            var i = 0
            while i < 110 {
                i = i + 1
                RLP.decodeString("xxxxxxxxxxxxxxxxxxxxxx".utf8)
            }
        }
        f()
    }
    execute {
        var f: fun(): Void = fun(){}
    }
}

Environment

- Cadence version: 1.0
- Network: any
@janezpodhostnik janezpodhostnik added Bug Something isn't working Feedback labels Apr 3, 2024
@turbolent
Copy link
Member

We should allow the import and not report an error.

This also applies to other contracts that are part of the standard library, e.g. BLS.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Something isn't working Feedback
Projects
None yet
Development

No branches or pull requests

2 participants