Skip to content

Commit

Permalink
Merge branch 'feat/throttle-complete-attempt-2' into shawn/consumer-t…
Browse files Browse the repository at this point in the history
…hrottle-state-query
  • Loading branch information
shaspitz committed Sep 14, 2023
2 parents 688fd8a + 727e731 commit 000d4a5
Show file tree
Hide file tree
Showing 7 changed files with 110 additions and 1,392 deletions.
36 changes: 0 additions & 36 deletions proto/interchain_security/ccv/provider/v1/query.proto
Original file line number Diff line number Diff line change
Expand Up @@ -65,13 +65,6 @@ service Query {
"/interchain_security/ccv/provider/throttle_state";
}

// [DEPRECATED] Returns an empty set.
rpc QueryThrottledConsumerPacketData(QueryThrottledConsumerPacketDataRequest)
returns (QueryThrottledConsumerPacketDataResponse) {
option (google.api.http).get =
"/interchain_security/ccv/provider/pending_consumer_packets";
}

// QueryRegisteredConsumerRewardDenoms returns a list of consumer reward
// denoms that are registered
rpc QueryRegisteredConsumerRewardDenoms(
Expand Down Expand Up @@ -150,35 +143,6 @@ message QueryThrottleStateResponse {
// full
google.protobuf.Timestamp next_replenish_candidate = 3
[ (gogoproto.stdtime) = true, (gogoproto.nullable) = false ];
// data relevant to currently throttled slash packets
repeated ThrottledSlashPacket packets = 4;
}

message QueryThrottledConsumerPacketDataRequest { string chain_id = 1; }

message QueryThrottledConsumerPacketDataResponse {
string chain_id = 1;
uint64 size = 2;
repeated ThrottledPacketDataWrapper packetDataInstances = 3
[ (gogoproto.nullable) = false ];
}

// A query wrapper type for the global entry and data relevant to a throttled
// slash packet.
message ThrottledSlashPacket {
interchain_security.ccv.provider.v1.GlobalSlashEntry global_entry = 1
[ (gogoproto.nullable) = false ];
interchain_security.ccv.v1.SlashPacketData data = 2
[ (gogoproto.nullable) = false ];
}

// ThrottledPacketDataWrapper contains either SlashPacketData or
// VSCMaturedPacketData
message ThrottledPacketDataWrapper {
oneof data {
interchain_security.ccv.v1.SlashPacketData slash_packet = 1;
interchain_security.ccv.v1.VSCMaturedPacketData vsc_matured_packet = 2;
}
}

message QueryRegisteredConsumerRewardDenomsRequest {}
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/actions.go
Original file line number Diff line number Diff line change
Expand Up @@ -1970,7 +1970,7 @@ func (tr TestRun) waitForSlashMeterReplenishment(
panic(fmt.Sprintf("\n\nwaitForSlashMeterReplenishment has timed out after: %s\n\n", action.timeout))
}

time.Sleep(500 * time.Millisecond)
tr.WaitTime(5 * time.Second)
}
}

Expand Down
5 changes: 3 additions & 2 deletions tests/e2e/steps_downtime.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,8 @@ func stepsDowntime(consumerName string) []Step {
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 509,
validatorID("bob"): 500,
// Bob's stake may or may not be slashed at this point depending on comet vs cometmock
// See https://github.com/cosmos/interchain-security/issues/1304
validatorID("carol"): 501,
},
},
Expand Down Expand Up @@ -342,7 +343,7 @@ func stepsThrottledDowntime(consumerName string) []Step {
chainID(consumerName): ChainState{
ValPowers: &map[validatorID]uint{
validatorID("alice"): 511,
validatorID("bob"): 500, // VSC packet applying bob jailing is not yet relayed to consumer
validatorID("bob"): 500, // VSC packet jailing bob is not yet relayed to consumer
validatorID("carol"): 500,
},
PendingPacketQueueSize: uintPtr(1), // carol's downtime slash packet is queued
Expand Down
36 changes: 0 additions & 36 deletions x/ccv/provider/client/cli/query.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ func NewQueryCmd() *cobra.Command {
cmd.AddCommand(CmdConsumerValidatorKeyAssignment())
cmd.AddCommand(CmdProviderValidatorKey())
cmd.AddCommand(CmdThrottleState())
cmd.AddCommand(CmdThrottledConsumerPacketData())
cmd.AddCommand(CmdRegisteredConsumerRewardDenoms())

return cmd
Expand Down Expand Up @@ -286,41 +285,6 @@ $ %s query provider throttle-state
return cmd
}

func CmdThrottledConsumerPacketData() *cobra.Command {
cmd := &cobra.Command{
Use: "throttled-consumer-packet-data [chainid]",
Short: "[DEPRECIATED] Returns an empty set.",
Long: strings.TrimSpace(
fmt.Sprintf(`[DEPRECIATED] Returns an empty set.
Example:
$ %s query provider throttled-consumer-packet-data foochain
`,
version.AppName,
),
),
Args: cobra.ExactArgs(1),
RunE: func(cmd *cobra.Command, args []string) (err error) {
clientCtx, err := client.GetClientQueryContext(cmd)
if err != nil {
return err
}
queryClient := types.NewQueryClient(clientCtx)

req := &types.QueryThrottledConsumerPacketDataRequest{ChainId: args[0]}
res, err := queryClient.QueryThrottledConsumerPacketData(cmd.Context(), req)
if err != nil {
return err
}

return clientCtx.PrintProto(res)
},
}

flags.AddQueryFlagsToCmd(cmd)

return cmd
}

func CmdRegisteredConsumerRewardDenoms() *cobra.Command {
cmd := &cobra.Command{
Use: "registered-consumer-reward-denoms",
Expand Down
25 changes: 0 additions & 25 deletions x/ccv/provider/keeper/grpc_query.go
Original file line number Diff line number Diff line change
Expand Up @@ -147,36 +147,11 @@ func (k Keeper) QueryThrottleState(goCtx context.Context, req *types.QueryThrott
meter := k.GetSlashMeter(ctx)
allowance := k.GetSlashMeterAllowance(ctx)
candidate := k.GetSlashMeterReplenishTimeCandidate(ctx) // always UTC
packets := []*types.ThrottledSlashPacket{}

return &types.QueryThrottleStateResponse{
SlashMeter: meter.Int64(),
SlashMeterAllowance: allowance.Int64(),
NextReplenishCandidate: candidate,
Packets: packets,
}, nil
}

func (k Keeper) QueryThrottledConsumerPacketData(goCtx context.Context, req *types.QueryThrottledConsumerPacketDataRequest) (*types.QueryThrottledConsumerPacketDataResponse, error) {
if req == nil {
return nil, status.Error(codes.InvalidArgument, "empty request")
}

if req.ChainId == "" {
return nil, status.Error(codes.InvalidArgument, "invalid chain-id")
}

ctx := sdk.UnwrapSDKContext(goCtx)
if _, found := k.GetChainToChannel(ctx, req.ChainId); !found {
return nil, status.Error(codes.InvalidArgument, "invalid chain-id")
}

packetDataInstances := []types.ThrottledPacketDataWrapper{}

return &types.QueryThrottledConsumerPacketDataResponse{
ChainId: req.ChainId,
Size_: 0,
PacketDataInstances: packetDataInstances,
}, nil
}

Expand Down
Loading

0 comments on commit 000d4a5

Please sign in to comment.