Skip to content

Commit b6f8bad

Browse files
authored
[SHARED][CLI] adds message routing type field to debug messages and CLI commands (#561)
## Description Adds a `MessageRoutingType` field for distinguishing debug message [routing types](https://en.wikipedia.org/wiki/Routing) in the debug CLI. ## Issue Fixes #344 ## Type of change Please mark the relevant option(s): - [ ] New feature, functionality or library - [ ] Bug fix - [x] Code health or cleanup - [ ] Major breaking change - [ ] Documentation - [ ] Other <!-- add details here if it a different type of change --> ## List of changes - Adds a RoutingType field to the DebugMessage - Distinguishes the routing types of each message in the Debug CLI ## Testing - [x] `make develop_test` - [x] [LocalNet](https://github.com/pokt-network/pocket/blob/main/docs/development/README.md) w/ all of the steps outlined in the `README` ## Required Checklist - [x] I have performed a self-review of my own code - [x] I have commented my code, particularly in hard-to-understand areas - [x] I have tested my changes using the available tooling - [x] I have updated the corresponding CHANGELOG ### If Applicable Checklist - [ ] I have updated the corresponding README(s); local and/or global - [ ] I have added tests that prove my fix is effective or that my feature works - [ ] I have added, or updated, [mermaid.js](https://mermaid-js.github.io) diagrams in the corresponding README(s) - [ ] I have added, or updated, documentation and [mermaid.js](https://mermaid-js.github.io) diagrams in `shared/docs/*` if I updated `shared/*`README(s)
1 parent c3de3ab commit b6f8bad

File tree

4 files changed

+36
-14
lines changed

4 files changed

+36
-14
lines changed

app/client/cli/debug.go

+16-10
Original file line numberDiff line numberDiff line change
@@ -24,15 +24,13 @@ import (
2424

2525
// TECHDEBT: Lowercase variables / constants that do not need to be exported.
2626
const (
27-
PromptResetToGenesis string = "ResetToGenesis"
28-
PromptPrintNodeState string = "PrintNodeState"
29-
PromptTriggerNextView string = "TriggerNextView"
30-
PromptTogglePacemakerMode string = "TogglePacemakerMode"
31-
32-
PromptShowLatestBlockInStore string = "ShowLatestBlockInStore"
33-
34-
PromptSendMetadataRequest string = "MetadataRequest"
35-
PromptSendBlockRequest string = "BlockRequest"
27+
PromptResetToGenesis string = "ResetToGenesis (broadcast)"
28+
PromptPrintNodeState string = "PrintNodeState (broadcast)"
29+
PromptTriggerNextView string = "TriggerNextView (broadcast)"
30+
PromptTogglePacemakerMode string = "TogglePacemakerMode (broadcast)"
31+
PromptShowLatestBlockInStore string = "ShowLatestBlockInStore (anycast)"
32+
PromptSendMetadataRequest string = "MetadataRequest (broadcast)"
33+
PromptSendBlockRequest string = "BlockRequest (broadcast)"
3634
)
3735

3836
var (
@@ -155,42 +153,50 @@ func handleSelect(cmd *cobra.Command, selection string) {
155153
case PromptResetToGenesis:
156154
m := &messaging.DebugMessage{
157155
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_RESET_TO_GENESIS,
156+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_BROADCAST,
158157
Message: nil,
159158
}
160159
broadcastDebugMessage(cmd, m)
161160
case PromptPrintNodeState:
162161
m := &messaging.DebugMessage{
163162
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_PRINT_NODE_STATE,
163+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_BROADCAST,
164164
Message: nil,
165165
}
166166
broadcastDebugMessage(cmd, m)
167167
case PromptTriggerNextView:
168168
m := &messaging.DebugMessage{
169169
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_TRIGGER_NEXT_VIEW,
170+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_BROADCAST,
170171
Message: nil,
171172
}
172173
broadcastDebugMessage(cmd, m)
173174
case PromptTogglePacemakerMode:
174175
m := &messaging.DebugMessage{
175176
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_TOGGLE_PACE_MAKER_MODE,
177+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_BROADCAST,
176178
Message: nil,
177179
}
178180
broadcastDebugMessage(cmd, m)
179181
case PromptShowLatestBlockInStore:
180182
m := &messaging.DebugMessage{
181-
Action: messaging.DebugMessageAction_DEBUG_SHOW_LATEST_BLOCK_IN_STORE,
183+
Action: messaging.DebugMessageAction_DEBUG_SHOW_LATEST_BLOCK_IN_STORE,
184+
// NB: Anycast because we technically accept any node but we arbitrarily choose the first in our address book.
185+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_ANYCAST,
182186
Message: nil,
183187
}
184188
sendDebugMessage(cmd, m)
185189
case PromptSendMetadataRequest:
186190
m := &messaging.DebugMessage{
187191
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_SEND_METADATA_REQ,
192+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_BROADCAST,
188193
Message: nil,
189194
}
190195
broadcastDebugMessage(cmd, m)
191196
case PromptSendBlockRequest:
192197
m := &messaging.DebugMessage{
193198
Action: messaging.DebugMessageAction_DEBUG_CONSENSUS_SEND_BLOCK_REQ,
199+
Type: messaging.DebugMessageRoutingType_DEBUG_MESSAGE_TYPE_BROADCAST,
194200
Message: nil,
195201
}
196202
broadcastDebugMessage(cmd, m)

app/docs/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.0.0.3] - 2023-03-20
11+
12+
- Adds message routing type field labels to debug CLI actions
13+
1014
## [0.0.0.2] - 2023-03-14
1115

1216
- Simplifies the debug CLI tooling by embedding private-keys.yaml manifest

shared/CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
77

88
## [Unreleased]
99

10+
## [0.0.0.40] - 2023-03-20
11+
12+
- Adds enum DebugMessageType for distinguishing message routing behavior
13+
1014
## [0.0.0.39] - 2023-03-09
1115

1216
- Fix diagrams in SLIP documentation to be in the correct order

shared/messaging/proto/debug_message.proto

+12-4
Original file line numberDiff line numberDiff line change
@@ -22,12 +22,20 @@ enum DebugMessageAction {
2222

2323
DEBUG_PERSISTENCE_CLEAR_STATE = 8;
2424
DEBUG_PERSISTENCE_RESET_TO_GENESIS = 9;
25-
26-
27-
2825
}
2926

3027
message DebugMessage {
3128
DebugMessageAction action = 1;
32-
google.protobuf.Any message = 2;
29+
DebugMessageRoutingType type = 2;
30+
google.protobuf.Any message = 3;
3331
}
32+
33+
// NB: See https://en.wikipedia.org/wiki/Routing for more info on routing and delivery schemes.
34+
enum DebugMessageRoutingType {
35+
DEBUG_MESSAGE_TYPE_UNKNOWN = 0;
36+
37+
DEBUG_MESSAGE_TYPE_ANYCAST = 1;
38+
DEBUG_MESSAGE_TYPE_MULTICAST = 2;
39+
DEBUG_MESSAGE_TYPE_BROADCAST = 3;
40+
DEBUG_MESSAGE_TYPE_UNICAST = 4;
41+
}

0 commit comments

Comments
 (0)