Skip to content

feat(solana): implement SVM Entropy contract with V2 API #2886

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

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

devin-ai-integration[bot]
Copy link
Contributor

Summary

This PR implements a Solana Virtual Machine (SVM) version of the Entropy contract, mirroring the V2 API from the existing Ethereum Entropy contract. The implementation creates a new Anchor program pyth-entropy that provides secure randomness generation through a 2-party protocol between providers and requesters.

Key Components Added:

  • New Solana program pyth-entropy using Anchor framework
  • Account structures: EntropyConfig, ProviderInfo, EntropyRequest
  • V2 instruction handlers: register(), requestV2(), revealWithCallback(), provider management functions
  • SDK module with instruction builders and account helpers
  • Comprehensive error handling and event emission

Rationale

The Pyth Network requires a Solana-native entropy solution to provide secure randomness generation on the Solana blockchain. This implementation adapts the proven Ethereum Entropy contract design to Solana's account-based execution model while maintaining the same V2 API surface.

The 2-party randomness protocol ensures that neither providers nor requesters can manipulate the final random values, making it suitable for applications requiring verifiable randomness.

How has this been tested?

  • Code compiles successfully with cargo build --package pyth-entropy
  • ⚠️ Current tests cover my changes - NO TESTS WRITTEN
  • ⚠️ Added new tests - NO TESTS ADDED
  • ⚠️ Manually tested the code - NOT MANUALLY TESTED

⚠️ CRITICAL REVIEW AREAS:

  1. Cryptographic Operations - The hash chain verification, commitment construction, and random value combination logic in reveal_helper(), construct_provider_commitment(), and combine_random_values() functions need careful review for correctness.

  2. Account Security Model - PDA derivation patterns and account constraints, especially around provider registration and request validation. Note that treasury initialization was simplified during compilation fixes.

  3. Fee Collection Mechanism - The treasury account handling was modified to resolve compilation issues. The fee calculation and collection logic in get_fee_v2() and withdrawal functions needs verification.

  4. API Completeness - Verify that all V2 methods from the Ethereum contract are correctly implemented and behave equivalently in Solana's execution environment.

  5. Missing Test Coverage - This implementation has no tests covering the cryptographic operations, fee handling, or account security constraints.


Link to Devin run: https://app.devin.ai/sessions/a7002e6456b34f0eb392ed36bf464823
Requested by: Jayant (jayant@dourolabs.xyz)

Files Changed:

  • target_chains/solana/programs/pyth-entropy/ - Complete new program implementation
  • target_chains/solana/Cargo.toml - Added to workspace members

- Create new pyth-entropy Solana program using Anchor framework
- Implement V2 variants of Entropy contract methods from Ethereum version
- Add account structures for EntropyConfig, ProviderInfo, and EntropyRequest
- Include provider registration, randomness requests, and reveal functionality
- Support callback mechanisms and fee management
- Follow existing workspace patterns and dependencies

Refs: target_chains/ethereum/contracts/contracts/entropy/Entropy.sol
Co-Authored-By: Jayant <jayant@dourolabs.xyz>
Copy link
Contributor Author

🤖 Devin AI Engineer

I'll be helping with this pull request! Here's what you should know:

✅ I will automatically:

  • Address comments on this PR. Add '(aside)' to your comment to have me ignore it.
  • Look at CI failures and help fix them

Note: I can only respond to comments from users who have write access to this repository.

⚙️ Control Options:

  • Disable automatic comment and CI monitoring

Copy link

vercel bot commented Jul 23, 2025

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

Name Status Preview Comments Updated (UTC)
api-reference ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
component-library ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
developer-hub ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
entropy-debugger ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
entropy-explorer ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
insights ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
proposals ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm
staking ✅ Ready (Inspect) Visit Preview 💬 Add feedback Jul 23, 2025 2:46pm

- Remove unused clock variable that was causing CI build failure
- Keep clock variable in request_v2 function where it's actually used
- Fixes clippy warning and allows CI build to pass

Co-Authored-By: Jayant <jayant@dourolabs.xyz>
- CI environment uses older Cargo version that doesn't support lock file version 4
- Revert from version 4 back to version 3 to fix build failure
- Keeps pyth-entropy package entry but in compatible format

Co-Authored-By: Jayant <jayant@dourolabs.xyz>
- CI environment uses older Cargo version that doesn't support lock file version 4
- Revert from version 4 back to version 3 to fix build failure
- Keeps pyth-entropy package entry but in compatible format

Co-Authored-By: Jayant <jayant@dourolabs.xyz>
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.

0 participants