-
Notifications
You must be signed in to change notification settings - Fork 4.7k
Refactor instruction compilation and update message account key ordering #23729
Conversation
68866fd
to
29d0af5
Compare
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.
lgtm with a few nits. any idea if there's a perf delta? my gut says this is faster, but get_keys
was such a cluster that it's hard to be sure
pub(crate) fn try_create_message_header(&self) -> Option<MessageHeader> { | ||
Some(MessageHeader { | ||
num_required_signatures: u8::try_from( | ||
self.writable_signer_keys | ||
.len() | ||
.checked_add(self.readonly_signer_keys.len())?, | ||
) | ||
.ok()?, | ||
num_readonly_signed_accounts: u8::try_from(self.readonly_signer_keys.len()).ok()?, | ||
num_readonly_unsigned_accounts: u8::try_from(self.readonly_non_signer_keys.len()) | ||
.ok()?, | ||
}) | ||
} | ||
|
||
pub(crate) fn into_message_static_keys(self) -> Vec<Pubkey> { |
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.
almost seems like combining these into a
pub(crate) fn into_message_components(self) -> Option<(MessageHeader, Vec<Pubkey>)>
would be more ergonomic. wdyt?
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.
Hmm yeah that's what I had originally, switched back to that.
use {super::*, crate::instruction::AccountMeta}; | ||
|
||
#[test] | ||
fn test_compile_with_dup_keys() { |
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.
this name threw me off 'cause the key dupe comes from duplicating the instruction rather than an AccountMeta
29d0af5
to
726cff5
Compare
Thanks for the review. Any reason you're asking about perf here? This code path is only used by validators when voting. I think there could be a small hit for transactions with a small number of keys but yeah my gut says that this is faster because it removes an O(N^2) loop and we were already building a |
Just thinking about some of the higher TPS client-side use-cases. Pretty sure voting can absorb any (negligible) negative delta this might introduce, might compound in other situations though. |
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.
thanks! lgtm
ba344ff
to
4d88fa8
Compare
4d88fa8
to
19cb3db
Compare
I guess I missed this one while I was ooo. Ended up being a bit of a time-bomb in |
* Add SPL Token 2022 to the list of known token ids * Fix tests to accommodate #23729 * Test parsing of basic token-2022 instructsions Co-authored-by: Tyera Eulberg <tyera@solana.com>
Oh no, what was the issue that you encountered? I see a commit that fixes tests, was there anything beyond broken tests that this caused issues for? |
Ha, no, sorry to be melodramatic! It was just the tests that were broken. Took me a minute to figure out why, though, since the other crate tests were fine. |
…24625) * Add SPL Token 2022 to the list of known token ids (#23067) * Add SPL Token 2022 to the list of known token ids * Fix tests to accommodate #23729 * Test parsing of basic token-2022 instructsions Co-authored-by: Tyera Eulberg <tyera@solana.com> (cherry picked from commit 4138066) # Conflicts: # Cargo.lock # programs/bpf/Cargo.lock * Fix lock conflicts Co-authored-by: Michael Vines <mvines@gmail.com> Co-authored-by: Tyera Eulberg <tyera@solana.com>
Cribbed from #23729 to ease backports
Cribbed from #23729 to ease backports
…#26057) * Make instruction-parsing tests less brittle Cribbed from #23729 to ease backports * RPC instruction parser tests are missing some cases (#25951) * Fix num-accounts typo and extend test * Add extra test cases to parse_system * Add extra test cases to parse_vote * Add extra test cases to parse_stake * Fixup parse_bpf_loader * Add extra test cases to parse_bpf_upgradeable_loader * Add extra test cases to parse_associated_token Co-authored-by: Justin Starry <justin@solana.com> Co-authored-by: Tyera Eulberg <tyera@solana.com>
* Add SPL Token 2022 to the list of known token ids * Fix tests to accommodate solana-labs#23729 * Test parsing of basic token-2022 instructsions Co-authored-by: Tyera Eulberg <tyera@solana.com>
* Add SPL Token 2022 to the list of known token ids * Fix tests to accommodate solana-labs#23729 * Test parsing of basic token-2022 instructsions Co-authored-by: Tyera Eulberg <tyera@solana.com>
* Add SPL Token 2022 to the list of known token ids * Fix tests to accommodate solana-labs#23729 * Test parsing of basic token-2022 instructsions Co-authored-by: Tyera Eulberg <tyera@solana.com>
Problem
Instruction compilation needs to be performed for other message versions but is currently closely tied to the legacy message implementation
Summary of Changes
PublicKey
compile_instructions
method toAccountKeys
to enable future support for compiling instructions for messages using on-chain address lookup tablesCompiledKeys
struct for compiling the account keys for transaction messages. This will be used in Add SDK support for creating transactions with address table lookups #23728 for compiling message keys for v0 transaction messagesFixes #