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

deps!: support cosmos-sdk-v45-ics-lsm integration #1120

Merged
merged 19 commits into from
Aug 16, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

Add an entry to the unreleased section whenever merging a PR to main that is not targeted at a specific release. These entries will eventually be included in a release.

* (deps!) [#1120](https://github.com/cosmos/interchain-security/pull/1120) Bump [Cosmos SDK](https://github.com/cosmos/cosmos-sdk) to [v0.45.16-ics-lsm](https://github.com/cosmos/cosmos-sdk/tree/v0.45.16-ics-lsm). This requires adapting ICS to support this SDK release. Changes are state breaking.
* (fix) [#720](https://github.com/cosmos/interchain-security/issues/720) Fix the attribute `AttributeDistributionTotal` value in `FeeDistribution` event emit.

## v2.0.0
Expand Down
2 changes: 1 addition & 1 deletion go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -153,7 +153,7 @@ require (
)

replace (
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.15-ics
github.com/cosmos/cosmos-sdk => github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm-rc0
github.com/gogo/protobuf => github.com/regen-network/protobuf v1.3.3-alpha.regen.1
github.com/tendermint/tendermint => github.com/cometbft/cometbft v0.34.28
google.golang.org/grpc => google.golang.org/grpc v1.33.2
Expand Down
4 changes: 2 additions & 2 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -231,8 +231,8 @@ github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32 h1:zlCp9n3uwQieEL
github.com/cosmos/cosmos-db v0.0.0-20221226095112-f3c38ecb5e32/go.mod h1:kwMlEC4wWvB48zAShGKVqboJL6w4zCLesaNQ3YLU2BQ=
github.com/cosmos/cosmos-proto v1.0.0-beta.1 h1:iDL5qh++NoXxG8hSy93FdYJut4XfgbShIocllGaXx/0=
github.com/cosmos/cosmos-proto v1.0.0-beta.1/go.mod h1:8k2GNZghi5sDRFw/scPL8gMSowT1vDA+5ouxL8GjaUE=
github.com/cosmos/cosmos-sdk v0.45.15-ics h1:ujrXsulYGwggLCC0oD7CizvlAerqMQHfCHHjHqIamfY=
github.com/cosmos/cosmos-sdk v0.45.15-ics/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm-rc0 h1:zFSOIuoTbVCCnqIbfG0KZ099bIr6i9G+J3IOR9dgG80=
github.com/cosmos/cosmos-sdk v0.45.16-ics-lsm-rc0/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40=
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=
Expand Down
25 changes: 14 additions & 11 deletions legacy_ibc_testing/testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -79,20 +79,23 @@ func SetupWithGenesisValSet(t *testing.T, appIniter AppIniter, valSet *tmtypes.V
pkAny, err := codectypes.NewAnyWithValue(pk)
require.NoError(t, err)
validator := stakingtypes.Validator{
OperatorAddress: sdk.ValAddress(val.Address).String(),
ConsensusPubkey: pkAny,
Jailed: false,
Status: stakingtypes.Bonded,
Tokens: bondAmt,
DelegatorShares: sdk.OneDec(),
Description: stakingtypes.Description{},
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
MinSelfDelegation: sdk.ZeroInt(),
OperatorAddress: sdk.ValAddress(val.Address).String(),
ConsensusPubkey: pkAny,
Jailed: false,
Status: stakingtypes.Bonded,
Tokens: bondAmt,
DelegatorShares: sdk.OneDec(),
Description: stakingtypes.Description{},
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
// MinSelfDelegation: sdk.ZeroInt(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Why is this commented out instead of removed outright?

Copy link
Contributor

Choose a reason for hiding this comment

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

It was deprecated in SDK. Probably @MSalopek can give a better reasoning for commenting it out.

}

validators = append(validators, validator)
// NOTE: @MSalopek
Copy link
Contributor

Choose a reason for hiding this comment

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

That's because we don't have any ICS tests that are dealing with this flag.

// need more info about stakingtypes.Delegation.ValidatorBond flag usage
// setting this to both true or false does not affect the test results
delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec()))
}

Expand Down
24 changes: 12 additions & 12 deletions tests/difference/core/driver/setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -176,17 +176,17 @@ func (b *Builder) getAppBytesAndSenders(
require.NoError(b.suite.T(), err)

validator := stakingtypes.Validator{
OperatorAddress: sdk.ValAddress(val.Address).String(),
ConsensusPubkey: pkAny,
Jailed: false,
Status: status,
Tokens: tokens,
DelegatorShares: sumShares,
Description: stakingtypes.Description{},
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
MinSelfDelegation: sdk.ZeroInt(),
OperatorAddress: sdk.ValAddress(val.Address).String(),
ConsensusPubkey: pkAny,
Jailed: false,
Status: status,
Tokens: tokens,
DelegatorShares: sumShares,
Description: stakingtypes.Description{},
UnbondingHeight: int64(0),
UnbondingTime: time.Unix(0, 0).UTC(),
Commission: stakingtypes.NewCommission(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
// MinSelfDelegation: sdk.ZeroInt(),
}

stakingValidators = append(stakingValidators, validator)
Expand Down Expand Up @@ -413,7 +413,7 @@ func (b *Builder) addValidatorToStakingModule(privVal mock.PV) {
coin,
stakingtypes.Description{},
stakingtypes.NewCommissionRates(sdk.ZeroDec(), sdk.ZeroDec(), sdk.ZeroDec()),
sdk.ZeroInt())
)
b.suite.Require().NoError(err)
pskServer := stakingkeeper.NewMsgServerImpl(b.providerStakingKeeper())
_, _ = pskServer.CreateValidator(sdk.WrapSDKContext(b.providerCtx()), msg)
Expand Down
72 changes: 70 additions & 2 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,9 @@ func (tr TestRun) submitConsumerRemovalProposal(
`--chain-id`, string(tr.chainConfigs[action.chain].chainId),
`--home`, tr.getValidatorHome(action.chain, action.from),
`--node`, tr.getValidatorNode(action.chain, action.from),
`--keyring-backend`, `test`,
`--gas`, `auto`,
`-b`, `block`,
`--keyring-backend`, `test`,
`-y`,
).CombinedOutput()

Expand Down Expand Up @@ -1417,6 +1418,74 @@ func (tr TestRun) unbondTokens(
tr.waitBlocks(action.chain, 1, 10*time.Second)
}

type cancelUnbondTokensAction struct {
chain chainID
delegator validatorID
validator validatorID
amount uint
}

func (tr TestRun) cancelUnbondTokens(
action cancelUnbondTokensAction,
verbose bool,
) {
validator := tr.validatorConfigs[action.validator].valoperAddress
if tr.validatorConfigs[action.validator].useConsumerKey {
validator = tr.validatorConfigs[action.validator].consumerValoperAddress
}

// get creation-height from state
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName,
"q", "staking", "unbonding-delegation",
tr.validatorConfigs[action.delegator].delAddress,
validator,
`--home`, tr.getValidatorHome(action.chain, action.delegator),
`--node`, tr.getValidatorNode(action.chain, action.delegator),
`-o`, `json`,
)
if verbose {
fmt.Println("get unbonding delegations cmd:", cmd.String())
}

bz, err := cmd.CombinedOutput()
if err != nil {
log.Fatal(err, "\n", string(bz))
}
creationHeight := gjson.Get(string(bz), "entries.0.creation_height").Int()
if creationHeight == 0 {
log.Fatal("invalid creation height")
}

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
cmd = exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[action.chain].binaryName,
"tx", "staking", "cancel-unbond",
validator,
fmt.Sprint(action.amount)+`stake`,
fmt.Sprint(creationHeight),
`--from`, `validator`+fmt.Sprint(action.delegator),
`--chain-id`, string(tr.chainConfigs[action.chain].chainId),
`--home`, tr.getValidatorHome(action.chain, action.delegator),
`--node`, tr.getValidatorNode(action.chain, action.delegator),
`--gas`, "900000",
`--keyring-backend`, `test`,
`-o`, `json`,
`-y`,
)

if verbose {
fmt.Println("unbond cmd:", cmd.String())
}

bz, err = cmd.CombinedOutput()
if err != nil {
log.Fatal(err, "\n", string(bz))
}

// wait for inclusion in a block -> '--broadcast-mode block' is deprecated
tr.waitBlocks(action.chain, 2, 20*time.Second)
}

type redelegateTokensAction struct {
chain chainID
src validatorID
Expand Down Expand Up @@ -1589,7 +1658,6 @@ func (tr TestRun) registerRepresentative(
`--commission-rate`, "0.1",
`--commission-max-rate`, "0.2",
`--commission-max-change-rate`, "0.01",
`--min-self-delegation`, "1",
`--from`, `validator`+fmt.Sprint(val),
`--chain-id`, string(tr.chainConfigs[action.chain].chainId),
`--home`, tr.getValidatorHome(action.chain, val),
Expand Down
2 changes: 2 additions & 0 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ func (tr *TestRun) runStep(step Step, verbose bool) {
tr.delegateTokens(action, verbose)
case unbondTokensAction:
tr.unbondTokens(action, verbose)
case cancelUnbondTokensAction:
tr.cancelUnbondTokens(action, verbose)
case redelegateTokensAction:
tr.redelegateTokens(action, verbose)
case downtimeSlashAction:
Expand Down
91 changes: 91 additions & 0 deletions tests/e2e/step_delegation.go
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,97 @@ func stepsUnbond(consumerName string) []Step {
}
}

// stepsCancelUnbond canceling unbonding operation for delegator and validator combination
// the steps perform a full unbonding where the unbonding delegation is removed from the unbonding queue
func stepsCancelUnbond(consumerName string) []Step {
return []Step{
{
action: unbondTokensAction{
chain: chainID("provi"),
unbondFrom: validatorID("alice"),
sender: validatorID("alice"),
amount: 1000000,
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
chainID("consu"): ChainState{
ValPowers: &map[validatorID]uint{
// Voting power on consumer should not be affected yet
validatorID("alice"): 510,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
{
action: relayPacketsAction{
chainA: chainID("provi"),
chainB: chainID(consumerName),
port: "provider",
channel: 0,
},
state: State{
chainID("consu"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
{
action: cancelUnbondTokensAction{
chain: chainID("provi"),
delegator: validatorID("alice"),
validator: validatorID("alice"),
amount: 1000000, // cancel unbonding the full amount
},
state: State{
chainID("provi"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 510, // power restored
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
chainID("consu"): ChainState{
ValPowers: &map[validatorID]uint{
// Voting power on consumer should not be affected yet
validatorID("alice"): 509,
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
{
action: relayPacketsAction{
chainA: chainID("provi"),
chainB: chainID(consumerName),
port: "provider",
channel: 0,
},
state: State{
chainID("consu"): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 510, // power restored on consumer
validatorID("bob"): 500,
validatorID("carol"): 500,
},
},
},
},
}
}

// stepsRedelegateForOptOut tests redelegation, and sets up voting powers s.t
// alice will have less than 5% of the total voting power. This is needed to
// test opt-out functionality.
Expand Down
1 change: 1 addition & 0 deletions tests/e2e/steps.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ var happyPathSteps = concatSteps(
stepsDelegate("consu"),
stepsAssignConsumerKeyOnStartedChain("consu", "bob"),
stepsUnbond("consu"),
stepsCancelUnbond("consu"),
stepsRedelegateForOptOut("consu"),
stepsDowntimeWithOptOut("consu"),
stepsRedelegate("consu"),
Expand Down
15 changes: 15 additions & 0 deletions testutil/keeper/mocks.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading