Skip to content

Commit

Permalink
feat: Add QueryAllPairsValConAddrByConsumerChainID (#1503)
Browse files Browse the repository at this point in the history
* add QueryAllPairsValConAddrByConsumerChainID

* Lint

* add pubkey in PairValConAddrProviderAndConsumer struct

* add test TestQueryAllPairsValConAddrByConsumerChainID

* add doc

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

Co-authored-by: MSalopek <matija.salopek994@gmail.com>

* add changelog

* update with Marius Poke's suggestions

* update logic get data

---------

Co-authored-by: Du Nguyen <dunguyen643@gmail.com>
Co-authored-by: MSalopek <matija.salopek994@gmail.com>
  • Loading branch information
3 people authored Jan 5, 2024
1 parent cc9a98a commit 56399f6
Show file tree
Hide file tree
Showing 17 changed files with 1,352 additions and 86 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 @@ -82,6 +83,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 @@ -171,3 +181,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 @@ -42,6 +43,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 0,
Expand Down Expand Up @@ -91,6 +93,7 @@
"bob": 9500000000,
"carol": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -137,6 +140,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -178,6 +182,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -232,6 +237,7 @@
"alice": 9489999999,
"bob": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -281,6 +287,7 @@
"alice": 9500000000,
"bob": 9500000000
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand Down Expand Up @@ -335,6 +342,7 @@
"State": {
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand All @@ -353,6 +361,7 @@
},
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand Down Expand Up @@ -407,6 +416,7 @@
"ValBalances": {
"bob": 0
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand All @@ -432,6 +442,7 @@
"State": {
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 500,
Expand All @@ -450,6 +461,7 @@
},
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 500,
"bob": 500,
Expand Down Expand Up @@ -479,6 +491,7 @@
"State": {
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 500,
Expand Down Expand Up @@ -510,6 +523,7 @@
"ValBalances": {
"bob": 100
},
"ProposedConsumerChains": null,
"ValPowers": null,
"StakedTokens": null,
"Params": null,
Expand All @@ -535,6 +549,7 @@
"State": {
"provi": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 510,
"bob": 500,
Expand All @@ -553,6 +568,7 @@
},
"sover": {
"ValBalances": null,
"ProposedConsumerChains": null,
"ValPowers": {
"alice": 511,
"bob": 500,
Expand Down Expand Up @@ -582,6 +598,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 56399f6

Please sign in to comment.