Skip to content

Commit b2fcf52

Browse files
authored
feat(lazer): update and improve governance proto (#2878)
* feat(lazer): update and improve governance proto * chore: bump pyth-lazer-publisher-sdk to 0.3.0
1 parent f933171 commit b2fcf52

File tree

2 files changed

+68
-49
lines changed

2 files changed

+68
-49
lines changed

lazer/publisher_sdk/proto/governance_instruction.proto

Lines changed: 62 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -23,11 +23,11 @@ package pyth_lazer;
2323
// <magic:u32><module:u8><action:u8><chain:u16><GovernanceInstruction:bytes>
2424
// You can find the xc-admin spec in: ../../../governance/xc_admin/packages/xc_admin_common/src/governance_payload
2525
message GovernanceInstruction {
26-
// Action requested by this instruction. For the instruction to be accepted, all directives
26+
// Action requested by this instruction. For the instruction to be accepted, all items
2727
// must be successfully applied. In case of any failure, the whole instruction is reverted.
2828
// However, note that if the instruction targets multiple (or all) shards, each shard will
2929
// accept or reject the instruction independently of other shards.
30-
repeated GovernanceDirective directives = 2;
30+
repeated GovernanceInstructionItem items = 2;
3131
// [optional] If specified, the instruction will be rejected if the current timestamp
3232
// is less than the specified value. In case of rejection, the same instruction can be resubmitted
3333
// and executed later once the time requirement is met.
@@ -70,7 +70,7 @@ message ShardFilter {
7070
}
7171

7272
// An item of a governance instruction.
73-
message GovernanceDirective {
73+
message GovernanceInstructionItem {
7474
// [required] Specifies which shards the governance instruction applies to.
7575
// The instruction applies to each shard independently of other shards and may apply
7676
// at a different time. The instruction may succeed on some shards and fail on other shards.
@@ -84,13 +84,16 @@ message GovernanceDirective {
8484
CreateShard create_shard = 101;
8585
AddGovernanceSource add_governance_source = 102;
8686
UpdateGovernanceSource update_governance_source = 103;
87-
SetShardName set_shard_name = 104;
88-
SetShardGroup set_shard_group = 105;
89-
ResetLastSequenceNo reset_last_sequence_no = 106;
90-
AddPublisher add_publisher = 107;
91-
UpdatePublisher update_publisher = 108;
92-
AddFeed add_feed = 109;
93-
UpdateFeed update_feed = 110;
87+
RemoveGovernanceSource remove_governance_source = 104;
88+
SetShardName set_shard_name = 105;
89+
SetShardGroup set_shard_group = 106;
90+
ResetLastSequenceNo reset_last_sequence_no = 107;
91+
AddPublisher add_publisher = 108;
92+
UpdatePublisher update_publisher = 109;
93+
RemovePublisher remove_publisher = 110;
94+
AddFeed add_feed = 111;
95+
UpdateFeed update_feed = 112;
96+
RemoveFeed remove_feed = 113;
9497
}
9598
}
9699

@@ -100,21 +103,33 @@ message Permissions {
100103
enum ShardAction {
101104
// Required by protobuf. Instruction will be rejected if this value is encountered.
102105
SHARD_ACTION_UNSPECIFIED = 0;
106+
// All operations, including operations added in the future.
107+
ALL_ACTIONS = 1;
103108
CREATE_SHARD = 101;
104109
ADD_GOVERNANCE_SOURCE = 102;
110+
// All operations under `UpdateGovernanceSource`,
111+
// including operations added in the future.
105112
UPDATE_GOVERNANCE_SOURCE = 103;
106-
SET_SHARD_NAME = 104;
107-
SET_SHARD_GROUP = 105;
108-
RESET_LAST_SEQUENCE_NO = 106;
109-
ADD_PUBLISHER = 107;
110-
ADD_FEED = 109;
113+
REMOVE_GOVERNANCE_SOURCE = 104;
114+
SET_SHARD_NAME = 105;
115+
SET_SHARD_GROUP = 106;
116+
RESET_LAST_SEQUENCE_NO = 107;
117+
ADD_PUBLISHER = 108;
118+
// All operations under `UpdatePublisher`,
119+
// including operations added in the future.
120+
UPDATE_PUBLISHER = 109;
121+
REMOVE_PUBLISHER = 110;
122+
ADD_FEED = 111;
123+
// All operations under `UpdateFeed`,
124+
// including operations added in the future.
125+
UPDATE_FEED = 112;
126+
REMOVE_FEED = 113;
111127
}
112128

113129
enum UpdateGovernanceSourceAction {
114130
// Required by protobuf. Instruction will be rejected if this value is encountered.
115131
UPDATE_GOVERNANCE_SOURCE_ACTION_UNSPECIFIED = 0;
116132
SET_GOVERNANCE_SOURCE_PERMISSIONS = 101;
117-
REMOVE_GOVERNANCE_SOURCE = 199;
118133
}
119134

120135
enum UpdatePublisherAction {
@@ -125,7 +140,6 @@ message Permissions {
125140
REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
126141
SET_PUBLISHER_PUBLIC_KEYS = 104;
127142
SET_PUBLISHER_ACTIVE = 105;
128-
REMOVE_PUBLISHER = 199;
129143
}
130144

131145
enum UpdateFeedAction {
@@ -135,24 +149,12 @@ message Permissions {
135149
UPDATE_FEED_METADATA = 102;
136150
ENABLE_FEED_IN_SHARD = 103;
137151
DISABLE_FEED_IN_SHARD = 104;
138-
REMOVE_FEED = 199;
139152
}
140153

141-
// All operations, including operations added in the future.
142-
optional bool all_actions = 1;
143-
repeated ShardAction shard_actions = 2;
144-
// All operations under `UpdateGovernanceSource` (update and delete),
145-
// including operations added in the future.
146-
optional bool all_update_governance_source_actions = 3;
147-
repeated UpdateGovernanceSourceAction update_governance_source_actions = 4;
148-
// All operations under `UpdatePublisher` (update and delete),
149-
// including operations added in the future.
150-
optional bool all_update_publisher_action = 5;
151-
repeated UpdatePublisherAction update_publisher_actions = 6;
152-
// All operations under `UpdateFeed` (update and delete),
153-
// including operations added in the future.
154-
optional bool all_update_feed_actions = 7;
155-
repeated UpdateFeedAction update_feed_actions = 8;
154+
repeated ShardAction actions = 1;
155+
repeated UpdateGovernanceSourceAction update_governance_source_actions = 2;
156+
repeated UpdatePublisherAction update_publisher_actions = 3;
157+
repeated UpdateFeedAction update_feed_actions = 4;
156158
}
157159

158160
// Specifies the way governance transactions are signed and verified.
@@ -183,8 +185,8 @@ message GovernanceSource {
183185
// to allow horizontal scaling when the number of feeds grows. Feeds can be divided into subsets
184186
// and each subset will be assigned to a shard.
185187
//
186-
// Shard name will be determined by the value of `GovernanceDirective.filter`.
187-
// This action will be rejected unless `GovernanceDirective.filter` specified a single shard.
188+
// Shard name will be determined by the value of `GovernanceInstructionItem.filter`.
189+
// This action will be rejected unless `GovernanceInstructionItem.filter` specified a single shard.
188190
// Shard name must be unique across all shards in all groups.
189191
// (Warning: it's not possible to enforce this rule within a shard!)
190192
message CreateShard {
@@ -215,10 +217,6 @@ message UpdateGovernanceSource {
215217
// Note: when adding a new variant here, update `Permissions` as well.
216218
oneof action {
217219
SetGovernanceSourcePermissions set_governance_source_permissions = 101;
218-
// Removes a governance source. Note that the last sequence number associated with this source
219-
// will be retained in the state to prevent repeated execution of instructions in case
220-
// the same source is re-added later.
221-
google.protobuf.Empty remove_governance_source = 199;
222220
}
223221
}
224222

@@ -227,15 +225,24 @@ message SetGovernanceSourcePermissions {
227225
optional Permissions permissions = 1;
228226
}
229227

230-
// Set shard name. This action will be rejected if `GovernanceDirective.shard_names` is empty or contains
228+
// Removes a governance source. Note that the last sequence number associated with this source
229+
// will be retained in the state to prevent repeated execution of instructions in case
230+
// the same source is re-added later.
231+
message RemoveGovernanceSource {
232+
// [required] Governance source that should be deleted. Rejects if there is no such source.
233+
// Rejects if the specified source is the same as the source of the current instruction.
234+
optional GovernanceSource source = 1;
235+
}
236+
237+
// Set shard name. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
231238
// more than one item.
232239
message SetShardName {
233240
// [required] New shard name. Must be unique across all shards in all groups.
234241
// (Warning: it's not possible to enforce this rule within a shard!)
235242
optional string shard_name = 1;
236243
}
237244

238-
// Set shard group. This action will be rejected if `GovernanceDirective.shard_names` is empty or contains
245+
// Set shard group. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
239246
// more than one item.
240247
message SetShardGroup {
241248
// [required] Group name, e.g. "production", "staging", "testing", etc.
@@ -273,10 +280,14 @@ message UpdatePublisher {
273280
RemovePublisherPublicKeys remove_publisher_public_keys = 103;
274281
SetPublisherPublicKeys set_publisher_public_keys = 104;
275282
SetPublisherActive set_publisher_active = 105;
276-
google.protobuf.Empty remove_publisher = 199;
277283
}
278284
}
279285

286+
message RemovePublisher {
287+
// [required] ID of the publisher that is being deleted. Rejects if there is no such publisher.
288+
optional uint32 publisher_id = 1;
289+
}
290+
280291
message SetPublisherName {
281292
// [required] New name.
282293
optional string name = 1;
@@ -343,10 +354,14 @@ message UpdateFeed {
343354
UpdateFeedMetadata update_feed_metadata = 102;
344355
EnableFeedInShard enable_feed_in_shard = 103;
345356
DisableFeedInShard disable_feed_in_shard = 104;
346-
google.protobuf.Empty remove_feed = 199;
347357
}
348358
}
349359

360+
message RemoveFeed {
361+
// [required] ID of the feed that is being removed. Rejects if there is no such feed.
362+
optional uint32 feed_id = 1;
363+
}
364+
350365
// Update a feed's properties. The feed will be updated with values present in each field.
351366
// If a value is not supplied, the corresponding property will remain unchanged.
352367
// Refer to `Feed` message fields documentation.
@@ -386,8 +401,8 @@ message UpdateFeedMetadata {
386401
// moved between shards, use `enable_in_shard_timestamp` and `disable_in_shard_timestamp`
387402
// to disable it in the old shard and enable it in the new shard at the same time.
388403
message EnableFeedInShard {
389-
// [optional] If provided, the feed will be enabled at the specified timestamp.
390-
// If `enable_in_shard_timestamp` is already passed or if it's unset,
404+
// [required] The feed will be enabled at the specified timestamp.
405+
// If `enable_in_shard_timestamp` is already passed,
391406
// the feed will be enabled immediately when this
392407
// governance instruction is processed.
393408
optional google.protobuf.Timestamp enable_in_shard_timestamp = 1;
@@ -398,8 +413,8 @@ message EnableFeedInShard {
398413
// when this governance instruction is processed.
399414
// See also: `EnableFeedInShard` docs.
400415
message DisableFeedInShard {
401-
// [optional] If provided, the feed will be disabled at the specified timestamp.
402-
// If `disable_in_shard_timestamp` is already passed or if it's unset,
416+
// [required] The feed will be disabled at the specified timestamp.
417+
// If `disable_in_shard_timestamp` is already passed,
403418
// the feed will be disabled immediately when this
404419
// governance instruction is processed.
405420
optional google.protobuf.Timestamp disable_in_shard_timestamp = 1;

lazer/publisher_sdk/proto/state.proto

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,10 +23,14 @@ message State {
2323
// [required] Timestamp of the last update provided by Kafka/Nats.
2424
// If no updates were applied, contains the timestamp of genesis snapshot creation time.
2525
optional google.protobuf.Timestamp last_timestamp = 3;
26-
// [required] Shard name (only for debug/monitoring/management purposes). Must be unique.
26+
// [required] Shard name. Must be unique. Used for governance instruction targeting and
27+
// for logs, metrics, etc. Example: "shard1.tokyo.staging.pyth-lazer"
2728
optional string shard_name = 4;
29+
// [required] Shard group name. Used for governance instruction targeting.
30+
// Example: "tokyo.staging.pyth-lazer"
31+
optional string shard_group = 5;
2832
// [required] Minimal aggregation rate allowed in this shard.
29-
optional google.protobuf.Duration min_rate = 5;
33+
optional google.protobuf.Duration min_rate = 6;
3034
// List of feeds.
3135
repeated Feed feeds = 7;
3236
// List of publishers.

0 commit comments

Comments
 (0)