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

Import repair #1099

Closed
wants to merge 10 commits into from
Closed

Import repair #1099

wants to merge 10 commits into from

Conversation

faddat
Copy link
Contributor

@faddat faddat commented Dec 10, 2021

Closes: #1064

If we ship current v6.0.0 we'll ship with an iavl that just had race conditions identified on it.

Furthermore, we'd be shipping with a go.sum that imports like 4 versions of iavl.

And we'd be shipping it with Tendermint as far back as v0.34.0-rc0

Personally, I just prefer that we don't do that.

This PR also makes CI use the latest golangci-lint by default, and changes some settings that were making ci fail due to the deprecation of various linters.

You can think of this PR as mainly problem-identification and defense. The real solution here is better coordination throughout the cosmos ecosystem.

Here's a tweet where I summarized findings, and also linked to pull requests that fully resolve the issue and would make the replace statements at the bottom of go.mod unnecessary.

twitter.com/gadikian/status/1469512833809678342

If we wanted to ship as-is everything would most likely be fine. Also, there's a slim chance that my changes actually introduce issues by causing imported modules to use incompatible versions of software, but so far, so good.

Summary of findings:

So, if those three PRs were merged pre-launch, I think that'd be a step towards an easier to maintain, possibly more performant, possibly more secure gaia.

@@ -189,14 +159,11 @@ github.com/cockroachdb/datadriven v0.0.0-20190809214429-80d97fb3cbaa/go.mod h1:z
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/coinbase/rosetta-sdk-go v0.6.10 h1:rgHD/nHjxLh0lMEdfGDqpTtlvtSBwULqrrZ2qPdNaCM=
github.com/coinbase/rosetta-sdk-go v0.6.10/go.mod h1:J/JFMsfcePrjJZkwQFLh+hJErkAmdm9Iyy3D5Y0LfXo=
github.com/confio/ics23/go v0.0.0-20200817220745-f173e6211efb/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
github.com/confio/ics23/go v0.6.3/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
github.com/confio/ics23/go v0.6.6 h1:pkOy18YxxJ/r0XFDCnrl4Bjv6h4LkBSpLS6F38mrKL8=
github.com/confio/ics23/go v0.6.6/go.mod h1:E45NqnlpxGnpfTWL/xauN7MRwEE28T4Dd4uraToOaKg=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

github.com/cosmos/gorocksdb v0.0.0-20211202124722-2c356d6d98e4 h1:WxvYoiQOATTS4dNsqEKiRWGNPJHs5BM2cbO74NlhkUo=
github.com/cosmos/gorocksdb v0.0.0-20211202124722-2c356d6d98e4/go.mod h1:b/U29r/CtguX3TF7mKG1Jjn4APDqh4wECshxXdiWHpA=
github.com/cosmos/iavl v0.17.3 h1:s2N819a2olOmiauVa0WAhoIJq9EhSXE9HDBAoR9k+8Y=
github.com/cosmos/iavl v0.17.3/go.mod h1:prJoErZFABYZGDHka1R6Oay4z9PrNeFFiMKHDAMOi4w=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

go.sum Outdated
github.com/cosmos/iavl v0.17.1/go.mod h1:7aisPZK8yCpQdy3PMvKeO+bhq1NwDjUwjzxwwROUxFk=
github.com/cosmos/ibc-go/v2 v2.0.0 h1:BMRg73JcdV9wGPI51j89ihm7VBZQsDLkqQ+tmzdeA9Y=
github.com/cosmos/gorocksdb v0.0.0-20211202124722-2c356d6d98e4 h1:WxvYoiQOATTS4dNsqEKiRWGNPJHs5BM2cbO74NlhkUo=
github.com/cosmos/gorocksdb v0.0.0-20211202124722-2c356d6d98e4/go.mod h1:b/U29r/CtguX3TF7mKG1Jjn4APDqh4wECshxXdiWHpA=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

?

github.com/cosmos/go-bip39 v0.0.0-20180819234021-555e2067c45d/go.mod h1:tSxLoYXyBmiFeKpvmq4dzayMdCjCnu8uqmCysIGBT2Y=
github.com/cosmos/go-bip39 v1.0.0 h1:pcomnQdrdH22njcAatO0yWojsUnCO3y2tNoV1cb6hHY=
github.com/cosmos/go-bip39 v1.0.0/go.mod h1:RNJv0H/pOIVgxw6KS7QeX2a0Uo0aKUlfhZ4xuwvCdJw=
github.com/cosmos/iavl v0.15.0-rc3.0.20201009144442-230e9bdf52cd/go.mod h1:3xOIaNNX19p0QrX0VqWa6voPRoJRGGYtny+DH8NEPvE=
github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I=
github.com/cosmos/iavl v0.15.3/go.mod h1:OLjQiAQ4fGD2KDZooyJG9yz+p2ao2IAYSbke8mVvSA4=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

github.com/cosmos/iavl v0.15.0-rc5/go.mod h1:WqoPL9yPTQ85QBMT45OOUzPxG/U/JcJoN7uMjgxke/I=
github.com/cosmos/iavl v0.15.3/go.mod h1:OLjQiAQ4fGD2KDZooyJG9yz+p2ao2IAYSbke8mVvSA4=
github.com/cosmos/iavl v0.17.1 h1:b/Cl8h1PRMvsu24+TYNlKchIu7W6tmxIBGe6E9u2Ybw=
github.com/cosmos/iavl v0.17.1/go.mod h1:7aisPZK8yCpQdy3PMvKeO+bhq1NwDjUwjzxwwROUxFk=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marbar3778 this is of specific concern

github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s=
github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tendermint v0.34.0-rc4/go.mod h1:yotsojf2C1QBOw4dZrTcxbyxmPUrT4hNuOQWX9XUwB4=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

?

github.com/tendermint/btcd v0.1.1 h1:0VcxPfflS2zZ3RiOAHkBiFUcPvbtRj5O7zHmcJWHV7s=
github.com/tendermint/btcd v0.1.1/go.mod h1:DC6/m53jtQzr/NFmMNEu0rxf18/ktVoVtMrnDD5pN+U=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15 h1:hqAk8riJvK4RMWx1aInLzndwxKalgi5rTqgfXxOxbEI=
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15/go.mod h1:z4YtwM70uOnk8h0pjJYlj3zdYwi9l03By6iAIF5j/Pk=
github.com/tendermint/go-amino v0.16.0 h1:GyhmgQKvqF82e2oZeuMSp9JTN0N09emoSZlb2lyGa2E=
github.com/tendermint/go-amino v0.16.0/go.mod h1:TQU0M1i/ImAo+tYpZi73AU3V/dKeCoMC9Sphe2ZwGME=
github.com/tendermint/tendermint v0.34.0-rc4/go.mod h1:yotsojf2C1QBOw4dZrTcxbyxmPUrT4hNuOQWX9XUwB4=
github.com/tendermint/tendermint v0.34.0-rc6/go.mod h1:ugzyZO5foutZImv0Iyx/gOFCX6mjJTgbLHTwi17VDVg=
github.com/tendermint/tendermint v0.34.0/go.mod h1:Aj3PIipBFSNO21r+Lq3TtzQ+uKESxkbA3yo/INM4QwQ=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@marbar3778 this too

github.com/tendermint/tendermint v0.34.14 h1:GCXmlS8Bqd2Ix3TQCpwYLUNHe+Y+QyJsm5YE+S/FkPo=
github.com/tendermint/tendermint v0.34.14/go.mod h1:FrwVm3TvsVicI9Z7FlucHV6Znfd5KBc/Lpp69cCwtk0=
github.com/tendermint/tm-db v0.6.2/go.mod h1:GYtQ67SUvATOcoY8/+x6ylk8Qo02BQyLrAs+yAcLvGI=
github.com/tendermint/tm-db v0.6.3/go.mod h1:lfA1dL9/Y/Y8wwyPp2NMLyn5P5Ptr/gvDFNWtrCWSf8=
github.com/tendermint/tm-db v0.6.4 h1:3N2jlnYQkXNQclQwd/eKV/NzlqPlfK21cpRRIx80XXQ=
github.com/tendermint/tm-db v0.6.4/go.mod h1:dptYhIpJ2M5kUuenLr+Yyf3zQOv1SgBZcl8/BmWlMBw=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

github.com/yuin/goldmark v1.1.25/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.27/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.1.32/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.2.1/go.mod h1:3hX8gzYuyVAZsxl0MRgGTJEmQBFcNTphYh9decYSb74=
github.com/yuin/goldmark v1.3.5/go.mod h1:mwnBkeHKe2W/ZEtQ+71ViKU8L12m81fl3OWwC1Zlc8k=
github.com/zondax/hid v0.9.0 h1:eiT3P6vNxAEVxXMw66eZUAAnU2zD33JBkfG/EnfAKl8=
github.com/zondax/hid v0.9.0/go.mod h1:l5wttcP0jwtdLjqjMMWFVEE7d1zO0jvSPA9OPZxWpEM=
go.etcd.io/bbolt v1.3.2/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.3/go.mod h1:IbVyRI1SCnLcuJnV2u8VeU0CEYM7e686BmAb1XKL+uU=
go.etcd.io/bbolt v1.3.4/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
go.etcd.io/bbolt v1.3.5 h1:XAzx9gjCb0Rxj7EoqcClPD1d5ZBxZJk0jbuoPHenBt0=
go.etcd.io/bbolt v1.3.5/go.mod h1:G5EMThwa9y8QZGBClrRx5EY+Yw9kAhnjy3bSjsnlVTQ=
Copy link
Contributor Author

Choose a reason for hiding this comment

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

this

@codecov
Copy link

codecov bot commented Dec 10, 2021

Codecov Report

Merging #1099 (3100b48) into main (4533e8a) will decrease coverage by 0.02%.
The diff coverage is 40.00%.

@@            Coverage Diff             @@
##             main    #1099      +/-   ##
==========================================
- Coverage   12.00%   11.97%   -0.03%     
==========================================
  Files           9        9              
  Lines         933      935       +2     
==========================================
  Hits          112      112              
- Misses        816      817       +1     
- Partials        5        6       +1     

@faddat faddat changed the title fixes flaws that shouldn't ship in Vega. Import repair Dec 10, 2021
@faddat
Copy link
Contributor Author

faddat commented Dec 10, 2021

There are two solutions to this, and really I figure that it's best that for now we pursue both:

  • replace statements
  • collaboration in the ecosystem to ensure that we do not import ancient versions of our own software

It's time for sleep, but I can fix the stuff the linter found tomorrow.

@faddat faddat mentioned this pull request Dec 10, 2021
11 tasks
@lgtm-com
Copy link

lgtm-com bot commented Dec 10, 2021

This pull request introduces 1 alert when merging 0442e16 into c5e5b1d - view on LGTM.com

new alerts:

  • 1 for Useless assignment to local variable

@faddat
Copy link
Contributor Author

faddat commented Dec 10, 2021

CosmWasm/wasmd#692

@faddat
Copy link
Contributor Author

faddat commented Dec 11, 2021

I checked through cosmos-sdk 0.44.3 and 0.44.5. While 0.44.3 exhibits this issue, 0.44.5 does not.

@faddat
Copy link
Contributor Author

faddat commented Dec 11, 2021

This patch now satisfies the linter, too :)

@tac0turtle
Copy link
Member

Hey could you run go mod tidy . Having multiple checksums does not mean we are importing multiple versions -> https://go.dev/ref/mod#minimal-version-selection

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

on this, or on gaia's main branch?

@tac0turtle
Copy link
Member

this

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

sure :)

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

Screen Shot 2021-12-12 at 7 44 20 PM

exactly like that?

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

@marbar3778 what I think is happening is that various things that gaia imports, pull in really old software, and build against them, and that's my concern here.

@tac0turtle
Copy link
Member

In gaia the bot that we had fixing this was removed, still unclear as to why? I think if we add depndabot back for go modules it should keep modules and versions up to date.

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

I should mention that this problem is very much not limited to gaia.

I think I am up to six chains, and I think I could easily find it to be near-universal.

See, thing is, it isn't enough to just specify stuff in go.mod because a lot of this comes from the cosmos-sdk. v0.44.3 shows this problem, while 0.44.5 doesn't.

Then, if you import anything that depends on cosmos-sdk v0.44.3 or lower, you end up getting tendermint 0.34.0-rc4 in go.sum and -- please correct me if I'm wrong-- that's no bueno. I am going to try this: go list-m all

MVS starts at the main module (a special vertex in the graph that has no version) and traverses the graph, tracking the highest required version of each module. At the end of the traversal, the highest required versions comprise the build list: they are the minimum versions that satisfy all requirements.

The build list may be inspected with the command go list -m all. Unlike other dependency management systems, the build list is not saved in a “lock” file. MVS is deterministic, and the build list doesn’t change when new versions of dependencies are released, so MVS is used to compute it at the beginning of every module-aware command.

Consider the example in the diagram below. The main module requires module A at version 1.2 or higher and module B at version 1.2 or higher. A 1.2 and B 1.2 require C 1.3 and C 1.4, respectively. C 1.3 and C 1.4 both require D 1.2.

Then, the problem comes back into the main branch of cosmos-sdk here:

cosmos/cosmos-sdk#10570

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

Well, well.....

@marbar3778 thanks for the teachin. Can you let me know if --

  1. this is actually an issue, despite what this command says below

or

  1. I was chasing a nothingburger because Go was showing the lowest version that it could build against, then building against a required version?

or

  1. something else, which I still don't understand?

main:

 ~/testiepoo (main)> go list -m all | grep tendermint
github.com/tendermint/btcd v0.1.1
github.com/tendermint/crypto v0.0.0-20191022145703-50d29ede1e15
github.com/tendermint/go-amino v0.16.0
github.com/tendermint/tendermint v0.34.14
github.com/tendermint/tm-db v0.6.4
~/testiepoo (main)> go list -m all | grep cosmos
github.com/cosmos/gaia/v6
github.com/cosmos/cosmos-sdk v0.44.3 => github.com/cosmos/cosmos-sdk v0.44.2
github.com/cosmos/go-bip39 v1.0.0
github.com/cosmos/iavl v0.17.1
github.com/cosmos/ibc-go/v2 v2.0.0
github.com/cosmos/ledger-cosmos-go v0.11.1
github.com/cosmos/ledger-go v0.9.2
github.com/regen-network/cosmos-proto v0.3.1

@williambanfield
Copy link

williambanfield commented Dec 12, 2021

Hey @faddat, it looks like what we're seeing here is this behavior of go.sum:

The go.sum file may contain hashes for multiple versions of a module. The go command may need to load go.mod files from multiple versions of a dependency in order to perform minimal version selection.

You can see that a similar stanza exists at the top of the go.sum file containing many different go.mod files correspond to cloud.google.com/go versions. These are stored because the tooling fetched them and used them as part of its calculation for MVS.

The version that the binary will be built with is the version output by go list -m all

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

Thanks @marbar3778, @williambanfield -- final question-- the difference in go.sum between cosmos-sdk 0.44.3 and 0.44.5 -- also nothing? (that difference, is really quite vast, but it seems I've learned a great deal about Go today)

cloud.google.com/go

refers to go itself?

Thanks again!

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

Hey, please let me know if this should be closed, left open, or what-- pretty clear that I was at least to some degree chasing a nothingburger based on a misnterpertation of go.sum

@tac0turtle
Copy link
Member

The dependency update should be merged imo.

@williambanfield
Copy link

williambanfield commented Dec 12, 2021

Thanks @marbar3778, @williambanfield -- final question-- the difference in go.sum between cosmos-sdk 0.44.3 and 0.44.5 -- also nothing? (that difference, is really quite vast, but it seems I've learned a great deal about Go today)

Correct, the go.sum file does not dictate what's going to be included in a build. It's just some record keeping the tooling does to ensure that it can fetch a consistent version of a dependency. It's effectively a checksum, not a lock file. It has no effect on what is in the dependency graph. It should generally be ignored.

cloud.google.com/go

refers to go itself?

Thanks again!

From go mod graph, that shows as a dependency of a grpc library:

...
google.golang.org/grpc@v1.19.1 cloud.google.com/go@v0.26.0

Repo here.

Thanks for keeping an eye on our imports. If you do spot issues where our versions look out of date, please feel free to open an issue or reach out.

@williambanfield
Copy link

I think we can close this for now. The replace statement makes versioning a bit more confusing since you need to manage the version two places in the go.mod and I'm not sure it's necessary right now, although when versioning versions of software that do not use sem ver at all, it can definitely be useful.

@faddat
Copy link
Contributor Author

faddat commented Dec 12, 2021

You're right about the replace statements for sure. I have to go and let others know ..... Thanks to you both @marbar3778 and @williambanfield for the lesson in go.sum ; I appreciate it.

@faddat faddat mentioned this pull request Dec 12, 2021
11 tasks
@faddat faddat closed this Dec 12, 2021
@faddat faddat mentioned this pull request Dec 13, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Versioning Issues
3 participants