stellar / stellar-docs

Documentation for Stellar
https://developers.stellar.org
Apache License 2.0
59 stars 124 forks source link

Add guidelines on data storage model #486

Open marta-lokhova opened 1 year ago

marta-lokhova commented 1 year ago

(as per discussion with @tomerweller) It would be nice to have some guidelines on storing large sets of data on chain. For example, when storing a list of accounts, it's not immediately obvious that a scalable approach is to have each individual account as a separate key (instead of having one key "accounts" and a list as a value). An explanation that each key-val pair creates a ledger entry in core that is strictly limited in size would also be helpful.

janewang commented 5 months ago

@marta-lokhova Is this something that you could help document? Maybe add to the granularity section on this page https://developers.stellar.org/docs/learn/smart-contract-internals/persisting-data#granularity

marta-lokhova commented 5 months ago

@janewang I think it'd be more appropriate for someone from the protocol team to take a stab at this (things probably have changed quite a bit since I opened the issue). tagging @sisuresh @dmkozh for input

dmkozh commented 5 months ago

@marta-lokhova Is this something that you could help document? Maybe add to the granularity section on this page https://developers.stellar.org/docs/learn/smart-contract-internals/persisting-data#granularity

I think this section is fine as it stands and describes the lower-level protocol behavior quite well. Maybe the sections that mention storage should make a more clear statement that env.storage().persistent()/temporary() creates or modifies a ledger entry, and that ledger entries are subject to fees and limits (as per respective docs section).

janewang commented 5 months ago

@marta-lokhova Thanks, please feel free re-assign to the best person from the protocol team as you've suggested. @dmkozh Thank you for your inputs here :)