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

feat(gnovm): packages loader #2932

Draft
wants to merge 183 commits into
base: master
Choose a base branch
from
Draft

Conversation

n0izn0iz
Copy link
Contributor

@n0izn0iz n0izn0iz commented Oct 10, 2024

WIP

Continuation of #2201
Taking #2904 into account

This implements a Load function with a similar interface to the packages.Load go function

Screenshot 2024-10-11 at 13 50 18
Contributors' checklist...
  • Added new tests, or not needed, or not feasible
  • Provided an example (e.g. screenshot) to aid review or the PR is self-explanatory
  • Updated the official documentation or not needed
  • No breaking changes were made, or a BREAKING CHANGE: xxx message was included in the description
  • Added references to related issues and PRs
  • Provided any useful hints for running manual tests
  • Added new benchmarks to generated graphs, if any. More info here.

thehowl and others added 8 commits May 26, 2024 13:41
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Oct 10, 2024
Copy link

codecov bot commented Oct 10, 2024

Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
Signed-off-by: Norman Meier <norman@samourai.coop>
…ve download to own file

Signed-off-by: Norman Meier <norman@samourai.coop>
@n0izn0iz n0izn0iz changed the title feat(gnovm): package resolver lib feat(gnovm): packages loader Oct 11, 2024
Signed-off-by: Norman Meier <norman@samourai.coop>
@@ -0,0 +1 @@
module gno.land
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we need this file?

if we need it, please explain in a comment.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

please see #2904 (comment) and tell me what you think

Copy link
Contributor Author

@n0izn0iz n0izn0iz Oct 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the best would be to have a gno.work file at repo root to support multiple modules in a monorepo
But in that case we need to implement the gno work commands

@@ -40,7 +40,7 @@ func TestMachineTestMemPackage(t *testing.T) {
Name: tt.name,
F: func(t2 *testing.T) { //nolint:thelper
rootDir := filepath.Join("..", "..")
store := TestStore(rootDir, "test", os.Stdin, os.Stdout, os.Stderr, ImportModeStdlibsOnly)
store := TestStore(rootDir, "test", nil, os.Stdin, os.Stdout, os.Stderr, ImportModeStdlibsOnly)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

create a variable that you set to nil, so we now what is this parameter.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in 0123512

func DownloadModule(pkgPath string, dst string) error {
modFilePath := filepath.Join(dst, ModfileName)
if _, err := os.Stat(modFilePath); os.IsNotExist(err) {
fmt.Fprintln(os.Stderr, "gno: downloading", pkgPath)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we usually don't use os.StdXXX, but stdouterr from a struct (io something) which is passed when needed.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done in e648305

n0izn0iz and others added 20 commits February 2, 2025 03:14
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
Signed-off-by: Norman <norman@samourai.coop>
thehowl added a commit that referenced this pull request Feb 10, 2025
featuring:  
- [X] **Lazy reload**: Super fast reload, only loading the needed
packages for the current directory package.
- [x] **Chain resolver**: You can change the gnodev resolving process so
it can resolve packages on-chain and configure a local fallback,
allowing you to try your package against the chain before submitting it.
	-  This will probably be updated when #2932 & #3123 will be merged
- [x] **Staging Mode**: `gnodev` now starts from the current directory
by default. The staging subcommand will reproduce previous behaviors by
loading and monitoring the entire example folder.

<details><summary>Contributors' checklist...</summary>

- [ ] Added new tests, or not needed, or not feasible
- [ ] Provided an example (e.g. screenshot) to aid review or the PR is
self-explanatory
- [ ] Updated the official documentation or not needed
- [ ] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [ ] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
</details>

---------

Signed-off-by: gfanton <8671905+gfanton@users.noreply.github.com>
Co-authored-by: Leon Hudak <33522493+leohhhn@users.noreply.github.com>
Co-authored-by: Morgan <git@howl.moe>
Co-authored-by: Morgan <morgan@morganbaz.com>
@n0izn0iz
Copy link
Contributor Author

notes from morgan from call

gno test ./r/morgan/guestbook -> should not automatically load other packages from $PWD
	=> cd ./r/morgan/guestbook; gno test . -> should be the same as above
gno test ./r/morgan/guestbook -> should not automatically load other packages from $GIT_ROOT
	=> better to have a gno.work, even though i don't like it

gno monorepo gno.mod:
	module gno.land
a package on the monorepo cannot specify a package that only exists on-chain
	import "gno.land/p/demo/avl" // should try to fetch locally, and fail if it doesn't exist

gnoswap monorepo gno.mod(s):
	contract/r/gnoswap/gno.mod -> module gno.land/r/gnoswap; replace gno.land/p/gnoswap/... => ../../p/gnoswap
	contract/p/gnoswap/gno.mod -> module gno.land/p/gnoswap

"monorepo" of project by same author:
	gno.land/r/morgan/foo
		// part of the same project
		import "gno.land/p/morgan/foo/baz"
		// independent package by same author
		import "gno.land/p/morgan/seqid"

realms/gno.mod
	module gno.land/r/teritori/socialdapp; replace gno.land/p/teritori/socialdapp -> ../packages
gno.land/p/teritori/socialdapp
	module gno.land/p/teritori/socialdapp

outside gno.mod:
	module gno.land/r/demo/gnochess
	import "gno.land/p/demo/avl" // should try to fetch on-chain

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages.
Projects
Status: No status
Status: Triage
Development

Successfully merging this pull request may close these issues.

4 participants