Skip to content

v0.2.2

Latest

Choose a tag to compare

@solarpx solarpx released this 10 Feb 18:39
60e5b98

Stake Interface v0.2.2: Explicit Whitelist Entry Parameter

Summary

Updated delegate_stake() to accept the validator whitelist entry as an explicit 4th parameter instead of deriving it internally. This improves API clarity and test flexibility while maintaining backward compatibility through wrapper functions.

Changes

API Update:

// Before (v0.2.1)
pub fn delegate_stake(
    stake_pubkey: &Pubkey,
    authorized_pubkey: &Pubkey,
    vote_pubkey: &Pubkey,
) -> Instruction

// After (v0.2.2)
pub fn delegate_stake(
    stake_pubkey: &Pubkey,
    authorized_pubkey: &Pubkey,
    vote_pubkey: &Pubkey,
    whitelist_entry_pubkey: &Pubkey,  // ← New explicit parameter
) -> Instruction

Why This Change:

  • Tests can now control which whitelist entry to pass (edge case testing)
  • API is explicit about required accounts (better developer experience)
  • Fixes test failures where implicit derivation caused wrong error paths

Backward Compatibility:

  • Wrapper functions (create_account_and_delegate_stake, etc.) auto-derive the whitelist entry
  • 99% of existing code uses wrappers → no changes needed
  • Instruction format unchanged (still 7 accounts) → validator unaffected

Files Changed

Interface:

  • interface/src/instruction.rs: Updated delegate_stake() signature and wrappers

Tests:

  • program/tests/stake_instruction.rs: Added 4th param to 2 test calls
  • program/tests/program_test.rs: Simplified helper function
  • program/tests/interface.rs: Simplified test call

Workspace:

  • Cargo.toml: Version bump 0.2.1 → 0.2.2

Testing

✅ All stake program tests passing (56 tests)

cargo test -p spherenet-stake-program