Skip to content

Commit 50e76e0

Browse files
authored
feat(lazer): add governance sources info to state (#2927)
1 parent 5d7c6af commit 50e76e0

File tree

4 files changed

+100
-96
lines changed

4 files changed

+100
-96
lines changed

Cargo.lock

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

lazer/publisher_sdk/proto/governance_instruction.proto

Lines changed: 0 additions & 93 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,6 @@ message GovernanceInstructionItem {
8484
CreateShard create_shard = 101;
8585
AddGovernanceSource add_governance_source = 102;
8686
UpdateGovernanceSource update_governance_source = 103;
87-
RemoveGovernanceSource remove_governance_source = 104;
8887
SetShardName set_shard_name = 105;
8988
SetShardGroup set_shard_group = 106;
9089
ResetLastSequenceNo reset_last_sequence_no = 107;
@@ -97,89 +96,6 @@ message GovernanceInstructionItem {
9796
}
9897
}
9998

100-
// Permissions granted to a governance source.
101-
// bool fields in this message are optional and default to false (no permission).
102-
message Permissions {
103-
enum ShardAction {
104-
// Required by protobuf. Instruction will be rejected if this value is encountered.
105-
SHARD_ACTION_UNSPECIFIED = 0;
106-
// All operations, including operations added in the future.
107-
ALL_ACTIONS = 1;
108-
CREATE_SHARD = 101;
109-
ADD_GOVERNANCE_SOURCE = 102;
110-
// All operations under `UpdateGovernanceSource`,
111-
// including operations added in the future.
112-
UPDATE_GOVERNANCE_SOURCE = 103;
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;
127-
}
128-
129-
enum UpdateGovernanceSourceAction {
130-
// Required by protobuf. Instruction will be rejected if this value is encountered.
131-
UPDATE_GOVERNANCE_SOURCE_ACTION_UNSPECIFIED = 0;
132-
SET_GOVERNANCE_SOURCE_PERMISSIONS = 101;
133-
}
134-
135-
enum UpdatePublisherAction {
136-
// Required by protobuf. Instruction will be rejected if this value is encountered.
137-
UPDATE_PUBLISHER_ACTION_UNSPECIFIED = 0;
138-
SET_PUBLISHER_NAME = 101;
139-
ADD_PUBLISHER_PUBLIC_KEYS = 102;
140-
REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
141-
SET_PUBLISHER_PUBLIC_KEYS = 104;
142-
SET_PUBLISHER_ACTIVE = 105;
143-
}
144-
145-
enum UpdateFeedAction {
146-
// Required by protobuf. Instruction will be rejected if this value is encountered.
147-
UPDATE_FEED_ACTION_UNSPECIFIED = 0;
148-
UPDATE_FEED_PROPERTIES = 101;
149-
UPDATE_FEED_METADATA = 102;
150-
ENABLE_FEED_IN_SHARD = 103;
151-
DISABLE_FEED_IN_SHARD = 104;
152-
}
153-
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;
158-
}
159-
160-
// Specifies the way governance transactions are signed and verified.
161-
message GovernanceSource {
162-
// Governance transactions are signed by a single Ed25519 signature.
163-
// This will generally be used in development and testing groups.
164-
message SingleEd25519 {
165-
// [required] Ed25519 public key that signs governance transactions.
166-
optional bytes public_key = 1;
167-
}
168-
169-
message WormholeEmitter {
170-
// [required] Wormhole emitter address.
171-
optional bytes address = 1;
172-
// [required] Wormhole emitter chain ID. Restricted to uint16.
173-
optional uint32 chain_id = 2;
174-
}
175-
176-
// [required]
177-
oneof source {
178-
SingleEd25519 single_ed25519 = 1;
179-
WormholeEmitter wormhole_emitter = 2;
180-
}
181-
}
182-
18399
// Create a new shard. A shard is a partially isolated part of Lazer that has its own state and
184100
// cannot be directly influenced by other shards. The main purpose of shards in Lazer is
185101
// to allow horizontal scaling when the number of feeds grows. Feeds can be divided into subsets
@@ -225,15 +141,6 @@ message SetGovernanceSourcePermissions {
225141
optional Permissions permissions = 1;
226142
}
227143

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-
237144
// Set shard name. This action will be rejected if `GovernanceInstructionItem.shard_names` is empty or contains
238145
// more than one item.
239146
message SetShardName {

lazer/publisher_sdk/proto/state.proto

Lines changed: 98 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ message State {
3535
repeated Feed feeds = 7;
3636
// List of publishers.
3737
repeated Publisher publishers = 8;
38-
// TODO: governance state (pubkey, last sequence no)
38+
// List of governance sources.
39+
repeated GovernanceSourceState governance_sources = 9;
3940
}
4041

4142
// An item of the state describing a publisher.
@@ -159,3 +160,99 @@ message FeedData {
159160
// [optional] Funding rate interval. Can be absent if no data is available. Can only be present for funding rate feeds.
160161
optional google.protobuf.Duration funding_rate_interval = 7;
161162
}
163+
164+
// State associated with a governance source.
165+
message GovernanceSourceState {
166+
// [required]
167+
optional GovernanceSource source = 1;
168+
// [required]
169+
optional Permissions permissions = 2;
170+
// [required]
171+
optional uint64 last_sequence_no = 3;
172+
}
173+
174+
// Permissions granted to a governance source.
175+
// bool fields in this message are optional and default to false (no permission).
176+
message Permissions {
177+
enum ShardAction {
178+
// Required by protobuf. Instruction will be rejected if this value is encountered.
179+
SHARD_ACTION_UNSPECIFIED = 0;
180+
// All operations, including operations added in the future.
181+
ALL_ACTIONS = 1;
182+
CREATE_SHARD = 101;
183+
ADD_GOVERNANCE_SOURCE = 102;
184+
// All operations under `UpdateGovernanceSource`,
185+
// including operations added in the future.
186+
UPDATE_GOVERNANCE_SOURCE = 103;
187+
SET_SHARD_NAME = 105;
188+
SET_SHARD_GROUP = 106;
189+
RESET_LAST_SEQUENCE_NO = 107;
190+
ADD_PUBLISHER = 108;
191+
// All operations under `UpdatePublisher`,
192+
// including operations added in the future.
193+
UPDATE_PUBLISHER = 109;
194+
REMOVE_PUBLISHER = 110;
195+
ADD_FEED = 111;
196+
// All operations under `UpdateFeed`,
197+
// including operations added in the future.
198+
UPDATE_FEED = 112;
199+
REMOVE_FEED = 113;
200+
}
201+
202+
enum UpdateGovernanceSourceAction {
203+
// Required by protobuf. Instruction will be rejected if this value is encountered.
204+
UPDATE_GOVERNANCE_SOURCE_ACTION_UNSPECIFIED = 0;
205+
SET_GOVERNANCE_SOURCE_PERMISSIONS = 101;
206+
}
207+
208+
enum UpdatePublisherAction {
209+
// Required by protobuf. Instruction will be rejected if this value is encountered.
210+
UPDATE_PUBLISHER_ACTION_UNSPECIFIED = 0;
211+
SET_PUBLISHER_NAME = 101;
212+
ADD_PUBLISHER_PUBLIC_KEYS = 102;
213+
REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
214+
SET_PUBLISHER_PUBLIC_KEYS = 104;
215+
SET_PUBLISHER_ACTIVE = 105;
216+
}
217+
218+
enum UpdateFeedAction {
219+
// Required by protobuf. Instruction will be rejected if this value is encountered.
220+
UPDATE_FEED_ACTION_UNSPECIFIED = 0;
221+
UPDATE_FEED_PROPERTIES = 101;
222+
UPDATE_FEED_METADATA = 102;
223+
ENABLE_FEED_IN_SHARD = 103;
224+
DISABLE_FEED_IN_SHARD = 104;
225+
}
226+
227+
repeated ShardAction actions = 1;
228+
repeated UpdateGovernanceSourceAction update_governance_source_actions = 2;
229+
repeated UpdatePublisherAction update_publisher_actions = 3;
230+
repeated UpdateFeedAction update_feed_actions = 4;
231+
}
232+
233+
234+
// Specifies the way governance transactions are signed and verified.
235+
// Note that once added, a governance source cannot be removed.
236+
// The last sequence number associated with this source
237+
// will be retained in the state indefinitely to prevent repeated execution of instructions.
238+
message GovernanceSource {
239+
// Governance transactions are signed by a single Ed25519 signature.
240+
// This will generally be used in development and testing groups.
241+
message SingleEd25519 {
242+
// [required] Ed25519 public key that signs governance transactions.
243+
optional bytes public_key = 1;
244+
}
245+
246+
message WormholeEmitter {
247+
// [required] Wormhole emitter address.
248+
optional bytes address = 1;
249+
// [required] Wormhole emitter chain ID. Restricted to uint16.
250+
optional uint32 chain_id = 2;
251+
}
252+
253+
// [required]
254+
oneof source {
255+
SingleEd25519 single_ed25519 = 1;
256+
WormholeEmitter wormhole_emitter = 2;
257+
}
258+
}

lazer/publisher_sdk/rust/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "pyth-lazer-publisher-sdk"
3-
version = "0.4.1"
3+
version = "0.5.0"
44
edition = "2021"
55
description = "Pyth Lazer Publisher SDK types."
66
license = "Apache-2.0"

0 commit comments

Comments
 (0)