Skip to content

[BUG]: the entire chain lived in memory and was lost on every restart #57

@aniket866

Description

@aniket866

Bug Description

What

Adds minichain/persistence.py — a minimal module that can write the full blockchain and account state to disk and restore it across sessions.

data/
  blockchain.json   ← serialized list of blocks
  state.json        ← accounts dict (balances, nonces, contract storage)

Why

Previously the entire chain lived in memory and was lost on every restart. This made multi-session research, demos, and testnet usage impossible.

API

from minichain.persistence import save, load

Save

save(blockchain, path="data/")

Restore

blockchain = load(path="data/")

load() returns a fully working Blockchain instance — new blocks can be mined and added immediately after loading.

Steps to Reproduce

No response

Logs and Screenshots

No response

Environment Details

No response

Impact

Critical - Application is unusable

Code of Conduct

  • I have joined the Discord server and will post updates there
  • I have searched existing issues to avoid duplicates

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions