Conversation
There was a problem hiding this comment.
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
StakeProgramclass 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.
.../src/integration-test/java/com/lmax/solana4j/client/jsonrpc/GetVoteAccountsContractTest.java
Outdated
Show resolved
Hide resolved
client/src/main/java/com/lmax/solana4j/client/jsonrpc/VoteAccountDTO.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
amilbourne
left a comment
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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(); |
There was a problem hiding this comment.
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); |
There was a problem hiding this comment.
Could we use a Constant for the initialised state (1)?
Add support for the Solana staking program and add RPC endpoints required to test the staking program