-
Notifications
You must be signed in to change notification settings - Fork 65
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
[BP: release/v6 <- #202]
refactor: remove the ability to take a fee for each forwarded packet
#206
Merged
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -144,7 +144,6 @@ cosmovisor: | |
mocks: $(MOCKS_DIR) | ||
go install go.uber.org/mock/[email protected] | ||
mockgen -package=mock -destination=./test/mock/transfer_keeper.go $(GOMOD)/packetforward/types TransferKeeper | ||
mockgen -package=mock -destination=./test/mock/distribution_keeper.go $(GOMOD)/packetforward/types DistributionKeeper | ||
mockgen -package=mock -destination=./test/mock/bank_keeper.go $(GOMOD)/packetforward/types BankKeeper | ||
mockgen -package=mock -destination=./test/mock/channel_keeper.go $(GOMOD)/packetforward/types ChannelKeeper | ||
mockgen -package=mock -destination=./test/mock/ics4_wrapper.go github.com/cosmos/ibc-go/v6/modules/core/05-port/types ICS4Wrapper | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
174 changes: 174 additions & 0 deletions
174
middleware/packet-forward-middleware/e2e/upgrade_test.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,174 @@ | ||
package e2e | ||
|
||
import ( | ||
"context" | ||
"fmt" | ||
"testing" | ||
"time" | ||
|
||
sdkmath "cosmossdk.io/math" | ||
upgradetypes "cosmossdk.io/x/upgrade/types" | ||
cosmosproto "github.com/cosmos/gogoproto/proto" | ||
"github.com/docker/docker/client" | ||
"github.com/strangelove-ventures/interchaintest/v8" | ||
"github.com/strangelove-ventures/interchaintest/v8/chain/cosmos" | ||
"github.com/strangelove-ventures/interchaintest/v8/ibc" | ||
"github.com/strangelove-ventures/interchaintest/v8/testutil" | ||
"github.com/stretchr/testify/require" | ||
) | ||
|
||
const ( | ||
chainName = "simapp" | ||
upgradeName = "v2" // x/params migration | ||
|
||
haltHeightDelta = uint64(9) // will propose upgrade this many blocks in the future | ||
blocksAfterUpgrade = uint64(7) | ||
|
||
VotingPeriod = "15s" | ||
MaxDepositPeriod = "10s" | ||
) | ||
|
||
var ( | ||
// baseChain is the current version of the chain that will be upgraded from | ||
// docker image load -i ../prev_builds/pfm_7_0_1.tar | ||
baseChain = ibc.DockerImage{ | ||
Repository: "pfm", | ||
Version: "v7.0.1", | ||
UidGid: "1025:1025", | ||
} | ||
|
||
// make local-image | ||
upgradeTo = ibc.DockerImage{ | ||
Repository: "pfm", | ||
Version: "local", | ||
} | ||
) | ||
|
||
func TestPFMUpgrade(t *testing.T) { | ||
CosmosChainUpgradeTest(t, chainName, upgradeTo.Repository, upgradeTo.Version, upgradeName) | ||
} | ||
|
||
func CosmosChainUpgradeTest(t *testing.T, chainName, upgradeRepo, upgradeDockerTag, upgradeName string) { | ||
if testing.Short() { | ||
t.Skip("skipping in short mode") | ||
} | ||
|
||
t.Parallel() | ||
|
||
previousVersionGenesis := []cosmos.GenesisKV{ | ||
{ | ||
Key: "app_state.gov.params.voting_period", | ||
Value: VotingPeriod, | ||
}, | ||
{ | ||
Key: "app_state.gov.params.max_deposit_period", | ||
Value: MaxDepositPeriod, | ||
}, | ||
{ | ||
Key: "app_state.gov.params.min_deposit.0.denom", | ||
Value: Denom, | ||
}, | ||
} | ||
|
||
// Upgrade default to use the base chain image | ||
cfg := DefaultConfig | ||
cfg.ModifyGenesis = cosmos.ModifyGenesis(previousVersionGenesis) | ||
cfg.Images = []ibc.DockerImage{baseChain} | ||
|
||
numVals, numNodes := 2, 0 | ||
chains := interchaintest.CreateChainWithConfig(t, numVals, numNodes, chainName, upgradeDockerTag, cfg) | ||
chain := chains[0].(*cosmos.CosmosChain) | ||
|
||
ctx, ic, client, _ := interchaintest.BuildInitialChain(t, chains, false) | ||
t.Cleanup(func() { | ||
ic.Close() | ||
}) | ||
|
||
var userFunds = sdkmath.NewInt(10_000_000_000) | ||
users := interchaintest.GetAndFundTestUsers(t, ctx, t.Name(), userFunds, chain) | ||
chainUser := users[0] | ||
|
||
// upgrade | ||
height, err := chain.Height(ctx) | ||
require.NoError(t, err, "error fetching height before submit upgrade proposal") | ||
|
||
haltHeight := height + haltHeightDelta | ||
proposalID := SubmitUpgradeProposal(t, ctx, chain, chainUser, upgradeName, haltHeight) | ||
|
||
ValidatorVoting(t, ctx, chain, proposalID, height, haltHeight) | ||
UpgradeNodes(t, ctx, chain, client, haltHeight, upgradeRepo, upgradeDockerTag) | ||
} | ||
|
||
func SubmitUpgradeProposal(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, user ibc.Wallet, upgradeName string, haltHeight uint64) string { | ||
upgradeMsg := []cosmosproto.Message{ | ||
&upgradetypes.MsgSoftwareUpgrade{ | ||
// Gov Module account | ||
Authority: "cosmos10d07y265gmmuvt4z0w9aw880jnsr700j6zn9kn", | ||
Plan: upgradetypes.Plan{ | ||
Name: upgradeName, | ||
Height: int64(haltHeight), | ||
}, | ||
}, | ||
} | ||
|
||
proposal, err := chain.BuildProposal(upgradeMsg, "Chain Upgrade "+upgradeName, "Summary desc", "ipfs://CID", fmt.Sprintf(`500000000%s`, chain.Config().Denom), user.KeyName(), false) | ||
require.NoError(t, err, "error building proposal") | ||
|
||
txProp, err := chain.SubmitProposal(ctx, user.KeyName(), proposal) | ||
require.NoError(t, err, "error submitting proposal") | ||
|
||
t.Log("txProp", txProp) | ||
return txProp.ProposalID | ||
} | ||
|
||
func UpgradeNodes(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, client *client.Client, haltHeight uint64, upgradeRepo, upgradeBranchVersion string) { | ||
// bring down nodes to prepare for upgrade | ||
t.Log("stopping node(s)") | ||
err := chain.StopAllNodes(ctx) | ||
require.NoError(t, err, "error stopping node(s)") | ||
|
||
// upgrade version on all nodes | ||
t.Log("upgrading node(s)") | ||
chain.UpgradeVersion(ctx, client, upgradeRepo, upgradeBranchVersion) | ||
|
||
// start all nodes back up. | ||
// validators reach consensus on first block after upgrade height | ||
// and chain block production resumes. | ||
t.Log("starting node(s)") | ||
err = chain.StartAllNodes(ctx) | ||
require.NoError(t, err, "error starting upgraded node(s)") | ||
|
||
timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*60) | ||
defer timeoutCtxCancel() | ||
|
||
err = testutil.WaitForBlocks(timeoutCtx, int(blocksAfterUpgrade), chain) | ||
require.NoError(t, err, "chain did not produce blocks after upgrade") | ||
|
||
height, err := chain.Height(ctx) | ||
require.NoError(t, err, "error fetching height after upgrade") | ||
|
||
require.GreaterOrEqual(t, height, haltHeight+blocksAfterUpgrade, "height did not increment enough after upgrade") | ||
} | ||
|
||
func ValidatorVoting(t *testing.T, ctx context.Context, chain *cosmos.CosmosChain, proposalID string, height uint64, haltHeight uint64) { | ||
err := chain.VoteOnProposalAllValidators(ctx, proposalID, cosmos.ProposalVoteYes) | ||
require.NoError(t, err, "failed to submit votes") | ||
|
||
_, err = cosmos.PollForProposalStatusV8(ctx, chain, height, height+haltHeightDelta, proposalID, cosmos.ProposalStatusPassedV8) | ||
require.NoError(t, err, "proposal status did not change to passed in expected number of blocks") | ||
|
||
timeoutCtx, timeoutCtxCancel := context.WithTimeout(ctx, time.Second*45) | ||
defer timeoutCtxCancel() | ||
|
||
height, err = chain.Height(ctx) | ||
require.NoError(t, err, "error fetching height before upgrade") | ||
|
||
// this should timeout due to chain halt at upgrade height. | ||
_ = testutil.WaitForBlocks(timeoutCtx, int(haltHeight-height), chain) | ||
|
||
height, err = chain.Height(ctx) | ||
require.NoError(t, err, "error fetching height after chain should have halted") | ||
|
||
// make sure that chain is halted | ||
require.Equal(t, haltHeight, height, "height is not equal to halt height") | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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 do not think this file is run at all here (due to not adding the gh ci), it can probably be removed safely for anything which is not main branch
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.
good call out, there may be a bit of dead code at this point. may need to just do an audit of that while we rectify any issues discovered in the audit.