Przeglądaj źródła

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
Pavel Strakhov 3 miesięcy temu
rodzic
commit
b2fcf52895

+ 62 - 47
lazer/publisher_sdk/proto/governance_instruction.proto

@@ -23,11 +23,11 @@ package pyth_lazer;
 // <magic:u32><module:u8><action:u8><chain:u16><GovernanceInstruction:bytes>
 // You can find the xc-admin spec in: ../../../governance/xc_admin/packages/xc_admin_common/src/governance_payload
 message GovernanceInstruction {
-    // Action requested by this instruction. For the instruction to be accepted, all directives
+    // Action requested by this instruction. For the instruction to be accepted, all items
     // must be successfully applied. In case of any failure, the whole instruction is reverted.
     // However, note that if the instruction targets multiple (or all) shards, each shard will
     // accept or reject the instruction independently of other shards.
-    repeated GovernanceDirective directives = 2;
+    repeated GovernanceInstructionItem items = 2;
     // [optional] If specified, the instruction will be rejected if the current timestamp
     // is less than the specified value. In case of rejection, the same instruction can be resubmitted
     // and executed later once the time requirement is met.
@@ -70,7 +70,7 @@ message ShardFilter {
 }
 
 // An item of a governance instruction.
-message GovernanceDirective {
+message GovernanceInstructionItem {
     // [required] Specifies which shards the governance instruction applies to.
     // The instruction applies to each shard independently of other shards and may apply
     // at a different time. The instruction may succeed on some shards and fail on other shards.
@@ -84,13 +84,16 @@ message GovernanceDirective {
         CreateShard create_shard = 101;
         AddGovernanceSource add_governance_source = 102;
         UpdateGovernanceSource update_governance_source = 103;
-        SetShardName set_shard_name = 104;
-        SetShardGroup set_shard_group = 105;
-        ResetLastSequenceNo reset_last_sequence_no = 106;
-        AddPublisher add_publisher = 107;
-        UpdatePublisher update_publisher = 108;
-        AddFeed add_feed = 109;
-        UpdateFeed update_feed = 110;
+        RemoveGovernanceSource remove_governance_source = 104;
+        SetShardName set_shard_name = 105;
+        SetShardGroup set_shard_group = 106;
+        ResetLastSequenceNo reset_last_sequence_no = 107;
+        AddPublisher add_publisher = 108;
+        UpdatePublisher update_publisher = 109;
+        RemovePublisher remove_publisher = 110;
+        AddFeed add_feed = 111;
+        UpdateFeed update_feed = 112;
+        RemoveFeed remove_feed = 113;
     }
 }
 
@@ -100,21 +103,33 @@ message Permissions {
     enum ShardAction {
         // Required by protobuf. Instruction will be rejected if this value is encountered.
         SHARD_ACTION_UNSPECIFIED = 0;
+        // All operations, including operations added in the future.
+        ALL_ACTIONS = 1;
         CREATE_SHARD = 101;
         ADD_GOVERNANCE_SOURCE = 102;
+        // All operations under `UpdateGovernanceSource`,
+        // including operations added in the future.
         UPDATE_GOVERNANCE_SOURCE = 103;
-        SET_SHARD_NAME = 104;
-        SET_SHARD_GROUP = 105;
-        RESET_LAST_SEQUENCE_NO = 106;
-        ADD_PUBLISHER = 107;
-        ADD_FEED = 109;
+        REMOVE_GOVERNANCE_SOURCE = 104;
+        SET_SHARD_NAME = 105;
+        SET_SHARD_GROUP = 106;
+        RESET_LAST_SEQUENCE_NO = 107;
+        ADD_PUBLISHER = 108;
+        // All operations under `UpdatePublisher`,
+        // including operations added in the future.
+        UPDATE_PUBLISHER = 109;
+        REMOVE_PUBLISHER = 110;
+        ADD_FEED = 111;
+        // All operations under `UpdateFeed`,
+        // including operations added in the future.
+        UPDATE_FEED = 112;
+        REMOVE_FEED = 113;
     }
 
     enum UpdateGovernanceSourceAction {
         // Required by protobuf. Instruction will be rejected if this value is encountered.
         UPDATE_GOVERNANCE_SOURCE_ACTION_UNSPECIFIED = 0;
         SET_GOVERNANCE_SOURCE_PERMISSIONS = 101;
-        REMOVE_GOVERNANCE_SOURCE = 199;
     }
 
     enum UpdatePublisherAction {
@@ -125,7 +140,6 @@ message Permissions {
         REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
         SET_PUBLISHER_PUBLIC_KEYS = 104;
         SET_PUBLISHER_ACTIVE = 105;
-        REMOVE_PUBLISHER = 199;
     }
 
     enum UpdateFeedAction {
@@ -135,24 +149,12 @@ message Permissions {
         UPDATE_FEED_METADATA = 102;
         ENABLE_FEED_IN_SHARD = 103;
         DISABLE_FEED_IN_SHARD = 104;
-        REMOVE_FEED = 199;
     }
 
-    // All operations, including operations added in the future.
-    optional bool all_actions = 1;
-    repeated ShardAction shard_actions = 2;
-    // All operations under `UpdateGovernanceSource` (update and delete),
-    // including operations added in the future.
-    optional bool all_update_governance_source_actions = 3;
-    repeated UpdateGovernanceSourceAction update_governance_source_actions = 4;
-    // All operations under `UpdatePublisher` (update and delete),
-    // including operations added in the future.
-    optional bool all_update_publisher_action = 5;
-    repeated UpdatePublisherAction update_publisher_actions = 6;
-    // All operations under `UpdateFeed` (update and delete),
-    // including operations added in the future.
-    optional bool all_update_feed_actions = 7;
-    repeated UpdateFeedAction update_feed_actions = 8;
+    repeated ShardAction actions = 1;
+    repeated UpdateGovernanceSourceAction update_governance_source_actions = 2;
+    repeated UpdatePublisherAction update_publisher_actions = 3;
+    repeated UpdateFeedAction update_feed_actions = 4;
 }
 
 // Specifies the way governance transactions are signed and verified.
@@ -183,8 +185,8 @@ message GovernanceSource {
 // to allow horizontal scaling when the number of feeds grows. Feeds can be divided into subsets
 // and each subset will be assigned to a shard.
 //
-// Shard name will be determined by the value of `GovernanceDirective.filter`.
-// This action will be rejected unless `GovernanceDirective.filter` specified a single shard.
+// Shard name will be determined by the value of `GovernanceInstructionItem.filter`.
+// This action will be rejected unless `GovernanceInstructionItem.filter` specified a single shard.
 // Shard name must be unique across all shards in all groups.
 // (Warning: it's not possible to enforce this rule within a shard!)
 message CreateShard {
@@ -215,10 +217,6 @@ message UpdateGovernanceSource {
     // Note: when adding a new variant here, update `Permissions` as well.
     oneof action {
         SetGovernanceSourcePermissions set_governance_source_permissions = 101;
-        // Removes a governance source. Note that the last sequence number associated with this source
-        // will be retained in the state to prevent repeated execution of instructions in case
-        // the same source is re-added later.
-        google.protobuf.Empty remove_governance_source = 199;
     }
 }
 
@@ -227,7 +225,16 @@ message SetGovernanceSourcePermissions {
     optional Permissions permissions = 1;
 }
 
-// Set shard name. This action will be rejected if `GovernanceDirective.shard_names` is empty or contains
+// Removes a governance source. Note that the last sequence number associated with this source
+// will be retained in the state to prevent repeated execution of instructions in case
+// the same source is re-added later.
+message RemoveGovernanceSource {
+    // [required] Governance source that should be deleted. Rejects if there is no such source.
+    // Rejects if the specified source is the same as the source of the current instruction.
+    optional GovernanceSource source = 1;
+}
+
+// Set shard name. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
 // more than one item.
 message SetShardName {
     // [required] New shard name. Must be unique across all shards in all groups.
@@ -235,7 +242,7 @@ message SetShardName {
     optional string shard_name = 1;
 }
 
-// Set shard group. This action will be rejected if `GovernanceDirective.shard_names` is empty or contains
+// Set shard group. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
 // more than one item.
 message SetShardGroup {
     // [required] Group name, e.g. "production", "staging", "testing", etc.
@@ -273,10 +280,14 @@ message UpdatePublisher {
         RemovePublisherPublicKeys remove_publisher_public_keys = 103;
         SetPublisherPublicKeys set_publisher_public_keys = 104;
         SetPublisherActive set_publisher_active = 105;
-        google.protobuf.Empty remove_publisher = 199;
     }
 }
 
+message RemovePublisher {
+    // [required] ID of the publisher that is being deleted. Rejects if there is no such publisher.
+    optional uint32 publisher_id = 1;
+}
+
 message SetPublisherName {
     // [required] New name.
     optional string name = 1;
@@ -343,10 +354,14 @@ message UpdateFeed {
         UpdateFeedMetadata update_feed_metadata = 102;
         EnableFeedInShard enable_feed_in_shard = 103;
         DisableFeedInShard disable_feed_in_shard = 104;
-        google.protobuf.Empty remove_feed = 199;
     }
 }
 
+message RemoveFeed {
+    // [required] ID of the feed that is being removed. Rejects if there is no such feed.
+    optional uint32 feed_id = 1;
+}
+
 // Update a feed's properties. The feed will be updated with values present in each field.
 // If a value is not supplied, the corresponding property will remain unchanged.
 // Refer to `Feed` message fields documentation.
@@ -386,8 +401,8 @@ message UpdateFeedMetadata {
 // moved between shards, use `enable_in_shard_timestamp` and `disable_in_shard_timestamp`
 // to disable it in the old shard and enable it in the new shard at the same time.
 message EnableFeedInShard {
-    // [optional] If provided, the feed will be enabled at the specified timestamp.
-    // If `enable_in_shard_timestamp` is already passed or if it's unset,
+    // [required] The feed will be enabled at the specified timestamp.
+    // If `enable_in_shard_timestamp` is already passed,
     // the feed will be enabled immediately when this
     // governance instruction is processed.
     optional google.protobuf.Timestamp enable_in_shard_timestamp = 1;
@@ -398,8 +413,8 @@ message EnableFeedInShard {
 // when this governance instruction is processed.
 // See also: `EnableFeedInShard` docs.
 message DisableFeedInShard {
-    // [optional] If provided, the feed will be disabled at the specified timestamp.
-    // If `disable_in_shard_timestamp` is already passed or if it's unset,
+    // [required] The feed will be disabled at the specified timestamp.
+    // If `disable_in_shard_timestamp` is already passed,
     // the feed will be disabled immediately when this
     // governance instruction is processed.
     optional google.protobuf.Timestamp disable_in_shard_timestamp = 1;

+ 6 - 2
lazer/publisher_sdk/proto/state.proto

@@ -23,10 +23,14 @@ message State {
     // [required] Timestamp of the last update provided by Kafka/Nats.
     // If no updates were applied, contains the timestamp of genesis snapshot creation time.
     optional google.protobuf.Timestamp last_timestamp = 3;
-    // [required] Shard name (only for debug/monitoring/management purposes). Must be unique.
+    // [required] Shard name. Must be unique. Used for governance instruction targeting and
+    // for logs, metrics, etc. Example: "shard1.tokyo.staging.pyth-lazer"
     optional string shard_name = 4;
+    // [required] Shard group name. Used for governance instruction targeting.
+    // Example: "tokyo.staging.pyth-lazer"
+    optional string shard_group = 5;
     // [required] Minimal aggregation rate allowed in this shard.
-    optional google.protobuf.Duration min_rate = 5;
+    optional google.protobuf.Duration min_rate = 6;
     // List of feeds.
     repeated Feed feeds = 7;
     // List of publishers.