Skip to content

fix: reserve event cpi discriminator in dispatch#4581

Open
abhinavgautam01 wants to merge 1 commit into
otter-sec:anchor-nextfrom
abhinavgautam01:fix/4272-v2-event-discriminator-shadow
Open

fix: reserve event cpi discriminator in dispatch#4581
abhinavgautam01 wants to merge 1 commit into
otter-sec:anchor-nextfrom
abhinavgautam01:fix/4272-v2-event-discriminator-shadow

Conversation

@abhinavgautam01
Copy link
Copy Markdown

Fixes #4272

Summary

  • Dispatches the reserved event-CPI tag before user instruction discriminators.
  • Prevents a custom short discriminator like [0xe4] from shadowing the full event-CPI tag.
  • Adds a regression test showing that the overlapping short custom discriminator still dispatches normally when sent by itself.

Testing

  • rustfmt --check lang/syn/src/codegen/program/dispatch.rs tests/events/programs/events/src/lib.rs
  • git diff --check
  • cargo test -p anchor-syn
  • cargo test --manifest-path tests/events/programs/events/Cargo.toml
  • cargo test -p tests-v2 event_cpi
  • PATH="$HOME/.local/bin:$HOME/.nvm/versions/node/v20.19.0/bin:$PATH" ../../target/debug/anchor test --skip-lint from tests/events

Full tests/events result: 5 passing

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant