Typeberry is a TypeScript implementation of JAM protocol by Fluffy Labs.
NOTE: Since we are taking part in the JAM Prize, we do not accept any external PRs unless the contributor waives any claims to the prize and copy rights for the submitted code. By creating the PR you accept this requirement.
Gray Paper compliance can be controlled via GP_VERSION
environment variable.
- 0.6.7
- 0.7.0
- 0.7.1 (partial)
- 0.7.2 (partial)
JAM Prize requirements
- Milestone 1
- Block import
- W3F test vectors
- JAM Conformance Fuzzer
- Performance optimisations
- Milestone 2
- Networking (partial)
- Fast PVM
- Milestone 3
- PVM Recompiler
- Milestone 4
- Milestone 5
$ node --version
v 22.9.0
We recommend NVM to install and manage different
node
versions.
$ npm ci
$ npm start
$ npm start -- fuzz-target
Build and run typeberry using Docker:
# Build the Docker image
$ docker build -t typeberry .
# Run with default settings
$ docker run typeberry
# Run with custom arguments
$ docker run typeberry --config /app/configs/typeberry-dev.json --node-name my-node
# Run with environment variables (e.g., for logging)
$ docker run -e JAM_LOG=trace GP_VERSION=0.7.0 typeberry
# Run with volume mounts for persistent data
$ docker run -v $(pwd)/database:/app/database typeberry
The Docker container uses a minimal Alpine Linux image and forwards all arguments to npm start
.
JSON-RPC does not require typeberry
to be running, so we just need to point the binary to the correct database.
Note the DB needs to be already initialized.
$ npm start -w @typeberry/rpc
- @typeberry/convert - convert common JAM formats
- JAM search - search across all public JAM-related channels
- State Viewer - load & inspect state of test vectors
- PVM Debugger - load & inspect a PVM program
- Gray Paper Reader - view the Gray Paper
- Ananas - AssemblyScript PVM interpreter
$ npm run qa
Formatting & linting is done by biomejs). You can run separate tools using commands below. Note that all safe fixes will be applied automatically.
$ npm run format # format the code
$ npm run lint # lint the code & organise imports
A shorthand to run all the checks and apply safe fixes all at once is:
$ npm run qa-fix
$ npm run test
Running tests from a single package:
$ npm run test -w @typeberry/trie
This command will run all benchmarks from ./benchmarks/
folder
$ npm start -w @typeberry/benchmark
Since each benchmark file is also runnable, it's easy to run just one benchmark, e.g:
$ npm exec tsx ./benchmarks/math/mul_overflow.ts
To run JSON test cases coming from the official
JAM test vectors repository you need
to first check out the repository with test cases and then use test-runner
to execute them.
$ git clone https://github.com/w3f/jamtestvectors.git
$ npm run w3f -w @typeberry/test-runner -- jamtestvectors/**/*.json ../jamtestvectors/erasure_coding/vectors/*
Since there are multiple sources of test vectors (and their versions may differ), all relevant ones can be easily checked out from our test vectors repository.
Obviously it's also possible to run just single test case or part of the test cases by altering the glob pattern in the path.
To run JSON RPC E2E test-vectors test-vectors repository needs to be checked out with ref matching our tests. Then to run tests:
$ npm run test:e2e -w @typeberry/rpc
$ npm init -w ./packages/core/mycomponent
$ npm init -w ./packages/jam/mycomponent
This command will automatically update the workspaces
field in top-level package.json
.
A brief, but evolving description of our codestyle and guideliness is availabe in CODESTYLE.
- Open Gray Paper Reader and go to Notes > Settings (⚙️).
- Click "+ New Source".
- Set Source Name to Typeberry.
- Paste the following in Source URL:
https://fluffylabs.dev/typeberry/links.json