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: support custom VM domain #2911

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

feat: support custom VM domain #2911

wants to merge 23 commits into from

Conversation

moul
Copy link
Member

@moul moul commented Oct 5, 2024

Introducing the concept of "ChainDomain," a local primary domain for packages.

The next step, which will be another PR, is to ensure that we can launch a gnoland/gnodev instance while importing a local folder or using a genesis to preload packages from other domains. This will allow users to add packages only to the primary domain while accessing packages from multiple domains. The result will be a preview of the upcoming IBC era, where a single chain can add packages only to its domain but can fetch missing dependencies from other registered zones.

  • gnovm unaware of gno.land, just accepting valid domains
  • vmkeeper initialized with a domain
  • Stdlib to know the current primary domain + new std.ChainDomain
  • new unit tests around custom domains

Depends on #2910
Depends on #3003
Blocks a new PR that will add multidomain support.
Related with #2904 (comment)

@moul moul self-assigned this Oct 5, 2024
@github-actions github-actions bot added 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Oct 5, 2024
@moul moul changed the title dev/moul/gno domain feat: support custom VM domain Oct 5, 2024
Copy link

codecov bot commented Oct 5, 2024

Codecov Report

Attention: Patch coverage is 93.61702% with 3 lines in your changes missing coverage. Please review.

Project coverage is 63.26%. Comparing base (5c876f3) to head (9d73f9d).
Report is 12 commits behind head on master.

Files with missing lines Patch % Lines
gnovm/stdlibs/std/native.go 0.00% 2 Missing ⚠️
gno.land/pkg/sdk/vm/keeper.go 92.30% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #2911      +/-   ##
==========================================
+ Coverage   63.18%   63.26%   +0.07%     
==========================================
  Files         561      561              
  Lines       78636    78520     -116     
==========================================
- Hits        49690    49677      -13     
+ Misses      25569    25462     -107     
- Partials     3377     3381       +4     
Flag Coverage Δ
contribs/gnodev 60.72% <100.00%> (+0.77%) ⬆️
contribs/gnofaucet 15.77% <ø> (+0.94%) ⬆️
gno.land 67.47% <96.00%> (+0.08%) ⬆️
gnovm 67.58% <83.33%> (-0.02%) ⬇️
misc/genstd 79.72% <ø> (ø)
tm2 62.27% <100.00%> (-0.05%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
Signed-off-by: moul <[email protected]>
gno.land/cmd/gnoland/start.go Outdated Show resolved Hide resolved
@moul moul marked this pull request as ready for review October 6, 2024 09:27
@moul moul requested a review from thehowl as a code owner October 6, 2024 09:27
Comment on lines +227 to +228
// ChainDomain is the primary domain name for the chain and its packages.
ChainDomain string
Copy link
Contributor

Choose a reason for hiding this comment

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

why add this here instead of in genesis?

Copy link
Member Author

Choose a reason for hiding this comment

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

I think that I prefer your idea. I'm waiting for more feedback before making the change.

Copy link
Member

Choose a reason for hiding this comment

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

Yeah I agree it should be in genesis. Allows us more easily to find problems when there's a mismatch between two nodes.

Copy link
Member Author

Choose a reason for hiding this comment

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

switching the PR to draft until I finish and merge #3003.

gno.land/pkg/sdk/vm/keeper.go Outdated Show resolved Hide resolved
Copy link
Member

@thehowl thehowl left a comment

Choose a reason for hiding this comment

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

Maybe look at changing this for gno.land/pkg/gnoweb/gnoweb.go as well. No other significant places breaking that I can see, at least in our codebase.

// be realms and as such to have their state persisted. This is used by [IsRealmPath].
const RealmPathPrefix = "gno.land/r/"
var ReGnoRealmPath = regexp.MustCompile(`^([a-zA-Z0-9-]+\.)*[a-zA-Z0-9-]+\.[a-zA-Z]{2,}/r/`)
Copy link
Member

Choose a reason for hiding this comment

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

Should use this to validate the chain domain elsewhere.

Comment on lines +30 to +36
parts := strings.Split(s, "/")
if len(parts) > 0 {
// Check if the first part contains a dot
if strings.Contains(parts[0], ".") {
return false // It's a domain, so it's not part of the standard library
}
}
Copy link
Member

Choose a reason for hiding this comment

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

return strings.IndexByte(s[:strings.IndexByte(s, '/')+1], '.') < 0

@@ -27,6 +27,10 @@ func GetChainID(m *gno.Machine) string {
return GetContext(m).ChainID
}

func GetChainDomain(m *gno.Machine) string {
return GetContext(m).ChainDomain
Copy link
Member

Choose a reason for hiding this comment

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

Since this is used to write the import paths, should this not be largely known by gno files already (so no need for the function)?

Copy link
Member Author

Choose a reason for hiding this comment

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

It's for when your p/ package is imported from one chain to another. The code remains the same, but the behavior may change.

@thehowl
Copy link
Member

thehowl commented Oct 22, 2024

I like the feature. I shared it with the core contribs so we have some warning ahead of time of what we want to do :)

@moul moul marked this pull request as draft October 22, 2024 23:17
@moul
Copy link
Member Author

moul commented Oct 30, 2024

Draft because depending on #3003

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
Projects
Status: In Progress
Status: 🎯 Current Topics
Status: In Progress
Development

Successfully merging this pull request may close these issues.

3 participants