-
Notifications
You must be signed in to change notification settings - Fork 262
feat(pyth-lazer-publisher-sdk): Add SDK for Publisher Transactions #2557
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
Changes from all commits
Commits
Show all changes
26 commits
Select commit
Hold shift + click to select a range
e69e71c
add proto files
darunrs ea14862
Update proto file and build generated files
darunrs 72f3dd4
Code gen in TS
darunrs a9dcdca
Update proto file
darunrs 979f793
rename
darunrs aa21d2a
rename proto fields and re-generate
darunrs 770c987
Update package json scripts and field ids
darunrs 57cb606
comment build.rs file
darunrs f5ac983
rebase lock file and git ignore generated files
darunrs 36a34bb
update js generated files
darunrs 308ea14
Add turbo build and update proto codegen command
darunrs 1bcbe45
update readme
darunrs 031ea71
comment proto file
darunrs a06c2d4
add prost-types
darunrs 56b5a56
remove generated files
darunrs 59ae65b
try using protobuf-codegen
darunrs a88c3df
add publisher sdk
darunrs e93cdd9
remove remaining changes
darunrs 3979cc8
add pub id
darunrs 7c8ae8c
add new pub sdk to workspace
darunrs ac2e981
duplicate workspace
darunrs d2df006
remove unnecessary ignores
darunrs bfb713a
add caching inputs for turbo
darunrs 10b17d8
change export of js sdk
darunrs 50de6e4
remove js publisher sdk
darunrs 8c11702
fix publish
darunrs File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
name: Publish Rust package pyth-lazer-publisher-sdk to crates.io | ||
|
||
on: | ||
push: | ||
tags: | ||
- rust-pyth-lazer-publisher-sdk-v* | ||
jobs: | ||
publish-pyth-lazer-publisher-sdk: | ||
name: Publish Rust package pyth-lazer-publisher-sdk to crates.io | ||
runs-on: ubuntu-latest | ||
steps: | ||
- name: Checkout sources | ||
uses: actions/checkout@v2 | ||
|
||
- run: cargo publish --token ${CARGO_REGISTRY_TOKEN} | ||
env: | ||
CARGO_REGISTRY_TOKEN: ${{ secrets.CARGO_REGISTRY_TOKEN }} | ||
working-directory: "lazer/publisher-sdk/rust" |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,59 @@ | ||
syntax = "proto3"; | ||
|
||
import "google/protobuf/timestamp.proto"; | ||
|
||
package pyth_lazer_transaction; | ||
|
||
// PublisherUpdate contains an array of individual updates and a timestamp | ||
message PublisherUpdate { | ||
// Array of updates, each of which target a single feed | ||
repeated FeedUpdate updates = 1; | ||
|
||
// ID of the Publisher that is sending the update | ||
// Should match ID stored in Pyth Lazer | ||
optional uint32 publisher_id = 2; | ||
|
||
// Timestamp when this message was created | ||
optional google.protobuf.Timestamp publisher_timestamp = 3; | ||
} | ||
|
||
// Update to a feed. May contain different types of data depending on what kind of update it is | ||
message FeedUpdate { | ||
// Feed which the update should be applied to | ||
// Should match a feed id recognized by PythLazer | ||
optional uint32 feed_id = 1; | ||
|
||
// Timestamp when this data was first acquired or generated | ||
optional google.protobuf.Timestamp source_timestamp = 2; | ||
|
||
// one of the valid updates allowed by publishers for a lazer feed | ||
oneof update { | ||
PriceUpdate price_update = 3; | ||
FundingRateUpdate funding_rate_update = 4; | ||
}; | ||
} | ||
|
||
message PriceUpdate { | ||
// Price for the symbol as an integer | ||
// Should be produced with a matching exponent to the configured exponent value in PythLazer | ||
// May be missing if no price data is available | ||
optional int64 price = 1; | ||
|
||
// Best Bid Price for the symbol as an integer | ||
// Should be produced with a matching exponent to the configured exponent value in PythLazer | ||
// May be missing if no data is available | ||
optional int64 best_bid_price = 2; | ||
|
||
// Best Ask Price for the symbol as an integer | ||
// Should be produced with a matching exponent to the configured exponent value in PythLazer | ||
// May be missing if no data is available | ||
optional int64 best_ask_price = 3; | ||
} | ||
|
||
message FundingRateUpdate { | ||
// Price for which the funding rate applies to | ||
optional int64 price = 1; | ||
|
||
// Perpetual Future funding rate | ||
optional int64 rate = 2; | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,34 @@ | ||
syntax = "proto3"; | ||
|
||
package pyth_lazer_transaction; | ||
|
||
import "publisher_update.proto"; | ||
|
||
// Types of Signatures allowed for signing Lazer Transactions | ||
enum TransactionSignatureType { | ||
// signature is 64 bytes long | ||
ed25519 = 0; | ||
} | ||
|
||
// Signed lazer transaction payload | ||
// This is what Pyth Lazer expects as input to the system | ||
message SignedLazerTransaction { | ||
// Type and signature should match | ||
optional TransactionSignatureType signature_type = 1; | ||
|
||
// Signature derived by signing payload with private key | ||
optional bytes signature = 2; | ||
|
||
// a LazerTransaction message which is already encoded with protobuf as bytes | ||
// The encoded bytes are what should be signed | ||
optional bytes payload = 3; | ||
} | ||
|
||
// Transaction contianing one of the valid Lazer Transactions | ||
message LazerTransaction { | ||
oneof payload { | ||
// Expected transaction sent by Publishers | ||
// May contain many individual updates to various feeds | ||
PublisherUpdate publisher_update = 1; | ||
} | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
[package] | ||
name = "pyth-lazer-publisher-sdk" | ||
version = "0.1.0" | ||
edition = "2021" | ||
description = "Pyth Lazer Publisher SDK types." | ||
license = "Apache-2.0" | ||
repository = "https://github.com/pyth-network/pyth-crosschain" | ||
build = "build.rs" | ||
|
||
[dependencies] | ||
protobuf = "3.7.2" | ||
|
||
[build-dependencies] | ||
protobuf-codegen = "3.7.2" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
use std::io::Result; | ||
|
||
/// Automatically runs during cargo build. | ||
/// Proto files for Lazer are defined in the lazer sdk folder in the proto/ subdirectory. | ||
/// Both JS and Rust SDKs read the proto files for generating types. | ||
fn main() -> Result<()> { | ||
// Tell cargo to recompile if any .proto files change | ||
println!("cargo:rerun-if-changed=../proto/"); | ||
|
||
protobuf_codegen::Codegen::new() | ||
.pure() | ||
.include("../proto") | ||
.input("../proto/publisher_update.proto") | ||
.input("../proto/pyth_lazer_transaction.proto") | ||
.cargo_out_dir("protobuf") | ||
.run_from_script(); | ||
|
||
Ok(()) | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
pub mod transaction { | ||
pub use crate::protobuf::pyth_lazer_transaction::*; | ||
} | ||
|
||
mod protobuf { | ||
include!(concat!(env!("OUT_DIR"), "/protobuf/mod.rs")); | ||
} |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
{ | ||
"$schema": "https://turbo.build/schema.json", | ||
"extends": ["//"], | ||
"tasks": { | ||
"build": { | ||
"dependsOn": ["^build"], | ||
"outputs": ["dist/**"] | ||
}, | ||
"build:cjs": { | ||
"dependsOn": ["build"], | ||
"outputs": ["dist/cjs/**"] | ||
}, | ||
"build:esm": { | ||
"dependsOn": ["build"], | ||
"outputs": ["dist/esm/**"] | ||
} | ||
darunrs marked this conversation as resolved.
Show resolved
Hide resolved
|
||
} | ||
} |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
After yesterday's discussion I realized that this structure is not very well suited for governance mesages that are based on wormhole. Maybe we need something like this?
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like to have a fixed transaction layout and then have customisability in the payload layer. I see transaction as something for sequencer and content of it as something for the aggregator. It's good to have permissioning over who does what. And then, you can say that the sequencer only streams txs from verified pubkeys. Otherwise, you'd need to either think of continuing the tokenized gateway (which is kind of like sigs) or verifying wh messages (which is very expensive)