From 790feda27368d17b7996370498b3f8c543e8433b Mon Sep 17 00:00:00 2001 From: MSalopek Date: Fri, 7 Jul 2023 11:41:21 +0200 Subject: [PATCH 01/18] tests: check cosmos-sdk-v45-ics-lsm integration --- go.mod | 2 +- go.sum | 4 ++-- legacy_ibc_testing/testing/app.go | 27 ++++++++++++++------------ tests/difference/core/driver/setup.go | 28 +++++++++++++-------------- x/ccv/provider/keeper/hooks.go | 4 ++++ 5 files changed, 36 insertions(+), 29 deletions(-) diff --git a/go.mod b/go.mod index 58b8eaa667..7f847a9734 100644 --- a/go.mod +++ b/go.mod @@ -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/iqlusioninc/cosmos-sdk v0.34.4-0.20230628024121-1b4d7e811a43 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 diff --git a/go.sum b/go.sum index ed38bf1bab..c4b4ec154c 100644 --- a/go.sum +++ b/go.sum @@ -231,8 +231,6 @@ 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/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= @@ -581,6 +579,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= +github.com/iqlusioninc/cosmos-sdk v0.34.4-0.20230628024121-1b4d7e811a43 h1:j299CKODCKQgtjKFtKesA4fQYaHXTXDW7WaanTa6/X4= +github.com/iqlusioninc/cosmos-sdk v0.34.4-0.20230628024121-1b4d7e811a43/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= diff --git a/legacy_ibc_testing/testing/app.go b/legacy_ibc_testing/testing/app.go index 45d5248773..a324c966a2 100644 --- a/legacy_ibc_testing/testing/app.go +++ b/legacy_ibc_testing/testing/app.go @@ -79,21 +79,24 @@ 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(), } validators = append(validators, validator) - delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) + // NOTE: @MSalopek + // 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(), true)) } // set validators and delegations diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index 4798c2e3ca..96e6625798 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -176,25 +176,25 @@ 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) // Store delegation from the model delegator account - delegations = append(delegations, stakingtypes.NewDelegation(accounts[0].GetAddress(), val.Address.Bytes(), delShares)) + delegations = append(delegations, stakingtypes.NewDelegation(accounts[0].GetAddress(), val.Address.Bytes(), delShares, true)) // Remaining delegation is from extra account - delegations = append(delegations, stakingtypes.NewDelegation(accounts[1].GetAddress(), val.Address.Bytes(), sumShares.Sub(delShares))) + delegations = append(delegations, stakingtypes.NewDelegation(accounts[1].GetAddress(), val.Address.Bytes(), sumShares.Sub(delShares), false)) } bondDenom := sdk.DefaultBondDenom @@ -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) diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 3cf1e6cc30..909e1ad408 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -140,3 +140,7 @@ func (h Hooks) AfterValidatorBeginUnbonding(_ sdk.Context, _ sdk.ConsAddress, _ func (h Hooks) BeforeDelegationRemoved(_ sdk.Context, _ sdk.AccAddress, _ sdk.ValAddress) { } + +func (h Hooks) BeforeTokenizeShareRecordRemoved(_ sdk.Context, _ uint64) error { + return nil +} From 6b4d0d98cab608c188a4f969d8bd1acbc1fae866 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Tue, 11 Jul 2023 15:14:31 +0200 Subject: [PATCH 02/18] bump cosmos-sdk to inqlusion latest --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 7f847a9734..d2b187042c 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.34.4-0.20230628024121-1b4d7e811a43 + github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711020134-b8d94b61386b 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 diff --git a/go.sum b/go.sum index c4b4ec154c..7a6b3865b9 100644 --- a/go.sum +++ b/go.sum @@ -579,8 +579,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iqlusioninc/cosmos-sdk v0.34.4-0.20230628024121-1b4d7e811a43 h1:j299CKODCKQgtjKFtKesA4fQYaHXTXDW7WaanTa6/X4= -github.com/iqlusioninc/cosmos-sdk v0.34.4-0.20230628024121-1b4d7e811a43/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711020134-b8d94b61386b h1:snzeOOgIsXgnhGDIhvW3WBqBaBjlIiat5BCrsnAHp60= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711020134-b8d94b61386b/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= From b5f147b8b2f57000d10adfe4c8029996b27f079b Mon Sep 17 00:00:00 2001 From: MSalopek Date: Tue, 11 Jul 2023 15:18:11 +0200 Subject: [PATCH 03/18] support new method signatuers --- legacy_ibc_testing/testing/app.go | 2 +- tests/difference/core/driver/setup.go | 14 +++++++++++--- 2 files changed, 12 insertions(+), 4 deletions(-) diff --git a/legacy_ibc_testing/testing/app.go b/legacy_ibc_testing/testing/app.go index a324c966a2..83c8a01d58 100644 --- a/legacy_ibc_testing/testing/app.go +++ b/legacy_ibc_testing/testing/app.go @@ -96,7 +96,7 @@ func SetupWithGenesisValSet(t *testing.T, appIniter AppIniter, valSet *tmtypes.V // NOTE: @MSalopek // 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(), true)) + delegations = append(delegations, stakingtypes.NewDelegation(genAccs[0].GetAddress(), val.Address.Bytes(), sdk.OneDec())) } // set validators and delegations diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index 96e6625798..a8e41a7a2f 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -4,6 +4,7 @@ import ( "bytes" cryptoEd25519 "crypto/ed25519" "encoding/json" + "fmt" "time" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -383,12 +384,14 @@ func (b *Builder) ensureValidatorLexicographicOrderingMatchesModel() { // delegate is used to delegate tokens to newly created // validators in the setup process. -func (b *Builder) delegate(del int, val sdk.ValAddress, amt int64) { +func (b *Builder) delegate(del int, val sdk.ValAddress, amt int64, validatorBond bool) { d := b.provider().SenderAccounts[del].SenderAccount.GetAddress() coins := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(amt)) msg := stakingtypes.NewMsgDelegate(d, val, coins) pskServer := stakingkeeper.NewMsgServerImpl(b.providerStakingKeeper()) + // if validatorBond { _, err := pskServer.Delegate(sdk.WrapSDKContext(b.providerCtx()), msg) + fmt.Println("## ERRORED ON DELEGATE ##", err) b.suite.Require().NoError(err) } @@ -440,14 +443,19 @@ func (b *Builder) addExtraProviderValidators() { b.ensureValidatorLexicographicOrderingMatchesModel() + fmt.Println("#ADDING EXTRA VALIDATORS") for i := range b.initState.ValStates.Status { if b.initState.ValStates.Status[i] == stakingtypes.Unbonded { del := b.initState.ValStates.Delegation[i] extra := b.initState.ValStates.ValidatorExtraTokens[i] - b.delegate(0, b.validator(int64(i)), int64(del)) - b.delegate(1, b.validator(int64(i)), int64(extra)) + fmt.Println("## ATTEMPT TO DELEGATE #", b.validator(int64(i)), int64(del)) + b.delegate(0, b.validator(int64(i)), int64(del), false) + fmt.Println("## DELEGATED ##", i, del) + b.delegate(1, b.validator(int64(i)), int64(extra), false) + fmt.Println("## DELEGATED EXTRA ##", i, extra) } } + fmt.Println("# DONE ADDING EXTRA VALIDATORS") } func (b *Builder) setProviderParams() { From 21624a6f298a639572445a07f1c29183f24c7f48 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Tue, 11 Jul 2023 22:56:07 +0200 Subject: [PATCH 04/18] fix: bump v0.45.16-ics-lsm to latest [fixes difftests] --- go.mod | 2 +- go.sum | 4 ++-- tests/difference/core/driver/setup.go | 18 +++++------------- 3 files changed, 8 insertions(+), 16 deletions(-) diff --git a/go.mod b/go.mod index d2b187042c..4b58453529 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711020134-b8d94b61386b + github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711153639-a118c0fc9ad3 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 diff --git a/go.sum b/go.sum index 7a6b3865b9..cf9b53a357 100644 --- a/go.sum +++ b/go.sum @@ -579,8 +579,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711020134-b8d94b61386b h1:snzeOOgIsXgnhGDIhvW3WBqBaBjlIiat5BCrsnAHp60= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711020134-b8d94b61386b/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711153639-a118c0fc9ad3 h1:WMKL82CAAOem/956NfUG+5R9Isz/JMmwpHwP8nnkmD0= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711153639-a118c0fc9ad3/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= diff --git a/tests/difference/core/driver/setup.go b/tests/difference/core/driver/setup.go index a8e41a7a2f..196d59e524 100644 --- a/tests/difference/core/driver/setup.go +++ b/tests/difference/core/driver/setup.go @@ -4,7 +4,6 @@ import ( "bytes" cryptoEd25519 "crypto/ed25519" "encoding/json" - "fmt" "time" codectypes "github.com/cosmos/cosmos-sdk/codec/types" @@ -193,9 +192,9 @@ func (b *Builder) getAppBytesAndSenders( stakingValidators = append(stakingValidators, validator) // Store delegation from the model delegator account - delegations = append(delegations, stakingtypes.NewDelegation(accounts[0].GetAddress(), val.Address.Bytes(), delShares, true)) + delegations = append(delegations, stakingtypes.NewDelegation(accounts[0].GetAddress(), val.Address.Bytes(), delShares)) // Remaining delegation is from extra account - delegations = append(delegations, stakingtypes.NewDelegation(accounts[1].GetAddress(), val.Address.Bytes(), sumShares.Sub(delShares), false)) + delegations = append(delegations, stakingtypes.NewDelegation(accounts[1].GetAddress(), val.Address.Bytes(), sumShares.Sub(delShares))) } bondDenom := sdk.DefaultBondDenom @@ -384,14 +383,12 @@ func (b *Builder) ensureValidatorLexicographicOrderingMatchesModel() { // delegate is used to delegate tokens to newly created // validators in the setup process. -func (b *Builder) delegate(del int, val sdk.ValAddress, amt int64, validatorBond bool) { +func (b *Builder) delegate(del int, val sdk.ValAddress, amt int64) { d := b.provider().SenderAccounts[del].SenderAccount.GetAddress() coins := sdk.NewCoin(sdk.DefaultBondDenom, sdk.NewInt(amt)) msg := stakingtypes.NewMsgDelegate(d, val, coins) pskServer := stakingkeeper.NewMsgServerImpl(b.providerStakingKeeper()) - // if validatorBond { _, err := pskServer.Delegate(sdk.WrapSDKContext(b.providerCtx()), msg) - fmt.Println("## ERRORED ON DELEGATE ##", err) b.suite.Require().NoError(err) } @@ -443,19 +440,14 @@ func (b *Builder) addExtraProviderValidators() { b.ensureValidatorLexicographicOrderingMatchesModel() - fmt.Println("#ADDING EXTRA VALIDATORS") for i := range b.initState.ValStates.Status { if b.initState.ValStates.Status[i] == stakingtypes.Unbonded { del := b.initState.ValStates.Delegation[i] extra := b.initState.ValStates.ValidatorExtraTokens[i] - fmt.Println("## ATTEMPT TO DELEGATE #", b.validator(int64(i)), int64(del)) - b.delegate(0, b.validator(int64(i)), int64(del), false) - fmt.Println("## DELEGATED ##", i, del) - b.delegate(1, b.validator(int64(i)), int64(extra), false) - fmt.Println("## DELEGATED EXTRA ##", i, extra) + b.delegate(0, b.validator(int64(i)), int64(del)) + b.delegate(1, b.validator(int64(i)), int64(extra)) } } - fmt.Println("# DONE ADDING EXTRA VALIDATORS") } func (b *Builder) setProviderParams() { From 3a37e8232a5380b48a8d55d6e7bf75de1488a331 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Wed, 12 Jul 2023 19:07:00 +0200 Subject: [PATCH 05/18] fix: update democracy tests representative registration --- tests/e2e/actions.go | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 06bcb7f5f7..715d4f3f75 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1589,7 +1589,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), From 314cd35bbaeae6ce935343f088510558b7104b8a Mon Sep 17 00:00:00 2001 From: MSalopek Date: Tue, 25 Jul 2023 12:13:25 +0200 Subject: [PATCH 06/18] chore: bump iqlusion:cosmos-sdk to latest --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 4b58453529..df5bc24d2b 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711153639-a118c0fc9ad3 + github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230720195127-73e72b9ef30f 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 diff --git a/go.sum b/go.sum index cf9b53a357..447f18091d 100644 --- a/go.sum +++ b/go.sum @@ -579,8 +579,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711153639-a118c0fc9ad3 h1:WMKL82CAAOem/956NfUG+5R9Isz/JMmwpHwP8nnkmD0= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230711153639-a118c0fc9ad3/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230720195127-73e72b9ef30f h1:hPQ61igc7i2RGbuDVhbAFx9p/Dra5pm5JJz4rbL6GNU= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230720195127-73e72b9ef30f/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= From d9b80ff80f5b8e10822a12bc9b6339a37a3bceef Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Aug 2023 12:08:23 +0200 Subject: [PATCH 07/18] chore: bump iqlusion:cosmos-sdk to latest --- go.mod | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/go.mod b/go.mod index df5bc24d2b..600147ba59 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230720195127-73e72b9ef30f + github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk 81ef370eed6a333143e21a038d1174dc754835fc 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 From c26bd7743ca2f8454052e11c0106ec9f82c5f13f Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Aug 2023 12:12:06 +0200 Subject: [PATCH 08/18] chore: bump iqlusion:cosmos-sdk to latest --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 600147ba59..fd5aac3c3e 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk 81ef370eed6a333143e21a038d1174dc754835fc + github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230801193606-81ef370eed6a 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 diff --git a/go.sum b/go.sum index 447f18091d..1de7283f96 100644 --- a/go.sum +++ b/go.sum @@ -579,8 +579,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230720195127-73e72b9ef30f h1:hPQ61igc7i2RGbuDVhbAFx9p/Dra5pm5JJz4rbL6GNU= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230720195127-73e72b9ef30f/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230801193606-81ef370eed6a h1:RIrc+AHmT6/gBWMuplqUwzGnvLk25bOugciwU06ksxw= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230801193606-81ef370eed6a/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= From 3336e5cef275cf3d830c7d4b4523fa5862fa6c54 Mon Sep 17 00:00:00 2001 From: Marius Poke Date: Mon, 12 Jun 2023 16:12:32 +0200 Subject: [PATCH 09/18] fix!: avoid panicking on CancelUnbondingDelegation (#977) * handle CancelUnbondingDelegation message * tests: add cancel-unbond e2e test * fix: appease linter * chore: Hardcode golangci-lint version (#990) * Hardcode golangci-lint version * Hardcode version in CI config --------- Co-authored-by: MSalopek Co-authored-by: Philip Offtermatt <57488781+p-offtermatt@users.noreply.github.com> --- tests/e2e/actions.go | 68 +++++++++++++++++++++++++ tests/e2e/main.go | 2 + tests/e2e/step_delegation.go | 89 +++++++++++++++++++++++++++++++++ tests/e2e/steps.go | 1 + testutil/keeper/mocks.go | 8 +++ x/ccv/provider/keeper/relay.go | 14 +++++- x/ccv/types/expected_keepers.go | 1 + 7 files changed, 181 insertions(+), 2 deletions(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 715d4f3f75..24a1aa7c91 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -1417,6 +1417,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 diff --git a/tests/e2e/main.go b/tests/e2e/main.go index 737a318de2..bf89f73853 100644 --- a/tests/e2e/main.go +++ b/tests/e2e/main.go @@ -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: diff --git a/tests/e2e/step_delegation.go b/tests/e2e/step_delegation.go index f33fc136d4..2a27aa85fc 100644 --- a/tests/e2e/step_delegation.go +++ b/tests/e2e/step_delegation.go @@ -129,6 +129,95 @@ 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{ + chain: chainID("provi"), + 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{ + chain: chainID("provi"), + 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. diff --git a/tests/e2e/steps.go b/tests/e2e/steps.go index 7613b05558..c9830c2aa2 100644 --- a/tests/e2e/steps.go +++ b/tests/e2e/steps.go @@ -18,6 +18,7 @@ var happyPathSteps = concatSteps( stepsDelegate("consu"), stepsAssignConsumerKeyOnStartedChain("consu", "bob"), stepsUnbond("consu"), + stepsCancelUnbond("consu"), stepsRedelegateForOptOut("consu"), stepsDowntimeWithOptOut("consu"), stepsRedelegate("consu"), diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index 4f931d8152..c77f6e0368 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -110,6 +110,14 @@ func (m *MockStakingKeeper) GetLastValidators(ctx types.Context) []types4.Valida return ret0 } +func (m *MockStakingKeeper) GetUnbondingType(ctx types0.Context, id uint64) (types5.UnbondingType, bool) { + m.ctrl.T.Helper() + ret := m.ctrl.Call(m, "GetUnbondingType", ctx, id) + ret0, _ := ret[0].(types5.UnbondingType) + ret1, _ := ret[1].(bool) + return ret0, ret1 +} + // GetLastValidators indicates an expected call of GetLastValidators. func (mr *MockStakingKeeperMockRecorder) GetLastValidators(ctx interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() diff --git a/x/ccv/provider/keeper/relay.go b/x/ccv/provider/keeper/relay.go index 65edeac170..637036fe41 100644 --- a/x/ccv/provider/keeper/relay.go +++ b/x/ccv/provider/keeper/relay.go @@ -114,8 +114,18 @@ func (k Keeper) completeMaturedUnbondingOps(ctx sdk.Context) { // Attempt to complete unbonding in staking module err := k.stakingKeeper.UnbondingCanComplete(ctx, id) if err != nil { - // UnbondingCanComplete fails if the unbonding operation was not found, - // which means that the state of the x/staking module of cosmos-sdk is invalid. + if stakingtypes.ErrUnbondingNotFound.Is(err) { + // The unbonding was not found. + unbondingType, found := k.stakingKeeper.GetUnbondingType(ctx, id) + if found && unbondingType == stakingtypes.UnbondingType_UnbondingDelegation { + // If this is an unbonding delegation, it may have been removed + // after through a CancelUnbondingDelegation message + k.Logger(ctx).Debug("unbonding delegation was already removed:", "unbondingID", id) + continue + } + } + // UnbondingCanComplete failing means that the state of the x/staking module + // of cosmos-sdk is invalid. An exception is the case handled above panic(fmt.Sprintf("could not complete unbonding op: %s", err.Error())) } k.Logger(ctx).Debug("unbonding operation matured on all consumers", "opID", id) diff --git a/x/ccv/types/expected_keepers.go b/x/ccv/types/expected_keepers.go index 7f18324c8d..dd81c5e801 100644 --- a/x/ccv/types/expected_keepers.go +++ b/x/ccv/types/expected_keepers.go @@ -44,6 +44,7 @@ type StakingKeeper interface { GetLastTotalPower(ctx sdk.Context) sdk.Int GetLastValidators(ctx sdk.Context) (validators []stakingtypes.Validator) BondDenom(ctx sdk.Context) (res string) + GetUnbondingType(ctx sdk.Context, id uint64) (unbondingType stakingtypes.UnbondingType, found bool) } type EvidenceKeeper interface { From 15cc76e1f50512bfa44f125400baca11f664525b Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Aug 2023 12:48:54 +0200 Subject: [PATCH 10/18] tests: fix broken cancelUnbond e2e after cherry pick --- tests/e2e/step_delegation.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/e2e/step_delegation.go b/tests/e2e/step_delegation.go index 2a27aa85fc..b6e7c8ad76 100644 --- a/tests/e2e/step_delegation.go +++ b/tests/e2e/step_delegation.go @@ -160,7 +160,8 @@ func stepsCancelUnbond(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, @@ -201,7 +202,8 @@ func stepsCancelUnbond(consumerName string) []Step { }, { action: relayPacketsAction{ - chain: chainID("provi"), + chainA: chainID("provi"), + chainB: chainID(consumerName), port: "provider", channel: 0, }, From aa25ce9298f0026df85b5a416bca186ede1b99b6 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Aug 2023 13:11:19 +0200 Subject: [PATCH 11/18] chore: regenerate mocks --- go.sum | 2 ++ testutil/keeper/mocks.go | 17 ++++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/go.sum b/go.sum index 1de7283f96..050c1fc648 100644 --- a/go.sum +++ b/go.sum @@ -1128,6 +1128,7 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= +golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1380,6 +1381,7 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4= +golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= diff --git a/testutil/keeper/mocks.go b/testutil/keeper/mocks.go index c77f6e0368..9976a03b15 100644 --- a/testutil/keeper/mocks.go +++ b/testutil/keeper/mocks.go @@ -110,18 +110,25 @@ func (m *MockStakingKeeper) GetLastValidators(ctx types.Context) []types4.Valida return ret0 } -func (m *MockStakingKeeper) GetUnbondingType(ctx types0.Context, id uint64) (types5.UnbondingType, bool) { +// GetLastValidators indicates an expected call of GetLastValidators. +func (mr *MockStakingKeeperMockRecorder) GetLastValidators(ctx interface{}) *gomock.Call { + mr.mock.ctrl.T.Helper() + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastValidators", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastValidators), ctx) +} + +// GetUnbondingType mocks base method. +func (m *MockStakingKeeper) GetUnbondingType(ctx types.Context, id uint64) (types4.UnbondingType, bool) { m.ctrl.T.Helper() ret := m.ctrl.Call(m, "GetUnbondingType", ctx, id) - ret0, _ := ret[0].(types5.UnbondingType) + ret0, _ := ret[0].(types4.UnbondingType) ret1, _ := ret[1].(bool) return ret0, ret1 } -// GetLastValidators indicates an expected call of GetLastValidators. -func (mr *MockStakingKeeperMockRecorder) GetLastValidators(ctx interface{}) *gomock.Call { +// GetUnbondingType indicates an expected call of GetUnbondingType. +func (mr *MockStakingKeeperMockRecorder) GetUnbondingType(ctx, id interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetLastValidators", reflect.TypeOf((*MockStakingKeeper)(nil).GetLastValidators), ctx) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetUnbondingType", reflect.TypeOf((*MockStakingKeeper)(nil).GetUnbondingType), ctx, id) } // GetValidator mocks base method. From c295e2775a8a19b5a087e4729a69c7471af13d97 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Aug 2023 13:17:48 +0200 Subject: [PATCH 12/18] chore: run make proto-gen --- go.sum | 2 -- 1 file changed, 2 deletions(-) diff --git a/go.sum b/go.sum index 050c1fc648..1de7283f96 100644 --- a/go.sum +++ b/go.sum @@ -1128,7 +1128,6 @@ golang.org/x/mod v0.4.0/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.1/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.4.2/go.mod h1:s0Qsj1ACt9ePp/hMypM3fl4fZqREWJwdYDEqhRiZZUA= golang.org/x/mod v0.7.0 h1:LapD9S96VoQRhi/GrNTqeBJFrUjs5UHCAtTlgwA5oZA= -golang.org/x/mod v0.7.0/go.mod h1:iBbtSCu2XBx23ZKBPSOrRkjjQPZFPuis4dIYUhu/chs= golang.org/x/net v0.0.0-20180719180050-a680a1efc54d/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180724234803-3673e40ba225/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= golang.org/x/net v0.0.0-20180906233101-161cd47e91fd/go.mod h1:mL1N/T3taQHkDXs73rZJwtUhF3w3ftmwwsq0BUmARs4= @@ -1381,7 +1380,6 @@ golang.org/x/tools v0.1.1/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.3/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.1.5/go.mod h1:o0xws9oXOQQZyjljx8fwUC0k7L1pTE6eaCbjGeHmOkk= golang.org/x/tools v0.4.0 h1:7mTAgkunk3fr4GAloyyCasadO6h9zSsQZbwvcaIciV4= -golang.org/x/tools v0.4.0/go.mod h1:UE5sM2OK9E/d67R0ANs2xJizIymRP5gJU295PvKXxjQ= golang.org/x/xerrors v0.0.0-20190717185122-a985d3407aa7/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191011141410-1b5146add898/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= golang.org/x/xerrors v0.0.0-20191204190536-9bdfabe68543/go.mod h1:I/5z698sn9Ka8TeJc9MKroUUfqBBauWjQqLJ2OPfmY0= From c18e89119425be420d64fe073148d54439004605 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Thu, 3 Aug 2023 13:29:00 +0200 Subject: [PATCH 13/18] fix: complete concel-unbond handling in hooks --- x/ccv/provider/keeper/hooks.go | 41 +++++++++++++++++++++++----------- 1 file changed, 28 insertions(+), 13 deletions(-) diff --git a/x/ccv/provider/keeper/hooks.go b/x/ccv/provider/keeper/hooks.go index 909e1ad408..537153757b 100644 --- a/x/ccv/provider/keeper/hooks.go +++ b/x/ccv/provider/keeper/hooks.go @@ -1,8 +1,6 @@ package keeper import ( - "fmt" - stakingtypes "github.com/cosmos/cosmos-sdk/x/staking/types" sdk "github.com/cosmos/cosmos-sdk/types" @@ -34,6 +32,19 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { // Do not put the unbonding op on hold if there are no consumer chains return nil } + // Call back into staking to tell it to stop this op from unbonding when the unbonding period is complete + if err := h.k.stakingKeeper.PutUnbondingOnHold(ctx, id); err != nil { + // Note: that in the case of a validator unbonding, AfterUnbondingInitiated is called + // from staking.EndBlock. + + // In this case PutUnbondingOnHold fails if either the unbonding operation was + // not found or the UnbondingOnHoldRefCount is negative. + + // This change should be updated for SDK v0.48 because it will include changes in handling + // check: https://github.com/cosmos/cosmos-sdk/pull/16043 + ctx.Logger().Error("unbonding could not be put on hold: %w", err) + return nil + } valsetUpdateID := h.k.GetValidatorSetUpdateId(ctx) unbondingOp := providertypes.UnbondingOp{ Id: id, @@ -49,18 +60,22 @@ func (h Hooks) AfterUnbondingInitiated(ctx sdk.Context, id uint64) error { h.k.SetUnbondingOp(ctx, unbondingOp) + // NOTE: This is a temporary fix backported from ICSv3 (cosmos-sdk v0.47) -> we should not panic in this edge case + // since the AfterUnbondInitiatedHook can be called with a non-existing UnbondingEntry.id + // check: https://github.com/cosmos/cosmos-sdk/pull/16043 + // // Call back into staking to tell it to stop this op from unbonding when the unbonding period is complete - if err := h.k.stakingKeeper.PutUnbondingOnHold(ctx, id); err != nil { - // If there was an error putting the unbonding on hold, panic to end execution for - // the current tx and prevent committal of this invalid state. - // - // Note: that in the case of a validator unbonding, AfterUnbondingInitiated is called - // form staking.EndBlock, thus the following panic would halt the chain. - // In this case PutUnbondingOnHold fails if either the unbonding operation was - // not found or the UnbondingOnHoldRefCount is negative. In either cases, - // the state of the x/staking module of cosmos-sdk is invalid. - panic(fmt.Errorf("unbonding could not be put on hold: %w", err)) - } + // if err := h.k.stakingKeeper.PutUnbondingOnHold(ctx, id); err != nil { + // // If there was an error putting the unbonding on hold, panic to end execution for + // // the current tx and prevent committal of this invalid state. + // // + // // Note: that in the case of a validator unbonding, AfterUnbondingInitiated is called + // // from staking.EndBlock, thus the following panic would halt the chain. + // // In this case PutUnbondingOnHold fails if either the unbonding operation was + // // not found or the UnbondingOnHoldRefCount is negative. In either cases, + // // the state of the x/staking module of cosmos-sdk is invalid. + // panic(fmt.Errorf("unbonding could not be put on hold: %w", err)) + // } return nil } From 18fa79462a6eb4238efe3ffe1e276609588e0b4a Mon Sep 17 00:00:00 2001 From: MSalopek Date: Mon, 7 Aug 2023 14:30:05 +0200 Subject: [PATCH 14/18] chore: bump iqlusion:cosmos-sdk to latest --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index fd5aac3c3e..889d0b903b 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230801193606-81ef370eed6a + github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230803192832-aab739edf2ca 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 diff --git a/go.sum b/go.sum index 1de7283f96..086a587134 100644 --- a/go.sum +++ b/go.sum @@ -579,8 +579,8 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230801193606-81ef370eed6a h1:RIrc+AHmT6/gBWMuplqUwzGnvLk25bOugciwU06ksxw= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230801193606-81ef370eed6a/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230803192832-aab739edf2ca h1:ddvixv/W+SIWAy0rCKiVmzq0aAzAowxj61rYJr06MH4= +github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230803192832-aab739edf2ca/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= From b31026b234346899e34257d6a181a542dfa66786 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Mon, 7 Aug 2023 15:47:41 +0200 Subject: [PATCH 15/18] chore: fix brokene gov prop submit --- tests/e2e/actions.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 24a1aa7c91..127a10c8f2 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -331,8 +331,8 @@ 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), + `--gas`, `auto`, `--keyring-backend`, `test`, - `-b`, `block`, `-y`, ).CombinedOutput() From 863915e43e6a06a1e707487bc241bb4f24d9e2a2 Mon Sep 17 00:00:00 2001 From: MSalopek Date: Mon, 7 Aug 2023 16:21:51 +0200 Subject: [PATCH 16/18] chore: fix brokene gov prop submit --- tests/e2e/actions.go | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/e2e/actions.go b/tests/e2e/actions.go index 127a10c8f2..702a82d5cd 100644 --- a/tests/e2e/actions.go +++ b/tests/e2e/actions.go @@ -332,6 +332,7 @@ func (tr TestRun) submitConsumerRemovalProposal( `--home`, tr.getValidatorHome(action.chain, action.from), `--node`, tr.getValidatorNode(action.chain, action.from), `--gas`, `auto`, + `-b`, `block`, `--keyring-backend`, `test`, `-y`, ).CombinedOutput() From 49797ece5c4c185a62552f54197385dd485bd973 Mon Sep 17 00:00:00 2001 From: mpoke Date: Wed, 16 Aug 2023 12:17:56 +0200 Subject: [PATCH 17/18] use SDK 0.45.16-ics-lsm-rc0 --- go.mod | 2 +- go.sum | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/go.mod b/go.mod index 889d0b903b..a3423e16e5 100644 --- a/go.mod +++ b/go.mod @@ -153,7 +153,7 @@ require ( ) replace ( - github.com/cosmos/cosmos-sdk => github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230803192832-aab739edf2ca + 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 diff --git a/go.sum b/go.sum index 086a587134..19a06e3c81 100644 --- a/go.sum +++ b/go.sum @@ -231,6 +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.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= @@ -579,8 +581,6 @@ github.com/influxdata/promql/v2 v2.12.0/go.mod h1:fxOPu+DY0bqCTCECchSRtWfc+0X19y github.com/influxdata/roaring v0.4.13-0.20180809181101-fc520f41fab6/go.mod h1:bSgUQ7q5ZLSO+bKBGqJiCBGAl+9DxyW63zLTujjUlOE= github.com/influxdata/tdigest v0.0.0-20181121200506-bf2b5ad3c0a9/go.mod h1:Js0mqiSBE6Ffsg94weZZ2c+v/ciT8QRHFOap7EKDrR0= github.com/influxdata/usage-client v0.0.0-20160829180054-6d3895376368/go.mod h1:Wbbw6tYNvwa5dlB6304Sd+82Z3f7PmVZHVKU637d4po= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230803192832-aab739edf2ca h1:ddvixv/W+SIWAy0rCKiVmzq0aAzAowxj61rYJr06MH4= -github.com/iqlusioninc/cosmos-sdk v0.45.17-0.20230803192832-aab739edf2ca/go.mod h1:bScuNwWAP0TZJpUf+SHXRU3xGoUPp+X9nAzfeIXts40= github.com/iris-contrib/blackfriday v2.0.0+incompatible/go.mod h1:UzZ2bDEoaSGPbkg6SAB4att1aAwTmVIx/5gCVqeyUdI= github.com/iris-contrib/go.uuid v2.0.0+incompatible/go.mod h1:iz2lgM/1UnEf1kP0L/+fafWORmlnuysV2EMP8MW+qe0= github.com/iris-contrib/i18n v0.0.0-20171121225848-987a633949d0/go.mod h1:pMCz62A0xJL6I+umB2YTlFRwWXaDFA0jy+5HzGiJjqI= From fbe682196d5b30a51cce09dab236773d967e9c72 Mon Sep 17 00:00:00 2001 From: mpoke Date: Wed, 16 Aug 2023 13:21:00 +0200 Subject: [PATCH 18/18] add changelog entry --- CHANGELOG.md | 1 + 1 file changed, 1 insertion(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 11fc543bc9..5a5011e0c6 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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