fix: conditionally include discriminator in CPI context account hashing#2369
fix: conditionally include discriminator in CPI context account hashing#2369sergeytimoshin wants to merge 1 commit intomainfrom
Conversation
CpiContextInAccount and CpiContextOutAccount always passed Some((discriminator, data_hash)) to hash_with_hashed_values, even when has_data() was false. This caused hash mismatches for no-data compressed accounts, as the regular account hashing correctly passes None when there is no data. Now both implementations check has_data() before including discriminator/data_hash in the hash, matching the behavior of the non-CPI-context account hashing. Forester is not affected - it uses pre-computed hashes from the indexer and never calls hash_with_hashed_values directly. https://claude.ai/code/session_01GEhytcJ5GZXB2ZZMH1ouS3
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Path: .coderabbit.yaml Review profile: ASSERTIVE Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe PR updates the hash computation logic for CPI context accounts, making discriminator and data hash inclusion conditional. Previously, these values were always included in the hashing input; now they are included only when Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes The change affects critical hashing semantics that impact account verification. Reviewers should verify the motivation behind the conditional logic, assess backward compatibility implications, confirm that empty accounts are properly handled throughout the system, and ensure adequate test coverage validates both the presence and absence cases. Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 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 |
|
Compressed accounts owned by programs must always have data. |
CpiContextInAccount and CpiContextOutAccount always passed
Some((discriminator, data_hash)) to hash_with_hashed_values, even when
has_data() was false. This caused hash mismatches for no-data compressed
accounts, as the regular account hashing correctly passes None when there
is no data. Now both implementations check has_data() before including
discriminator/data_hash in the hash, matching the behavior of the
non-CPI-context account hashing.
Forester is not affected - it uses pre-computed hashes from the indexer
and never calls hash_with_hashed_values directly.
https://claude.ai/code/session_01GEhytcJ5GZXB2ZZMH1ouS3
Summary by CodeRabbit