Skip to content

Conversation

@RyanHealey
Copy link
Collaborator

Add support for the Solana staking program and add RPC endpoints required to test the staking program

Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR adds support for the Solana staking program and RPC endpoints needed to test staking operations.

Key Changes:

  • Introduces a new StakeProgram class with comprehensive support for stake account operations (initialize, delegate, deactivate, withdraw, split, merge, authorize)
  • Adds RPC endpoints for querying vote accounts (getVoteAccounts) required for testing stake delegation
  • Implements supporting infrastructure including transaction factories, driver methods, and DSL helpers for integration testing

Reviewed Changes

Copilot reviewed 15 out of 15 changed files in this pull request and generated 2 comments.

Show a summary per file
File Description
message-encoding/src/main/java/com/lmax/solana4j/programs/StakeProgram.java New stake program implementation with instruction builders for all stake operations
message-encoding/src/main/java/com/lmax/solana4j/encoding/SysVar.java Adds CLOCK and STAKE_HISTORY sysvar constants required by stake instructions
message-encoding/src/test-support/java/com/lmax/solana4j/transaction/V0TransactionBlobFactory.java Implements V0 transaction builders for stake operations
message-encoding/src/test-support/java/com/lmax/solana4j/transaction/LegacyTransactionBlobFactory.java Implements legacy transaction builders for stake operations
message-encoding/src/test-support/java/com/lmax/solana4j/transaction/TransactionBlobFactory.java Adds interface methods for stake account operations
message-encoding/src/test-support/java/com/lmax/solana4j/SolanaDriver.java Adds driver methods for creating, delegating, deactivating, and withdrawing from stake accounts; adds vote accounts and cluster nodes retrieval
message-encoding/src/test-support/java/com/lmax/solana4j/SolanaNodeDsl.java Implements DSL methods for testing stake operations and retrieving validator vote accounts
message-encoding/src/integration-test/java/com/lmax/solana4j/programs/StakeProgramIntegrationTest.java Integration tests covering create, delegate, deactivate, and withdraw stake operations
client/src/main/java/com/lmax/solana4j/client/api/VoteAccounts.java API interface for vote accounts response
client/src/main/java/com/lmax/solana4j/client/api/VoteAccount.java API interface for individual vote account details
client/src/main/java/com/lmax/solana4j/client/jsonrpc/VoteAccountsDTO.java DTO for deserializing vote accounts RPC response
client/src/main/java/com/lmax/solana4j/client/jsonrpc/VoteAccountDTO.java DTO for individual vote account data
client/src/main/java/com/lmax/solana4j/client/api/SolanaApi.java Adds getVoteAccounts RPC method signatures
client/src/main/java/com/lmax/solana4j/client/jsonrpc/SolanaJsonRpcClient.java Implements getVoteAccounts RPC client methods
client/src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetVoteAccountsContractTest.java Contract tests for getVoteAccounts RPC endpoint with various optional parameters

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

RyanHealey and others added 2 commits November 11, 2025 14:33
Co-authored-by: Copilot <[email protected]>
Co-authored-by: Copilot <[email protected]>
Copy link
Contributor

@amilbourne amilbourne left a comment

Choose a reason for hiding this comment

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

This is a great addition and all my comments are small points.

final VoteAccounts voteAccounts = SOLANA_API.getVoteAccounts(optionalParams).getResponse();
assertThat(voteAccounts).isNotNull();

final List<VoteAccount> currentVoteAccounts = voteAccounts.getCurrent();
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this check that some zero-stake delinquents were returned? Presumably there won't always be any. I guess it is possible that there won't be any delinquents at all.

*
* @return the epoch credits history
*/
java.util.List<java.util.List<Long>> getEpochCredits();
Copy link
Contributor

Choose a reason for hiding this comment

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

Would it be better to have an object to represent the array entries; as in an object with fields for epoch, credits, and previousCredits?

byte[] accountInfoBytes = Base64.decode(accountInfo.getData().getAccountInfoEncoded().get(0));

// Verify stake account is initialized (state = 1)
assertThat(accountInfoBytes[0]).isEqualTo((byte) 1);
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we use a Constant for the initialised state (1)?

Copy link
Contributor

@ml-james ml-james left a comment

Choose a reason for hiding this comment

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

I surely can't still approve PRs here?

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.

4 participants