Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
91c9969
feat: issue #8 project scaffolding
arunabha003 Feb 16, 2026
1a26ae7
feat(crypto): add Ed25519 identity and signature helpers
arunabha003 Feb 16, 2026
fce3e7a
test(crypto): cover keypair, address, and signature validation
arunabha003 Feb 16, 2026
15c67bd
feat(serialization): add canonical transaction and header encoding
arunabha003 Feb 16, 2026
313ee5d
test(serialization): add deterministic encoding coverage
arunabha003 Feb 16, 2026
58125c2
chore: fix serialization lint formatting
arunabha003 Feb 17, 2026
dcc3d23
feat: implement signed transaction model and verification
arunabha003 Feb 17, 2026
ca2fd8e
test: add transaction tamper and identity mismatch coverage
arunabha003 Feb 17, 2026
92e96a4
feat: add merkle root computation using blake2b
arunabha003 Feb 21, 2026
761eb20
test: add merkle root determinism and edge-case coverage
arunabha003 Feb 21, 2026
0b5b764
feat: add deterministic transaction id hashing
arunabha003 Feb 21, 2026
bd229ab
feat: implement block header hashing and merkle validation
arunabha003 Feb 21, 2026
a7b4f4b
test: add block hash and merkle-root coverage
arunabha003 Feb 21, 2026
aa7ea05
feat: implement account state transitions and atomic block apply
arunabha003 Feb 21, 2026
af35a69
test: add state transfer, nonce, and rollback coverage
arunabha003 Feb 21, 2026
1fb521f
feat: add configurable genesis block and state initialization
arunabha003 Feb 21, 2026
b930f7e
test: add genesis block creation and application coverage
arunabha003 Feb 21, 2026
42cba00
feat: implement proof-of-work mining engine
arunabha003 Feb 21, 2026
0783e6d
test: add pow validation and mining interruption coverage
arunabha003 Feb 21, 2026
3d723fd
feat: implement bounded difficulty adjustment
arunabha003 Feb 22, 2026
8a4d38b
test: add difficulty retarget scenarios
arunabha003 Feb 22, 2026
748a959
feat: add coinbase transaction validation and state handling
arunabha003 Feb 23, 2026
8f05a01
test: cover coinbase acceptance and rejection paths
arunabha003 Feb 23, 2026
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
29 changes: 29 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
name: CI

on:
push:
branches: [main]
pull_request:

jobs:
test:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4

- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
Comment on lines +15 to +18
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider enabling pip caching to speed up CI.

actions/setup-python@v5 supports a cache option that avoids re-downloading packages on every run.

Proposed fix
       - name: Setup Python
         uses: actions/setup-python@v5
         with:
           python-version: "3.11"
+          cache: "pip"
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
- name: Setup Python
uses: actions/setup-python@v5
with:
python-version: "3.11"
cache: "pip"
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/ci.yml around lines 15 - 18, CI step using
actions/setup-python@v5 doesn't enable pip caching, which causes dependencies to
be downloaded every run; update the Setup Python step (actions/setup-python@v5)
to include the cache option (e.g., set cache: "pip") so the action caches pip
packages between runs, and ensure the python-version: "3.11" setting remains
unchanged and test a workflow run to confirm the cache is being used.


- name: Install dependencies
run: |
python -m pip install --upgrade pip
python -m pip install -e .[dev]
- name: Lint
run: make lint

- name: Run tests
run: make test
14 changes: 14 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -258,6 +258,17 @@ pythontex-files-*/
# easy-todo
*.lod

# MiniChain local planning docs (do not commit)
issues.md
architectureProposal.md

# Python caches and virtualenvs
__pycache__/
*.py[cod]
.pytest_cache/
.ruff_cache/
.venv/
Comment on lines +261 to +270
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Add .env to prevent accidental secret commits.

The Python section adds cache and virtualenv entries, but omits .env. For a blockchain project that handles private keys and may source secrets from environment files, committing a .env file by accident is a meaningful security risk.

🔒 Proposed addition
 # Python caches and virtualenvs
 __pycache__/
 *.py[cod]
 .pytest_cache/
 .ruff_cache/
 .venv/
+.env
+.env.*
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
# MiniChain local planning docs (do not commit)
issues.md
architectureProposal.md
# Python caches and virtualenvs
__pycache__/
*.py[cod]
.pytest_cache/
.ruff_cache/
.venv/
# MiniChain local planning docs (do not commit)
issues.md
architectureProposal.md
# Python caches and virtualenvs
__pycache__/
*.py[cod]
.pytest_cache/
.ruff_cache/
.venv/
.env
.env.*
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore around lines 261 - 270, Add `.env` to the Python/dev section of
the .gitignore to prevent accidental commits of environment secret files; locate
the block containing entries like "__pycache__/", "*.py[cod]", ".pytest_cache/",
".ruff_cache/", and ".venv/" and insert a new line with ".env" alongside them so
local environment files are ignored.

Comment on lines +265 to +270
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Python entries are inserted mid-LaTeX-section — consider moving them to the end.

Lines 265–270 split the continuous LaTeX auxiliary-files block (which continues at line 272 with # xcolor). Python-specific entries belong either in their own section at the end of the file, grouped with the docs/ entry at lines 338–340, or in a dedicated Python section before the LaTeX block.

♻️ Suggested reorganization
-# Python caches and virtualenvs
-__pycache__/
-*.py[cod]
-.pytest_cache/
-.ruff_cache/
-.venv/
-
 # xcolor
 *.xcp

And append at the end of the file (after the existing content):

+
+# Python caches and virtualenvs
+__pycache__/
+*.py[cod]
+.pytest_cache/
+.ruff_cache/
+.venv/
+.env
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore around lines 265 - 270, The Python ignore lines (__pycache__/,
*.py[cod], .pytest_cache/, .ruff_cache/, .venv/) are currently inserted in the
middle of the LaTeX auxiliary-files block (near the "# xcolor" entry); move
these Python-specific entries out of that block and into a dedicated Python
section (or append them to the end of the file near the docs/ entries) so the
LaTeX section remains contiguous and Python ignores are grouped together.


# xcolor
*.xcp

Expand Down Expand Up @@ -324,3 +335,6 @@ TSWLatexianTemp*
# option is specified. Footnotes are the stored in a file with suffix Notes.bib.
# Uncomment the next line to have this generated file ignored.
#*Notes.bib


docs/
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

docs/ blanket ignore may silently drop versioned documentation.

Ignoring the entire docs/ directory is appropriate only when its contents are fully auto-generated (e.g., Sphinx HTML output). If the directory also contains hand-written files — ADRs, architecture proposals, migration notes, or API references — they will be invisible to git and permanently unversioned without any warning.

If docs are auto-generated, scope the rule to the build output sub-path instead:

🛡️ Proposed scoped alternative
-docs/
+docs/_build/
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
docs/
docs/_build/
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.gitignore at line 340, The .gitignore currently contains a blanket "docs/"
rule which can silently omit handwritten documentation; update the .gitignore by
narrowing or removing that rule: either remove "docs/" to keep the directory
versioned, replace it with a scoped path for generated output (e.g.,
"docs/_build/" or "docs/build/") if docs are generated, or add explicit
allow-list exceptions (e.g., negate patterns like "!docs/**/*.md" or specific
files) so ADRs and manual docs are not ignored; locate the "docs/" entry in
.gitignore and apply one of these scoped alternatives accordingly.

21 changes: 21 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
PYTHON ?= python3

.PHONY: install dev-install test lint format start-node
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🧹 Nitpick | 🔵 Trivial

Consider adding a clean target.

checkmake flags the missing clean phony target. Cleaning __pycache__, .ruff_cache, dist, and *.egg-info is useful in CI and local development.

♻️ Proposed addition
-.PHONY: install dev-install test lint format start-node
+.PHONY: install dev-install test lint format start-node clean
+
+clean:
+	find . -type d -name '__pycache__' -exec rm -rf {} +
+	find . -type d -name '*.egg-info' -exec rm -rf {} +
+	rm -rf .ruff_cache dist
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
.PHONY: install dev-install test lint format start-node
.PHONY: install dev-install test lint format start-node clean
clean:
find . -type d -name '__pycache__' -exec rm -rf {} +
find . -type d -name '*.egg-info' -exec rm -rf {} +
rm -rf .ruff_cache dist
🧰 Tools
🪛 checkmake (0.2.2)

[warning] 3-3: Missing required phony target "all"

(minphony)


[warning] 3-3: Missing required phony target "clean"

(minphony)

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 3, Add a new clean phony target to the Makefile and include
it in the existing .PHONY list: declare a target named clean that removes build
and cache artifacts (e.g., __pycache__, .ruff_cache, dist, and any *.egg-info)
so CI and local dev can reset state; update the .PHONY line (currently listing
install dev-install test lint format start-node) to also include clean and
ensure the clean target performs safe removals (rm -rf or equivalent) for those
directories/patterns.


install:
$(PYTHON) -m pip install .

dev-install:
$(PYTHON) -m pip install -e .[dev]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Quote .[dev] to prevent shell glob expansion.

In POSIX shells, [dev] is interpreted as a bracket expression matching the single characters d, e, or v. If a file named .d, .e, or .v exists in the project root, the shell expands it before pip sees the argument, silently installing the wrong target.

🐛 Proposed fix
-	$(PYTHON) -m pip install -e .[dev]
+	$(PYTHON) -m pip install -e '.[dev]'
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
$(PYTHON) -m pip install -e .[dev]
$(PYTHON) -m pip install -e '.[dev]'
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@Makefile` at line 9, The Makefile target invoking pip uses an unquoted
bracket expression (the command invoking $(PYTHON) -m pip install -e .[dev]),
which can be expanded by the shell; fix it by quoting or escaping the extras
spec so pip receives the literal ".[dev]" (e.g., change the pip install
invocation to use '.[dev]' or ".[dev]" or escape the brackets) while leaving the
$(PYTHON) variable and the rest of the command intact.


test:
$(PYTHON) -m pytest

lint:
$(PYTHON) -m ruff check src tests

format:
$(PYTHON) -m ruff format src tests

start-node:
PYTHONPATH=src $(PYTHON) -m minichain --host 127.0.0.1 --port 7000
265 changes: 50 additions & 215 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,236 +1,71 @@
<!-- Don't delete it -->
<div name="readme-top"></div>
# MiniChain

<!-- Organization Logo -->
<div align="center" style="display: flex; align-items: center; justify-content: center; gap: 16px;">
<img alt="Stability Nexus" src="public/stability.svg" width="175">
<img src="public/todo-project-logo.svg" width="175" />
</div>
MiniChain is a minimal, research-oriented blockchain implementation in Python. This repository currently contains the project scaffolding and development environment for the v0 core chain roadmap.

&nbsp;
## Current Status

<!-- Organization Name -->
<div align="center">
Issue #1 (project scaffolding) is implemented with:

[![Static Badge](https://img.shields.io/badge/Stability_Nexus-/TODO-228B22?style=for-the-badge&labelColor=FFC517)](https://TODO.stability.nexus/)
- Python package layout under `src/minichain`
- Placeholder component modules for:
- `crypto`, `transaction`, `block`, `state`, `mempool`, `consensus`, `network`, `storage`, `node`
- `pyproject.toml` project configuration
- `Makefile` for common developer tasks
- Basic CI workflow (`.github/workflows/ci.yml`)
- Baseline tests under `tests/`

<!-- Correct deployed url to be added -->
## Requirements

</div>
- Python 3.11+

<!-- Organization/Project Social Handles -->
<p align="center">
<!-- Telegram -->
<a href="https://t.me/StabilityNexus">
<img src="https://img.shields.io/badge/Telegram-black?style=flat&logo=telegram&logoColor=white&logoSize=auto&color=24A1DE" alt="Telegram Badge"/></a>
&nbsp;&nbsp;
<!-- X (formerly Twitter) -->
<a href="https://x.com/StabilityNexus">
<img src="https://img.shields.io/twitter/follow/StabilityNexus" alt="X (formerly Twitter) Badge"/></a>
&nbsp;&nbsp;
<!-- Discord -->
<a href="https://discord.gg/YzDKeEfWtS">
<img src="https://img.shields.io/discord/995968619034984528?style=flat&logo=discord&logoColor=white&logoSize=auto&label=Discord&labelColor=5865F2&color=57F287" alt="Discord Badge"/></a>
&nbsp;&nbsp;
<!-- Medium -->
<a href="https://news.stability.nexus/">
<img src="https://img.shields.io/badge/Medium-black?style=flat&logo=medium&logoColor=black&logoSize=auto&color=white" alt="Medium Badge"></a>
&nbsp;&nbsp;
<!-- LinkedIn -->
<a href="https://linkedin.com/company/stability-nexus">
<img src="https://img.shields.io/badge/LinkedIn-black?style=flat&logo=LinkedIn&logoColor=white&logoSize=auto&color=0A66C2" alt="LinkedIn Badge"></a>
&nbsp;&nbsp;
<!-- Youtube -->
<a href="https://www.youtube.com/@StabilityNexus">
<img src="https://img.shields.io/youtube/channel/subscribers/UCZOG4YhFQdlGaLugr_e5BKw?style=flat&logo=youtube&logoColor=white&logoSize=auto&labelColor=FF0000&color=FF0000" alt="Youtube Badge"></a>
</p>

---

<div align="center">
<h1>MiniChain</h1>
</div>

MiniChain is a minimal fully functional blockchain implemented in Python.

### Background and Motivation

* Most well-known blockchains are now several years old and have accumulated a lot of technical debt.
Simply forking their codebases is not an optimal option for starting a new chain.

* MiniChain will be focused on research. Its primary purpose is not to be yet another blockchain
trying to be the one blockchain to kill them all, but rather to serve as a clean codebase that can be a benchmark for research of
variations of the technology. (We hope that MiniChain will be as valuable for blockchain research as, for instance,
MiniSat was valuable for satisfiability and automated reasoning research. MiniSat had less than 600 lines of C++ code.)

* MiniChain will be focused on education. By having a clean and small codebase, devs will be able to understand
blockchains by looking at the codebase.

* The blockchain space is again going through a phase where many new blockchains are being launched.
Back in 2017 and 2018, such an expansion period led to many general frameworks for blockchains,
such as Scorex and various Hyperledger frameworks. But most of these frameworks suffered from speculative generality and
were bloated. They focused on extensibility and configurability. MiniChain has a different philosophy:
focus on minimality and, therefore, ease of modification.

* Recent advances in networking and crypto libraries for Python make it possible to develop MiniChain in Python.
Given that Python is one of the easiest languages to learn and results in usually boilerplate-minimized and easy to read code,
implementing MiniChain in Python aligns with MiniChain's educational goal.


### Overview of Tasks

* Develop a fully functional minimal blockchain in Python, with all the expected components:
peer-to-peer networking, consensus, mempool, ledger, ...

* Bonus task: add smart contracts to the blockchain.

Candidates are expected to refine these tasks in their GSoC proposals.
It is encouraged that you develop an initial prototype during the application phase.

### Requirements

* Use [PyNaCl](https://pynacl.readthedocs.io/en/latest/) library for hashing, signing transactions and verifying signatures.
* Use [Py-libp2p](https://github.com/libp2p/py-libp2p/tree/main) for p2p networking.
* Implement Proof-of-Work as the consensus protocol.
* Use accounts (instead of UTxO) as the accounting model for the ledger.
* Use as few lines of code as possible without compromising readability and understandability.
* For the bonus task, make Python itself be the language used for smart contracts, but watch out for security concerns related to executing arbitrary code from untrusted sources.

### Resources

* Read this book: https://www.marabu.dev/blockchain-foundations.pdf


---

## Project Maturity

TODO: In the checklist below, mark the items that have been completed and delete items that are not applicable to the current project:

* [ ] The project has a logo.
* [ ] The project has a favicon.
* [ ] The protocol:
- [ ] has been described and formally specified in a paper.
- [ ] has had its main properties mathematically proven.
- [ ] has been formally verified.
* [ ] The smart contracts:
- [ ] were thoroughly reviewed by at least two knights of The Stable Order.
- [ ] were deployed to:
- [ ] Ergo
- [ ] Cardano
- [ ] EVM Chains:
- [ ] Ethereum Classic
- [ ] Ethereum
- [ ] Polygon
- [ ] BSC
- [ ] Base
* [ ] The mobile app:
- [ ] has an _About_ page containing the Stability Nexus's logo and pointing to the social media accounts of the Stability Nexus.
- [ ] is available for download as a release in this repo.
- [ ] is available in the relevant app stores.
* [ ] The web frontend:
- [ ] has proper title and metadata.
- [ ] has proper open graph metadata, to ensure that it is shown well when shared in social media (Discord, Telegram, Twitter, LinkedIn).
- [ ] has a footer, containing the Stability Nexus's logo and pointing to the social media accounts of the Stability Nexus.
- [ ] is fully static and client-side.
- [ ] is deployed to Github Pages via a Github Workflow.
- [ ] is accessible through the https://TODO:PROJECT-NAME.stability.nexus domain.
* [ ] the project is listed in [https://stability.nexus/protocols](https://stability.nexus/protocols).

---

## Tech Stack

TODO:

### Frontend

TODO:

- Next.js 14+ (React)
- TypeScript
- TailwindCSS
- shadcn/ui

### Blockchain

TODO:

- Wagmi
- Solidity Smart Contracts
- Ethers.js

---

## Getting Started

### Prerequisites

TODO

- Node.js 18+
- npm/yarn/pnpm
- MetaMask or any other web3 wallet browser extension

### Installation

TODO

#### 1. Clone the Repository
## Setup

```bash
git clone https://github.com/StabilityNexus/TODO.git
cd TODO
python3 -m venv .venv
source .venv/bin/activate
python -m pip install --upgrade pip
make dev-install
```

#### 2. Install Dependencies

Using your preferred package manager:
If you also want networking dependencies:

```bash
npm install
# or
yarn install
# or
pnpm install
python -m pip install -e .[network]
```

#### 3. Run the Development Server

Start the app locally:
## Common Commands

```bash
npm run dev
# or
yarn dev
# or
pnpm dev
make test # run unit tests
make lint # run ruff checks
make format # format with ruff
make start-node # run scaffold node entrypoint
```

#### 4. Open your Browser

Navigate to [http://localhost:3000](http://localhost:3000) to see the application.

---

## Contributing

We welcome contributions of all kinds! To contribute:

1. Fork the repository and create your feature branch (`git checkout -b feature/AmazingFeature`).
2. Commit your changes (`git commit -m 'Add some AmazingFeature'`).
3. Run the development workflow commands to ensure code quality:
- `npm run format:write`
- `npm run lint:fix`
- `npm run typecheck`
4. Push your branch (`git push origin feature/AmazingFeature`).
5. Open a Pull Request for review.
## Run the Node Entrypoint

If you encounter bugs, need help, or have feature requests:

- Please open an issue in this repository providing detailed information.
- Describe the problem clearly and include any relevant logs or screenshots.

We appreciate your feedback and contributions!
```bash
PYTHONPATH=src python -m minichain --host 127.0.0.1 --port 7000
```

© 2025 The Stable Order.
## Repository Layout

```text
.github/workflows/ci.yml
src/minichain/
__init__.py
__main__.py
crypto.py
transaction.py
block.py
state.py
mempool.py
consensus.py
network.py
storage.py
node.py
tests/
test_scaffold.py
issues.md
architectureProposal.md
```
Comment on lines +53 to +71
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟡 Minor

Repository layout is missing newly added modules.

genesis.py, merkle.py, and serialization.py are introduced in this PR but are not listed in the Repository Layout section.

📝 Proposed update
 src/minichain/
   __init__.py
   __main__.py
   crypto.py
   transaction.py
   block.py
+  genesis.py
+  merkle.py
+  serialization.py
   state.py
   mempool.py
   consensus.py
   network.py
   storage.py
   node.py
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
```text
.github/workflows/ci.yml
src/minichain/
__init__.py
__main__.py
crypto.py
transaction.py
block.py
state.py
mempool.py
consensus.py
network.py
storage.py
node.py
tests/
test_scaffold.py
issues.md
architectureProposal.md
```
.github/workflows/ci.yml
src/minichain/
__init__.py
__main__.py
crypto.py
transaction.py
block.py
genesis.py
merkle.py
serialization.py
state.py
mempool.py
consensus.py
network.py
storage.py
node.py
tests/
test_scaffold.py
issues.md
architectureProposal.md
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@README.md` around lines 53 - 71, The README's "Repository layout" is missing
the new modules; update that section to include genesis.py, merkle.py, and
serialization.py under src/minichain (e.g., add lines for genesis.py, merkle.py,
serialization.py alongside existing files such as crypto.py and block.py) so the
list reflects the current codebase; ensure the filenames match exactly
(genesis.py, merkle.py, serialization.py) and maintain the same
indentation/format as the surrounding entries.

Loading