-
Notifications
You must be signed in to change notification settings - Fork 4
feat: add support for Solana ALT #237
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
base: main
Are you sure you want to change the base?
Conversation
📝 WalkthroughWalkthroughRewrote Solana execution flow in Changes
Sequence Diagram(s)sequenceDiagram
participant Caller as solanaExecute
participant Decoder as decodeMessage
participant DecoderALT as decodeMessageALT
participant Executor as execute / executeSplToken
participant TxBuilder as executeTransaction
participant RPC as RPC/Network
Caller->>Decoder: attempt non-ALT decode
alt non-ALT decode succeeds
Decoder-->>Caller: decoded message (non-ALT)
else non-ALT decode fails
Caller->>DecoderALT: attempt ALT decode
alt ALT decode succeeds
DecoderALT-->>Caller: decoded message (ALT)
else both fail
DecoderALT-->>Caller: throw decode error
end
end
Caller->>Executor: create instructions & signers (SOL or SPL)
Executor->>TxBuilder: build transaction (v0 if ALT else legacy)
TxBuilder->>RPC: sendRawTransaction
RPC-->>TxBuilder: tx signature
TxBuilder->>RPC: confirm transaction
RPC-->>Caller: final confirmation / result
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 2
🧹 Nitpick comments (4)
src/chains/solana/execute.ts (4)
391-394: Use resolved tokenDecimals in loggingEnsure the log reflects the actual decimals used.
- decimals + tokenDecimals
114-117: Log the error object, not string interpolationInterpolating err risks “[object Object]”. Pass the error as structured metadata to retain stack/message.
- logger.error(`Error executing Gateway execute: ${err}`, { - chain: NetworkID.Solana, - }); + logger.error("Error executing Gateway execute", { + chain: NetworkID.Solana, + err, + });
56-74: Preserve decode failure context for troubleshootingAdd debug logs for both decoding attempts to aid diagnosis, without changing user-facing errors.
try { ({ remainingAccounts, data } = decodeMessage(message)); } catch (nonAltError) { + logger.debug(`Non-ALT decode failed: ${(nonAltError as Error).message}`, { + chain: NetworkID.Solana, + }); try { ({ altAccount, remainingAccounts, data } = await decodeMessageALT( message, connection )); } catch (altError) { + logger.debug(`ALT decode failed: ${(altError as Error).message}`, { + chain: NetworkID.Solana, + }); throw new Error( `Failed to decode message as neither non-ALT nor ALT format` ); } }
402-434: Unify confirmation strategy for consistencyFor non-ALT, confirmTransaction(signature, "confirmed") does not bind to the blockhash used for send. Prefer the same latest-blockhash pattern as ALT for deterministic confirmation.
} else { // build transaction without ALT - const transaction = new anchor.web3.Transaction().add(executeIx); - signature = await connection.sendTransaction(transaction, [payer]); - await connection.confirmTransaction(signature, "confirmed"); + const latestBh = await connection.getLatestBlockhash(); + const transaction = new anchor.web3.Transaction({ + feePayer: payer.publicKey, + recentBlockhash: latestBh.blockhash, + }).add(executeIx); + signature = await connection.sendTransaction(transaction, [payer]); + await connection.confirmTransaction({ signature, ...latestBh }, "confirmed"); }
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
Disabled knowledge base sources:
- Linear integration is disabled by default for public repositories
You can enable these sources in your CodeRabbit configuration.
📒 Files selected for processing (1)
src/chains/solana/execute.ts(2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
src/chains/solana/execute.ts (3)
src/chains/solana/constants.ts (1)
payer(24-26)src/logger.ts (1)
logger(47-47)src/constants.ts (1)
NetworkID(13-20)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
- GitHub Check: cli-integration
🔇 Additional comments (1)
src/chains/solana/execute.ts (1)
120-145: Non-ALT decoding looks correctDecodes accounts and data and maps to AccountMeta with correct writability handling.
|
@ws4charlie what's the status of this PR? Is it compatible with protocol contracts solana v6? Should we review and merge it? |
This one was created according to node PR , which was recreated as 4226. Can @skosito confirm there is no significant gap between the 4226 and latest develop ALT implementation? |
This PR is a PoC to support Solana
Address Lookup Table. See the corresponding PRsSummary by CodeRabbit
Bug Fixes
Refactor
Chores