Skip to content

feat(lazer): add governance sources info to state #2927

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Aug 7, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

93 changes: 0 additions & 93 deletions lazer/publisher_sdk/proto/governance_instruction.proto
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ message GovernanceInstructionItem {
CreateShard create_shard = 101;
AddGovernanceSource add_governance_source = 102;
UpdateGovernanceSource update_governance_source = 103;
RemoveGovernanceSource remove_governance_source = 104;
SetShardName set_shard_name = 105;
SetShardGroup set_shard_group = 106;
ResetLastSequenceNo reset_last_sequence_no = 107;
Expand All @@ -97,89 +96,6 @@ message GovernanceInstructionItem {
}
}

// Permissions granted to a governance source.
// bool fields in this message are optional and default to false (no permission).
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;
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;
}

enum UpdatePublisherAction {
// Required by protobuf. Instruction will be rejected if this value is encountered.
UPDATE_PUBLISHER_ACTION_UNSPECIFIED = 0;
SET_PUBLISHER_NAME = 101;
ADD_PUBLISHER_PUBLIC_KEYS = 102;
REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
SET_PUBLISHER_PUBLIC_KEYS = 104;
SET_PUBLISHER_ACTIVE = 105;
}

enum UpdateFeedAction {
// Required by protobuf. Instruction will be rejected if this value is encountered.
UPDATE_FEED_ACTION_UNSPECIFIED = 0;
UPDATE_FEED_PROPERTIES = 101;
UPDATE_FEED_METADATA = 102;
ENABLE_FEED_IN_SHARD = 103;
DISABLE_FEED_IN_SHARD = 104;
}

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.
message GovernanceSource {
// Governance transactions are signed by a single Ed25519 signature.
// This will generally be used in development and testing groups.
message SingleEd25519 {
// [required] Ed25519 public key that signs governance transactions.
optional bytes public_key = 1;
}

message WormholeEmitter {
// [required] Wormhole emitter address.
optional bytes address = 1;
// [required] Wormhole emitter chain ID. Restricted to uint16.
optional uint32 chain_id = 2;
}

// [required]
oneof source {
SingleEd25519 single_ed25519 = 1;
WormholeEmitter wormhole_emitter = 2;
}
}

// Create a new shard. A shard is a partially isolated part of Lazer that has its own state and
// cannot be directly influenced by other shards. The main purpose of shards in Lazer is
// to allow horizontal scaling when the number of feeds grows. Feeds can be divided into subsets
Expand Down Expand Up @@ -225,15 +141,6 @@ message SetGovernanceSourcePermissions {
optional Permissions permissions = 1;
}

// 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 {
Expand Down
99 changes: 98 additions & 1 deletion lazer/publisher_sdk/proto/state.proto
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,8 @@ message State {
repeated Feed feeds = 7;
// List of publishers.
repeated Publisher publishers = 8;
// TODO: governance state (pubkey, last sequence no)
// List of governance sources.
repeated GovernanceSourceState governance_sources = 9;
}

// An item of the state describing a publisher.
Expand Down Expand Up @@ -159,3 +160,99 @@ message FeedData {
// [optional] Funding rate interval. Can be absent if no data is available. Can only be present for funding rate feeds.
optional google.protobuf.Duration funding_rate_interval = 7;
}

// State associated with a governance source.
message GovernanceSourceState {
// [required]
optional GovernanceSource source = 1;
// [required]
optional Permissions permissions = 2;
// [required]
optional uint64 last_sequence_no = 3;
}

// Permissions granted to a governance source.
// bool fields in this message are optional and default to false (no permission).
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 = 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;
}

enum UpdatePublisherAction {
// Required by protobuf. Instruction will be rejected if this value is encountered.
UPDATE_PUBLISHER_ACTION_UNSPECIFIED = 0;
SET_PUBLISHER_NAME = 101;
ADD_PUBLISHER_PUBLIC_KEYS = 102;
REMOVE_PUBLISHER_PUBLIC_KEYS = 103;
SET_PUBLISHER_PUBLIC_KEYS = 104;
SET_PUBLISHER_ACTIVE = 105;
}

enum UpdateFeedAction {
// Required by protobuf. Instruction will be rejected if this value is encountered.
UPDATE_FEED_ACTION_UNSPECIFIED = 0;
UPDATE_FEED_PROPERTIES = 101;
UPDATE_FEED_METADATA = 102;
ENABLE_FEED_IN_SHARD = 103;
DISABLE_FEED_IN_SHARD = 104;
}

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.
// Note that once added, a governance source cannot be removed.
// The last sequence number associated with this source
// will be retained in the state indefinitely to prevent repeated execution of instructions.
message GovernanceSource {
// Governance transactions are signed by a single Ed25519 signature.
// This will generally be used in development and testing groups.
message SingleEd25519 {
// [required] Ed25519 public key that signs governance transactions.
optional bytes public_key = 1;
}

message WormholeEmitter {
// [required] Wormhole emitter address.
optional bytes address = 1;
// [required] Wormhole emitter chain ID. Restricted to uint16.
optional uint32 chain_id = 2;
}

// [required]
oneof source {
SingleEd25519 single_ed25519 = 1;
WormholeEmitter wormhole_emitter = 2;
}
}
2 changes: 1 addition & 1 deletion lazer/publisher_sdk/rust/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "pyth-lazer-publisher-sdk"
version = "0.4.1"
version = "0.5.0"
edition = "2021"
description = "Pyth Lazer Publisher SDK types."
license = "Apache-2.0"
Expand Down