governance_instruction.proto 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365
  1. syntax = "proto3";
  2. import "google/protobuf/timestamp.proto";
  3. import "google/protobuf/duration.proto";
  4. import "google/protobuf/empty.proto";
  5. import "dynamic_value.proto";
  6. import "state.proto";
  7. // If any field documented as `[required]` is not present in the instruction,
  8. // the instruction will be rejected.
  9. package pyth_lazer;
  10. // Representation of a complete governance instruction. This value will be signed
  11. // by a governance source.
  12. //
  13. // If the governance source is SingleEd25519, this message will be the payload of LazerTransaction.
  14. //
  15. // If the governance source is Wormhole emitter, this message will be the body of the GovernancePayload which
  16. // is the VAA message Pyth governance sends to Wormhole. The GovernancePayload follows xc-admin spec
  17. // and looks like so:
  18. // <magic:u32><module:u8><action:u8><chain:u16><GovernanceInstruction:bytes>
  19. // You can find the xc-admin spec in: ../../../governance/xc_admin/packages/xc_admin_common/src/governance_payload
  20. message GovernanceInstruction {
  21. // Action requested by this instruction. For the instruction to be accepted, all items
  22. // must be successfully applied. In case of any failure, the whole instruction is reverted.
  23. // However, note that if the instruction targets multiple (or all) shards, each shard will
  24. // accept or reject the instruction independently of other shards.
  25. repeated GovernanceInstructionItem items = 2;
  26. // [optional] If specified, the instruction will be rejected if the current timestamp
  27. // is less than the specified value. In case of rejection, the same instruction can be resubmitted
  28. // and executed later once the time requirement is met.
  29. optional google.protobuf.Timestamp min_execution_timestamp = 3;
  30. // [optional] If specified, the instruction will be rejected if the current timestamp
  31. // is greater than the specified value. After `max_execution_timestamp` is in the past,
  32. // it will no longer be possible to execute this instruction.
  33. optional google.protobuf.Timestamp max_execution_timestamp = 4;
  34. // [optional] Sequence number of this instruction. Required for SingleEd25519 governance source
  35. // and optional for WomrholeEmitter governance source (because Wormhole has its own sequence
  36. // numbers). If set, it must be greater than 0, and always be increasing, but not required to be
  37. // strictly sequential (i.e. gaps are allowed). Each shard separately keeps track of the last
  38. // executed governance instruction and will reject instructions with the same or smaller
  39. // sequence no. Note that if instructions are received out of order, some of them may become
  40. // permanently rejected (e.g. if instruction #3 has been successfully processed before
  41. // instruction #2 was observed, #2 will always be rejected). Sequence numbers are assigned and
  42. // tracked separately for each governance source.
  43. optional uint32 governance_sequence_no = 5;
  44. }
  45. // Specifies which shards the governance instruction applies to.
  46. message ShardFilter {
  47. // The instruction applies to the specified shards.
  48. message ShardNames {
  49. // Must not be empty.
  50. repeated string shard_names = 1;
  51. }
  52. // The instruction applies to the specified shard groups.
  53. message ShardGroups {
  54. // Must not be empty.
  55. repeated string shard_groups = 1;
  56. }
  57. // [required]
  58. oneof filter {
  59. // The instruction applies to all shards.
  60. google.protobuf.Empty all_shards = 1;
  61. ShardNames shard_names = 2;
  62. ShardGroups shard_groups = 3;
  63. }
  64. }
  65. // An item of a governance instruction.
  66. message GovernanceInstructionItem {
  67. // [required] Specifies which shards the governance instruction applies to.
  68. // The instruction applies to each shard independently of other shards and may apply
  69. // at a different time. The instruction may succeed on some shards and fail on other shards.
  70. // Note that each shard has its own list of governance sources and permissions,
  71. // and a `GovernanceInstruction` is issued by a single source, so multiple instructions
  72. // from different sources may be needed to apply a change to multiple shards or shard groups.
  73. optional ShardFilter shard_filter = 1;
  74. // [required]
  75. // Note: when adding a new variant here, update `Permissions` as well.
  76. oneof action {
  77. CreateShard create_shard = 101;
  78. AddGovernanceSource add_governance_source = 102;
  79. UpdateGovernanceSource update_governance_source = 103;
  80. SetShardName set_shard_name = 105;
  81. SetShardGroup set_shard_group = 106;
  82. ResetLastSequenceNo reset_last_sequence_no = 107;
  83. AddPublisher add_publisher = 108;
  84. UpdatePublisher update_publisher = 109;
  85. RemovePublisher remove_publisher = 110;
  86. AddFeed add_feed = 111;
  87. UpdateFeed update_feed = 112;
  88. RemoveFeed remove_feed = 113;
  89. AddFeatureFlag add_feature_flag = 114;
  90. RemoveFeatureFlag remove_feature_flag = 115;
  91. }
  92. }
  93. // Create a new shard. A shard is a partially isolated part of Lazer that has its own state and
  94. // cannot be directly influenced by other shards. The main purpose of shards in Lazer is
  95. // to allow horizontal scaling when the number of feeds grows. Feeds can be divided into subsets
  96. // and each subset will be assigned to a shard.
  97. //
  98. // Shard name will be determined by the value of `GovernanceInstructionItem.filter`.
  99. // This action will be rejected unless `GovernanceInstructionItem.filter` specified a single shard.
  100. // Shard name must be unique across all shards in all groups.
  101. // (Warning: it's not possible to enforce this rule within a shard!)
  102. message CreateShard {
  103. // [required] ID of the new shard.
  104. // Shard ID must be unique across all shards in all groups.
  105. // (Warning: it's not possible to enforce this rule within a shard!)
  106. optional uint32 shard_id = 1;
  107. // [required] Group name, e.g. "production", "staging", "testing", etc.
  108. // Data from shards belonging to the same group can be joined and served to consumers as a whole.
  109. // Active feed names must be unique within a group, but not across all groups.
  110. optional string shard_group = 2;
  111. // [required] Minimal aggregation rate allowed in this shard.
  112. optional google.protobuf.Duration min_rate = 3;
  113. }
  114. message AddGovernanceSource {
  115. // [required] Governance source that should be added.
  116. optional GovernanceSource new_source = 1;
  117. // [required] Permissions granted to this source.
  118. optional Permissions permissions = 2;
  119. }
  120. message UpdateGovernanceSource {
  121. // [required] Governance source that should be updated. Rejects if there is no such source.
  122. // Rejects if the specified source is the same as the source of the current instruction.
  123. optional GovernanceSource source = 1;
  124. // [required]
  125. // Note: when adding a new variant here, update `Permissions` as well.
  126. oneof action {
  127. SetGovernanceSourcePermissions set_governance_source_permissions = 101;
  128. }
  129. }
  130. message SetGovernanceSourcePermissions {
  131. // [required] Permissions granted to this source. Replaces all previous permissions.
  132. optional Permissions permissions = 1;
  133. }
  134. // Set shard name. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
  135. // more than one item.
  136. message SetShardName {
  137. // [required] New shard name. Must be unique across all shards in all groups.
  138. // (Warning: it's not possible to enforce this rule within a shard!)
  139. optional string shard_name = 1;
  140. }
  141. // Set shard group. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
  142. // more than one item.
  143. message SetShardGroup {
  144. // [required] Group name, e.g. "production", "staging", "testing", etc.
  145. // Data from shards belonging to the same group can be joined and served to consumers as a whole.
  146. // Active feed names must be unique within a group, but not across all groups.
  147. optional string shard_group = 1;
  148. }
  149. // Set `last_sequence_no`. This can be used as a workaround in case some updates are lost and
  150. // the services are unable to proceed.
  151. message ResetLastSequenceNo {
  152. optional uint64 last_sequence_no = 1;
  153. }
  154. message AddPublisher {
  155. // [required] Publisher ID. Restricted to uint16. Must be different from existing ids.
  156. optional uint32 publisher_id = 1;
  157. // [required] Publisher name (only for debug/monitoring/management purposes).
  158. // Must be different from existing publisher names.
  159. optional string name = 2;
  160. // Public keys used to sign publisher update transactions.
  161. repeated bytes public_keys = 3;
  162. // [required] If true, the publisher is active, i.e. it's allowed to publish updates.
  163. optional bool is_active = 4;
  164. // IDs of the feeds for which the publisher's price will be included in the aggregate.
  165. repeated uint32 allowed_feed_ids = 5;
  166. }
  167. message UpdatePublisher {
  168. // [required] ID of the publisher that is being updated. Rejects if there is no such publisher.
  169. optional uint32 publisher_id = 1;
  170. // [required]
  171. // Note: when adding a new variant here, update `Permissions` as well.
  172. oneof action {
  173. SetPublisherName set_publisher_name = 101;
  174. AddPublisherPublicKeys add_publisher_public_keys = 102;
  175. RemovePublisherPublicKeys remove_publisher_public_keys = 103;
  176. SetPublisherPublicKeys set_publisher_public_keys = 104;
  177. SetPublisherActive set_publisher_active = 105;
  178. AddPublisherAllowedFeedIds add_publisher_allowed_feed_ids = 106;
  179. RemovePublisherAllowedFeedIds remove_publisher_allowed_feed_ids = 107;
  180. SetPublisherAllowedFeedIds set_publisher_allowed_feed_ids = 108;
  181. }
  182. }
  183. message RemovePublisher {
  184. // [required] ID of the publisher that is being deleted. Rejects if there is no such publisher.
  185. optional uint32 publisher_id = 1;
  186. }
  187. message SetPublisherName {
  188. // [required] New name.
  189. optional string name = 1;
  190. }
  191. // Add new keys.
  192. message AddPublisherPublicKeys {
  193. // Must not be empty.
  194. repeated bytes public_keys = 1;
  195. }
  196. // Remove existing keys.
  197. message RemovePublisherPublicKeys {
  198. // Must not be empty.
  199. repeated bytes public_keys = 1;
  200. }
  201. // Remove all existing public keys and add new keys (if specified).
  202. message SetPublisherPublicKeys {
  203. repeated bytes public_keys = 1;
  204. }
  205. // Allow publisher to publish for the specified feeds.
  206. message AddPublisherAllowedFeedIds {
  207. // Must not be empty.
  208. repeated bytes allowed_feed_ids_to_add = 1;
  209. }
  210. // Disallow publisher to publish for the specified feeds.
  211. message RemovePublisherAllowedFeedIds {
  212. // Must not be empty.
  213. repeated bytes allowed_feed_ids_to_remove = 1;
  214. }
  215. // Allow publisher to publish for only the specified feeds.
  216. // Remove all previous allowances.
  217. message SetPublisherAllowedFeedIds {
  218. repeated bytes allowed_feed_ids = 1;
  219. }
  220. message SetPublisherActive {
  221. // [required]
  222. optional bool is_active = 1;
  223. }
  224. // Add a new feed. Refer to `Feed` message fields documentation.
  225. message AddFeed {
  226. // [required]
  227. optional uint32 feed_id = 1;
  228. // [required]
  229. optional DynamicValue.Map metadata = 3;
  230. // [required]
  231. optional string name = 101;
  232. // [required]
  233. optional sint32 exponent = 102;
  234. // [required]
  235. optional uint32 min_publishers = 103;
  236. // [required]
  237. optional Channel min_channel = 104;
  238. // [required]
  239. optional google.protobuf.Duration expiry_time = 105;
  240. // [required]
  241. optional string market_schedule = 106;
  242. // [required]
  243. optional FeedState state = 107;
  244. // [required]
  245. optional FeedKind kind = 108;
  246. // [required]
  247. optional bool is_enabled_in_shard = 201;
  248. // TODO: IDs of publishers enabled for this feed.
  249. // repeated uint32 permissioned_publishers = 3;
  250. }
  251. message UpdateFeed {
  252. // [required] ID of the feed that is being updated. Rejects if there is no such feed.
  253. optional uint32 feed_id = 1;
  254. // [required]
  255. // Note: when adding a new variant here, update `Permissions` as well.
  256. oneof action {
  257. UpdateFeedProperties update_feed_properties = 101;
  258. UpdateFeedMetadata update_feed_metadata = 102;
  259. EnableFeedInShard enable_feed_in_shard = 103;
  260. DisableFeedInShard disable_feed_in_shard = 104;
  261. }
  262. }
  263. message RemoveFeed {
  264. // [required] ID of the feed that is being removed. Rejects if there is no such feed.
  265. optional uint32 feed_id = 1;
  266. }
  267. // Update a feed's properties. The feed will be updated with values present in each field.
  268. // If a value is not supplied, the corresponding property will remain unchanged.
  269. // Refer to `Feed` message fields documentation.
  270. message UpdateFeedProperties {
  271. // [optional]
  272. optional DynamicValue.Map metadata = 3;
  273. // [optional]
  274. optional string name = 101;
  275. // [optional]
  276. optional sint32 exponent = 102;
  277. // [optional]
  278. optional uint32 min_publishers = 103;
  279. // [optional]
  280. optional Channel min_channel = 104;
  281. // [optional]
  282. optional google.protobuf.Duration expiry_time = 105;
  283. // [optional]
  284. optional string market_schedule = 106;
  285. // [optional]
  286. optional FeedState state = 107;
  287. // [optional]
  288. optional bool is_enabled_in_shard = 201;
  289. }
  290. message UpdateFeedMetadata {
  291. // [required] Property name.
  292. optional string name = 1;
  293. // [optional] Property value. If unset, the property will be removed.
  294. optional DynamicValue value = 2;
  295. }
  296. // Set the feed as enabled in this shard or shedule it for a certain timestamp.
  297. // If there was already a pending status change, it will be cleared
  298. // when this governance instruction is processed.
  299. // Warning: there must never be two feeds with the same name enabled at the same time
  300. // within a shard group. This cannot be enforced within a shard. When a feed needs to be
  301. // moved between shards, use `enable_in_shard_timestamp` and `disable_in_shard_timestamp`
  302. // to disable it in the old shard and enable it in the new shard at the same time.
  303. message EnableFeedInShard {
  304. // [required] The feed will be enabled at the specified timestamp.
  305. // If `enable_in_shard_timestamp` is already passed,
  306. // the feed will be enabled immediately when this
  307. // governance instruction is processed.
  308. optional google.protobuf.Timestamp enable_in_shard_timestamp = 1;
  309. }
  310. // Set the feed as disabled in this shard or shedule it for a certain timestamp.
  311. // If there was already a pending status change, it will be cleared
  312. // when this governance instruction is processed.
  313. // See also: `EnableFeedInShard` docs.
  314. message DisableFeedInShard {
  315. // [required] The feed will be disabled at the specified timestamp.
  316. // If `disable_in_shard_timestamp` is already passed,
  317. // the feed will be disabled immediately when this
  318. // governance instruction is processed.
  319. optional google.protobuf.Timestamp disable_in_shard_timestamp = 1;
  320. }
  321. // Add a new feature flag.
  322. message AddFeatureFlag {
  323. // [required] Feature flag to add.
  324. optional string feature_flag = 1;
  325. }
  326. // Remove a feature flag.
  327. message RemoveFeatureFlag {
  328. // [required] Feature flag to remove.
  329. optional string feature_flag = 1;
  330. }