Typeberry by Fluffy Labs - v0.4.0
    Preparing search index...

    typeberry 🫐

    JAM Conformance 0.7.1 W3F davxy 0.7.1 W3F vectors Publish commits License: MPL 2.0

    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.

    • [x] 0.6.7
    • [x] 0.7.0
    • [x] 0.7.1
    • [x] 0.7.2

    JAM Prize requirements

    • [x] Milestone 1
      • [x] Block import
      • [x] W3F test vectors
      • [x] JAM Conformance Fuzzer
      • [x] Performance optimisations
    • [ ] Milestone 2
      • [x] Networking (partial)
      • [x] Fast PVM (ananas)
    • [ ] 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.2 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 
    
    $ 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.

    1. Open Gray Paper Reader and go to Notes > Settings (⚙️).
      gpr-source-notes-1
    2. Click "+ New Source". gpr-source-notes-2
    3. Set Source Name to Typeberry.
    4. Paste the following in Source URL:
    https://fluffylabs.dev/typeberry/links.json
    
    1. Select All Versions. gpr-source-notes-3
    2. Click OK.
    3. Ensure the ✅ next to Typeberry is enabled.