Skip to content

feat: is token mint classifier#401

Open
sonicfromnewyoke wants to merge 1 commit intosolana-foundation:mainfrom
sonicfromnewyoke:sonic/feat-is-token-mint-classifier
Open

feat: is token mint classifier#401
sonicfromnewyoke wants to merge 1 commit intosolana-foundation:mainfrom
sonicfromnewyoke:sonic/feat-is-token-mint-classifier

Conversation

@sonicfromnewyoke
Copy link
Copy Markdown
Contributor

Problem

classifying accs as Mints on the hot path of an indexer or unfiltered getProgramAccounts pipeline is expensive if done via a full borsh decode - hundreds of nanoseconds and dozens of allocations per candidate, most of which are discarded.
#396 proposes a byte-level IsTokenMint(acc *Account) bool helper, but the submitted version has a latent nil-panic on acc == nil, uses magic numbers, and orders its checks so every call pays for a 32-byte PublicKey comparison - including the majority case where the account isn't a token at all

Summary of Changes

  • added helper with the same API and logic as proposed in Add IsTokenMint helper #396
  • added test-cases
  • performed benchmarks, to not propose worse solution - 1.86x faster on mixed indexer workloads, 1.77x on cold path, 0 allocations

Benches

Scenario switch-on-owner length-first Speedup
Mixed 8-shape rotation (indexer) 3.51 ns 1.89 ns 1.86x
Hot path - bare SPL Token mint 2.68 ns 2.47 ns 1.09x
Cold path - non-token owner 3.15 ns 1.78 ns 1.77x

supresses #396

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