Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: clean protos for clarity #1071

Merged
merged 26 commits into from
Aug 24, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion app/consumer-democracy/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -112,6 +112,7 @@ import (
ccvdistr "github.com/cosmos/interchain-security/v3/x/ccv/democracy/distribution"
ccvgov "github.com/cosmos/interchain-security/v3/x/ccv/democracy/governance"
ccvstaking "github.com/cosmos/interchain-security/v3/x/ccv/democracy/staking"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)

const (
Expand Down Expand Up @@ -712,7 +713,7 @@ func New(
return fromVM, fmt.Errorf("failed to unmarshal genesis state: %w", err)
}

consumerGenesis := consumertypes.GenesisState{}
consumerGenesis := ccvtypes.GenesisState{}
appCodec.MustUnmarshalJSON(appState[consumertypes.ModuleName], &consumerGenesis)

consumerGenesis.PreCCV = true
Expand Down
3 changes: 2 additions & 1 deletion legacy_ibc_testing/testing/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ import (
"github.com/cosmos/interchain-security/v3/legacy_ibc_testing/core"
"github.com/cosmos/interchain-security/v3/legacy_ibc_testing/simapp"
consumertypes "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types"
ccvtypes "github.com/cosmos/interchain-security/v3/x/ccv/types"
)

/*
Expand Down Expand Up @@ -111,7 +112,7 @@ func SetupWithGenesisValSet(t *testing.T, appIniter AppIniter, valSet *tmtypes.V
// set validators and delegations
var (
stakingGenesis stakingtypes.GenesisState
consumerGenesis consumertypes.GenesisState
consumerGenesis ccvtypes.GenesisState
bondDenom string
)
if genesisState[stakingtypes.ModuleName] != nil {
Expand Down
86 changes: 15 additions & 71 deletions proto/interchain_security/ccv/consumer/v1/consumer.proto
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
syntax = "proto3";

Check failure on line 1 in proto/interchain_security/ccv/consumer/v1/consumer.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "LastTransmissionBlockHeight" was deleted from file.

Check failure on line 1 in proto/interchain_security/ccv/consumer/v1/consumer.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "MaturingVSCPacket" was deleted from file.

Check failure on line 1 in proto/interchain_security/ccv/consumer/v1/consumer.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "Params" was deleted from file.
package interchain_security.ccv.consumer.v1;

import "interchain_security/ccv/v1/ccv.proto";
import "interchain_security/ccv/v1/wire.proto";

option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types";

Expand All @@ -11,68 +11,17 @@
import "google/protobuf/duration.proto";
import "google/protobuf/timestamp.proto";

// Params defines the parameters for CCV consumer module
message Params {
// TODO: Remove enabled flag and find a better way to setup integration tests
// See: https://github.com/cosmos/interchain-security/issues/339
bool enabled = 1;

///////////////////////
// Distribution Params
// Number of blocks between ibc-token-transfers from the consumer chain to
// the provider chain. Note that at this transmission event a fraction of
// the accumulated tokens are divided and sent consumer redistribution
// address.
int64 blocks_per_distribution_transmission = 2;

// Channel, and provider-chain receiving address to send distribution token
// transfers over. These parameters is auto-set during the consumer <->
// provider handshake procedure.
string distribution_transmission_channel = 3;
string provider_fee_pool_addr_str = 4;
// Sent CCV related IBC packets will timeout after this duration
google.protobuf.Duration ccv_timeout_period = 5
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];

// Sent transfer related IBC packets will timeout after this duration
google.protobuf.Duration transfer_timeout_period = 6
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];

// The fraction of tokens allocated to the consumer redistribution address
// during distribution events. The fraction is a string representing a
// decimal number. For example "0.75" would represent 75%.
string consumer_redistribution_fraction = 7;

// The number of historical info entries to persist in store.
// This param is a part of the cosmos sdk staking module. In the case of
// a ccv enabled consumer chain, the ccv module acts as the staking module.
int64 historical_entries = 8;

// Unbonding period for the consumer,
// which should be smaller than that of the provider in general.
google.protobuf.Duration unbonding_period = 9
[ (gogoproto.nullable) = false, (gogoproto.stdduration) = true ];

// The threshold for the percentage of validators at the bottom of the set who
// can opt out of running the consumer chain without being punished. For
// example, a value of 0.05 means that the validators in the bottom 5% of the
// set can opt out
string soft_opt_out_threshold = 10;

// Reward denoms. These are the denominations which are allowed to be sent to
// the provider as rewards.
repeated string reward_denoms = 11;

// Provider-originated reward denoms. These are denoms coming from the
// provider which are allowed to be used as rewards. e.g. "uatom"
repeated string provider_reward_denoms = 12;
}

// LastTransmissionBlockHeight is the last time validator holding
// pools were transmitted to the provider chain
message LastTransmissionBlockHeight { int64 height = 1; }

// CrossChainValidator defines the validators for CCV consumer module
//
// Note any type defined in this file is ONLY used internally to the consumer CCV module.
// These schemas can change with proper consideration of compatibility or migration.
//

// CrossChainValidator defines the type used to store validator information internal
// to the consumer CCV module. Note one cross chain validator entry is persisted for
// each consumer validator, where incoming VSC packets update this data, which is eventually
// forwarded to comet for consumer chain consensus.
//
// Note this type is only used internally to the consumer CCV module.
message CrossChainValidator {
bytes address = 1;
int64 power = 2;
Expand All @@ -83,17 +32,12 @@
];
}

// MaturingVSCPacket contains the maturing time of a received VSCPacket
message MaturingVSCPacket {
uint64 vscId = 1;
google.protobuf.Timestamp maturity_time = 2
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}

// A record storing the state of a slash packet sent to the provider chain
// which may bounce back and forth until handled by the provider.
//
// Note this type is only used internally to the consumer CCV module.
message SlashRecord {
bool waiting_on_reply = 1;
google.protobuf.Timestamp send_time = 2
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}
}
58 changes: 0 additions & 58 deletions proto/interchain_security/ccv/consumer/v1/genesis.proto

This file was deleted.

3 changes: 2 additions & 1 deletion proto/interchain_security/ccv/consumer/v1/query.proto
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
syntax = "proto3";

package interchain_security.ccv.consumer.v1;
import "interchain_security/ccv/v1/shared_consumer.proto";
option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/consumer/types";

import "gogoproto/gogo.proto";
Expand Down Expand Up @@ -54,7 +55,7 @@
// QueryParamsResponse is response type for the Query/Params RPC method.
message QueryParamsResponse {
// params holds all the parameters of this module.
Params params = 1 [ (gogoproto.nullable) = false ];
interchain_security.ccv.v1.Params params = 1 [ (gogoproto.nullable) = false ];

Check failure on line 58 in proto/interchain_security/ccv/consumer/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "1" on message "QueryParamsResponse" changed type from "interchain_security.ccv.consumer.v1.Params" to "interchain_security.ccv.v1.Params".
}

message QueryProviderInfoRequest {}
Expand Down
13 changes: 7 additions & 6 deletions proto/interchain_security/ccv/provider/v1/genesis.proto
Original file line number Diff line number Diff line change
Expand Up @@ -5,10 +5,9 @@
option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/provider/types";

import "gogoproto/gogo.proto";
import "interchain_security/ccv/v1/ccv.proto";
import "interchain_security/ccv/v1/shared_consumer.proto";
import "interchain_security/ccv/v1/wire.proto";
import "interchain_security/ccv/provider/v1/provider.proto";
import "interchain_security/ccv/consumer/v1/consumer.proto";
import "interchain_security/ccv/consumer/v1/genesis.proto";
import "tendermint/crypto/keys.proto";

// GenesisState defines the CCV provider chain genesis state
Expand All @@ -24,7 +23,7 @@
repeated interchain_security.ccv.provider.v1.UnbondingOp unbonding_ops = 3
[ (gogoproto.nullable) = false ];
// empty for a new chain
interchain_security.ccv.v1.MaturedUnbondingOps mature_unbonding_ops = 4;
interchain_security.ccv.provider.v1.MaturedUnbondingOps mature_unbonding_ops = 4;

Check failure on line 26 in proto/interchain_security/ccv/provider/v1/genesis.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "4" on message "GenesisState" changed type from "interchain_security.ccv.v1.MaturedUnbondingOps" to "interchain_security.ccv.provider.v1.MaturedUnbondingOps".
// empty for a new chain
repeated ValsetUpdateIdToHeight valset_update_id_to_height = 5
[ (gogoproto.nullable) = false ];
Expand Down Expand Up @@ -52,7 +51,9 @@
[ (gogoproto.nullable) = false ];
}

// consumer chain
// The provider CCV module's knowledge of consumer state.
//
// Note this type is only used internally to the provider CCV module.
message ConsumerState {
// ChainID defines the chain ID for the consumer chain
string chain_id = 1;
Expand All @@ -63,7 +64,7 @@
// InitalHeight defines the initial block height for the consumer chain
uint64 initial_height = 4;
// ConsumerGenesis defines the initial consumer chain genesis states
interchain_security.ccv.consumer.v1.GenesisState consumer_genesis = 5
interchain_security.ccv.v1.GenesisState consumer_genesis = 5

Check failure on line 67 in proto/interchain_security/ccv/provider/v1/genesis.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "5" on message "ConsumerState" changed type from "interchain_security.ccv.consumer.v1.GenesisState" to "interchain_security.ccv.v1.GenesisState".
[ (gogoproto.nullable) = false ];
// PendingValsetChanges defines the pending validator set changes for the
// consumer chain
Expand Down
28 changes: 22 additions & 6 deletions proto/interchain_security/ccv/provider/v1/provider.proto
Original file line number Diff line number Diff line change
@@ -1,9 +1,11 @@
syntax = "proto3";

Check failure on line 1 in proto/interchain_security/ccv/provider/v1/provider.proto

View workflow job for this annotation

GitHub Actions / break-check

Previously present message "HandshakeMetadata" was deleted from file.

package interchain_security.ccv.provider.v1;

option go_package = "github.com/cosmos/interchain-security/v3/x/ccv/provider/types";

import "interchain_security/ccv/v1/shared_consumer.proto";
import "interchain_security/ccv/v1/wire.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "google/protobuf/duration.proto";
Expand All @@ -13,6 +15,11 @@
import "cosmos/evidence/v1beta1/evidence.proto";
import "cosmos/base/v1beta1/coin.proto";

//
// Note any type defined in this file is ONLY used internally to the provider CCV module.
// These schemas can change with proper consideration of compatibility or migration.
//

// ConsumerAdditionProposal is a governance proposal on the provider chain to
// spawn a new consumer chain. If it passes, then all validators on the provider
// chain are expected to validate the consumer chain at spawn time or get
Expand Down Expand Up @@ -96,6 +103,10 @@
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}

// EquivocationProposal is a governance proposal on the provider chain to
// punish a validator for equivocation on a consumer chain.
//
// This type is only used internally to the consumer CCV module.
message EquivocationProposal {
// the title of the proposal
string title = 1;
Expand Down Expand Up @@ -164,13 +175,8 @@
[ (gogoproto.nullable) = false ];
}

message HandshakeMetadata {
string provider_fee_pool_addr = 1;
string version = 2;
}

// SlashAcks contains cons addresses of consumer chain validators
// successfully slashed on the provider chain
// successfully slashed on the provider chain.
message SlashAcks { repeated string addresses = 1; }

// ConsumerAdditionProposals holds pending governance proposals on the provider
Expand Down Expand Up @@ -221,6 +227,16 @@
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
}

// ValidatorSetChangePackets is a pb list of ccv.ValidatorSetChangePacketData.
message ValidatorSetChangePackets {
repeated interchain_security.ccv.v1.ValidatorSetChangePacketData list = 1
[ (gogoproto.nullable) = false ];
}

// MaturedUnbondingOps defines a list of ids corresponding to ids of matured
// unbonding operations.
message MaturedUnbondingOps { repeated uint64 ids = 1; }

// ExportedVscSendTimestamps is VscSendTimestamp with chainID info for exporting to genesis
message ExportedVscSendTimestamp {
string chain_id = 1;
Expand Down
6 changes: 3 additions & 3 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@
import "google/api/annotations.proto";
import "gogoproto/gogo.proto";
import "google/protobuf/timestamp.proto";
import "interchain_security/ccv/v1/ccv.proto";
import "interchain_security/ccv/consumer/v1/genesis.proto";
import "interchain_security/ccv/provider/v1/provider.proto";
import "interchain_security/ccv/v1/shared_consumer.proto";
import "interchain_security/ccv/v1/wire.proto";

service Query {
// ConsumerGenesis queries the genesis state needed to start a consumer chain
Expand Down Expand Up @@ -86,7 +86,7 @@
message QueryConsumerGenesisRequest { string chain_id = 1; }

message QueryConsumerGenesisResponse {
interchain_security.ccv.consumer.v1.GenesisState genesis_state = 1
interchain_security.ccv.v1.GenesisState genesis_state = 1

Check failure on line 89 in proto/interchain_security/ccv/provider/v1/query.proto

View workflow job for this annotation

GitHub Actions / break-check

Field "1" on message "QueryConsumerGenesisResponse" changed type from "interchain_security.ccv.consumer.v1.GenesisState" to "interchain_security.ccv.v1.GenesisState".
[ (gogoproto.nullable) = false ];
}

Expand Down
Loading
Loading