Skip to content

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 26 commits into from
Apr 11, 2025

Conversation

darunrs
Copy link
Contributor

@darunrs darunrs commented Apr 4, 2025

Summary

Created new publisher_sdk which will store all sdk related code for publishers. Publishers is now more of a gneral term for anyone who publishes transactions to Lazer. Right now that's only Feed Publishers but in the future, there will be Governance, and maybe others too. The new publisher_sdk has proto files for which types are generated. Pyth Lazer will use these for encoding/decoding incoming transactions to the system in the future.

Rationale

Lazer needs to support more types of input and be capable of changing its input schema as updates happen. Using a new format for input provides this flexibility. Using protobuf for message passing provides additional flexibility for updating schemas and also improves the message compression size.

How has this been tested?

  • Current tests cover my changes
  • Added new tests
  • Manually tested the code

Was able to generate types successfully.

Copy link

vercel bot commented Apr 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Apr 11, 2025 3:24pm
5 Skipped Deployments
Name Status Preview Comments Updated (UTC)
api-reference ⬜️ Ignored (Inspect) Visit Preview Apr 11, 2025 3:24pm
component-library ⬜️ Ignored (Inspect) Visit Preview Apr 11, 2025 3:24pm
entropy-debugger ⬜️ Ignored (Inspect) Visit Preview Apr 11, 2025 3:24pm
insights ⬜️ Ignored (Inspect) Visit Preview Apr 11, 2025 3:24pm
proposals ⬜️ Ignored (Inspect) Apr 11, 2025 3:24pm

@darunrs darunrs requested a review from a team as a code owner April 9, 2025 21:56
@darunrs darunrs changed the title feat(pyth-lazer-protocol): Implement Protobuf files for Lazer Transactions feat(pyth-lazer-publisher-sdk): Add SDK for Publisher Transactions Apr 9, 2025
Copy link
Collaborator

@cprussin cprussin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Nice! Overall js packaging stuff looks great, just a few minor points to improve but overall lgtm

```
cd to crosschain root
$ pnpm install
$ pnpm turbo --filter @pythnetwork/pyth-lazer-publisher-sdk build
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Usually build in and of itself isn't a goal -- usually you're building to do something else. My general advice is to document the actual things you might want to do in the docs (e.g. "run tests" or "run this example" etc) and let the build happen automatically with the task orchestrator

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that makes sense. I will add in a followup PR an example showing how to use the SDK to create some of the types, sign them, and then encode them.

@@ -0,0 +1 @@
export * from "./generated/proto.js";
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I generally recommend against barrel exports. Instead, just point the main export at generated/proto.js directly.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By this, do you mean changing main and types in package.json to point to the proto.js instead of index.ts?

Comment on lines +15 to +25
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;
}
Copy link
Contributor

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?

// replaces old SignedLazerTransaction and LazerTransaction
message LazerTransaction {
    oneof message {
        PublisherUpdateTransaction publisher_update = 1;
        GovernanceTransaction governance = 2;
    }
}
message PublisherUpdateTransaction {
    optional bytes signature = 1;
    // protobuf-encoded PublisherUpdate
    optional bytes payload = 2;
}
message GovernanceTransaction {
    // encoded in wormhole format, with guardian signatures inside
    optional bytes payload = 1;
}

Copy link
Collaborator

@ali-behjati ali-behjati Apr 11, 2025

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)

Copy link
Contributor

@Riateche Riateche left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Very good!

@darunrs darunrs merged commit e098914 into main Apr 11, 2025
9 of 11 checks passed
@darunrs darunrs deleted the add-pyth-lazer-transactions branch April 11, 2025 16:30
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants