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

fix: Local-interchain cleanup #710

Merged
merged 9 commits into from
Sep 27, 2023
Merged

Conversation

DavidNix
Copy link
Contributor

@DavidNix DavidNix commented Aug 16, 2023

Fixes one compiler error.

go build -ldflags '-X main.MakeFileInstallDirectory=/Users/davidnix/src/strangelove/interchaintest/local-interchain/' -o ../bin/local-ic ./cmd/local-ic
# github.com/strangelove-ventures/localinterchain/interchain
interchain/genesis.go:65:15: cannot use coin.Amount.Int64() (value of type int64) as "cosmossdk.io/math".Int value in struct literal
make: *** [Makefile:11: build] Error 1

@DavidNix DavidNix requested a review from a team as a code owner August 16, 2023 17:45
@DavidNix DavidNix requested a review from jtieri August 16, 2023 17:45
Comment on lines -189 to -186
func init() {
rootCmd.AddCommand(newChainCmd)
}
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I avoid init() functions at all costs. Even though this is common in Viper and co-located with the subcommand file, I think it's an anti-pattern. It hides order of operations and hides functionality in the main() function. IOW, I want to look at main() and know exactly what's happening.

Comment on lines 12 to 14
var (
MakeFileInstallDirectory string
)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Avoid global vars. In this case, wasn't needed at all.

Copy link
Member

@Reecepbcups Reecepbcups Aug 22, 2023

Choose a reason for hiding this comment

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

This is required for the ldflags in makefile to work I believe.
or does the var in get directory work properly when you make install. This is the reason it is a globalvar

ldflags = -X main.MakeFileInstallDirectory=$(CWD)

There are 3 install cases:

  1. the user make installs, it sets the current install location in the system
  2. ICTEST_HOME env is used
  3. neither of the above are true, and we set ictest to be at the user's $HOME/local-interchain location

This would remove the first which is the most common desire imo

@DavidNix DavidNix marked this pull request as draft August 16, 2023 17:50
@DavidNix DavidNix requested review from boojamya and removed request for jtieri August 16, 2023 17:50
@DavidNix DavidNix marked this pull request as ready for review August 17, 2023 13:49
Copy link
Contributor

@boojamya boojamya left a comment

Choose a reason for hiding this comment

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

Thank you for the context around init.

@@ -62,7 +63,7 @@ func SetupGenesisWallets(config *types.Config, chains []ibc.Chain) map[ibc.Chain
for _, coin := range amount {
additionalWallets[chainObj] = append(additionalWallets[chainObj], ibc.WalletAmount{
Address: acc.Address,
Amount: coin.Amount.Int64(),
Amount: math.NewInt(coin.Amount.Int64()),
Copy link
Contributor

Choose a reason for hiding this comment

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

Ah nice. Yea this makes sense because this got merged first:

#679

Really surprised CI didn't catch this??

Copy link
Contributor

Choose a reason for hiding this comment

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

Oh one more note... around backporting.
That PR is not backported yet: #685

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh good catch. We should get that back ported. I can look at it.

@boojamya boojamya added the BACKPORT backport into all maintained branches label Aug 17, 2023
@DavidNix
Copy link
Contributor Author

Thank you for the context around init.

Of course! Consider init functions harmful. They modify or create global state and their order of operations is not intuitive.

Copy link
Member

@Reecepbcups Reecepbcups left a comment

Choose a reason for hiding this comment

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

@DavidNix I reverted your change here to make the variable private (b87ff71). The reason this is public is for the makefile to build to the proper directory (static link within the bin at compile time)

I added a comment to make others aware of this in the code too

ldflags = -X main.MakeFileInstallDirectory=$(CWD)
...
.PHONY: install
install:
	go install $(BUILD_FLAGS) ./cmd/local-ic ./interchain

Other than that it LGTM

@Reecepbcups Reecepbcups enabled auto-merge (squash) September 27, 2023 16:35
@Reecepbcups Reecepbcups merged commit 5c4c2b6 into main Sep 27, 2023
7 checks passed
@Reecepbcups Reecepbcups deleted the nix/feat/local-interchain-cleanup branch September 27, 2023 16:42
mergify bot pushed a commit that referenced this pull request Sep 27, 2023
* Fix compiler error

* Use go run in Makefile

Prevents needing to build the binary first.

* Remove unecessary init functions

* Remove unecessary global var

* Fix misspelling in var name

* Revert "Remove unecessary global var"

This reverts commit 20cf604.

* Add comment for why InstallDir must be public

---------

Co-authored-by: Reece Williams <[email protected]>
(cherry picked from commit 5c4c2b6)
Reecepbcups pushed a commit that referenced this pull request Sep 27, 2023
* Fix compiler error

* Use go run in Makefile

Prevents needing to build the binary first.

* Remove unecessary init functions

* Remove unecessary global var

* Fix misspelling in var name

* Revert "Remove unecessary global var"

This reverts commit 20cf604.

* Add comment for why InstallDir must be public

---------

Co-authored-by: Reece Williams <[email protected]>
(cherry picked from commit 5c4c2b6)

Co-authored-by: David Nix <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BACKPORT backport into all maintained branches
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants