Skip to content

Commit f9bc4ac

Browse files
committed
feat(lazer): more governance improvements
1 parent 37075b1 commit f9bc4ac

File tree

2 files changed

+105
-44
lines changed

2 files changed

+105
-44
lines changed

lazer/publisher_sdk/proto/governance_instruction.proto

Lines changed: 101 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -69,55 +69,85 @@ message GovernanceDirective {
6969
// from different sources may be needed to apply a change to multiple shards or shard groups.
7070
optional ShardFilter shard_filter = 1;
7171
// [required]
72+
// Note: when adding a new variant here, update `Permissions` as well.
7273
oneof action {
73-
AddGovernanceSource add_governance_source = 101;
74-
UpdateGovernanceSource update_governance_source = 102;
75-
SetShardName set_shard_name = 103;
76-
SetShardGroup set_shard_group = 104;
77-
AddPublisher add_publisher = 105;
78-
UpdatePublisher update_publisher = 106;
79-
AddFeed add_feed = 107;
80-
UpdateFeed update_feed = 108;
74+
CreateShard create_shard = 101;
75+
AddGovernanceSource add_governance_source = 102;
76+
UpdateGovernanceSource update_governance_source = 103;
77+
SetShardName set_shard_name = 104;
78+
SetShardGroup set_shard_group = 105;
79+
ResetLastSequenceNo reset_last_sequence_no = 106;
80+
AddPublisher add_publisher = 107;
81+
UpdatePublisher update_publisher = 108;
82+
AddFeed add_feed = 109;
83+
UpdateFeed update_feed = 110;
8184
}
8285
}
8386

8487
// Permissions granted to a governance source.
8588
// bool fields in this message are optional and default to false (no permission).
8689
message Permissions {
90+
enum ShardAction {
91+
// Required by protobuf. Instruction will be rejected if this value is encountered.
92+
SHARD_ACTION_UNSPECIFIED = 0;
93+
CREATE_SHARD = 101;
94+
ADD_GOVERNANCE_SOURCE = 102;
95+
UPDATE_GOVERNANCE_SOURCE = 103;
96+
SET_SHARD_NAME = 104;
97+
SET_SHARD_GROUP = 105;
98+
RESET_LAST_SEQUENCE_NO = 106;
99+
ADD_PUBLISHER = 107;
100+
ADD_FEED = 109;
101+
}
102+
103+
enum UpdateGovernanceSourceAction {
104+
// Required by protobuf. Instruction will be rejected if this value is encountered.
105+
UPDATE_GOVERNANCE_SOURCE_ACTION_UNSPECIFIED = 0;
106+
SET_GOVERNANCE_SOURCE_PERMISSIONS = 101;
107+
REMOVE_GOVERNANCE_SOURCE = 199;
108+
}
109+
110+
enum UpdatePublisherAction {
111+
// Required by protobuf. Instruction will be rejected if this value is encountered.
112+
UPDATE_PUBLISHER_ACTION_UNSPECIFIED = 0;
113+
SET_PUBLISHER_NAME = 101;
114+
ADD_PUBLISHER_PUBLIC_KEYS = 102;
115+
REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
116+
SET_PUBLISHER_PUBLIC_KEYS = 104;
117+
SET_PUBLISHER_ACTIVE = 105;
118+
REMOVE_PUBLISHER = 199;
119+
}
120+
121+
enum UpdateFeedAction {
122+
// Required by protobuf. Instruction will be rejected if this value is encountered.
123+
UPDATE_FEED_ACTION_UNSPECIFIED = 0;
124+
UPDATE_FEED_METADATA = 101;
125+
ACTIVATE_FEED = 102;
126+
DEACTIVATE_FEED = 103;
127+
REMOVE_FEED = 199;
128+
}
129+
87130
// All operations, including operations added in the future.
88-
optional bool all = 1;
89-
optional bool add_governance_source = 2;
131+
optional bool all_actions = 1;
132+
repeated ShardAction shard_actions = 2;
90133
// All operations under `UpdateGovernanceSource` (update and delete),
91134
// including operations added in the future.
92-
optional bool update_governance_source_all = 3;
93-
optional bool update_governance_source_permissions = 4;
94-
optional bool remove_governance_source = 5;
95-
optional bool set_shard_name = 6;
96-
optional bool set_shard_group = 7;
97-
optional bool add_publisher = 8;
135+
optional bool all_update_governance_source_actions = 3;
136+
repeated UpdateGovernanceSourceAction update_governance_source_actions = 4;
98137
// All operations under `UpdatePublisher` (update and delete),
99138
// including operations added in the future.
100-
optional bool update_publisher_all = 9;
101-
optional bool set_publisher_name = 10;
102-
optional bool add_publisher_public_keys = 11;
103-
optional bool remove_publisher_public_keys = 12;
104-
optional bool set_publisher_public_keys = 13;
105-
optional bool set_publisher_active = 14;
106-
optional bool remove_publisher = 15;
107-
optional bool add_feed = 16;
139+
optional bool all_update_publisher_action = 5;
140+
repeated UpdatePublisherAction update_publisher_actions = 6;
108141
// All operations under `UpdateFeed` (update and delete),
109142
// including operations added in the future.
110-
optional bool update_feed_all = 17;
111-
optional bool update_feed_metadata = 18;
112-
optional bool activate_feed = 19;
113-
optional bool deactivate_feed = 20;
114-
optional bool remove_feed = 21;
143+
optional bool all_update_feed_actions = 7;
144+
repeated UpdateFeedAction update_feed_actions = 8;
115145
}
116146

117147
// Specifies the way governance transactions are signed and verified.
118148
message GovernanceSource {
119149
// Governance transactions are signed by a single Ed25519 signature.
120-
// This will generally be used in development and testing environments.
150+
// This will generally be used in development and testing groups.
121151
message SingleEd25519 {
122152
// [required] Ed25519 public key that signs governance transactions.
123153
optional bytes public_key = 1;
@@ -130,6 +160,23 @@ message GovernanceSource {
130160
}
131161
}
132162

163+
// Create a new shard. Shard name will be determined by the value of `GovernanceDirective.filter`.
164+
// This action will be rejected unless `GovernanceDirective.filter` specified a single shard.
165+
// Shard name must be unique across all shards in all groups.
166+
// (Warning: it's not possible to enforce this rule within a shard!)
167+
message CreateShard {
168+
// [required] ID of the new shard.
169+
// Shard ID must be unique across all shards in all groups.
170+
// (Warning: it's not possible to enforce this rule within a shard!)
171+
optional uint32 shard_id = 1;
172+
// [required] Group name, e.g. "production", "staging", "testing", etc.
173+
// Data from shards belonging to the same group can be joined and served to consumers as a whole.
174+
// Active feed names must be unique within a group, but not across all groups.
175+
optional string shard_group = 2;
176+
// [required] Minimal aggregation rate allowed in this shard.
177+
optional google.protobuf.Duration min_rate = 3;
178+
}
179+
133180
message AddGovernanceSource {
134181
// [required] Governance source that should be added.
135182
optional GovernanceSource new_source = 1;
@@ -139,26 +186,28 @@ message AddGovernanceSource {
139186

140187
message UpdateGovernanceSource {
141188
// [required] Governance source that should be updated. Rejects if there is no such source.
189+
// Rejects if the specified source is the same as the source of the current instruction.
142190
optional GovernanceSource source = 1;
143191
// [required]
192+
// Note: when adding a new variant here, update `Permissions` as well.
144193
oneof action {
145-
SetGovernanceSourcePermissions set_governance_source_permissions = 2;
194+
SetGovernanceSourcePermissions set_governance_source_permissions = 101;
146195
// Removes a governance source. Note that the last sequence number associated with this source
147196
// will be retained in the state to prevent repeated execution of instructions in case
148197
// the same source is re-added later.
149-
google.protobuf.Empty remove_governance_source = 3;
198+
google.protobuf.Empty remove_governance_source = 199;
150199
}
151200
}
152201

153202
message SetGovernanceSourcePermissions {
154203
// [required] Permissions granted to this source. Replaces all previous permissions.
155-
optional Permissions permissions = 2;
204+
optional Permissions permissions = 1;
156205
}
157206

158207
// Set shard name. This action will be rejected if `GovernanceDirective.shard_names` is empty or contains
159208
// more than one item.
160209
message SetShardName {
161-
// [required] New shard name. Must be unique across all shards in all environments.
210+
// [required] New shard name. Must be unique across all shards in all groups.
162211
// (Warning: it's not possible to enforce this rule within a shard!)
163212
optional string shard_name = 1;
164213
}
@@ -172,6 +221,12 @@ message SetShardGroup {
172221
optional string shard_group = 1;
173222
}
174223

224+
// Set `last_sequence_no`. This can be used as a workaround in case some updates are lost and
225+
// the services are unable to proceed.
226+
message ResetLastSequenceNo {
227+
optional uint64 last_sequence_no = 1;
228+
}
229+
175230
message AddPublisher {
176231
// [required] Publisher ID. Restricted to uint16. Must be different from existing ids.
177232
optional uint32 publisher_id = 1;
@@ -188,13 +243,14 @@ message UpdatePublisher {
188243
// [required] ID of the publisher that is being updated. Rejects if there is no such publisher.
189244
optional uint32 publisher_id = 1;
190245
// [required]
246+
// Note: when adding a new variant here, update `Permissions` as well.
191247
oneof action {
192-
SetPublisherName set_publisher_name = 2;
193-
AddPublisherPublicKeys add_publisher_public_keys = 3;
194-
RemovePublisherPublicKeys remove_publisher_public_keys = 4;
195-
SetPublisherPublicKeys set_publisher_public_keys = 5;
196-
SetPublisherActive set_publisher_active = 6;
197-
google.protobuf.Empty remove_publisher = 7;
248+
SetPublisherName set_publisher_name = 101;
249+
AddPublisherPublicKeys add_publisher_public_keys = 102;
250+
RemovePublisherPublicKeys remove_publisher_public_keys = 103;
251+
SetPublisherPublicKeys set_publisher_public_keys = 104;
252+
SetPublisherActive set_publisher_active = 105;
253+
google.protobuf.Empty remove_publisher = 199;
198254
}
199255
}
200256

@@ -242,11 +298,12 @@ message UpdateFeed {
242298
// [required] ID of the feed that is being updated. Rejects if there is no such feed.
243299
optional uint32 price_feed_id = 1;
244300
// [required]
301+
// Note: when adding a new variant here, update `Permissions` as well.
245302
oneof action {
246-
UpdateFeedMetadata update_feed_metadata = 2;
247-
ActivateFeed activate_feed = 3;
248-
DeactivateFeed deactivate_feed = 4;
249-
google.protobuf.Empty remove_feed = 5;
303+
UpdateFeedMetadata update_feed_metadata = 101;
304+
ActivateFeed activate_feed = 102;
305+
DeactivateFeed deactivate_feed = 103;
306+
google.protobuf.Empty remove_feed = 199;
250307
}
251308
}
252309

lazer/publisher_sdk/rust/src/lib.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ pub mod publisher_update {
66
pub use crate::protobuf::publisher_update::*;
77
}
88

9+
pub mod governance_instruction {
10+
pub use crate::protobuf::governance_instruction::*;
11+
}
12+
913
mod protobuf {
1014
include!(concat!(env!("OUT_DIR"), "/protobuf/mod.rs"));
1115
}

0 commit comments

Comments
 (0)