Skip to content

Commit

Permalink
fix nits
Browse files Browse the repository at this point in the history
  • Loading branch information
sainoe committed Oct 3, 2023
1 parent 7868be6 commit 8349b82
Show file tree
Hide file tree
Showing 8 changed files with 60 additions and 74 deletions.
58 changes: 58 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,64 @@ Upgrading a consumer from `v1.2.0-multiden` to `v2.0.0` will NOT require state m
* (api) Add consumer QueryParams [#746](https://github.com/cosmos/interchain-security/pull/746)
* (feature) New validation for keeper fields [#740](https://github.com/cosmos/interchain-security/pull/740)


## v1.2.0-multiden

The first release candidate for a fix built on top of v1.2.0, intended for consumers. This release adds a list of denoms on the consumer that are allowed to be sent to the provider as rewards. This prevents a potential DOS attack that was discovered during the audit of Replicated Security performed by Oak Security and funded by the Cosmos Hub community through Proposal 687. In an effort to move quickly, this release also includes a multisig fix that is effective only for provider. It shouldn't affect the consumer module.

Note PRs were made in a private security repo.

[full diff](https://github.com/cosmos/interchain-security/compare/v1.2.0...v1.2.0-multiden-rc0)

## v1.1.0-multiden

This release combines two fixes on top of v1.1.0, that we judged were urgent to get onto the Cosmos Hub before the launch of the first ICS consumer chain. This is an emergency release intended for providers.

The first fix is to enable the use of multisigs and Ledger devices when assigning keys for consumer chains. The second is to prevent a possible DOS vector involving the reward distribution system.

Note PRs were made in a private security repo.

[full diff](https://github.com/cosmos/interchain-security/compare/v1.1.0...release/v1.1.0-multiden)

### Multisig fix

On April 25th (a week and a half ago), we began receiving reports that validators using multisigs and Ledger devices were getting errors reading Error: unable to resolve type URL /interchain_security.ccv.provider.v1.MsgAssignConsumerKey: tx parse error when attempting to assign consensus keys for consumer chains.

We quickly narrowed the problem down to issues having to do with using the PubKey type directly in the MsgAssignConsumerKey transaction, and Amino (a deprecated serialization library still used in Ledger devices and multisigs) not being able to handle this. We attempted to fix this with the assistance of the Cosmos-SDK team, but after making no headway for a few days, we decided to simply use a JSON representation of the PubKey in the transaction. This is how it is usually represented anyway. We have verified that this fixes the problem.

### Distribution fix

The ICS distribution system works by allowing consumer chains to send rewards to a module address on the provider called the FeePoolAddress. From here they are automatically distributed to all validators and delegators through the distribution system that already exists to distribute staking rewards. The FeePoolAddress is usually blocked so that no tokens can be sent to it, but to enable ICS distribution we had to unblock it.

We recently realized that unblocking the FeePoolAddress could enable an attacker to send a huge number of different denoms into the distribution system. The distribution system would then attempt to distribute them all, leading to out of memory errors. Fixing a similar attack vector that existed in the distribution system before ICS led us to this realization.

To fix this problem, we have re-blocked the FeePoolAddress and created a new address called the ConsumerRewardsPool. Consumer chains now send rewards to this new address. There is also a new transaction type called RegisterConsumerRewardDenom. This transaction allows people to register denoms to be used as rewards from consumer chains. It costs 10 Atoms to run this transaction.The Atoms are transferred to the community pool. Only denoms registered with this command are then transferred to the FeePoolAddress and distributed out to delegators and validators.

## v1.2.1

* (fix) Remove SPM [#812](https://github.com/cosmos/interchain-security/pull/812)
* (refactor) Key assignment type safety [#725](https://github.com/cosmos/interchain-security/pull/725)

## v1.2.0

Date: April 13th, 2023

* (feat) Soft opt-out [#833](https://github.com/cosmos/interchain-security/pull/833)
* (fix) Correctly handle VSC packet with duplicate val updates on consumer [#846](https://github.com/cosmos/interchain-security/pull/846)
* (chore) bump: sdk v0.45.15-ics [#805](https://github.com/cosmos/interchain-security/pull/805)
* (api) add interchain security consumer QueryParams [#746](https://github.com/cosmos/interchain-security/pull/746)

## v1.1.1

* (fix) Remove SPM [#812](https://github.com/cosmos/interchain-security/pull/812)
* (refactor) Key assignment type safety [#725](https://github.com/cosmos/interchain-security/pull/725)

## v1.1.0

Date: March 24th, 2023

* (fix) StopConsumerChain not running in cachedContext [#802](https://github.com/cosmos/interchain-security/pull/802)

## v1.0.0

Date: February 6th, 2023
Expand Down
3 changes: 0 additions & 3 deletions tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1291,9 +1291,6 @@ func (tr TestConfig) relayRewardPacketsToProvider(
) {
blockPerDistribution, _ := strconv.ParseUint(strings.Trim(tr.getParam(action.ConsumerChain, Param{Subspace: "ccvconsumer", Key: "BlocksPerDistributionTransmission"}), "\""), 10, 64)
currentBlock := uint64(tr.getBlockHeight(action.ConsumerChain))
fmt.Println("blockPerDistribution", blockPerDistribution)
fmt.Println("currentBlock", currentBlock)

if currentBlock <= blockPerDistribution {
tr.waitBlocks(action.ConsumerChain, uint(blockPerDistribution-currentBlock+1), 60*time.Second)
}
Expand Down
21 changes: 0 additions & 21 deletions tests/e2e/actions_consumer_misbehaviour.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package main

import (
"bufio"
"fmt"
"log"
"os/exec"
"strconv"
Expand Down Expand Up @@ -97,23 +96,3 @@ func (tc TestConfig) updateLightClient(

tc.waitBlocks(action.HostChain, 5, 30*time.Second)
}

type assertChainIsHaltedAction struct {
chain ChainID
}

// assertChainIsHalted verifies that the chain isn't producing blocks
// by checking that the block height is still the same after 20 seconds
func (tc TestConfig) assertChainIsHalted(
action assertChainIsHaltedAction,
verbose bool,
) {
blockHeight := tc.getBlockHeight(action.chain)
time.Sleep(20 * time.Second)
if blockHeight != tc.getBlockHeight(action.chain) {
panic(fmt.Sprintf("chain %v isn't expected to produce blocks", action.chain))
}
if verbose {
log.Printf("assertChainIsHalted - chain %v was successfully halted\n", action.chain)
}
}
2 changes: 0 additions & 2 deletions tests/e2e/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ func (tr *TestConfig) runStep(step Step, verbose bool) {
tr.forkConsumerChain(action, verbose)
case updateLightClientAction:
tr.updateLightClient(action, verbose)
case assertChainIsHaltedAction:
tr.assertChainIsHalted(action, verbose)
case startConsumerEvidenceDetectorAction:
tr.startConsumerEvidenceDetector(action, verbose)
case submitChangeRewardDenomsProposalAction:
Expand Down
9 changes: 1 addition & 8 deletions tests/e2e/state.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ type ChainState struct {
Rewards *Rewards
ConsumerChains *map[ChainID]bool
AssignedKeys *map[ValidatorID]string
ProviderKeys *map[ValidatorID]string // ValidatorID: validator provider key
ProviderKeys *map[ValidatorID]string // validatorID: validator provider key
ConsumerChainQueueSizes *map[ChainID]uint
GlobalSlashQueueSize *uint
RegisteredConsumerRewardDenoms *[]string
Expand Down Expand Up @@ -324,13 +324,6 @@ func (tr TestConfig) getReward(chain ChainID, validator ValidatorID, blockHeight
delAddresss = tr.validatorConfigs[validator].ConsumerDelAddress
}

fmt.Println("getReward", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName,
"query", "distribution", "rewards",
delAddresss,

`--height`, fmt.Sprint(blockHeight),
`--node`, tr.getQueryNode(chain),
`-o`, `json`)
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments.
bz, err := exec.Command("docker", "exec", tr.containerConfig.InstanceName, tr.chainConfigs[chain].BinaryName,

Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/testnet-scripts/sovereign-genesis.json
Original file line number Diff line number Diff line change
Expand Up @@ -292,4 +292,4 @@
"upgrade": {},
"vesting": {}
}
}
}
1 change: 0 additions & 1 deletion tests/e2e/testnet-scripts/start-chain.sh
Original file line number Diff line number Diff line change
Expand Up @@ -198,7 +198,6 @@ do
#'s/foo/bar/;s/abc/def/'
sed -i "$TENDERMINT_CONFIG_TRANSFORM" $CHAIN_ID/validator$VAL_ID/config/config.toml
fi

done


Expand Down
38 changes: 0 additions & 38 deletions third_party/proto/tendermint/types/evidence.proto

This file was deleted.

0 comments on commit 8349b82

Please sign in to comment.