Skip to content

Commit

Permalink
feat: Add QueryAllPairsValConAddrByConsumerChainID (backport #1503) (
Browse files Browse the repository at this point in the history
…#1551)

feat: Add `QueryAllPairsValConAddrByConsumerChainID` (#1503)

* add QueryAllPairsValConAddrByConsumerChainID

* Lint

* add pubkey in PairValConAddrProviderAndConsumer struct

* add test TestQueryAllPairsValConAddrByConsumerChainID

* add doc

* Update docs/docs/features/key-assignment.md

Co-authored-by: MSalopek <[email protected]>

* add changelog

* update with Marius Poke's suggestions

* update logic get data

---------

Co-authored-by: Du Nguyen <[email protected]>
Co-authored-by: MSalopek <[email protected]>
(cherry picked from commit 56399f6)

# Conflicts:
#	tests/e2e/tracehandler_testdata/slashThrottle.json

Co-authored-by: Nguyen Thanh Nhan | Decentrio <[email protected]>
  • Loading branch information
mergify[bot] and ThanhNhann authored Jan 5, 2024
1 parent 2ccb10a commit b4daea5
Show file tree
Hide file tree
Showing 17 changed files with 1,438 additions and 85 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
- Add `QueryAllPairsValConAddrByConsumerChainID` method to get list of all pairs `valConsensus` address by `Consummer chainID`. ([\#1503](https://github.com/cosmos/interchain-security/pull/1503))
8 changes: 8 additions & 0 deletions docs/docs/features/key-assignment.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,14 @@ gaiad query provider validator-provider-key <consumer-chain-id> consumervalcons1

You must use a `valcons` address. You can obtain it by querying your node on the consumer `consumerd tendermint show-address`

OR

```bash
gaiad query provider all-pairs-valconsensus-address <consumer-chain-id>
```

You just need to use the `chainId` of consumer to query all pairs valconsensus address with `consumer-pub-key` for each of pair

## Changing a key

To change your key, simply repeat all of the steps listed above. Take note that your old key will be remembered for at least the unbonding period of the consumer chain so any slashes can be correctly applied
Expand Down
27 changes: 27 additions & 0 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ import "google/protobuf/timestamp.proto";
import "interchain_security/ccv/provider/v1/provider.proto";
import "interchain_security/ccv/v1/shared_consumer.proto";
import "interchain_security/ccv/v1/wire.proto";
import "tendermint/crypto/keys.proto";

service Query {
// ConsumerGenesis queries the genesis state needed to start a consumer chain
Expand Down Expand Up @@ -90,6 +91,15 @@ service Query {
option (google.api.http).get =
"/interchain_security/ccv/provider/proposed_consumer_chains";
}

// QueryAllPairsValConAddrByConsumerChainID returns a list of pair valconsensus address
// between provider and consumer chain
rpc QueryAllPairsValConAddrByConsumerChainID (
QueryAllPairsValConAddrByConsumerChainIDRequest)
returns (QueryAllPairsValConAddrByConsumerChainIDResponse) {
option (google.api.http).get =
"/interchain_security/ccv/provider/consumer_chain_id";
}
}

message QueryConsumerGenesisRequest { string chain_id = 1; }
Expand Down Expand Up @@ -208,3 +218,20 @@ message ProposedChain {
string chainID = 1;
uint64 proposalID = 2;
}

message QueryAllPairsValConAddrByConsumerChainIDRequest {
// The id of the consumer chain
string chain_id = 1;
}

message QueryAllPairsValConAddrByConsumerChainIDResponse {
repeated PairValConAddrProviderAndConsumer pair_val_con_addr = 1;
}

message PairValConAddrProviderAndConsumer {
// The consensus address of the validator on the provider chain
string provider_address = 1 [ (gogoproto.moretags) = "yaml:\"address\"" ];
// The consensus address of the validator on the consumer chain
string consumer_address = 2 [ (gogoproto.moretags) = "yaml:\"address\"" ];
tendermint.crypto.PublicKey consumer_key = 3;
}
17 changes: 17 additions & 0 deletions tests/e2e/tracehandler_testdata/changeover.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
"ValBalances": {
"alice": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand All @@ -43,6 +44,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 0,
Expand Down Expand Up @@ -93,6 +95,7 @@
"bob": 9500000000,
"carol": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -140,6 +143,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -182,6 +186,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -237,6 +242,7 @@
"alice": 9489999999,
"bob": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -287,6 +293,7 @@
"alice": 9500000000,
"bob": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -342,6 +349,7 @@
"State": {
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand All @@ -361,6 +369,7 @@
},
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand Down Expand Up @@ -416,6 +425,7 @@
"ValBalances": {
"bob": 0
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand All @@ -442,6 +452,7 @@
"State": {
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 500,
Expand All @@ -461,6 +472,7 @@
},
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand Down Expand Up @@ -491,6 +503,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 500,
Expand Down Expand Up @@ -523,6 +536,7 @@
"ValBalances": {
"bob": 100
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand All @@ -549,6 +563,7 @@
"State": {
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 510,
"bob": 500,
Expand All @@ -568,6 +583,7 @@
},
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 500,
Expand Down Expand Up @@ -598,6 +614,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 510,
"bob": 500,
Expand Down
15 changes: 15 additions & 0 deletions tests/e2e/tracehandler_testdata/consumer-double-sign.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@
"bob": 9500000000,
"carol": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -64,6 +65,9 @@
"alice": 9489999999,
"bob": 9500000000
},
"ProposedConsumerChains": [
"consu"
],
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -104,6 +108,7 @@
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -147,6 +152,7 @@
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -188,6 +194,7 @@
"alice": 9500000000,
"bob": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -246,6 +253,7 @@
"bob": 10000000000,
"carol": 10000000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand All @@ -264,6 +272,7 @@
"bob": 9500000000,
"carol": 9500000000
},
"ProposedConsumerChains": [],
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -310,6 +319,7 @@
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand All @@ -328,6 +338,7 @@
},
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand Down Expand Up @@ -358,6 +369,7 @@
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand All @@ -376,6 +388,7 @@
},
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 0,
Expand Down Expand Up @@ -409,6 +422,7 @@
"State": {
"consu": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 0,
Expand All @@ -427,6 +441,7 @@
},
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 0,
Expand Down
Loading

0 comments on commit b4daea5

Please sign in to comment.