-
Notifications
You must be signed in to change notification settings - Fork 759
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* verkle: initial commit * verkle: scaffold verkle trie implementation and types * verkle: fix installation issues * verkle: move rust verkle wasm to verkle package * verkle: remove package json and readme from rust verkle wasm dir * util: add some bigint LE utils for verkle * verkle: refactor constants and cryptographic methods to the verkle package * verkle: remove unnecessary constants & methods * verkle: verkle node classes and types * verkle: get method and rawNode utils * verkle: handle case where array item is not found * verkle: wip findPath method * verkle: wip * verkle: fromRawNode method * verkle: update packages * verkle: minor adjustments * verkle: wip * verkle: add test case for put and get * verkle: wip insertstem and related methods for verkle nodes * verkle: internal node test * verkle: default values and minor fixes to internalNode * verkle: make internal verkle node options optional * verkle: leafNode basic test * verkle: remove unused import * verkle: setDepth method for leafNode and commented out code for create method * verkle: wip * verkle: add Point interface * verkle: general cleanup and improvements * verkle: minor test adjustments * verkle: readme and testing related updates * verkle: capital V for verkle workflow * Update packages/verkle/README.md Co-authored-by: Scorbajio <[email protected]> * Update packages/verkle/README.md Co-authored-by: Scorbajio <[email protected]> * Update packages/verkle/README.md Co-authored-by: Scorbajio <[email protected]> * Update packages/verkle/README.md Co-authored-by: Scorbajio <[email protected]> * verkle: use Lock from util package * client: undo removal of link * util: update byte<>int conversion helpers * verkle: use Uint8Array instead of hexstrings for db * verkle: add imports to example * verkle: update db to Uint8Arrays * verkle: revert to using strings as keys for cache * verkle: update crypto import * verkle: adjust Key and Value encoding in create method * verkle: adjust value encoding in db del method * verkle: add missing key and value encoding opts to batch options * verkle: remove extra line --------- Co-authored-by: acolytec3 <[email protected]> Co-authored-by: Scorbajio <[email protected]>
- Loading branch information
1 parent
876e560
commit 2353bc7
Showing
44 changed files
with
2,623 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
--- | ||
name: 'Package: @ethereumjs/verkle' | ||
about: Create issue for @ethereumjs/verkle package | ||
title: '' | ||
labels: 'package: verkle' | ||
assignees: '' | ||
--- |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
name: Verkle | ||
on: | ||
push: | ||
branches: [master, develop] | ||
tags: ['*'] | ||
pull_request: | ||
types: [opened, reopened, synchronize] | ||
workflow_dispatch: | ||
|
||
env: | ||
cwd: ${{github.workspace}}/packages/verkle | ||
|
||
defaults: | ||
run: | ||
working-directory: packages/verkle | ||
|
||
concurrency: | ||
group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }} | ||
cancel-in-progress: true | ||
|
||
jobs: | ||
test-verkle: | ||
runs-on: ubuntu-latest | ||
strategy: | ||
matrix: | ||
node-version: [18] | ||
steps: | ||
- uses: actions/checkout@v3 | ||
with: | ||
submodules: recursive | ||
|
||
- name: Use Node.js ${{ matrix.node-version }} | ||
uses: actions/setup-node@v3 | ||
with: | ||
node-version: ${{ matrix.node-version }} | ||
cache: 'npm' | ||
|
||
- run: npm ci --omit=peer | ||
working-directory: ${{github.workspace}} | ||
|
||
- run: npm run lint | ||
- run: npm run test:node # Only run node tests for now until vitest browser test issues are sorted out |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
{ | ||
"extends": "../../config/.c8rc.json", | ||
"include": ["src/**/*.ts"] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
module.exports = { | ||
extends: '../../config/eslint.cjs', | ||
parserOptions: { | ||
project: ['./tsconfig.json', './tsconfig.benchmarks.json'], | ||
}, | ||
overrides: [ | ||
{ | ||
files: ['benchmarks/*.ts'], | ||
rules: { | ||
'no-console': 'off', | ||
}, | ||
}, | ||
], | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
test/ | ||
src/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
node_modules | ||
.vscode | ||
dist | ||
.nyc_output | ||
*.json | ||
docs |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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] - 2023-10-15 | ||
|
||
- Initial development release |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
# @ethereumjs/verkle | ||
|
||
[![NPM Package][verkle-npm-badge]][verkle-npm-link] | ||
[![GitHub Issues][verkle-issues-badge]][verkle-issues-link] | ||
[![Actions Status][verkle-actions-badge]][verkle-actions-link] | ||
[![Code Coverage][verkle-coverage-badge]][verkle-coverage-link] | ||
[![Discord][discord-badge]][discord-link] | ||
|
||
| Implementation of [Verkle Trees](https://ethereum.org/en/roadmap/verkle-trees/) as specified in [EIP-6800](https://eips.ethereum.org/EIPS/eip-6800) | | ||
| --------------------------------------------------------------------------------------------------------------------------------------------------- | | ||
|
||
> Verkle trees are a cryptographic data structure proposed for use in Ethereum to optimize storage and transaction verification. They combine features of Merkle Patricia Tries and Vector Commitment Trees to offer efficient data verification with smaller proof sizes. The goal is to improve scalability and efficiency in Ethereum's network operations. | ||
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 require the project using `npm`: | ||
|
||
```shell | ||
npm install @ethereumjs/verkle | ||
``` | ||
|
||
## Usage | ||
|
||
This class implements the basic [Modified Merkle Patricia Trie](https://ethereum.org/en/developers/docs/data-structures-and-encoding/patricia-merkle-trie/) in the `Trie` base class, which you can use with the `useKeyHashing` option set to `true` to create a trie which stores values under the `keccak256` hash of its keys (this is the Trie flavor which is used in Ethereum production systems). | ||
|
||
Checkpointing functionality to `Trie` through the methods `checkpoint`, `commit` and `revert`. | ||
|
||
It is best to select the variant that is most appropriate for your unique use case. | ||
|
||
### Initialization and Basic Usage | ||
|
||
```typescript | ||
import { VerkleTrie } from '@ethereumjs/verkle' | ||
import { bytesToUtf8, utf8ToBytes } from 'ethereumjs/util' | ||
|
||
const trie = new VerkleTrie() | ||
|
||
async function test() { | ||
await trie.put(utf8ToBytes('test'), utf8ToBytes('one')) | ||
const value = await trie.get(utf8ToBytes('test')) | ||
console.log(value ? bytesToUtf8(value) : 'not found') // 'one' | ||
} | ||
|
||
test() | ||
``` | ||
|
||
## Proofs | ||
|
||
### Verkle Proofs | ||
|
||
The EthereumJS Verkle package is still in its infancy, and as such, it does not currently support Verkle proof creation and verification. Support for Verkle proofs will be added eventually. | ||
|
||
## Examples | ||
|
||
You can find additional examples complete with detailed explanations [here](./examples/README.md). | ||
|
||
## Browser | ||
|
||
With the breaking release round in Summer 2023 we have added hybrid ESM/CJS builds for all our libraries (see section below) and have eliminated many of the caveats which had previously prevented frictionless browser usage. | ||
|
||
It is now easily possible to run a browser build of one of the EthereumJS libraries within a modern browser using the provided ESM build. For a setup example see [./examples/browser.html](./examples/browser.html). | ||
|
||
## API | ||
|
||
### Docs | ||
|
||
Generated TypeDoc API [Documentation](./docs/README.md) | ||
|
||
### Hybrid CJS/ESM Builds | ||
|
||
With the breaking releases from Summer 2023 we have started to ship our libraries with both CommonJS (`cjs` folder) and ESM builds (`esm` folder), see `package.json` for the detailed setup. | ||
|
||
If you use an ES6-style `import` in your code, files from the ESM build will be used: | ||
|
||
```typescript | ||
import { EthereumJSClass } from '@ethereumjs/[PACKAGE_NAME]' | ||
``` | ||
|
||
If you use Node.js-specific `require`, the CJS build will be used: | ||
|
||
```typescript | ||
const { EthereumJSClass } = require('@ethereumjs/[PACKAGE_NAME]') | ||
``` | ||
|
||
Using ESM will give you additional advantages over CJS beyond browser usage like static code analysis / Tree Shaking, which CJS cannot provide. | ||
|
||
## References | ||
|
||
- Wiki | ||
- [Overview of verkle tries](https://ethereum.org/en/roadmap/verkle-trees/) | ||
- [Verkle tries General Resource](https://verkle.info/) | ||
|
||
## 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 | ||
|
||
[MPL-2.0](<https://tldrlegal.com/license/mozilla-public-license-2.0-(mpl-2)>) | ||
|
||
[discord-badge]: https://img.shields.io/static/v1?logo=discord&label=discord&message=Join&color=blue | ||
[discord-link]: https://discord.gg/TNwARpR | ||
[verkle-npm-badge]: https://img.shields.io/npm/v/@ethereumjs/verkle.svg | ||
[verkle-npm-link]: https://www.npmjs.com/package/@ethereumjs/verkle | ||
[verkle-issues-badge]: https://img.shields.io/github/issues/ethereumjs/ethereumjs-monorepo/package:%20verkle?label=issues | ||
[verkle-issues-link]: https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aopen+is%3Aissue+label%3A"package%3A+verkle" | ||
[verkle-actions-badge]: https://github.com/ethereumjs/ethereumjs-monorepo/workflows/Trie/badge.svg | ||
[verkle-actions-link]: https://github.com/ethereumjs/ethereumjs-monorepo/actions?query=workflow%3A%22Trie%22 | ||
[verkle-coverage-badge]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/branch/master/graph/badge.svg?flag=verkle | ||
[verkle-coverage-link]: https://codecov.io/gh/ethereumjs/ethereumjs-monorepo/tree/master/packages/verkle |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
{ | ||
"name": "@ethereumjs/verkle", | ||
"version": "0.0.1", | ||
"description": "Implementation of verkle tries as used in Ethereum.", | ||
"keywords": [ | ||
"verkle", | ||
"trie", | ||
"ethereum" | ||
], | ||
"homepage": "https://github.com/ethereumjs/ethereumjs-monorepo/tree/master/packages/verkle#readme", | ||
"bugs": { | ||
"url": "https://github.com/ethereumjs/ethereumjs-monorepo/issues?q=is%3Aissue+label%3A%22package%3A+verkle%22" | ||
}, | ||
"repository": { | ||
"type": "git", | ||
"url": "https://github.com/ethereumjs/ethereumjs-monorepo.git" | ||
}, | ||
"license": "MPL-2.0", | ||
"author": "EthereumJS Team", | ||
"contributors": [ | ||
{ | ||
"name": "Gabriel Rocheleau", | ||
"url": "https://github.com/gabrocheleau" | ||
} | ||
], | ||
"main": "dist/cjs/index.js", | ||
"type": "commonjs", | ||
"module": "dist/esm/index.js", | ||
"exports": { | ||
".": { | ||
"import": "./dist/esm/index.js", | ||
"require": "./dist/cjs/index.js" | ||
} | ||
}, | ||
"files": [ | ||
"dist", | ||
"src" | ||
], | ||
"scripts": { | ||
"build": "../../config/cli/ts-build.sh", | ||
"clean": "../../config/cli/clean-package.sh", | ||
"coverage": "npx vitest run --coverage.enabled --coverage.reporter=lcov", | ||
"docs:build": "typedoc --options typedoc.cjs", | ||
"examples": "ts-node ../../scripts/examples-runner.ts -- verkle", | ||
"lint": "../../config/cli/lint.sh", | ||
"lint:diff": "../../config/cli/lint-diff.sh", | ||
"lint:fix": "../../config/cli/lint-fix.sh", | ||
"prepublishOnly": "../../config/cli/prepublish.sh", | ||
"test": "npx vitest run", | ||
"tsc": "../../config/cli/ts-compile.sh" | ||
}, | ||
"dependencies": { | ||
"@ethereumjs/rlp": "5.0.0", | ||
"@ethereumjs/util": "9.0.0", | ||
"lru-cache": "^10.0.0" | ||
}, | ||
"engines": { | ||
"node": ">=18" | ||
} | ||
} |
Oops, something went wrong.