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
875 stars 355 forks source link

Discussion: stdlibs/stdshim/*.gno #892

Closed piux2 closed 2 months ago

piux2 commented 1 year ago

Description

Shall we only name the files used by gvm as .gno? and move stdshim out of stdlibs?

https://github.com/gnolang/gno/tree/master/gnovm/stdlibs/stdshim

Files in stdlibs/stdshim are supposed to be temp go files generated from stdlibs/std/*.gno during the pre-compile process.

stdlibs/stdshim.go (not gno) is used to mock gno vm native function interface defined in stdlibs.go during gno precompile process so that precompile can use go build tools to check syntax and import path.

pre-compile and build are for developers to leverage the golang native build tool to check syntax and import during the gno development. GVM does not rely on anything from these optimizations or built outcomes.

thehowl commented 1 year ago

I guess I didn't specify it completely, but in #814's design stdshim loses its purpose :)

I address the part about precompilation in the second part of the proposal; but essentially I think that calls to native functions in gno code should simply call the Go function in the precompiled version, and if they require a *gno.Machine, then it is set to nil in the precompiled code, to indicate that this is outside of the normal gnovm execution.

So yes, in the "grand scheme" of things for my native bindings proposal, it would make sense to remove stdshim afterwards, as it wouldn't be used even for precompilation.

moul commented 1 year ago

Related with #814, I think we should close this issue and focus on the other one, nope?

TLDR: we'll have .gno files for each thing in stdlib (injected or not).

For gno precompile, I suggest storing generated files in a caching folder like ~/.gno/precompile-cache/gno.land/p/avl~PKGVERSION-RUNTIMEVERSION/files.gen.go, instead of the local directory.

piux2 commented 1 year ago

For gno precompile, I suggest storing generated files in a caching folder like ~/.gno/precompile-cache/gno.land/p/avl~PKGVERSION-RUNTIMEVERSION/files.gen.go, instead of the local directory.

@moul agree.

Can we keep this issue open for now? I am looking into some other related issues. thanks