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
896 stars 375 forks source link

Move standard library initialization to genesis transactions #2730

Open thehowl opened 2 months ago

thehowl commented 2 months ago

Standard libraries can and should be treated as regular packages; which, at least for the time being, can only be loaded at genesis.

Related discussion: https://github.com/gnolang/gno/pull/2319#discussion_r1729000179

After discussing with Milos, we agreed that it makes sense for the gno.land node at startup to be ignorant about standard libraries; this way, we can further separate the gno.land application binary from needing a surrounding gno repository to work.

To make this work, we'll likely additionally need adequate mechanisms to make stdlib loading fast in testing code and in gnodev, which often restart nodes from genesis. Currently, this is implemented by the method LoadStdlibCached, which is very effective at cutting down start-up costs in these scenarios currently, but would have to be removed if we moved to having stdlibs in the genesis file.

Related #1248

moul commented 3 weeks ago

The goal is to use a go-embed of the standard libraries and utilize this embedded component while generating the hot genesis in gnodev/gnoland start. At the end, we will be able to manually craft a static genesis when creating the mainnet one.