Skip to content

Commit

Permalink
Merge branch 'main' into ph/inactive-vals-v50-2
Browse files Browse the repository at this point in the history
  • Loading branch information
p-offtermatt committed Jul 26, 2024
2 parents 42c05b2 + aedc0c8 commit ff2f074
Show file tree
Hide file tree
Showing 29 changed files with 291 additions and 145 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix incorrect message defitions in the proto files of the provider module
([\#2095](https://github.com/cosmos/interchain-security/pull/2095))
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Fix incorrect message defitions in the proto files of the provider module
([\#2095](https://github.com/cosmos/interchain-security/pull/2095))
2 changes: 2 additions & 0 deletions .changelog/v5.1.0/api-breaking/1995-deprecate-soft-opt-out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove soft opt-out feature. ([\#1995](https://github.com/cosmos/interchain-security/pull/1995))
Backporting of ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)).
2 changes: 2 additions & 0 deletions .changelog/v5.1.0/features/1995-deprecate-soft-opt-out.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove soft opt-out feature. ([\#1995](https://github.com/cosmos/interchain-security/pull/1995))
Backporting of ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)).
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
- Remove soft opt-out feature. ([\#1995](https://github.com/cosmos/interchain-security/pull/1995))
Backporting of ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)).
1 change: 1 addition & 0 deletions .changelog/v5.1.0/summary.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
*July 19, 2024*
2 changes: 1 addition & 1 deletion .github/workflows/gosec.yml
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,4 @@ jobs:
- name: Run Gosec Security Scanner
uses: securego/gosec@master
with:
args: -exclude-dir=tests ./... -exclude-generated ./...
args: -exclude-dir=tests -exclude-dir=app -exclude-generated ./...
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ vendor/
build/
.vscode
.idea
__debug_*

# docusaurus versioned docs created during build
docs/versions.json
Expand Down
50 changes: 50 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,55 @@
# CHANGELOG

## v5.1.0

*July 19, 2024*

### API BREAKING

- General
- Remove soft opt-out feature. ([\#1995](https://github.com/cosmos/interchain-security/pull/1995))
Backporting of ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)).
- [Provider](x/ccv/provider)
- Change the UX in key assignment by returning an error if a validator tries to
reuse the same consumer key.
([\#1998](https://github.com/cosmos/interchain-security/pull/1998))

### DEPENDENCIES

- Bump [CometBFT](https://github.com/cometbft/cometbft) to
[v0.38.9](https://github.com/cometbft/cometbft/releases/tag/v0.38.9).
([\#2013](https://github.com/cosmos/interchain-security/pull/2013))
- Bump [ibc-go](https://github.com/cosmos/ibc-go) to
[v8.3.2](https://github.com/cosmos/ibc-go/releases/tag/v8.3.2).
([\#2053](https://github.com/cosmos/interchain-security/pull/2053))
- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to
[v0.50.8](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.8)
([\#2053](https://github.com/cosmos/interchain-security/pull/2053))

### FEATURES

- Remove soft opt-out feature. ([\#1995](https://github.com/cosmos/interchain-security/pull/1995))
Backporting of ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)).

### STATE BREAKING

- General
- Remove soft opt-out feature. ([\#1995](https://github.com/cosmos/interchain-security/pull/1995))
Backporting of ([\#1964](https://github.com/cosmos/interchain-security/pull/1964)).
- Bump [CometBFT](https://github.com/cometbft/cometbft) to
[v0.38.9](https://github.com/cometbft/cometbft/releases/tag/v0.38.9).
([\#2013](https://github.com/cosmos/interchain-security/pull/2013))
- Bump [ibc-go](https://github.com/cosmos/ibc-go) to
[v8.3.2](https://github.com/cosmos/ibc-go/releases/tag/v8.3.2).
([\#2053](https://github.com/cosmos/interchain-security/pull/2053))
- Bump [cosmos-sdk](https://github.com/cosmos/cosmos-sdk) to
[v0.50.8](https://github.com/cosmos/cosmos-sdk/releases/tag/v0.50.8)
([\#2053](https://github.com/cosmos/interchain-security/pull/2053))
- [Provider](x/ccv/provider)
- Change the UX in key assignment by returning an error if a validator tries to
reuse the same consumer key.
([\#1998](https://github.com/cosmos/interchain-security/pull/1998))

## v5.0.0

*May 9, 2024*
Expand Down
2 changes: 1 addition & 1 deletion docs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -94,4 +94,4 @@ The `./docs/legacy` directory gets included into the rest of the documentation u

Building on remote host is handled by [deploy-docs.yml workflow](.github/workflows/deploy-docs.yml).

It executes `./sync_versions.sh` and `./build_deploy.sh` scripts and allows the output of the build proces to be served by github pages.
It executes `./sync_versions.sh` and `./build_deploy.sh` scripts and allows the output of the build process to be served by github pages.
6 changes: 6 additions & 0 deletions proto/interchain_security/ccv/provider/v1/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -274,6 +274,8 @@ message MsgOptOutResponse {}
message MsgSetConsumerCommissionRate {
option (gogoproto.equal) = false;
option (gogoproto.goproto_getters) = false;
option (cosmos.msg.v1.signer) = "signer";

// The validator address on the provider
string provider_addr = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
// The chain id of the consumer chain to set a commission rate
Expand All @@ -285,6 +287,8 @@ message MsgSetConsumerCommissionRate {
(gogoproto.customtype) = "cosmossdk.io/math.LegacyDec",
(gogoproto.nullable) = false
];
// signer address
string signer = 4 [(cosmos_proto.scalar) = "cosmos.AddressString"];
}


Expand All @@ -296,6 +300,8 @@ message MsgSetConsumerCommissionRateResponse {}
//
// Note: this replaces ConsumerModificationProposal which is deprecated and will be removed soon
message MsgConsumerModification {
option (cosmos.msg.v1.signer) = "authority";

// the title of the proposal
string title = 1;
// the description of the proposal
Expand Down
24 changes: 12 additions & 12 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1003,10 +1003,10 @@ func (tr Chain) addChainToGorelayer(
}

addChainCommand := tr.target.ExecCommand("rly", "chains", "add", "--file", chainConfigFileName, string(ChainId))
e2e.ExecuteCommand(addChainCommand, "add chain")
e2e.ExecuteCommand(addChainCommand, "add chain", verbose)

keyRestoreCommand := tr.target.ExecCommand("rly", "keys", "restore", string(ChainId), "default", tr.testConfig.validatorConfigs[action.Validator].Mnemonic)
e2e.ExecuteCommand(keyRestoreCommand, "restore keys")
e2e.ExecuteCommand(keyRestoreCommand, "restore keys", verbose)
}

func (tr Chain) addChainToHermes(
Expand Down Expand Up @@ -1111,7 +1111,7 @@ func (tr Chain) addIbcConnectionGorelayer(

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
pathConfigCommand := tr.target.ExecCommand("bash", "-c", bashCommand)
e2e.ExecuteCommand(pathConfigCommand, "add path config")
e2e.ExecuteCommand(pathConfigCommand, "add path config", verbose)

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
newPathCommand := tr.target.ExecCommand("rly",
Expand All @@ -1122,20 +1122,20 @@ func (tr Chain) addIbcConnectionGorelayer(
"--file", pathConfigFileName,
)

e2e.ExecuteCommand(newPathCommand, "new path")
e2e.ExecuteCommand(newPathCommand, "new path", verbose)

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
newClientsCommand := tr.target.ExecCommand("rly", "transact", "clients", pathName)

e2e.ExecuteCommand(newClientsCommand, "new clients")
e2e.ExecuteCommand(newClientsCommand, "new clients", verbose)

tr.waitBlocks(action.ChainA, 1, 10*time.Second)
tr.waitBlocks(action.ChainB, 1, 10*time.Second)

//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
newConnectionCommand := tr.target.ExecCommand("rly", "transact", "connection", pathName)

e2e.ExecuteCommand(newConnectionCommand, "new connection")
e2e.ExecuteCommand(newConnectionCommand, "new connection", verbose)

tr.waitBlocks(action.ChainA, 1, 10*time.Second)
tr.waitBlocks(action.ChainB, 1, 10*time.Second)
Expand Down Expand Up @@ -1302,7 +1302,7 @@ func (tr Chain) addIbcChannelGorelayer(
"--order", action.Order,
"--debug",
)
e2e.ExecuteCommand(cmd, "addChannel")
e2e.ExecuteCommand(cmd, "addChannel", verbose)
}

func (tr Chain) addIbcChannelHermes(
Expand Down Expand Up @@ -1375,16 +1375,16 @@ func (tr Chain) transferChannelComplete(
log.Fatal("transferChannelComplete is not implemented for rly")
}

chanOpenTryCmd := tr.target.ExecCommand("hermes",
"tx", "chan-open-try",
chanOpenTryCmd := tr.target.ExecCommand("hermes", "tx", "chan-open-try",
"--dst-chain", string(tr.testConfig.chainConfigs[action.ChainB].ChainId),
"--src-chain", string(tr.testConfig.chainConfigs[action.ChainA].ChainId),
"--dst-connection", "connection-"+fmt.Sprint(action.ConnectionA),
"--dst-port", action.PortB,
"--src-port", action.PortA,
"--src-channel", "channel-"+fmt.Sprint(action.ChannelA),
)
e2e.ExecuteCommand(chanOpenTryCmd, "transferChanOpenTry")

e2e.ExecuteCommand(chanOpenTryCmd, "transferChanOpenTry", verbose)

chanOpenAckCmd := tr.target.ExecCommand("hermes",
"tx", "chan-open-ack",
Expand All @@ -1397,7 +1397,7 @@ func (tr Chain) transferChannelComplete(
"--src-channel", "channel-"+fmt.Sprint(action.ChannelB),
)

e2e.ExecuteCommand(chanOpenAckCmd, "transferChanOpenAck")
e2e.ExecuteCommand(chanOpenAckCmd, "transferChanOpenAck", verbose)

chanOpenConfirmCmd := tr.target.ExecCommand("hermes",
"tx", "chan-open-confirm",
Expand All @@ -1409,7 +1409,7 @@ func (tr Chain) transferChannelComplete(
"--dst-channel", "channel-"+fmt.Sprint(action.ChannelB),
"--src-channel", "channel-"+fmt.Sprint(action.ChannelA),
)
e2e.ExecuteCommand(chanOpenConfirmCmd, "transferChanOpenConfirm")
e2e.ExecuteCommand(chanOpenConfirmCmd, "transferChanOpenConfirm", verbose)
}

type RelayPacketsAction struct {
Expand Down
13 changes: 11 additions & 2 deletions tests/e2e/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,15 +133,24 @@ func (tr *TestConfig) Initialize() {
// Note: if no matching version is found an empty string is returned
func getIcsVersion(reference string) string {
icsVersion := ""
if reference == "" {

if reference == "" || reference == VLatest {
return icsVersion
}

if semver.IsValid(reference) {
// remove build suffix
return semver.Canonical(reference)
}

for _, tag := range []string{"v2.0.0", "v2.4.0", "v2.4.0-lsm", "v3.1.0", "v3.2.0", "v3.3.0", "v4.0.0", "v4.1.1", "v4.1.1-lsm"} {
// List of all tags matching vX.Y.Z or vX.Y.Z-lsm in ascending order
cmd := exec.Command("git", "tag", "-l", "--sort", "v:refname", "v*.?", "v*.?-lsm", "v*.??", "v*.??-lsm")
out, err := cmd.CombinedOutput()
if err != nil {
panic(fmt.Sprintf("Error getting sorted tag list from git: %s", err.Error()))
}
icsVersions := strings.Split(string(out), "\n")
for _, tag := range icsVersions {
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments
cmd := exec.Command("git", "merge-base", "--is-ancestor", reference, tag)
out, err := cmd.CombinedOutput()
Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -318,7 +318,7 @@ func (tr Chain) curlJsonRPCRequest(method, params, address string) {
cmd := tr.target.ExecCommand("bash", "-c", fmt.Sprintf(cmd_template, method, params, address))

verbosity := false
e2e.ExecuteCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity)
e2e.ExecuteCommand(cmd, "curlJsonRPCRequest", verbosity)
}

func uintPtr(i uint) *uint {
Expand Down Expand Up @@ -398,6 +398,7 @@ func (tr Commands) GetReward(chain ChainID, validator ValidatorID, blockHeight u

bz, err := cmd.CombinedOutput()
if err != nil {
log.Println("running cmd: ", cmd)
log.Fatal("failed getting rewards: ", err, "\n", string(bz))
}

Expand Down
3 changes: 2 additions & 1 deletion tests/e2e/steps_compatibility.go
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ import (

gov "github.com/cosmos/cosmos-sdk/x/gov/types/v1"
clienttypes "github.com/cosmos/ibc-go/v8/modules/core/02-client/types"
providertypes "github.com/cosmos/interchain-security/v5/x/ccv/provider/types"
)

func compstepStartProviderChain() []Step {
Expand Down Expand Up @@ -98,7 +99,7 @@ func compstepsStartConsumerChain(consumerName string, proposalIndex, chainIndex
ConsumerPubkey: getDefaultValidators()[ValidatorID("carol")].ConsumerValPubKey,
ReconfigureNode: false,
ExpectError: true,
ExpectedError: "a validator has assigned the consumer key already: consumer key is already in use by a validator",
ExpectedError: providertypes.ErrConsumerKeyInUse.Error(),
},
State: State{
ChainID(consumerName): ChainState{
Expand Down
9 changes: 1 addition & 8 deletions tests/e2e/testlib/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,7 @@ import (
"os/exec"
)

var verbose *bool //TODO: remove hack

func ExecuteCommandWithVerbosity(cmd *exec.Cmd, cmdName string, verbose bool) {
func ExecuteCommand(cmd *exec.Cmd, cmdName string, verbose bool) {
if verbose {
fmt.Println(cmdName+" cmd:", cmd.String())
}
Expand All @@ -36,8 +34,3 @@ func ExecuteCommandWithVerbosity(cmd *exec.Cmd, cmdName string, verbose bool) {
log.Fatal(err)
}
}

// Executes a command with verbosity specified by CLI flag
func ExecuteCommand(cmd *exec.Cmd, cmdName string) {
ExecuteCommandWithVerbosity(cmd, cmdName, *verbose)
}
2 changes: 1 addition & 1 deletion tests/e2e/v4/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -539,7 +539,7 @@ func (tr Commands) curlJsonRPCRequest(method, params, address string) {
cmd := tr.Target.ExecCommand("bash", "-c", fmt.Sprintf(cmd_template, method, params, address))

verbosity := false
e2e.ExecuteCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity)
e2e.ExecuteCommand(cmd, "curlJsonRPCRequest", verbosity)
}

// GetClientFrozenHeight returns the frozen height for a client with the given client ID
Expand Down
5 changes: 4 additions & 1 deletion x/ccv/consumer/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,10 @@ func (am AppModule) BeginBlock(goCtx context.Context) error {
am.keeper.SetHeightValsetUpdateID(ctx, blockHeight+1, vID)
am.keeper.Logger(ctx).Debug("block height was mapped to vscID", "height", blockHeight+1, "vscID", vID)

am.keeper.TrackHistoricalInfo(ctx)
err := am.keeper.TrackHistoricalInfo(ctx)
if err != nil {
am.keeper.Logger(ctx).Warn("failed to track historical info", "error", err)
}
return nil
}

Expand Down
4 changes: 2 additions & 2 deletions x/ccv/democracy/distribution/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -127,12 +127,12 @@ func (am AppModule) AllocateTokens(
representativesFraction := math.LegacyOneDec().Sub(communityTax)

// allocate tokens proportionally to representatives voting power
vs.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool {
_ = vs.IterateBondedValidatorsByPower(ctx, func(_ int64, validator stakingtypes.ValidatorI) bool {
// we get this validator's percentage of the total power by dividing their tokens by the total bonded tokens
powerFraction := math.LegacyNewDecFromInt(validator.GetTokens()).QuoTruncate(math.LegacyNewDecFromInt(totalBondedTokens))
// we truncate here again, which means that the reward will be slightly lower than it should be
reward := feesCollected.MulDecTruncate(representativesFraction).MulDecTruncate(powerFraction)
am.keeper.AllocateTokensToValidator(ctx, validator, reward)
_ = am.keeper.AllocateTokensToValidator(ctx, validator, reward)
remaining = remaining.Sub(reward)

return false
Expand Down
36 changes: 31 additions & 5 deletions x/ccv/democracy/governance/module.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,14 +112,41 @@ func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal govv1.Propo
return
}

logger := am.keeper.Logger(ctx)

// delete the votes related to the proposal calling Tally
// Tally's return result won't be used in decision if the tokens will be burned or refunded (they are always refunded), but
// this function needs to be called to delete the votes related to the given proposal, since the deleteVote function is
// private and cannot be called directly from the overridden app module
am.keeper.Tally(ctx, proposal)
_, _, _, err := am.keeper.Tally(ctx, proposal)
if err != nil {
logger.Warn(
"failed to tally disallowed proposal",
"proposal", proposal.Id,
"title", proposal.GetTitle(),
"total_deposit", proposal.TotalDeposit)
return
}

am.keeper.DeleteProposal(ctx, proposal.Id)
am.keeper.RefundAndDeleteDeposits(ctx, proposal.Id)
err = am.keeper.DeleteProposal(ctx, proposal.Id)
if err != nil {
logger.Warn(
"failed to delete disallowed proposal",
"proposal", proposal.Id,
"title", proposal.GetTitle(),
"total_deposit", proposal.TotalDeposit)
return
}

err = am.keeper.RefundAndDeleteDeposits(ctx, proposal.Id)
if err != nil {
logger.Warn(
"failed to refund deposits for disallowed proposal",
"proposal", proposal.Id,
"title", proposal.GetTitle(),
"total_deposit", proposal.TotalDeposit)
return
}

ctx.EventManager().EmitEvent(
sdk.NewEvent(
Expand All @@ -129,9 +156,8 @@ func deleteForbiddenProposal(ctx sdk.Context, am AppModule, proposal govv1.Propo
),
)

logger := am.keeper.Logger(ctx)
logger.Info(
"proposal is not whitelisted; deleted",
"proposal is not allowed; deleted",
"proposal", proposal.Id,
"title", proposal.GetTitle(),
"total_deposit", proposal.TotalDeposit)
Expand Down
Loading

0 comments on commit ff2f074

Please sign in to comment.