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

gnovm/pkg/transpiler: introduce Machine.RunContext which takes in a context that terminates running if cancelled to allow better flexibility #3427

Open
odeke-em opened this issue Dec 30, 2024 · 0 comments
Labels
🐞 bug Something isn't working

Comments

@odeke-em
Copy link
Contributor

Description

While investigating #3426, I had some insights:

Given this currently valid Gno program (but invalid Go program)

package main
func main(){
   const c1=1<8
    main()
    1
}

The mechanism to get things running is to invoke transpiler.Machine.Run which is alright for starters. However, that means that the program passed in cannot be terminated unless by killing the entire process.

Suggestion

For a smart contracting platform and place where running programs can cause losses of money and sensitive information, I highly advise introducing a new method (*Machine).RunContext(context.Context) which runs until the input context is terminated with if err := ctx.Error(); err != nil or <-ctx.Done()
That gives much finer grained control to running programs and paves way for dApps like cloud compute renting because instead of forking process using os/exec.Command*, one can allow programs to be ran in-process with a gas meter that's timed or depending on machine ticks. Even better it allows for much better testing because I've been doing analyses for programs that are valid in Gno yet invalid in Go and the lack of this fine grained control makes it hard to easily continue.

Kindly cc-ing @thehowl @petar-dambovaliev @jaekwon @moul

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug Something isn't working
Projects
Status: Triage
Development

No branches or pull requests

1 participant