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

[RFC][WIP] feat: implement versioning #1631

Closed
wants to merge 7 commits into from

Conversation

harry-hov
Copy link
Contributor

@harry-hov harry-hov commented Feb 5, 2024

This is rough and partial implementation of the proposal that I mentioned here

(NOTE: Marked this as "ready for review" for discussion and early feedback)

Changes/Status

  • gno.mod is mandatory to publish pkg/realm(s)
  • gno.mod's module directive takes version now
    e.g:
    module gno.land/p/{handle}/foo v1.2.3
  • pkg/realm(s) are versioned (IOW, multiple version of pkgs/realms can exist with same import path)
  • gnokey maketx addpkg command takes pkg path and version from gno.mod file
  • gnokey maketx call command takes -pkgPath in the format gno.land/p/{handle}/foo@v1.2.3
  • disable previous version of realm when someone publishes new version
  • realm state migration

Testing

to test, run (versioning.txtar):

$ cd gno.land/cmd/gnoland
$ go test -v . -run TestTestdata/versioning
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.

@github-actions github-actions bot added 🧾 package/realm Tag used for new Realms or Packages. 📦 🤖 gnovm Issues or PRs gnovm related 📦 🌐 tendermint v2 Issues or PRs tm2 related 📦 ⛰️ gno.land Issues or PRs gno.land package related labels Feb 5, 2024
@zivkovicmilos
Copy link
Member

@harry-hov

Can you please resolve the merge conflicts in this PR? 🙏

Copy link
Contributor

@ajnavarro ajnavarro left a comment

Choose a reason for hiding this comment

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

If we want to keep following semver, we have to change the first module release to v0.1.0:

https://semver.org/spec/v2.0.0.html#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase

gnovm/cmd/gno/mod.go Show resolved Hide resolved
gnovm/pkg/gnomod/gnomod_test.go Show resolved Hide resolved
gno.land/pkg/keyscli/run.go Show resolved Hide resolved
gnovm/cmd/gno/mod.go Show resolved Hide resolved
@moul
Copy link
Member

moul commented Mar 11, 2024

My main concern is visualizing its daily use. @leohhhn, can you collaborate with @harry-hov on creating a high-level tutorial draft (quick and high-level is probably enough) to clarify its functionality? Including one or two compelling examples would be great.

Copy link

codecov bot commented Mar 19, 2024

Codecov Report

Attention: Patch coverage is 0% with 12 lines in your changes are missing coverage. Please review.

Project coverage is 44.35%. Comparing base (5c5d9ef) to head (7279190).
Report is 201 commits behind head on master.

Files Patch % Lines
tm2/pkg/std/memfile.go 0.00% 11 Missing ⚠️
tm2/pkg/amino/binary_decode.go 0.00% 1 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##           master    #1631      +/-   ##
==========================================
- Coverage   47.49%   44.35%   -3.14%     
==========================================
  Files         388      433      +45     
  Lines       61311    65287    +3976     
==========================================
- Hits        29117    28956     -161     
- Misses      29756    33931    +4175     
+ Partials     2438     2400      -38     

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

@harry-hov
Copy link
Contributor Author

If we want to keep following semver, we have to change the first module release to v0.1.0:

https://semver.org/spec/v2.0.0.html#how-should-i-deal-with-revisions-in-the-0yz-initial-development-phase

I agree. changed it to v0.1.0 🙌

Thanks @ajnavarro

@zivkovicmilos zivkovicmilos added the breaking change Functionality that contains breaking changes label Mar 26, 2024
Copy link
Member

@zivkovicmilos zivkovicmilos left a comment

Choose a reason for hiding this comment

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

I like the idea behind this PR, but I don't think it has been executed correctly, yet 🙁

I am really not a fan of interacting with Realms (calling their methods...) by specifying their version number, alongside the path.
The path is clear, and the version should be resolved from the path when calling Realm methods (latest).

There's a lot to unpack here, I think we need to collectively decide the API for versioning before we continue

cc @moul @thehowl

Comment on lines +6 to +16
## add `hello`(v1) package located in $WORK/helloworld/v1
gnokey maketx addpkg -pkgdir $WORK/helloworld/v1 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
## add `hello`(v2) package located in $WORK/helloworld/v2
gnokey maketx addpkg -pkgdir $WORK/helloworld/v2 -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

## add `foo` realm; imports pkg `hello` v1
gnokey maketx addpkg -pkgdir $WORK/foo -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

## add `bar` realm; imports pkg `hello` v2
gnokey maketx addpkg -pkgdir $WORK/bar -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1

Copy link
Member

Choose a reason for hiding this comment

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

You can use the loadpkg txtar directive instead

stdout 'GAS USED: [0-9]+'

## execute Increment
gnokey maketx call -pkgpath gno.land/r/temp/counter@v1.0.0 -func Increment -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1
Copy link
Member

Choose a reason for hiding this comment

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

Will the version always be a part of the Realm path?

Args []string // Function arguments
Send string // Send amount
PkgPath string // Package path
PkgVersion string // Package version
Copy link
Member

Choose a reason for hiding this comment

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

This is an insanely breaking change. Please detail it in the PR description.

Why would it be necessary to provide the package version if the realm path already exists as part of the message?

@@ -144,7 +147,12 @@ func (c *Client) Run(cfg BaseTxCfg, msgs ...MsgRun) (*ctypes.ResultBroadcastTxCo
}

msg.Package.Name = "main"
msg.Package.Path = ""
if msg.Package.ModFile == nil {
Copy link
Member

Choose a reason for hiding this comment

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

When is this situation possible, if we require gno.mods?

if memPkg.IsEmpty() {
panic(fmt.Sprintf("found an empty package %q", cfg.PkgPath))
panic(fmt.Sprintf("found an empty package ar dir %q", cfg.PkgDir))
Copy link
Member

Choose a reason for hiding this comment

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

Why not return an error here, instead of panicking? The function supports an error return

// TODO(hariom): return error instead
panic(fmt.Sprintf("error parsing gno.mod at: %q", dir))
}
// TODO(hariom): make sure requires are accurate in gno.mod
Copy link
Member

Choose a reason for hiding this comment

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

Leftover?


// TODO(hariom): move to better place
func ParseMemMod(dir string) *std.MemMod {
var memMod std.MemMod
Copy link
Member

Choose a reason for hiding this comment

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

Why declare here, when you're actually setting the object at the end of the method?

panic(fmt.Sprintf("error parsing gno.mod at: %q", dir))
}
// TODO(hariom): make sure requires are accurate in gno.mod
var requires []*std.Requirements
Copy link
Member

Choose a reason for hiding this comment

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

You know exactly what the size of this slice is, make should be used

Comment on lines 68 to 70
const uversePkgPath = ".uverse"
const uversePkgVersion = "v0.1.0"

Copy link
Member

Choose a reason for hiding this comment

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

Nitpick: you can combine this in a common const

@@ -55,18 +56,20 @@ type Machine struct {
//
// Like for [NewMachineWithOptions], Machines initialized through this
// constructor must be finalized with [Machine.Release].
func NewMachine(pkgPath string, store Store) *Machine {
func NewMachine(pkgPath, pkgVersion string, store Store) *Machine {
Copy link
Member

Choose a reason for hiding this comment

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

What do you think about making NewMachine take in the Store, and have the other params as options?
As far as I can see, there is only one instance where pkgVersion != """

@harry-hov harry-hov marked this pull request as draft April 8, 2024 08:47
@harry-hov
Copy link
Contributor Author

Initially, I envisioned this PR to serve as a proof of concept for versioning. I marked it as ready for review to draw attention to this topic and to receive feedback on the idea in general.

As directed by @zivkovicmilos, I am converting this to a draft until I complete the implementation.

@@ -39,7 +39,7 @@ func (fr Frame) String() string {
fr.NumExprs,
fr.NumStmts,
fr.NumBlocks,
fr.LastPackage.PkgPath,
fr.LastPackage.ModFile.Path,
Copy link
Contributor

@piux2 piux2 Apr 9, 2024

Choose a reason for hiding this comment

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

Let's give it a second thought on implementing mod and package versioning at the VM level. Shouldn't the module be a development tool that manages package versioning outside of VM execution?

@@ -142,7 +142,7 @@ func (m *Machine) doOpInterfaceType() {
}
// push interface type
it := &InterfaceType{
PkgPath: m.Package.PkgPath,
PkgPath: m.Package.ModFile.Path,
Copy link
Contributor

@piux2 piux2 Apr 9, 2024

Choose a reason for hiding this comment

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

Let's give it a second thought on implementing mod and package versioning at the VM level. Shouldn't the module be a development tool that manages package versioning outside of VM execution?

Same as many other places in this implementation

@Kouteki
Copy link
Contributor

Kouteki commented Apr 11, 2024

@harry-hov is this a breaking change? Trying to determine whether we can do this feature post test4 launch.

@harry-hov
Copy link
Contributor Author

@harry-hov is this a breaking change? Trying to determine whether we can do this feature post test4 launch.

@Kouteki Yes it's a breaking change. It changes how you publish and interact with gno packages.

I have no problem with moving this post launch. Regardless, it's on my priority list.

@Kouteki Kouteki added the don't merge Please don't merge this functionality temporarily label May 31, 2024
@thehowl
Copy link
Member

thehowl commented Jun 18, 2024

Closing this PR; improved proposals are welcome.

@thehowl thehowl closed this Jun 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
breaking change Functionality that contains breaking changes don't merge Please don't merge this functionality temporarily 📦 🌐 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: Done
Status: No status
Development

Successfully merging this pull request may close these issues.

7 participants