Skip to content

Commit

Permalink
feat(gnomod)!: forbid require and find dependencies without it (#3123)
Browse files Browse the repository at this point in the history
A step towards the importer package (#2932) and future of `gno.mod`
(#2904)

- BREAKING CHANGE: remove `require` statement support from `gno.mod`
- BREAKING CHANGE: remove `-v` (verbose) and `--remote` flags in `gno
mod download`
- Don't require version specification in `gno.mod`'s `replace`
statements
- Use `.gno` files `import` statements to find dependencies
- Extract and refacto imports gathering utils in `gnovm/pkg/packages`
- Add `gnovm/cmd/gno/internal/pkgdownload.PackageFetcher` interface
- Implement `PackageFetcher` using `vm/qfile` queries in
`gnovm/cmd/gno/internal/pkgdownload/rpcpackagefetcher`
- Rewrite single package download routine in
`gnovm/cmd/gno/internal/pkgdownload`
- Move and refacto dependencies download routine in
`gnovm/cmd/gno/download_deps.go`
- Add a `--remote-overrides` flag for `gno mod download` that takes
`chain-domain=rpc-url` comma-separated pairs to override endpoints used
to fetch packages
- Add and use a testing implementation of `PackageFetcher` called
`examplesPackageFetcher` that serves package from the `examples`
directory for testing purposes (download tests before this PR use the
portal loop public endpoint)
- Make `ReadMemPackage` and it's dependencies error-out instead of
panicking
- Create panicking `MemPackage` utils that wrap the erroring ones and
use them at existing callsites

I decided to do this first to avoid having multiple ways to resolve
dependencies lying around in the codebase and causing confusion in
subsequent steps

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

- [x] 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
- [x] No breaking changes were made, or a `BREAKING CHANGE: xxx` message
was included in the description
- [x] Added references to related issues and PRs
- [ ] Provided any useful hints for running manual tests
</details>

---------

Signed-off-by: Norman Meier <[email protected]>
Co-authored-by: Morgan Bazalgette <[email protected]>
  • Loading branch information
n0izn0iz and thehowl authored Dec 7, 2024
1 parent 79c9b04 commit 53cee96
Show file tree
Hide file tree
Showing 171 changed files with 988 additions and 1,999 deletions.
2 changes: 1 addition & 1 deletion contribs/gnodev/pkg/dev/packages.go
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ func (pm PackagesMap) Load(fee std.Fee, start time.Time) ([]gnoland.TxWithMetada
}

// Open files in directory as MemPackage.
memPkg := gno.ReadMemPackage(modPkg.Dir, modPkg.Name)
memPkg := gno.MustReadMemPackage(modPkg.Dir, modPkg.Name)
if err := memPkg.Validate(); err != nil {
return nil, fmt.Errorf("invalid package: %w", err)
}
Expand Down
1 change: 0 additions & 1 deletion contribs/gnogenesis/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,6 @@ require (
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.65.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions contribs/gnogenesis/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

1 change: 0 additions & 1 deletion contribs/gnomigrate/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,6 @@ require (
golang.org/x/sys v0.24.0 // indirect
golang.org/x/term v0.23.0 // indirect
golang.org/x/text v0.17.0 // indirect
golang.org/x/tools v0.24.0 // indirect
google.golang.org/genproto/googleapis/api v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/genproto/googleapis/rpc v0.0.0-20240822170219-fc7c04adadcd // indirect
google.golang.org/grpc v1.65.0 // indirect
Expand Down
2 changes: 0 additions & 2 deletions contribs/gnomigrate/go.sum

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/acl/gno.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module gno.land/p/demo/acl

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/avl/pager/gno.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module gno.land/p/demo/avl/pager

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/avlhelpers/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/avlhelpers

require gno.land/p/demo/avl v0.0.0-latest
6 changes: 0 additions & 6 deletions examples/gno.land/p/demo/blog/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
module gno.land/p/demo/blog

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/mux v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/dao/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/dao

require gno.land/p/demo/ufmt v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/dom/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/dom

require gno.land/p/demo/avl v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/fqname/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/fqname

require gno.land/p/demo/uassert v0.0.0-latest
5 changes: 0 additions & 5 deletions examples/gno.land/p/demo/gnorkle/agent/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/demo/gnorkle/agent

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
12 changes: 0 additions & 12 deletions examples/gno.land/p/demo/gnorkle/feeds/static/gno.mod
Original file line number Diff line number Diff line change
@@ -1,13 +1 @@
module gno.land/p/demo/gnorkle/feeds/static

require (
gno.land/p/demo/gnorkle/feed v0.0.0-latest
gno.land/p/demo/gnorkle/gnorkle v0.0.0-latest
gno.land/p/demo/gnorkle/ingester v0.0.0-latest
gno.land/p/demo/gnorkle/ingesters/single v0.0.0-latest
gno.land/p/demo/gnorkle/message v0.0.0-latest
gno.land/p/demo/gnorkle/storage/simple v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
8 changes: 0 additions & 8 deletions examples/gno.land/p/demo/gnorkle/gnorkle/gno.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
module gno.land/p/demo/gnorkle/gnorkle

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/gnorkle/agent v0.0.0-latest
gno.land/p/demo/gnorkle/feed v0.0.0-latest
gno.land/p/demo/gnorkle/ingester v0.0.0-latest
gno.land/p/demo/gnorkle/message v0.0.0-latest
)
7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/gnorkle/ingesters/single/gno.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module gno.land/p/demo/gnorkle/ingesters/single

require (
gno.land/p/demo/gnorkle/gnorkle v0.0.0-latest
gno.land/p/demo/gnorkle/ingester v0.0.0-latest
gno.land/p/demo/gnorkle/storage/simple v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/gnorkle/message/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/gnorkle/message

require gno.land/p/demo/uassert v0.0.0-latest
8 changes: 0 additions & 8 deletions examples/gno.land/p/demo/gnorkle/storage/simple/gno.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
module gno.land/p/demo/gnorkle/storage/simple

require (
gno.land/p/demo/gnorkle/feed v0.0.0-latest
gno.land/p/demo/gnorkle/storage v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
6 changes: 0 additions & 6 deletions examples/gno.land/p/demo/grc/grc1155/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
module gno.land/p/demo/grc/grc1155

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
9 changes: 0 additions & 9 deletions examples/gno.land/p/demo/grc/grc20/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/p/demo/grc/grc20

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/grc/exts v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/grc/grc721/gno.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module gno.land/p/demo/grc/grc721

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/grc/grc777/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/grc/grc777

require gno.land/p/demo/grc/exts v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/groups/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/groups

require gno.land/p/demo/rat v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/int256/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/int256

require gno.land/p/demo/uint256 v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/json/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/json

require gno.land/p/demo/ufmt v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/math_eval/int32/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/math_eval/int32

require gno.land/p/demo/ufmt v0.0.0-latest
8 changes: 0 additions & 8 deletions examples/gno.land/p/demo/membstore/gno.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
module gno.land/p/demo/membstore

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
9 changes: 0 additions & 9 deletions examples/gno.land/p/demo/memeland/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/p/demo/memeland

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/seqid v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/demo/microblog/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/demo/microblog

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
8 changes: 0 additions & 8 deletions examples/gno.land/p/demo/ownable/exts/authorizable/gno.mod
Original file line number Diff line number Diff line change
@@ -1,9 +1 @@
module gno.land/p/demo/ownable/exts/authorizable

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/demo/ownable/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/demo/ownable

require (
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/demo/pausable/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/demo/pausable

require (
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/seqid/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/seqid

require gno.land/p/demo/cford32 v0.0.0-latest
11 changes: 0 additions & 11 deletions examples/gno.land/p/demo/simpledao/gno.mod
Original file line number Diff line number Diff line change
@@ -1,12 +1 @@
module gno.land/p/demo/simpledao

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/dao v0.0.0-latest
gno.land/p/demo/membstore v0.0.0-latest
gno.land/p/demo/seqid v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/subscription/lifetime/gno.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module gno.land/p/demo/subscription/lifetime

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
7 changes: 0 additions & 7 deletions examples/gno.land/p/demo/subscription/recurring/gno.mod
Original file line number Diff line number Diff line change
@@ -1,8 +1 @@
module gno.land/p/demo/subscription/recurring

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/svg/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/svg

require gno.land/p/demo/ufmt v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/tamagotchi/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/tamagotchi

require gno.land/p/demo/ufmt v0.0.0-latest
5 changes: 0 additions & 5 deletions examples/gno.land/p/demo/tests/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/demo/tests

require (
gno.land/p/demo/tests/subtests v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/demo/todolist/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/demo/todolist

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/uassert/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/uassert

require gno.land/p/demo/diff v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/urequire/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/urequire

require gno.land/p/demo/uassert v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/demo/watchdog/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/watchdog

require gno.land/p/demo/uassert v0.0.0-latest
6 changes: 0 additions & 6 deletions examples/gno.land/p/gov/executor/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
module gno.land/p/gov/executor

require (
gno.land/p/demo/context v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/moul/helplink/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/moul/helplink

require (
gno.land/p/demo/urequire v0.0.0-latest
gno.land/p/moul/txlink v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/moul/mdtable/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/moul/mdtable

require gno.land/p/demo/urequire v0.0.0-latest
2 changes: 0 additions & 2 deletions examples/gno.land/p/moul/printfdebugging/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/demo/printfdebugging

require gno.land/p/demo/ufmt v0.0.0-latest
5 changes: 0 additions & 5 deletions examples/gno.land/p/moul/realmpath/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/moul/realmpath

require (
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
)
2 changes: 0 additions & 2 deletions examples/gno.land/p/moul/txlink/gno.mod
Original file line number Diff line number Diff line change
@@ -1,3 +1 @@
module gno.land/p/moul/txlink

require gno.land/p/demo/urequire v0.0.0-latest
5 changes: 0 additions & 5 deletions examples/gno.land/p/n2p5/haystack/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/n2p5/haystack

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/n2p5/haystack/needle v0.0.0-latest
)
6 changes: 0 additions & 6 deletions examples/gno.land/p/n2p5/mgroup/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
module gno.land/p/n2p5/mgroup

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/ownable v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
)
9 changes: 0 additions & 9 deletions examples/gno.land/p/nt/poa/gno.mod
Original file line number Diff line number Diff line change
@@ -1,10 +1 @@
module gno.land/p/nt/poa

require (
gno.land/p/demo/avl v0.0.0-latest
gno.land/p/demo/testutils v0.0.0-latest
gno.land/p/demo/uassert v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/demo/urequire v0.0.0-latest
gno.land/p/sys/validators v0.0.0-latest
)
6 changes: 0 additions & 6 deletions examples/gno.land/p/wyhaines/rand/isaac/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
module gno.land/p/wyhaines/rand/isaac

require (
gno.land/p/demo/entropy v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/wyhaines/rand/xorshiftr128plus v0.0.0-latest
)
6 changes: 0 additions & 6 deletions examples/gno.land/p/wyhaines/rand/isaac64/gno.mod
Original file line number Diff line number Diff line change
@@ -1,7 +1 @@
module gno.land/p/wyhaines/rand/isaac64

require (
gno.land/p/demo/entropy v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
gno.land/p/wyhaines/rand/xorshiftr128plus v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/wyhaines/rand/xorshift64star/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/wyhaines/rand/xorshift64star

require (
gno.land/p/demo/entropy v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
5 changes: 0 additions & 5 deletions examples/gno.land/p/wyhaines/rand/xorshiftr128plus/gno.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1 @@
module gno.land/p/wyhaines/rand/xorshiftr128plus

require (
gno.land/p/demo/entropy v0.0.0-latest
gno.land/p/demo/ufmt v0.0.0-latest
)
Loading

0 comments on commit 53cee96

Please sign in to comment.