-
Notifications
You must be signed in to change notification settings - Fork 176
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
cleanup go.mod #137
cleanup go.mod #137
Conversation
64798f9
to
e5e72dc
Compare
@@ -60,8 +60,6 @@ require ( | |||
|
|||
replace mellium.im/sasl => github.com/mellium/sasl v0.2.1 | |||
|
|||
replace github.com/onflow/flow-go => ./ |
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 did we have this in the first place?
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 remember there being a reason for this, but I can't remember why 😓 I'll try to dig up the PR.
I'd say that if everything builds and all the test pass without it, we should remove it.
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 think this was temporary during the GH org migration
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.
Found the relevant PR: https://github.com/dapperlabs/flow-go/pull/1959#discussion_r361214248
I think it's okay to remove all of these replaces if the tests pass without them
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 can't remove them all, as you can see, the build will failure.
I can only remove this line to fix the build. But I don't understand why other "replace"s can't be removed
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 think part of the issue is the integration
package is pinning a very old version of flow-go
. With the replace
that old version gets replaced by whatever is in the replacement path on the machine but without the replace we actually fetch that old version.
The dependency on flow-go/crypto needs to be updated: https://github.com/onflow/flow-go/pull/137/files#diff-33ef32bf6c23acb95f5902d7097b7a1d5128ca061167ec0716715b0b9eeaa5f6R36 |
@zhangchiqing flow-go is already using new code of the crypto library, even though that hasn't been "released" yet. |
I've release the crypto package, at the same commit as v0.11.0: https://github.com/onflow/flow-go/releases/tag/crypto%2Fv0.11.0 |
Does it mean, with the "replace", flow-go will refer to the crypto code on the same commit. Whereas, without the "replace", it will refer to the code on the latest "release"? If that's the case, I think we should keep the two "replace", so that code is always compatible with the version on the same commit. no? |
Yes, when the Keeping the statement will "fix" the issue for this repo, but it breaks downstream dependencies like the emulator, which imports flow-go. |
See golang/go#30354 (comment):
|
go.mod
Outdated
// needed otherwise the code refers to the crypto package will refer to | ||
// the released version of the crypto library, which might not be the latest | ||
replace github.com/onflow/flow-go/crypto => ./crypto |
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.
Instead of this replace statement, crypto should be bumped to crypto/v0.11.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.
I agree with Bastian on this. We should pin a specific version and keep it up to date. Otherwise importers of flow-go
could have crypto-dependent flow-go
packages that either don't compile or are invisibly using an older version of crypto
.
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 agree. I was trying that, but for some reason, it didn't work.
The version for crypto
has been pinned here. Suppose we no longer need this replace
. But if I remove it, make lint
will start complaining.
Not sure what's the proper fix.
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 guess this is why:
Lines 16 to 26 in f84b80f
If you wish to only import the Flow cryptography package to your Go project, please follow the following steps: | |
- Get Flow cryptography package. | |
``` | |
go get github.com/onflow/flow-go/crypto | |
``` | |
- Install [CMake](https://cmake.org/install/), which is used for building the package. | |
- From the package directory in `$GOPATH/pkg/mod/github.com/onflow/`, build the package dependencies. | |
``` | |
go generate | |
``` |
When we pin a version, Go will download a new copy in pkg/mod
and that copy hasn't had the extra C build steps applied to it. We would need to follow @tarakby's instructions for the copy managed by go mod
. Probably we would need to do that every time we change the version. From a bit of searching it doesn't really seem like Go has a good solution for modules that require a non-Go build step.
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 think there is another reason for @zhangchiqing's linter issues that need to be solved.
When we go get
Flow crypto lib, the C source code of the package is copied along with Go files to pkg/mod
. What I recommended in the readme is only related to the Relic dependency.
Update: Relic dependency is actually what was missing. cgo could work properly once I followed the readme step (still v0.11.0 is an outdated version and needs to be updated)
@@ -23,6 +23,6 @@ require ( | |||
|
|||
replace github.com/onflow/flow-go => ../ |
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.
Here I think it's ok to keep this at least in the short term 👍. Integration tests aren't really intended to be imported to other projects.
Brought it up yesterday again (https://axiomzen.slack.com/archives/C015G65HR2P/p1606232145256900): the replace statements should be removed and crypto should be tagged instead. |
0d7bfe4
to
8961a7c
Compare
ccfb576
to
41abbf4
Compare
I did the following thing to resolve the dependencies for now:
I have tested that it works:
After that, I'm able to make a build without the error. |
Co-authored-by: Jordan Schalm <jordan@dapperlabs.com>
@zhangchiqing Fantastic work, thank you so much for cleaning this up! 👏 🏅 |
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.
Great work!
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 changes our setup process as well.
Do we need to update Git submodules any more if we aren't directly working on crypto
?
Lines 60 to 64 in a406926
- Clone this repository's submodules: | |
```bash | |
git submodule update --init --recursive | |
``` |
We also need to ensure the go generate
gets run after a fresh install and every time we change the version of flow-go/crypto
dependency:
cd $GOPATH/pkg/mod/github.com/onflow/flow-go/crypto@v0.12.0/
sudo go generate
Should we put this in README
as a manual step?
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.
Thank you Leo for looking at this!
We don't need to run We also don't need to run It's only needed when |
I see, I was still was thinking we would remove that as well. Thanks @zhangchiqing |
That's the tradeoff. If we remove the "replace", we could ensure the flow-go use the right crypto library. However, everytime we make changes to crypto, and tag a new version, people will have to run If we were to remove the "replace", maybe even makes sense to make crypto as a stand alone repo, but we will still have to run so I think it's easier just to keep the replace. |
Remove the replace in go.mod to fix circular dependency