Skip to content

Conversation

@MikaelVallenet
Copy link
Member

@MikaelVallenet MikaelVallenet commented Jan 13, 2026

fix #1571

Description

Closes #1571

Enforces that package names must match the last element of their import path, following Go conventions.

BREAKING CHANGE: Packages with names that don't match their path's last element will be rejected on deployment. Existing on-chain packages are unaffected, but new deployments must comply. For example, deploying a package foo at path gno.land/r/demo/bar will now fail.

Changes

Core validation (gnovm/pkg/gnolang/mempackage.go):

  • LastPathElement() - extracts the last meaningful path element, skipping version suffixes
  • ValidatePkgNameMatchesPath() - ensures package name matches path element
  • Version suffixes (v1, v2, v3, ...) are recognized and skipped when matching

Note on v1: Go module convention states that v1 should not appear in import paths. However, i allowed v1 as a version suffix for backwards compatibility with existing packages like gno.land/r/gnoland/boards2/v1 and
gno.land/r/sys/users/v1.

Enforcement:

  • gno lint warns about mismatches before deployment
  • keeper.AddPackage() blocks deployment of non-compliant packages

It's not at mempackage since some pkg does not follow this rules like filetests so i decided to put it at keeper and linter layer instead at mem pkg validation.

Example package renames:

  • gnoblogblog
  • gnopagespages
  • foo20grc20factory
  • evalmath_eval
  • todolistrealmtodolist
  • emiteventsevents
  • image_embedimg_embed
  • testsvm (r/tests/vm)
  • mapdeletemap_delete
  • nir1218_evaluation_proposal → moved to subfolder /evaluation

Examples

Path Package Valid
gno.land/r/demo/counter counter
gno.land/r/demo/counter foo
gno.land/r/demo/foo/v2 foo
gno.land/r/demo/foo/v1 foo
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

@github-actions github-actions bot added 📖 documentation Improvements or additions to documentation 🧾 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 Jan 13, 2026
@Gno2D2 Gno2D2 requested a review from a team January 13, 2026 17:48
@Gno2D2
Copy link
Collaborator

Gno2D2 commented Jan 13, 2026

🛠 PR Checks Summary

🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff
🔴 Pending initial approval by a review team member, or review from tech-staff

Manual Checks (for Reviewers):
  • IGNORE the bot requirements for this PR (force green CI check)
Read More

🤖 This bot helps streamline PR reviews by verifying automated checks and providing guidance for contributors and reviewers.

✅ Automated Checks (for Contributors):

🟢 Maintainers must be able to edit this pull request (more info)
🔴 Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff
🔴 Pending initial approval by a review team member, or review from tech-staff

☑️ Contributor Actions:
  1. Fix any issues flagged by automated checks.
  2. Follow the Contributor Checklist to ensure your PR is ready for review.
    • Add new tests, or document why they are unnecessary.
    • Provide clear examples/screenshots, if necessary.
    • Update documentation, if required.
    • Ensure no breaking changes, or include BREAKING CHANGE notes.
    • Link related issues/PRs, where applicable.
☑️ Reviewer Actions:
  1. Complete manual checks for the PR, including the guidelines and additional checks if applicable.
📚 Resources:
Debug
Automated Checks
Maintainers must be able to edit this pull request (more info)

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 The pull request was created from a fork (head branch repo: MikaelVallenet/gno)

Then

🟢 Requirement satisfied
└── 🟢 Maintainer can modify this pull request

Changes to 'docs' folder must be reviewed/authored by at least one devrel and one tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 A changed file matches this pattern: ^docs/ (filename: docs/builders/deploy-packages.md)

Then

🔴 Requirement not satisfied
└── 🔴 And
    ├── 🔴 Or
    │   ├── 🔴 Pull request author is a member of the team: tech-staff
    │   └── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request(with state "APPROVED")
    └── 🔴 Or
        ├── 🔴 Pull request author is a member of the team: devrels
        └── 🔴 At least 1 user(s) of the team devrels reviewed pull request(with state "APPROVED")

Pending initial approval by a review team member, or review from tech-staff

If

🟢 Condition met
└── 🟢 And
    ├── 🟢 The base branch matches this pattern: ^master$
    └── 🟢 Not (🔴 Pull request author is a member of the team: tech-staff)

Then

🔴 Requirement not satisfied
└── 🔴 If
    ├── 🔴 Condition
    │   └── 🔴 Or
    │       ├── 🔴 At least one of these user(s) reviewed the pull request: [jefft0 notJoon omarsy MikaelVallenet] (with state "APPROVED")
    │       ├── 🔴 At least 1 user(s) of the team tech-staff reviewed pull request
    │       └── 🔴 This pull request is a draft
    └── 🔴 Else
        └── 🔴 And
            ├── 🟢 This label is applied to pull request: review/triage-pending
            └── 🔴 On no pull request

Manual Checks
**IGNORE** the bot requirements for this PR (force green CI check)

If

🟢 Condition met
└── 🟢 On every pull request

Can be checked by

  • Any user with comment edit permission

@codecov
Copy link

codecov bot commented Jan 13, 2026

Codecov Report

❌ Patch coverage is 86.66667% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
gno.land/pkg/sdk/vm/keeper.go 0.00% 1 Missing and 1 partial ⚠️
gnovm/pkg/gnolang/mempackage.go 88.88% 1 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

@MikaelVallenet MikaelVallenet marked this pull request as ready for review January 13, 2026 18:13
@Gno2D2 Gno2D2 added the review/triage-pending PRs opened by external contributors that are waiting for the 1st review label Jan 13, 2026

// LastPathElement extracts the last meaningful element from a package path.
// For versioned paths like "gno.land/r/foo/v2" or "gno.land/r/foo/v1", it
// returns "foo" since version suffixes (v1, v2, ...) are skipped.
Copy link
Contributor

Choose a reason for hiding this comment

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

The Go language spec says:

  • For a final path element of the form /vN where N looks numeric (ASCII digits and dots), N must not begin with a leading zero, must not be /v1

Go doesn't want you to use a package ending in /v1 . But we do this in Gno. Should Gno also forbid /v1?

Copy link
Member

Choose a reason for hiding this comment

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

Currently there is no alternative way to express the contract version other than this, I think it seems best to handle it as a special case as described in issue #1571

Copy link
Member Author

Choose a reason for hiding this comment

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

also v1 is widely used in the existing packages, i would like an input from core team to tell me whether i should do it or not.

@Davphla
Copy link
Contributor

Davphla commented Jan 14, 2026

Note: If this is merged we should create an issue on the LSP of Gno about this new feature.

Copy link
Contributor

@Davphla Davphla left a comment

Choose a reason for hiding this comment

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

Image Image

LGTM

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

📖 documentation Improvements or additions to documentation 🛠️ gnodev 📦 ⛰️ gno.land Issues or PRs gno.land package related 📦 🤖 gnovm Issues or PRs gnovm related 🧾 package/realm Tag used for new Realms or Packages. review/triage-pending PRs opened by external contributors that are waiting for the 1st review

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

rfc: enforce package name == last element of import path in maketx addpkg

6 participants