add_block deep-copies every account on every block
Maintainers usually reply within 1 day
@anshulchikhale30-p is already working on this.
Since Nov 10, 2026.
Assessment
- Difficulty
- 5/5
- Estimated time
- Over a week
- Newbie friendliness
- 45/100
- Issue type
- Refactor
- Clarity
- Mostly clear
- Activity status
- Active
- Tech stack
- python
- Domain
- backend, performance
Research direction
Start with State.snapshot() in minichain/state.py and trace how Blockchain.add_block stores and uses snapshots during reorgs. The issue suggests recording only accounts changed in a block’s journal and rebuilding older states when needed. Done means snapshots avoid copying every account while preserving correct state after a reorg; the issue names no tests to run.
Written by the indexing model from the issue text.
Description
Problem
Every time a block is added, Blockchain.add_block saves a snapshot of the state for reorgs, and State.snapshot() (minichain/state.py) does a copy.deepcopy of the whole accounts dict. So each block costs time proportional to the total number of accounts, even when the block only touches a few of them.
Measurements
Time for one empty block vs. the snapshot copy alone (best of 5):
| Accounts | One block | Snapshot copy alone |
|---|---|---|
| 1,000 | 2.7 ms | 2.1 ms |
| 10,000 | 34.5 ms | 29.5 ms |
| 50,000 | 194.4 ms | 204.1 ms |
The copy is most of the cost of a block and grows linearly with the number of accounts.
Impact
Fine at MiniChain's current scale, but block processing slows down as the number of accounts grows.
Possible direction
A block only changes the accounts in its journal, so a snapshot could record just those accounts instead of copying everything. Older states would then be rebuilt from those changes when a reorg needs them.
- Dominant language
- Python
- Stars
- 12
- Forks
- 27
- Avg merge
- 2m
- Merged PRs (30d)
- 1
Getting set up
- Ships a Dockerfile or Docker Compose file
- No pull request template
- Read the contributing 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 StabilityNexus/MiniChain
-
[BUG]: Handle JSON-RPC notifications and empty batches correctlyPossibly taken @Muneerali199 claimed this 10 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
StabilityNexus/MiniChain#177 · 2 comments ·
Maintainers usually reply within 1 day
-
automatic-copyright-year: keep README copyright currentPossibly taken @anshulchikhale30-p claimed this 7 days ago. Opendocumentation enhancement
Difficulty 3/5 Half a day Newbie friendliness 35/100
StabilityNexus/MiniChain#189 ·
Maintainers usually reply within 1 day
-
Difficulty: bound per-block EMA moves, add a difficulty floor, and preserve state across restartsPossibly taken @anshulchikhale30-p claimed this 7 days ago. Openbug documentation enhancement
Difficulty 4/5 3-5 days Newbie friendliness 25/100
StabilityNexus/MiniChain#187 ·
Maintainers usually reply within 1 day
-
[BUG]: Blocks on a different parent are classified INVALID and get the sender bannedPossibly taken @kansalakshat claimed this 7 days ago. Openbug
Difficulty 2/5 1-3 hours Newbie friendliness 35/100
StabilityNexus/MiniChain#185 ·
Maintainers usually reply within 1 day
-
[BUG]: P2P sync downloads full 500-block chunks without headers-first validationPossibly taken @anshulchikhale30-p claimed this 14 days ago. Openbug documentation enhancement
Difficulty 5/5 Over a week Newbie friendliness 25/100
StabilityNexus/MiniChain#178 ·
Maintainers usually reply within 1 day
All issues in StabilityNexus/MiniChain
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
huggingface/datasets#9128 ·
Maintainers usually reply within 1 day
-
priority:low ready-for-dev
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
OpenHands/extensions#975 ·
Maintainers usually reply within 1 day
-
Function/dict state handlers can't supply provider-state injected values (`generate.provider_state`)Open
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
pact-foundation/pact-python#1789 ·
Maintainers usually reply within 9 days
-
documentation
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
juandresrodca/AdminForge#66 ·
Maintainers usually reply within 1 day
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
Maintainers usually reply within 1 day