-
Notifications
You must be signed in to change notification settings - Fork 60
feat: API to process multiple ixs with one TransactionContext #186
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat: API to process multiple ixs with one TransactionContext #186
Conversation
cfc476b to
9febffc
Compare
|
applied the alternate approach #185 (comment) added a basic test to verify instructions have shared account txn context |
74fea54 to
40873a0
Compare
buffalojoec
left a comment
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 for throwing this together! It's going to be a pretty hefty change - requiring lots of tests - so bear with me, but we can move toward a working solution.
harness/src/compile_accounts.rs
Outdated
| pub fn compile_accounts_chain<'a, 'b>( | ||
| instructions: impl Iterator<Item = &'b Instruction>, | ||
| accounts: impl Iterator<Item = &'a (Pubkey, Account)>, | ||
| loader_key: Option<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.
We need to actually capture all owners of each program in the top-level instruction set, so we'll want to use something like a Vec<(Pubkey, Pubkey)> where we pass (program_id, owner).
Then, we can stub only the top-level instructions' program accounts. What you have here won't work for a transaction context with two different program IDs invoked.
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 test is a good start, but we'll want to really expand on the test coverage for the new API method. It would be good to run a few instructions against a few different programs in the same transaction context. We also should have at least one test that runs up against the transaction context limits, like number of accounts or CU budget.
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.
I have a similar comment about duplicated code in this file. There's tons of duplication going on for the new API method you added. Let's see how we can share common code across all of the process_ functions.
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.
I'm still seeing lots of code being duplicated, even after the rebase.
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.
sorry for the delay,
as the process_ and validate were nearly identical with some checks, i implemented helpers for single,chain and multi fn
passed the core fn to inner aswell to reuse the code
is this valid? i couldnt think of a better fix to code duplication
|
@buffalojoec , i tried to call compile_accounts for both the cases but it broke some tests.. because they build different KeyMaps for single vs all instruction the functionality couldn't be merged, do you have any other approach in mind extracted out functions from process_transaction_instructions and validate fixed the program owner bug, added more tests to verify the functionality i have reduced duplicate code aswell with extract func |
26f7965 to
f38968d
Compare
Thank you! that was logical to do so now i can map fallback_accounts instead of program_owners. |
Go ahead and rebase. I just merged. |
12ddfcb to
4367df6
Compare
I have implemented
edit: added docs to new api to show differences in both process_ |
4367df6 to
6e97a96
Compare
|
Hey @Duckaet sorry to do this to you again, but I just merged #189, and that changed the account compilation API to just use a Message directly. The good news is that this simplified the account compilation quite a bit, and it's already using a transaction primitive! So now it should be even easier to implement your new API. However, you'll have to rebase again. |
6e97a96 to
9647f3e
Compare
just rebased it, I passed the SanitizedMessage to prepare_next_top_level_instruction() now, but their is still alot of duplication in lib.rs should I also push the changes for the process_* and process_and_validate_* pairs using an inner helper with optional checks? |
fda1531 to
c6bb47d
Compare
|
@Duckaet thanks for the continued effort on this feature! It turned out to be much more of a beast than I anticipated, so I hopped in to assist. I've added several new commits, the first of which reverts the harness back to what's on This allowed me to implement both new API methods with shared code, and even clean up quite a bit of duplicated code! Have a look when you get a chance. |
it implemenst the issue #185