Skip to main content

Pure Python 3 Merkle Patricia Trie implementation

Project description

In order to understand Ethereum's core functionalities, I am implementing parts of it for myself. Here I am implementing the Merkle Patricia Trie (MPT) purely in Python 3.

Install

pip install ethereum-merkle-patricia-trie

Requirements

In order to use the package, you need to install LevelDb on your system.

Tests

In order to run the tests, execute the following command:

$ python -m unittest

Usage

Here an example on how to use the package:

from mpt.trie import Trie

t = Trie('./testdb')
t.update(b'abcd', b'hello world')

print(t.get_value(b'abcd'))

print(t.get_root_hash())

t.delete(b'abcd')

Upload to Pypi

Uploading and testing using test Pypi

python -m build
python -m twine upload --repository testpypi dist/*
pip install --index-url https://test.pypi.org/simple/ --no-deps merklePatriciaTrie

Uploading to Pypi

python -m build
python -m twine upload dist/*

Contributions

Create a new virtual environment and install all dependencies:

python3 -m virtualenv --python /path/to/python3 venv
source ./venv/bin/activate
pip install -r requirements.txt

Install the pre-commit hooks using the following command:

pre-commit install

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ethereum-merkle-patricia-trie-0.0.3.tar.gz (6.9 kB view hashes)

Uploaded Source

Built Distribution

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page