-
Notifications
You must be signed in to change notification settings - Fork 138
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
feat: consumer throttle state query #1285
Changes from 47 commits
7691bf5
a10a239
8a557b3
196ce38
0f27c31
cf09f5f
87ad0f4
7e6264f
5e4b845
8350956
6d20dd1
461878c
56242a6
1d963fa
e8acd9e
8ed33f3
ecac6a4
f6d4650
956e595
db8dc1b
78a8269
73db33b
5bfccc3
5196394
37e0e93
b1cb354
599854a
8945156
0544fd3
d8f5690
f91cb70
aca8362
66adc8a
cc9064d
6da7fef
840d290
8ec7bc5
b152c03
6bdfff9
3b27006
afa32f4
6ee88e2
c956441
280e854
688fd8a
000d4a5
8d50918
3ea0cf4
6e4768e
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -26,8 +26,7 @@ type ChainState struct { | |
ConsumerChains *map[chainID]bool | ||
AssignedKeys *map[validatorID]string | ||
ProviderKeys *map[validatorID]string // validatorID: validator provider key | ||
ConsumerChainQueueSizes *map[chainID]uint | ||
GlobalSlashQueueSize *uint | ||
PendingPacketQueueSize *uint // Only relevant to consumer chains | ||
RegisteredConsumerRewardDenoms *[]string | ||
} | ||
|
||
|
@@ -173,6 +172,11 @@ func (tr TestRun) getChainState(chain chainID, modelState ChainState) ChainState | |
chainState.RegisteredConsumerRewardDenoms = ®isteredConsumerRewardDenoms | ||
} | ||
|
||
if modelState.PendingPacketQueueSize != nil { | ||
pendingPacketQueueSize := tr.getPendingPacketQueueSize(chain) | ||
chainState.PendingPacketQueueSize = &pendingPacketQueueSize | ||
} | ||
|
||
if *verbose { | ||
log.Println("Done getting chain state:\n" + pretty.Sprint(chainState)) | ||
} | ||
|
@@ -694,6 +698,23 @@ func (tr TestRun) getRegisteredConsumerRewardDenoms(chain chainID) []string { | |
return rewardDenoms | ||
} | ||
|
||
func (tr TestRun) getPendingPacketQueueSize(chain chainID) uint { | ||
//#nosec G204 -- Bypass linter warning for spawning subprocess with cmd arguments. | ||
cmd := exec.Command("docker", "exec", tr.containerConfig.instanceName, tr.chainConfigs[chain].binaryName, | ||
|
||
"query", "ccvconsumer", "throttle-state", | ||
`--node`, tr.getQueryNode(chain), | ||
`-o`, `json`, | ||
) | ||
bz, err := cmd.CombinedOutput() | ||
if err != nil { | ||
log.Fatal(err, "\n", string(bz)) | ||
} | ||
|
||
packetData := gjson.Get(string(bz), "packet_data_queue").Array() | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could you add validation logic here? I'd be worried this could break in "interesting" ways. From the gjson documentation on the Get function https://godocs.io/github.com/tidwall/gjson#Get: There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yup seems reasonable to panic when |
||
return uint(len(packetData)) | ||
} | ||
|
||
func (tr TestRun) getValidatorNode(chain chainID, validator validatorID) string { | ||
// for CometMock, validatorNodes are all the same address as the query node (which is CometMocks address) | ||
if tr.useCometmock { | ||
|
@@ -742,3 +763,7 @@ func (tr TestRun) curlJsonRPCRequest(method, params, address string) { | |
verbosity := false | ||
executeCommandWithVerbosity(cmd, "curlJsonRPCRequest", verbosity) | ||
} | ||
|
||
func uintPtr(i uint) *uint { | ||
return &i | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can we make the name more explicitly mention Consumer chains again?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
3ea0cf4