chore: update streaming pages, update router pages, add pinocchio guide#24
chore: update streaming pages, update router pages, add pinocchio guide#24SwenSchaeferjohann merged 7 commits intomainfrom
Conversation
|
Caution Review failedThe pull request is closed. WalkthroughThis PR reorganizes Light Token docs navigation, adds a Pinocchio DeFi program guide, and updates streaming/cold-account handling docs and snippets while documenting public API changes to AmmSdk / LightProgramInterface and the runtime cold->hot load-instruction flow. Changes
Sequence Diagram(s)sequenceDiagram
participant Client as Client
participant Indexer as Indexer (stream)
participant Cache as Hot/Cold Cache
participant RPC as RPC/Node
Client->>Indexer: Subscribe accounts & transactions
Indexer-->>Client: Stream account updates (hot)
Client->>Cache: store/update hot state
Indexer-->>Client: Stream transaction (detect closed accounts)
Client->>Client: run find_closed_accounts(tx)
Client->>Cache: move closed pubkey -> cold_cache
Client->>RPC: get_account_interface(pubkey) for cold accounts
Client->>Client: load_specs(cold_accounts) -> AccountSpec[]
Client->>RPC: create_load_instructions(AccountSpec[])
Client->>RPC: send tx with prepended load instructions + action
Indexer-->>Client: Account reactivated (cold->hot)
Client->>Cache: move to hot cache
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing touches🧪 Generate unit tests (beta)
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.
Actionable comments posted: 6
🤖 Fix all issues with AI agents
In `@light-token/defi/programs-pinocchio.mdx`:
- Line 139: Fix the typo in the sentence referencing the init instruction:
change "you init instruction" to "your init instruction" and ensure the sentence
reads clearly (e.g., "Update your init instruction. Use `light_token_pinocchio`
CPI builders to create rent-free token accounts."). Locate the sentence
mentioning the init instruction and the `light_token_pinocchio` CPI builders in
the program documentation and update the wording accordingly.
In `@light-token/defi/routers.mdx`:
- Line 21: Fix the minor typo in the sentence "this can be separate from your
regular account cache." by capitalizing the first letter: change "this" to
"This" in the routers.mdx content so the sentence begins with a capital letter.
- Line 99: The short example passes payer directly to create_load_instructions
but the full example uses payer.pubkey(); update the short example to pass the
same type expected by create_load_instructions (use payer.pubkey() if it expects
a Pubkey) so the argument form is consistent with the full example and the
function signature (refer to create_load_instructions and payer.pubkey()).
- Around line 214-215: Replace the incorrect proof-of-work term "miners" with
Solana-appropriate terminology such as "validators" in the sentence that
currently reads "miners compress them onto the Solana ledger" (search for the
string "miners compress them onto the Solana ledger" in routers.mdx); update the
phrasing so it reads e.g. "validators compress them onto the Solana ledger" or
"validators prune/compress them onto the Solana ledger" to keep meaning intact
and accurate.
- Around line 38-51: The example spawns an async task that clones rpc but
captures cold_cache by move, which will cause a move-once compile error; ensure
cold_cache is shared (e.g., wrapped in Arc—Arc<DashMap<...>> or Arc<Mutex<...>>)
and clone it before the tokio::spawn call (same pattern used for rpc) so each
iteration uses cold_cache.clone() inside the loop; update the snippet around
find_closed_accounts, the for pubkey loop, and the tokio::spawn closure to use
the cloned cold_cache and document the expected cold_cache type.
In `@light-token/toolkits/for-streaming-pdas.mdx`:
- Around line 130-147: The snippet uses return; inside the
UpdateOneof::Transaction arm which will exit the enclosing function; change that
to continue (to skip processing this stream event and proceed to the next loop
iteration) or a no-op block if the surrounding context isn't a loop;
specifically replace the return; after the has_compress_instruction(tx_info)
check so when has_compress_instruction(tx_info) is false you skip further
handling of tx_update rather than exiting the function—update the match arm
around UpdateOneof::Transaction / tx_update and ensure subsequent logic that
moves entries from cache to cold_cache remains reachable only when
has_compress_instruction(tx_info) is true.
🧹 Nitpick comments (7)
light-token/defi/programs.mdx (1)
460-478: Undeclared identifiers in test snippet may confuse readers.
config_pda(line 475) andpayer(lines 475, 478) are used but never declared or commented as omitted in this test example. Consider adding a comment like// ... (payer, config_pda setup omitted)near the top of the test, similar to how Step 1/2 are annotated.light-token/defi/programs-pinocchio.mdx (1)
346-361:AccountSpec::Pdaused for token vaults here vsAccountSpec::Tokenin the Anchor guide.In
programs.mdx(line 419–420), token vaults are pushed asAccountSpec::Token(account.clone()). Here,token_a_vaultis pushed asAccountSpec::Pda(PdaSpec::new(...)). If this is intentional (Pinocchio wraps tokens with seed data into a PDA spec), a brief inline comment would help readers who cross-reference both guides.snippets/code-snippets/streaming/find-closed-accounts.mdx (1)
5-24:cold_cachecaptured bytokio::spawnwithout visible shared-ownership wrapper.The spawned task captures
cold_cache(line 18), but multiple spawns in a loop need shared access. Readers may not realize anArc<Mutex<...>>(orDashMap) wrapper is required. A one-line comment like// cold_cache: Arc<DashMap<[u8;32], AccountInterface>>on the data-structure description (line 3) would prevent confusion.light-token/toolkits/for-streaming-pdas.mdx (1)
310-314: User-facing TODO/Warning in documentation.This
<Warning>block contains a TODO that reads as an internal development note rather than user-facing guidance. While the page is currently hidden (visibility: "hidden"), this should be resolved or converted to an internal comment before the page is made visible.light-token/toolkits/for-streaming-tokens.mdx (1)
188-191: Point queries example hardcodes devnet config.The Connect step above offers both Mainnet and Devnet tabs, but the point queries example hardcodes
api.devnet.solana.comand a placeholderYOUR_KEY. Consider using a tab layout here too, or at minimum note that this is a devnet example.light-token/defi/routers.mdx (2)
238-239: Minor grammar nit: use a hyphen in compound adjective.
"1232 byte limit"→"1232-byte limit"(compound modifier before a noun).
254-263: Hardcoded Jito tip accounts may become stale.These addresses are embedded directly in the example. If Jito rotates or adds tip accounts, this snippet becomes silently wrong. Consider adding a comment pointing readers to the canonical source (e.g., Jito's docs or on-chain tip program) so they can keep accounts up to date.
| .value; | ||
| let cold: Vec<_> = interfaces.into_iter().flatten().collect(); | ||
| let specs = sdk.load_specs(&cold)?; | ||
| ixs.extend(create_load_instructions(&specs, payer, config_pda, &rpc).await?); |
There was a problem hiding this comment.
Inconsistent payer argument between code snippets.
Here payer is passed directly, but in the full example on line 173 it's payer.pubkey(). One of these is likely incorrect—if create_load_instructions expects a Pubkey, the short example should also use payer.pubkey().
🤖 Prompt for AI Agents
In `@light-token/defi/routers.mdx` at line 99, The short example passes payer
directly to create_load_instructions but the full example uses payer.pubkey();
update the short example to pass the same type expected by
create_load_instructions (use payer.pubkey() if it expects a Pubkey) so the
argument form is consistent with the full example and the function signature
(refer to create_load_instructions and payer.pubkey()).
| Accounts go cold after extended inactivity. Their virtual rent balance drops | ||
| below a threshold and miners compress them onto the Solana ledger. |
There was a problem hiding this comment.
Incorrect terminology: Solana uses "validators," not "miners."
Solana is a proof-of-stake network. Using "miners" (a proof-of-work term) is inaccurate and may confuse readers.
Suggested fix
-below a threshold and miners compress them onto the Solana ledger.
+below a threshold and validators compress them onto the Solana ledger.🧰 Tools
🪛 GitHub Check: Mintlify Validation (luminouslabs-cc5545c6) - vale-spellcheck
[warning] 215-215: light-token/defi/routers.mdx#L215
Did you really mean 'Solana'?
🤖 Prompt for AI Agents
In `@light-token/defi/routers.mdx` around lines 214 - 215, Replace the incorrect
proof-of-work term "miners" with Solana-appropriate terminology such as
"validators" in the sentence that currently reads "miners compress them onto the
Solana ledger" (search for the string "miners compress them onto the Solana
ledger" in routers.mdx); update the phrasing so it reads e.g. "validators
compress them onto the Solana ledger" or "validators prune/compress them onto
the Solana ledger" to keep meaning intact and accurate.
| ```rust | ||
| use helius_laserstream::grpc::subscribe_update::UpdateOneof; | ||
|
|
||
| Some(UpdateOneof::Transaction(tx_update)) => { | ||
| if let Some(ref tx_info) = tx_update.transaction { | ||
| if !has_compress_instruction(tx_info) { | ||
| return; // 99.999% of transactions exit here. | ||
| } | ||
| for pubkey in find_closed_accounts(tx_info) { | ||
| // Only process accounts we're tracking. | ||
| // This filters out unrelated accounts that went to 0 in the same tx. | ||
| if let Some(last_hot_state) = cache.remove(&pubkey) { | ||
| cold_cache.insert(pubkey, last_hot_state); | ||
| } | ||
| } | ||
| } | ||
| } | ||
| ``` |
There was a problem hiding this comment.
return; may confuse — consider using continue or a no-op block.
Line 136 uses return; inside a match arm, which would exit the enclosing function rather than skip to the next stream event. In the full event-loop context, this is likely meant to be a continue or simply an empty {} block. Since this is a documentation snippet, the intent is clear, but using the correct keyword prevents copy-paste bugs.
📝 Suggested fix
if !has_compress_instruction(tx_info) {
- return; // 99.999% of transactions exit here.
+ continue; // 99.999% of transactions skip here.
}🤖 Prompt for AI Agents
In `@light-token/toolkits/for-streaming-pdas.mdx` around lines 130 - 147, The
snippet uses return; inside the UpdateOneof::Transaction arm which will exit the
enclosing function; change that to continue (to skip processing this stream
event and proceed to the next loop iteration) or a no-op block if the
surrounding context isn't a loop; specifically replace the return; after the
has_compress_instruction(tx_info) check so when
has_compress_instruction(tx_info) is false you skip further handling of
tx_update rather than exiting the function—update the match arm around
UpdateOneof::Transaction / tx_update and ensure subsequent logic that moves
entries from cache to cold_cache remains reachable only when
has_compress_instruction(tx_info) is true.
Summary by CodeRabbit
New Features
Documentation