Deepcore / STORAGE.md
BKillings's picture
Upload 2 files
e4b5ded verified
|
Raw History Blame Contribute Delete
2.42 kB
# BKILLINGS durable runtime v3
This package adds SQLite storage to the locally tested runtime adapter. It is not deployed.
## Use
Install dependencies from requirements.txt. From the extracted bkillings directory:
```python
from bkillings_store import BKillingsStore
from deepcore_blockchain import Transaction
from cryptography.hazmat.primitives.asymmetric.ed25519 import Ed25519PrivateKey
# Demo key only; production key custody must be configured independently.
key = Ed25519PrivateKey.generate()
with BKillingsStore("bkillings.sqlite") as store:
tx = Transaction.sign(key, 1, "OBSERVATION", {"value": 10})
store.add_block([tx])
print(store.snapshot().verified_commitment())
```
Reopen the same database to recover the chain. Each operation reloads verified state under a SQLite transaction. Writes use BEGIN IMMEDIATE, WAL, and synchronous=FULL. Use one connection per thread or process; separate writers serialize through SQLite. Keep the database on a local filesystem with correct SQLite locking and sync semantics. Back up with SQLite's backup API; do not copy only the main file while WAL is active.
Verification on this turn: 21 unittest tests passed (7 mathematical, 8 runtime integration, 6 storage). The six storage checks cover restart equality, invalid-batch rollback, separate-writer reload, injected SQL failure, stored-commitment tampering, and subprocess termination before commit. The prior turn reported 24 additional baseline tests passing; they were not rerun here because pytest was unavailable.
Run the current suite with `python -m unittest -v test_math test_integration test_store`. Run all tests, including the original baseline, with `python -m pytest -q` when pytest is installed.
Limits: process-exit testing does not establish power-loss durability on every storage device. Stored hashes detect inconsistent edits, not an attacker rewriting all data and hashes or truncating a valid suffix. An empty database initializes genesis; external trusted checkpoints and backups are required to detect deletion or rollback. Full-prefix replay during loading is expensive (quadratic verification work); this is a small-chain prototype. It has no distributed consensus, signer service, persistent key custody, authenticated API, or Bitcoin broadcaster. Existing network-binding and clock-dependent replay limitations remain. No repository, deployment, or live chain was changed.