gnolang / gno

Gno: An interpreted, stack-based Go virtual machine to build succinct and composable apps + Gno.land: a blockchain for timeless code and fair open-source
https://gno.land/
Other
841 stars 342 forks source link

feat: new govdao pattern with context #2380

Open moul opened 1 week ago

moul commented 1 week ago

This PR introduces a new pattern for arbitrary govdao proposals using Gno code using contexts. It involves wrapping the provided closure with a system that configures a context.Context with a field indicating that the execution occurs in the context of an approvedByGovDao proposal. This opens the door to a new ACL system, not based on PrevRealm(), but on a context-based "certification" system.

I believe this pattern makes sense to exist; however, here are some drawbacks I can see:

  1. context.Context is not yet needed (no goroutine support), and we may eventually never need this package depending on how we implement goroutines internally. (h/t @thehowl)
  2. context.Context is used like an environment variable, which introduces implicitness—something we usually try to avoid to make Gno a very explicit language. Explicitness brings “simplicity” and “verifiability.”
  3. The usual Go idiomatic way of using context is to pass it as the first argument. If this becomes more common, it will result in more contracts having exposed functions that are not callable by maketx call (though they can be called with maketx run or via an import).

Depends on #2379
Related to #2386