-
Notifications
You must be signed in to change notification settings - Fork 372
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
Conversation
0d14e77
to
181308e
Compare
Can you please resolve the merge conflicts in this PR? 🙏 |
181308e
to
82d13ce
Compare
ce8456c
to
ee1d69f
Compare
There was a problem hiding this 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:
09cecd6
to
ff270fa
Compare
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. |
1286a4a
to
7279190
Compare
Codecov ReportAttention: Patch coverage is
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. |
I agree. changed it to Thanks @ajnavarro |
There was a problem hiding this 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
## 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 | ||
|
There was a problem hiding this comment.
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/[email protected] -func Increment -gas-fee 1000000ugnot -gas-wanted 2000000 -broadcast -chainid=tendermint_test test1 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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.mod
s?
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)) |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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 |
There was a problem hiding this comment.
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
const uversePkgPath = ".uverse" | ||
const uversePkgVersion = "v0.1.0" | ||
|
There was a problem hiding this comment.
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 { |
There was a problem hiding this comment.
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 != """
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, |
There was a problem hiding this comment.
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, |
There was a problem hiding this comment.
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
@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. |
Closing this PR; improved proposals are welcome. |
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
module
directive takes version nowe.g:
gnokey maketx addpkg
command takes pkg path and version from gno.mod filegnokey maketx call
command takes-pkgPath
in the formatgno.land/p/{handle}/[email protected]
Testing
to test, run (versioning.txtar):
Contributors' checklist...
BREAKING CHANGE: xxx
message was included in the description