Discuss harmful / easy mistakes that don't scale or could result in stuck contracts
Nobody has claimed this yet.
Assessment
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Newbie friendliness
- 55/100
- Issue type
- Documentation
- Clarity
- Mostly clear
- Activity status
- Active
- Domain
- blockchain, documentation
Research direction
Start with the storage documentation at developers.stellar.org/docs/learn/encyclopedia/storage/persisting-data and compare its guidance with the Soroban examples pull request #369. Review the issue's concerns about ledger-entry size, fees, and congestion, then determine how a do-not-do page should explain bounded versus unbounded collections. Done means the relevant documentation is updated with clear guidance and examples or links for safer storage patterns.
Written by the indexing model from the issue text.
Description
I think we need to discuss some of the harmful or easy mistakes to make with contract data, that can result in a contract not scaling, or getting stuck when data grows past a certain size.
The main case that's come up recently is seeing folks try to use the built in container types soroban_sdk::{Vec, Map} to hold what could be unbounded collections and storing those collections in a single contract data entry.
The docs on storage, such as the page below, don't discuss how collections stored in contract data ledger entries
Problems arise when contract callers can cause collections to grow. Contract data ledger entries are limited in size by the max size for any ledger entry. This means there's a point where writing new data to a collection will result in an error, because it won't be able to be written back out. Even before that limit is reached the fees related to building and writing the collection at that size may be impractical in terms of other resource costs.
Separate to size constraints the use of collections in a single entry, where multiple users may write to, will cause congestion since all transactions writing to the shared collection would need to occur serially. This will make using the contract more expensive since it won't be able to utilise multiple execution lanes. Simulation is likely to fail to estimate the cost of doing so if it is being written to by multiple users inside a single ledger.
Collections that are inherently unbounded in size should instead be stored with each individual entry in the collection being a separate contract data ledger entry. There's an unmerged example for how to do that here:
This topic would also be a good candidate for a "do-not-do" style page, such as like the on that Postgres has in its wiki:
- Dominant language
- MDX
- Stars
- 138
- Forks
- 313
- Avg merge
- 3d 11h
- Merged PRs (30d)
- 44
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from stellar/stellar-docs
-
Hubble data dictionary: num_subentries description and minimum balance formula are both incorrect Openanalytics bug documentation
Difficulty 2/5 1-3 hours Newbie friendliness 91/100
stellar/stellar-docs#2860 · 1 comment ·
-
raven
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
stellar/stellar-docs#2842 · 2 comments · 1 reaction ·
-
bug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
stellar/stellar-docs#2722 ·
-
raven
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
stellar/stellar-docs#2565 · 2 comments ·
-
bot:needs-decision documentation
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
stellar/stellar-docs#1767 · 2 comments · 1 reaction ·
All issues in stellar/stellar-docs
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 84/100
blinklabs-io/bursa#904 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
rust-bitcoin/rust-bitcoin#6908 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Merit-Systems/x402scan#1215 ·
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
Uniswap/default-token-list#2585 ·