-
Notifications
You must be signed in to change notification settings - Fork 90
fix: light event #2352
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
Merged
Merged
fix: light event #2352
Changes from all commits
Commits
Show all changes
7 commits
Select commit
Hold shift + click to select a range
30a606b
fix: handle mixed batch/non-batch inputs in create_nullifier_queue_in…
ananas-block 25967be
feat: add xtask fetch-block-events subcommand
ananas-block a5b1c81
fix: format
ananas-block 17325e0
chore: bump light-event 0.23.0 -> 0.23.1
ananas-block 1071d56
fix: extract ParsedInstruction struct to satisfy clippy::type_complexity
ananas-block 5d1c6da
fix: rustfmt fetch_block_events
ananas-block bfa7c87
test(light-event): add regression tests for mixed batch/legacy nullif…
ananas-block File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -11,3 +11,5 @@ | |
| pub mod error; | ||
| pub mod event; | ||
| pub mod parse; | ||
| #[cfg(test)] | ||
| mod regression_test; | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,110 @@ | ||
| /// Regression test for index-out-of-bounds panic in create_nullifier_queue_indices. | ||
| /// Transaction: 3ybts1eFSC7QN6aU4ao6NJCgn7xTbtBVyzeLDZJf9eVN93vHZWupX4TXqHHgV18xf17eit7Uw5T135uabnpToKK4 | ||
| /// Slot: 407265372 (mainnet) | ||
| /// This transaction crashed photon's indexer because `len` passed to | ||
| /// `create_nullifier_queue_indices` didn't match the number of input accounts. | ||
| #[cfg(test)] | ||
| mod tests { | ||
| use light_compressed_account::Pubkey; | ||
|
|
||
| use crate::parse::event_from_light_transaction; | ||
|
|
||
| fn pubkey(s: &str) -> Pubkey { | ||
| let bytes: [u8; 32] = bs58::decode(s).into_vec().unwrap().try_into().unwrap(); | ||
| Pubkey::from(bytes) | ||
| } | ||
|
|
||
| fn ix_data(s: &str) -> Vec<u8> { | ||
| bs58::decode(s).into_vec().unwrap() | ||
| } | ||
|
|
||
| // Account addresses used in the transaction | ||
| const USER: &str = "33X2Tg3gdxTwouaVSxpcNwVHJt2ZYxo3Hm7UjH2i8M3r"; | ||
| const REGISTERED_PDA: &str = "35hkDgaAKwMCaxRz2ocSZ6NaUrtKkyNqU6c4RV3tYJRh"; | ||
| const NOOP: &str = "noopb9bkMVfRPU8AsbpTUg8AQkHtKwMYZiFUjNRtMmV"; | ||
| const CPI_CONTEXT: &str = "HwXnGK3tPkkVY6P439H2p68AxpeuWXd5PcrAxFpbmfbA"; | ||
| const ACCOUNT_COMPRESSION: &str = "compr6CUsB5m2jS4Y3831ztGSTnDpnKJTKS95d64XVq"; | ||
| const SOL_POOL: &str = "CHK57ywWSDncAoRu1F8QgwYJeXuAJyyBYT4LixLXvMZ1"; | ||
| const SYSTEM_PROGRAM: &str = "11111111111111111111111111111111"; | ||
| const BMT3_TREE: &str = "bmt3ccLd4bqSVZVeCJnH1F6C8jNygAhaDfxDwePyyGb"; | ||
| const OQ3_QUEUE: &str = "oq3AxjekBWgo64gpauB6QtuZNesuv19xrhaC1ZM1THQ"; | ||
| const SMT5_TREE: &str = "smt5uPaQT9n6b1qAkgyonmzRxtuazA53Rddwntqistc"; | ||
| const NFQ5_QUEUE: &str = "nfq5b5xEguPtdD6uPetZduyrB5EUqad7gcUE46rALau"; | ||
| const BMT2_TREE: &str = "bmt2UxoBxB9xWev4BkLvkGdapsz6sZGkzViPNph7VFi"; | ||
| const OQ2_QUEUE: &str = "oq2UkeMsJLfXt2QHzim242SUi3nvjJs8Pn7Eac9H9vg"; | ||
|
|
||
| // Program IDs | ||
| const LIGHT_SYSTEM: &str = "SySTEM1eSU2p4BGQfQpimFEWWSC1XDFeun3Nqzz3rT7"; | ||
| const COMPUTE_BUDGET: &str = "ComputeBudget111111111111111111111111111111"; | ||
|
|
||
| #[test] | ||
| fn test_mainnet_tx_407265372_no_panic() { | ||
| // Tx 3ybts1eFSC7QN...ToKK4, slot 407265372 | ||
| // Before fix: panicked with "index out of bounds: the len is 3 but the index is 3" | ||
| let program_ids = vec![ | ||
| pubkey(COMPUTE_BUDGET), // SetComputeUnitLimit | ||
| pubkey(COMPUTE_BUDGET), // SetComputeUnitPrice | ||
| pubkey(LIGHT_SYSTEM), // Light system invoke | ||
| pubkey(SYSTEM_PROGRAM), // SOL transfer (inner) | ||
| pubkey(SYSTEM_PROGRAM), // SOL transfer (inner) | ||
| pubkey(SYSTEM_PROGRAM), // SOL transfer (inner) | ||
| pubkey(ACCOUNT_COMPRESSION), // InsertIntoQueues (inner) | ||
| ]; | ||
|
|
||
| let instructions: Vec<Vec<u8>> = vec![ | ||
| ix_data("K1FDJ7"), | ||
| ix_data("3cDeqiGMb6md"), | ||
| ix_data("7Xu3JKNhcxBjvH52amHsaGu55uKzfsGvVjkBKAcEAAByDYGHt2TQQRq8aam17wkuH3Vtu2xuLyh8nZRxaqTEZPKM88CTs2e9MMiHW1ZA2NmFwbtgeHLFSRvW2DCayZMqHZWGEPjKwXnEJ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Z5aEQ8q2JhayJx3hqDriN6g1Vc2br8MtGRPXuwQYAd84jJoS6puMoanPnyFccv35jaxkEwUi5vY8J88ejut9W4uP7JVBivLBXYgDyLteffxA5a6rhJtFZ"), | ||
| ]; | ||
|
|
||
| let accounts: Vec<Vec<Pubkey>> = vec![ | ||
| vec![], // ComputeBudget | ||
| vec![], // ComputeBudget | ||
| // Light system invoke: user, registered PDA, noop, CPI context, account compression, | ||
| // SOL pool, system program, V2 trees (bmt3, oq3), V1 trees (smt5, nfq5), V2 trees (bmt2, oq2) | ||
| vec![ | ||
| pubkey(USER), | ||
| pubkey(USER), | ||
| pubkey(REGISTERED_PDA), | ||
| pubkey(NOOP), | ||
| pubkey(CPI_CONTEXT), | ||
| pubkey(ACCOUNT_COMPRESSION), | ||
| pubkey(SOL_POOL), | ||
| pubkey(USER), | ||
| pubkey(SYSTEM_PROGRAM), | ||
| pubkey(BMT3_TREE), | ||
| pubkey(OQ3_QUEUE), | ||
| pubkey(SMT5_TREE), | ||
| pubkey(NFQ5_QUEUE), | ||
| pubkey(BMT2_TREE), | ||
| pubkey(OQ2_QUEUE), | ||
| ], | ||
| // SOL transfers (inner) | ||
| vec![pubkey(SOL_POOL), pubkey(USER)], | ||
| vec![pubkey(USER), pubkey(BMT3_TREE)], | ||
| vec![pubkey(USER), pubkey(SMT5_TREE)], | ||
| // InsertIntoQueues (inner): CPI context, registered PDA, queues and trees | ||
| vec![ | ||
| pubkey(CPI_CONTEXT), | ||
| pubkey(REGISTERED_PDA), | ||
| pubkey(OQ3_QUEUE), | ||
| pubkey(BMT3_TREE), | ||
| pubkey(NFQ5_QUEUE), | ||
| pubkey(SMT5_TREE), | ||
| pubkey(OQ2_QUEUE), | ||
| pubkey(BMT2_TREE), | ||
| ], | ||
| ]; | ||
|
|
||
| let result = event_from_light_transaction(&program_ids, &instructions, accounts); | ||
| assert!( | ||
| result.is_ok(), | ||
| "event_from_light_transaction failed: {:?}", | ||
| result.err() | ||
| ); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Assert that this fixture actually produces a parsed event.
This still passes on
Ok(None), so a future pattern-matching regression could skipcreate_nullifier_queue_indicesentirely and the test would stay green. Please assertOk(Some(events))so this fixture keeps exercising the failing path.✅ Suggested tightening
📝 Committable suggestion
🤖 Prompt for AI Agents