Skip to content

allow with_seed functions to accept any bytes, not just UTF-8#361

Draft
kevinheavey wants to merge 5 commits into
anza-xyz:masterfrom
kevinheavey:address-seed-bytes
Draft

allow with_seed functions to accept any bytes, not just UTF-8#361
kevinheavey wants to merge 5 commits into
anza-xyz:masterfrom
kevinheavey:address-seed-bytes

Conversation

@kevinheavey

Copy link
Copy Markdown
Contributor

The with_seed functions (eg Address::create_with_seed) and WithSeed instruction variants (eg SystemInstruction::CreateAccountWithSeed) all expect &str or String. But they don't do anything that requires UTF-8, and they just convert these values back to bytes.

Two reasons this is bad:

  1. Bincode wastes time on UTF-8 validation
  2. It would be nice to use arbitrary bytes (such as an Address) as a seed

Breaking changes:

  • Address::create_with_seed is technically a breaking change. Changing the type to &(impl AsRef<[u8]> + ?Sized), means it works as before for most people, but breaks for anyone passing create_with_seed itself to a function that expected the seed param to be &str. It's possible that nobody is doing this.
  • system-interface, vote-interface and the wasm helpers just change to &[u8] or Vec<u8>

In Agave there would be some small changes to system_processor.rs and vote_processor.rs. Firedancer would need to remove the UTF-8 check. Does this need a SIMD?

@t-nelson

t-nelson commented Oct 9, 2025

Copy link
Copy Markdown
Contributor

i don't think there is any rationale for enforcing utf8 here

Does this need a SIMD?

yes. during adoption of the change, upgraded vs not nodes would have differing execution results for non-utf8 inputs

@kevinheavey

kevinheavey commented Oct 11, 2025

Copy link
Copy Markdown
Contributor Author

Pre-SIMD discussion here solana-foundation/solana-improvement-documents#378

@kevinheavey

Copy link
Copy Markdown
Contributor Author

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.

2 participants