Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

binarytree: create binarytree package #3857

Merged
merged 50 commits into from
Feb 20, 2025
Merged
Show file tree
Hide file tree
Changes from 49 commits
Commits
Show all changes
50 commits
Select commit Hold shift + click to select a range
faadbe7
binarytree: scaffold new package
gabrocheleau Jan 29, 2025
d19b400
chore: update date and run npm install
gabrocheleau Jan 29, 2025
d9c4120
chore: add binarytree to cspell
gabrocheleau Jan 29, 2025
3859f43
binarytree: remove rlp from tsconfig deps
gabrocheleau Jan 29, 2025
ab50eab
binarytree: add two placeholder files
gabrocheleau Jan 29, 2025
5e57202
chore: add binarytree to cspell md
gabrocheleau Jan 29, 2025
61266e5
binarytree: remove examples
gabrocheleau Jan 29, 2025
215bb37
Merge branch 'master' into feat/binarytree-package
gabrocheleau Jan 31, 2025
ff25f65
util: bit helpers
gabrocheleau Feb 9, 2025
e769374
binarytree: add some deps
gabrocheleau Feb 9, 2025
ef1fc1a
binarytree: binary nodes
gabrocheleau Feb 9, 2025
d24975d
binarytree: checkpointdb
gabrocheleau Feb 9, 2025
99106ab
binary: early binary tree implementation
gabrocheleau Feb 10, 2025
3f5adbe
binarytree: test cases
gabrocheleau Feb 10, 2025
ef8fb7e
Merge branch 'master' into feat/binarytree-package
gabrocheleau Feb 10, 2025
d8f3096
Merge branch 'master' into feat/binarytree-package
gabrocheleau Feb 12, 2025
d442940
chore: add merkelize to cspell
gabrocheleau Feb 13, 2025
a8865b7
binarytree: cleanup
gabrocheleau Feb 13, 2025
6919a83
binarytree: minor improvements
gabrocheleau Feb 13, 2025
711c3f9
binarytree: more test vectors
gabrocheleau Feb 13, 2025
41f36ad
util: typo
gabrocheleau Feb 13, 2025
55b3b59
binarytree: fix stemRoot node handling
gabrocheleau Feb 13, 2025
293b914
binarytree: rework some logic
gabrocheleau Feb 14, 2025
e22199a
binarytree: add internalNode test case and fixes
gabrocheleau Feb 14, 2025
8cbdabd
binarytree: add stemNode test case
gabrocheleau Feb 14, 2025
8ff380b
binarytree: adjust test case
gabrocheleau Feb 14, 2025
b2a72cf
Update packages/binarytree/LICENSE
gabrocheleau Feb 14, 2025
4024ddc
Merge branch 'master' into feat/binarytree-package
gabrocheleau Feb 14, 2025
a0894e9
test: binarytree: push new test case2
gabrocheleau Feb 14, 2025
8837407
binarytree: fix internal node path encoding and decoding
gabrocheleau Feb 17, 2025
cd8e98f
util: fix bytes encoding
gabrocheleau Feb 17, 2025
66da0e6
binarytree: fix one test case
gabrocheleau Feb 17, 2025
338d3ac
binarytree: remove only
gabrocheleau Feb 17, 2025
13c7c28
binarytree: improve test coverage
gabrocheleau Feb 17, 2025
c3ef409
Add tree utils
acolytec3 Feb 17, 2025
e0b215f
switch node hashes to print keys as bits
acolytec3 Feb 18, 2025
69d39b8
Add internal nodes at each branch in the tree
acolytec3 Feb 19, 2025
d7aacbd
fix internal node insertion
acolytec3 Feb 19, 2025
683e2d4
binarytree: randomness put test case
gabrocheleau Feb 19, 2025
bc94ca4
binarytree: randomness put test case
gabrocheleau Feb 19, 2025
a7d9f0d
update comments
acolytec3 Feb 19, 2025
e900fa9
Merge remote-tracking branch 'origin/master' into feat/binarytree-pac…
acolytec3 Feb 19, 2025
1738b71
update wording in readme
acolytec3 Feb 19, 2025
21ebe0b
apply suggestion
acolytec3 Feb 20, 2025
6435314
binarytree: add test for set/check root
ScottyPoi Feb 20, 2025
a4a7e3b
binarytree: add test for checkpointing methods
ScottyPoi Feb 20, 2025
91d1667
binarytree: test root() with invalid length
ScottyPoi Feb 20, 2025
70d83ab
binarytree: test shallowCopy()
ScottyPoi Feb 20, 2025
79ab10c
binarytree: test dumpLeafValues and dumpNodeHashes
ScottyPoi Feb 20, 2025
86b1d45
fix lint error
ScottyPoi Feb 20, 2025
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
7 changes: 7 additions & 0 deletions .github/ISSUE_TEMPLATE/package--ethereumjs-binarytree.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
---
name: 'Package: @ethereumjs/binarytree'
about: Create issue for @ethereumjs/binarytree package
title: ''
labels: 'package: binarytree'
assignees: ''
---
56 changes: 56 additions & 0 deletions .github/workflows/binarytree-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
name: binarytree
on:
workflow_call:
inputs:
dep-cache-key:
required: false
type: string
workflow_dispatch:
inputs:
dep-cache-key:
required: false
default: 'none'
submodule-cache-key:
required: false
default: 'none'

env:
cwd: ${{github.workspace}}/packages/binarytree

defaults:
run:
working-directory: packages/binarytree

concurrency:
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}-binarytree
cancel-in-progress: true

jobs:
test-binarytree:
runs-on: ubuntu-latest

steps:
# We clone the repo and submodules if triggered from work-flow dispatch
- if: inputs.submodule-cache-key == 'none'
uses: actions/checkout@v4

# We restore the code/deps from cache if triggered from workflow_call (i.e. have valid cache key)
- if: inputs.dep-cache-key != 'none'
uses: actions/cache/restore@v4
id: dep-cache
with:
path: ${{github.workspace}}
key: ${{ inputs.dep-cache-key }}

- name: Use Node.js 20
uses: actions/setup-node@v4
with:
node-version: 20
cache: 'npm'

- name: Install Dependencies (if not restored from cache)
if: steps.dep-cache.outputs.cache-hit != 'true'
run: npm ci
working-directory: ${{ github.workspace }}

- run: npm run test
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ Below you can find a list of the packages included in this repository.

| package | npm | issues | tests | coverage |
| ------------------------------------------------ | --------------------------------------------------------------- | ----------------------------------------------------------------------------- | -------------------------------------------------------------------------- | --------------------------------------------------------------------------- |
| [@ethereumjs/binarytree][binarytree-package] | [![NPM Package][binarytree-npm-badge]][binarytree-npm-link] | [![VM Issues][binarytree-issues-badge]][binarytree-issues-link] | [![Actions Status][binarytree-actions-badge]][binarytree-actions-link] | [![Code Coverage][binarytree-coverage-badge]][binarytree-coverage-link]
| [@ethereumjs/block][block-package] | [![NPM Package][block-npm-badge]][block-npm-link] | [![Block Issues][block-issues-badge]][block-issues-link] | [![Actions Status][block-actions-badge]][block-actions-link] | [![Code Coverage][block-coverage-badge]][block-coverage-link] |
| [@ethereumjs/blockchain][blockchain-package] | [![NPM Package][blockchain-npm-badge]][blockchain-npm-link] | [![Blockchain Issues][blockchain-issues-badge]][blockchain-issues-link] | [![Actions Status][blockchain-actions-badge]][blockchain-actions-link] | [![Code Coverage][blockchain-coverage-badge]][blockchain-coverage-link] |
| [@ethereumjs/client][client-package] | [![NPM Package][client-npm-badge]][client-npm-link] | [![Client Issues][client-issues-badge]][client-issues-link] | [![Actions Status][client-actions-badge]][client-actions-link] | [![Code Coverage][client-coverage-badge]][client-coverage-link] |
Expand Down
3 changes: 2 additions & 1 deletion config/cspell-md.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
"/0x[0-9A-Fa-f]+/"
],
"words": [
"binarytree",
"trienode",
"t8ntool",
"calldatasize",
Expand Down Expand Up @@ -330,4 +331,4 @@
"ethportal",
"bytevector"
]
}
}
2 changes: 2 additions & 0 deletions config/cspell-ts.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
}
],
"words": [
"binarytree",
"merkelize",
"kaust",
"EEST",
"paulmillr",
Expand Down
32 changes: 32 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions packages/binarytree/.c8rc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
{
"extends": "../../config/.c8rc.json",
"include": ["src/**/*.ts"]
}
14 changes: 14 additions & 0 deletions packages/binarytree/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
module.exports = {
extends: '../../config/eslint.cjs',
parserOptions: {
project: ['./tsconfig.lint.json'],
},
overrides: [
{
files: ['benchmarks/*.ts', 'examples/*.ts'],
rules: {
'no-console': 'off',
},
},
],
}
1 change: 1 addition & 0 deletions packages/binarytree/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@

2 changes: 2 additions & 0 deletions packages/binarytree/.npmignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
test/
src/
11 changes: 11 additions & 0 deletions packages/binarytree/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
# Changelog

All notable changes to this project will be documented in this file.

The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
(modification: no type change headlines) and this project adheres to
[Semantic Versioning](http://semver.org/spec/v2.0.0.html).

## 0.0.1 - 2025-01-30

- Initial development release
22 changes: 22 additions & 0 deletions packages/binarytree/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
The MIT License (MIT)

Copyright (c) 2025 EthereumJS

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

40 changes: 40 additions & 0 deletions packages/binarytree/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
# @ethereumjs/binarytree

[![NPM Package][binarytree-npm-badge]][binarytree-npm-link]
[![GitHub Issues][binarytree-issues-badge]][binarytree-issues-link]
[![Actions Status][binarytree-actions-badge]][binarytree-actions-link]
[![Code Coverage][binarytree-coverage-badge]][binarytree-coverage-link]
[![Discord][discord-badge]][discord-link]

| Implementation of Binary Trees as specified in [EIP-7864](https://eips.ethereum.org/EIPS/eip-7864) |
| --------------------------------------------------------------------------------------------------------------------------------------------------- |

> Binary Trees are a novel cryptographic data structure proposed for use in Ethereum to optimize state storage and proof verification. Unlike Merkle Patricia Tries, Binary Trees use a strict binary branching structure, allowing smaller proof sizes. By reducing storage overhead and improving proof efficiency, Binary Trees aim to enhance Ethereum’s scalability while maintaining robust security guarantees.

This package is currently in early alpha and is a work in progress. It is not intended for use in production environments, but rather for research and development purposes. Any help in improving the package is very much welcome.

## Installation

To obtain the latest version, simply install the project using `npm`:

```shell
npm install @ethereumjs/binarytree
```
## EthereumJS

See our organizational [documentation](https://ethereumjs.readthedocs.io) for an introduction to `EthereumJS` as well as information on current standards and best practices. If you want to join for work or carry out improvements on the libraries, please review our [contribution guidelines](https://ethereumjs.readthedocs.io/en/latest/contributing.html) first.

## License

[MIT](https://opensource.org/licenses/MIT)

[discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue
[discord-link]: https://discord.gg/TNwARpR
[binarytree-npm-badge]: https://img.shields.io/npm/v/@ethereumjs/binarytree.svg
[binarytree-npm-link]: https://www.npmjs.com/package/@ethereumjs/binarytree
[binarytree-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20binarytree?label=issues
[binarytree-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A"package%3A+binarytree"
[binarytree-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/binarytree/badge.svg
[binarytree-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22binarytree%22
[binarytree-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=binarytree
[binarytree-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/binarytree
59 changes: 59 additions & 0 deletions packages/binarytree/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
{
"name": "@ethereumjs/binarytree",
"version": "0.0.1",
"description": "Implementation of binary trees as used in Ethereum.",
"keywords": ["binary", "tree", "trie", "ethereum"],
"homepage": "https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/binarytree#readme",
"bugs": {
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+binarytree%22"
},
"repository": {
"type": "git",
"url": "https://github.com/ethereumjs/ethereumjs-monorepo.git"
},
"license": "MIT",
"author": "EthereumJS Team",
"contributors": [
{
"name": "Gabriel Rocheleau",
"url": "https://github.com/gabrocheleau"
}
],
"type": "module",
"sideEffects": false,
"main": "dist/cjs/index.js",
"module": "dist/esm/index.js",
"exports": {
".": {
"import": "./dist/esm/index.js",
"require": "./dist/cjs/index.js"
}
},
"files": ["dist", "src"],
"scripts": {
"biome": "npx @biomejs/biome check",
"biome:fix": "npx @biomejs/biome check --write",
"build": "../../config/cli/ts-build.sh",
"clean": "../../config/cli/clean-package.sh",
"coverage": "DEBUG=ethjs npx vitest run -c ../../config/vitest.config.coverage.mts",
"docs:build": "typedoc --options typedoc.cjs",
"lint": "npm run biome && eslint --config .eslintrc.cjs . --ext .js,.ts",
"lint:fix": "npm run biome:fix && eslint --fix --config .eslintrc.cjs . --ext .js,.ts",
"prepublishOnly": "../../config/cli/prepublish.sh",
"test": "npm run test:node",
"test:node": "npx vitest run",
"test:browser": "npx vitest run --config=../../config/vitest.config.browser.mts",
"tsc": "../../config/cli/ts-compile.sh"
},
"dependencies": {
"@ethereumjs/rlp": "^6.0.0-alpha.1",
"@ethereumjs/util": "^10.0.0-alpha.1",
"@noble/hashes": "^1.7.1",
"debug": "^4.3.4",
"ethereum-cryptography": "^3.1.0",
"lru-cache": "10.1.0"
},
"engines": {
"node": ">=18"
}
}
Loading
Loading