-
Notifications
You must be signed in to change notification settings - Fork 2.2k
Support Account Data for Seeds in Account Resolution #5051
Conversation
e626e4a
to
d7105a2
Compare
TLV AR: Account Data Support
d7105a2
to
45a2658
Compare
All of those copied functions are definitely annoying... as a first pass, how about having the offchain version fetch all of the accounts in the instruction before using the same helpers? It means some more network calls, but it's not a huge deal. What do you think? |
I plucked my comment because that's what I just laid down ha! But yeah, the network calls are a bit overkill. However, it solves both the copy-pasta and cloning issues. 1 evil < 2 evils? |
1021f2c is my first-pass attempt at condensing the duplicated API functions, ie. addressing design note 1.
Is this what you had in mind? |
Yeah that's definitely on the right track. I haven't thought this through totally, but rather than separating out the addressable part and the data part, how about doing everything through This might end up being even cleaner than before! Kinda |
Cool, thanks! I'll take a look. I went with the |
Closing for #5182 |
This PR adds support for account data as a seed configuration for a PDA stored
within validation data.
A dynamic program-derived address may depend on one or more seeds that are
actually taken from the inner data of some account in the list of accounts
provided to the program.
Design Notes
There are a few notes to consider with this design.
The notes below each section will be tied to specific commits.
Separation of Off-Chain and On-Chain
Similar to the layout of the helpers in the Transfer Hook Interface, the
functions within TLV Account Resolution are now separated into off-chain and
on-chain use case categories.
Even though they share much of the same functionality, the main reason this
was done is because of the fact that on-chain programs can't use
async
/await
. Therefore, they couldn't share the sameFut
closure.Repeated
get_program_data_fn
InvocationsCurrently there is no mechanism in place to mitigate the amount of repeated
invocations of the
F(Pubkey) -> Fut
closure.For example, if two or more PDA seed configurations within a program
instruction's validation data depend on the account data of some account in the
list, we want to avoid invoking the closure more than once for the same account.
Right now, each time a
Seed::AccountData
config is encountered, the closureis invoked.
It's worth mentioning we could just put the onus on the user to add some client-level caching to their
get_account_data_fn
closure.