solana-labs / solana

Web-Scale Blockchain for fast, secure, scalable, decentralized apps and marketplaces.
https://solanalabs.com
Apache License 2.0
13.02k stars 4.19k forks source link

Mutable unsigned accounts passed to programs #1927

Closed garious closed 4 years ago

garious commented 5 years ago

Problem

Accounts referenced by unsigned keys and executable accounts are passed into programs using the same data structure as accounts referenced by signed keys. They are therefore mutable, which requires them to be cloned before being passed to programs. That'll be really slow for large accounts, such as executable accounts.

Proposed Solution

Pass programs immutable references to executable and unsigned accounts

garious commented 5 years ago

Per @jackcmay, this may be a superset of what's needed for: https://github.com/solana-labs/solana/issues/1545

garious commented 5 years ago

Removed the Beacons milestone and assignee because this is a performance enhancement and not the focus of that release cycle.

rob-solana commented 5 years ago

in general, unsigned accounts are mutable by programs that own them... what's the scope of this issue, now?

garious commented 5 years ago

This issue is 6 months old and needs rethinking with what we learned from implementing credit-only accounts. The goal of the issue is to get rid of any unnecessary account (or account data) clones in the runtime.

I agree, the problem description doesn't acknowledge unsigned program accounts, which can be modified by the program. My guess is this optimization would only be relevant if we generalize account permissions beyond credit-only/debitable to read-only/credit-only/debitable. Whether we could actually make use of that read-only case for higher TPS should be evaluated before we move forward with this one.

Also, as I recall, we might already special case the executable accounts (@jackcmay?). If so, and there's no clone() there, we can probably close this ticket.

jackcmay commented 5 years ago

The executable account (I think you are referring to the program itself) is not passed, so no extra clone there. All the accounts passed to programs are cloned (native are special cases) since they are serialized into the program's "process". Ideally unmodifiable accounts would be mapped in as RO.

@CriesofCarrots and I were discussing mapping those accounts into the program's space but it was not trivial and probably not done as part of the initial credit-only account effort.

CriesofCarrots commented 5 years ago

Correct, that work has not been done. It is briefly described by items 3-4 on this issue: https://github.com/solana-labs/solana/issues/4700 I'm not sure that this issue adds much context or nuance, so could be closed.

jackcmay commented 4 years ago

@greg This issue should probably be closed in lieu of an issue that asks that only RW accounts be cloned. If you agree I'll close and reopen and new more specific issue.

garious commented 4 years ago

Yeah, this issue is super dated, closing.