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

Epoch module as a importable package #2544

Closed
wants to merge 7 commits into from
Closed

Epoch module as a importable package #2544

wants to merge 7 commits into from

Conversation

vuong177
Copy link
Contributor

@vuong177 vuong177 commented Aug 29, 2022

Closes: #2522

What is the purpose of the change

Make epoch module into an importable module

Documentation and Release Note

  • Does this pull request introduce a new feature or user-facing behavior changes? (yes / no) no
  • Is a relevant changelog entry added to the Unreleased section in CHANGELOG.md? (yes / no) no
  • How is the feature or change documented? (not applicable / specification (x/<module>/spec/) / [Osmosis docs repo] / not documented) not applicable

@vuong177 vuong177 changed the title init go.mod Epoch module as a importable package Aug 29, 2022
@github-actions github-actions bot added the C:docs Improvements or additions to documentation label Aug 30, 2022
@vuong177 vuong177 marked this pull request as ready for review August 30, 2022 01:58
@vuong177 vuong177 requested a review from a team August 30, 2022 01:58
@ValarDragon
Copy link
Member

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
Copy link
Member

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
Comment on lines 137 to 148
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
)
Copy link
Member

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

Copy link
Member

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

Copy link
Member

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.

Copy link

@Anmol1696 Anmol1696 Aug 30, 2022

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?

Copy link
Contributor Author

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.

Copy link
Member

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

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

Copy link
Member

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

Copy link
Contributor Author

@vuong177 vuong177 Sep 6, 2022

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.

CHANGELOG.md Outdated Show resolved Hide resolved
@@ -0,0 +1,145 @@
module github.com/osmosis-labs/osmosis/x/epochs
Copy link

@Anmol1696 Anmol1696 Aug 31, 2022

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

Copy link
Member

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

Copy link
Member

@faddat faddat Sep 15, 2022

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)

Copy link
Member

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 .

vuong177 and others added 2 commits August 31, 2022 19:25
Co-authored-by: Anmol <anmol1696@gmail.com>
@github-actions
Copy link
Contributor

github-actions bot commented Oct 1, 2022

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!

@github-actions github-actions bot added the Stale label Oct 1, 2022
@github-actions github-actions bot closed this Oct 7, 2022
@faddat faddat reopened this Nov 8, 2022
@github-actions github-actions bot removed the C:docs Improvements or additions to documentation label Nov 8, 2022
@github-actions github-actions bot removed the Stale label Nov 9, 2022
@github-actions
Copy link
Contributor

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!

@github-actions github-actions bot added the Stale label Nov 24, 2022
@vuong177
Copy link
Contributor Author

I'll close this issue and open a new one.

@vuong177 vuong177 closed this Nov 24, 2022
@puneet2019 puneet2019 mentioned this pull request Feb 16, 2023
3 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

Epoch module as a importable package
5 participants