Rework the instruction parse API around per-input account borrows - #93
Rework the instruction parse API around per-input account borrows#93squadgazzz wants to merge 3 commits into
Conversation
|
hi @squadgazzz , We have started reviewing this PR internally. While we aren't ready to share a comprehensive review, a couple things that have caught our attention so far is, broadly:
We are in the process of getting CU benchmarks up and running btw #67 , but until then it may be a bit longer before we can fully review the PR 🙏 |
|
Thanks for the early look @kaze-cow 🙇 Agree on the placement, moved to the client crate. The interface only keeps the per-input parsers the program itself uses. Regarding the duplication, it doesn't re-parse anything, it's a single discriminator match that delegates to those same per-input parsers. Our indexer needs one entry point for "here's an instruction, tell me what it is", and without this it would hand-roll that match against the interface anyway. Regarding the second comment, the borrow split is compile-time only. The two settle inputs keep |
Description
Review of cowprotocol/services#4666 (the indexer parses instructions read-only) surfaced three rough edges in the interface crate: every input demanded
&'a mut [A]even when parsing only reads, callers had to recover the discriminator and dispatch by hand, and buffer pairs came back as positional[A; 2]arrays.Changes
InstructionInputParsinggains an associatedtype Accounts. Read-only inputs (initialize, create order, create buffer, reclaim order) now parse from&'a [A], the two settle inputs keep&'a mut [A].parse_instructionentry point dispatches by discriminator and returns aParsedInstructionenum.CreateBufferInputyields namedBufferAccounts { buffer_pda, mint }pairs instead of index-addressed arrays.AccountViewcopy writes through to the same runtime account.How to test
Updated unit tests.