-
Notifications
You must be signed in to change notification settings - Fork 618
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
Epoch module as a importable package #2544
Conversation
Wow this is shockingly simpler than I expected How are we not getting import cycles with epochs depending on osmosis, but osmosis v11 depending on epochs? |
@@ -299,6 +299,8 @@ replace ( | |||
github.com/cosmos/iavl => github.com/osmosis-labs/iavl v0.17.3-osmo-v7 | |||
// use cosmos-compatible protobufs | |||
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 | |||
github.com/osmosis-labs/osmosis/x/epochs => ./x/epochs |
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.
Ohh this is cool, this is why we don't have import cycle issues
x/epochs/go.mod
Outdated
replace ( | ||
// branch: v0.27.0.rc3-osmo, current tag: v0.27.0.rc3-osmo | ||
github.com/CosmWasm/wasmd => github.com/osmosis-labs/wasmd v0.27.0-rc2.0.20220517191021-59051aa18d58 | ||
// Our cosmos-sdk branch is: https://github.com/osmosis-labs/cosmos-sdk, current branch: osmosis-main. Direct commit link: https://github.com/osmosis-labs/cosmos-sdk/commit/5c9a51c277d067e0ec5cf48df30a85fae95bcd14 | ||
github.com/cosmos/cosmos-sdk => github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20220822135534-5c9a51c277d0 | ||
// Use Osmosis fast iavl | ||
github.com/cosmos/iavl => github.com/osmosis-labs/iavl v0.17.3-osmo-v7 | ||
// use cosmos-compatible protobufs | ||
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1 | ||
// use grpc compatible with cosmos protobufs | ||
google.golang.org/grpc => google.golang.org/grpc v1.33.2 | ||
) |
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.
cc @puneet2019 will this cause import issues for you all? This comes from the osmosis-labs/osmosis
import, but none of these replaces matter for you all.
The replaces won't happen when you import this module as only top-level package replaces get applied.
It may also be the case that osmosis-labs/osmosis/v11 doesn't get compiled, since its only imported in tests
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 the main repo is getting included in your go.mod via an indirect, it may also be worth trying exclude github.com/osmosis-labs/osmosis/v11
, which could potentially fix this
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 will be trying this today or tomorrow!
I had tried something similar but had import cycle issues.
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.
Go mod for the epochs module should be having an entry for the osmosis module itself, and that would need to be replaced with the file
Something like
require (
"github.com/osmosis-labs/osmosis/v11" v11.0.1
...
)
replace (
github.com/osmosis-labs/osmosis/v11 => ../../
)
This is something similar to what is being done on the cosmos-sdk, which basically took inspiration from k8s itself.
or is it not needed?
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.
yes. Better if we use this replace.
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.
Hey!
Could you possibly show an example on how to import this into other apps?
Here is what i tried.
- cloned an interchain-accounts repo
- cloned osmosis and switch to
epochs-module
branch. - it won't let me
go get
go: github.com/osmosis-labs/osmosis/x/epochs@v0.0.0: reading github.com/osmosis-labs/osmosis/x/epochs/x/epochs/go.mod at revision x/epochs/v0.0.0: unknown revision x/epochs/v0.0.0
- set the go.mod as such
go.mod
module github.com/cosmos/interchain-accounts
go 1.18
replace github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
replace (
github.com/osmosis-labs/osmosis/x/epochs => ../osmosis/x/epochs
)
exclude (
github.com/osmosis-labs/osmosis/v11 v11.0.1
)
require (
github.com/osmosis-labs/osmosis/x/epochs v0.0.0
github.com/cosmos/cosmos-sdk v0.45.6
github.com/gogo/protobuf v1.3.3
.........
- run
go mod tidy
➜ interchain-accounts git:(393d844) ✗ [31/08/22 4:44:58]$ go mod tidy
go: finding module for package github.com/osmosis-labs/osmosis/v11/app/apptesting
go: finding module for package github.com/osmosis-labs/osmosis/v11/osmoutils
go: finding module for package github.com/osmosis-labs/osmosis/v11/app
github.com/cosmos/interchain-accounts/app imports
github.com/osmosis-labs/osmosis/x/epochs/types imports
github.com/osmosis-labs/osmosis/v11/osmoutils: module github.com/osmosis-labs/osmosis@latest found (v1.0.4), but does not contain package github.com/osmosis-labs/osmosis/v11/osmoutils
github.com/cosmos/interchain-accounts/app imports
github.com/osmosis-labs/osmosis/x/epochs/keeper tested by
github.com/osmosis-labs/osmosis/x/epochs/keeper.test imports
github.com/osmosis-labs/osmosis/v11/app: module github.com/osmosis-labs/osmosis@latest found (v1.0.4), but does not contain package github.com/osmosis-labs/osmosis/v11/app
github.com/cosmos/interchain-accounts/app imports
github.com/osmosis-labs/osmosis/x/epochs/keeper tested by
github.com/osmosis-labs/osmosis/x/epochs/keeper.test imports
github.com/osmosis-labs/osmosis/v11/app/apptesting: module github.com/osmosis-labs/osmosis@latest found (v1.0.4), but does not contain package github.com/osmosis-labs/osmosis/v11/app/apptesting
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.
@puneet2019 the import actually works. For the other repo, we dont do replace, but go get
the package directly instead.
Ran, and it seems to work
go get github.com/osmosis-labs/osmosis/x/epochs@87034b3ca46c8a26812afe24a275882c65113dd0
Creates an entry in go.mod
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20220831122550-87034b3ca46c
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.
@Anmol1696 were you able to get it right? importing it into another repository?
go get
works, but import still seems to be an issue
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.
@puneet2019 seems problems from conflict with sdk45 and sdk46. I'm trying to fix it.
@@ -0,0 +1,145 @@ | |||
module github.com/osmosis-labs/osmosis/x/epochs |
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 module name is a bit confusing tbh. When ever we do the import, it is not evident that this is actually a module vs other imports that are not modular.
import (
"github.com/osmosis-labs/osmosis/v11/x/incentives/keeper"
"github.com/osmosis-labs/osmosis/x/epochs/keeper"
)
The only difference being the version after osmosis.
Inoder to avoid confusion for this, I was looking into something like osmosis.io/x/epochs
as this module, would have to do some more research into packaging and publishing the module. Versioning of this module also would be then easier and not conflicting with other packages. Something i am trying out here #2550
This would then be in harmony with the efforts on the cosmos-sdk side of things as well.
PS. osmosis.io/
can use a different name as well.
What do you think? @puneet2019 @ValarDragon @vuong177
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 have no preference tbh. as long as it works :P
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.
@puneet2019 - depending on what you'd like to do you may wish to check out:
https://github.com/eve-network/eve
Also, if you could let us know if epochs can be imported, that'd be super! (reasoning: eve's natively 46, and in order to use the osmosis epochs module, we made the changes needed to use 46)
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.
Hey, we are still figuring this out.
Seems like tests are a bit of a problem. Short term even I have forked the epochs module using git subtree
.
Co-authored-by: Anmol <anmol1696@gmail.com>
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
This pull request has been automatically marked as stale because it has not had any recent activity. It will be closed if no further activity occurs. Thank you! |
I'll close this issue and open a new one. |
Closes: #2522
What is the purpose of the change
Make
epoch
module into an importable moduleDocumentation and Release Note
Unreleased
section inCHANGELOG.md
? (yes / no) nox/<module>/spec/
) / [Osmosis docs repo] / not documented) not applicable