Skip to main content
@tevm/voltaire
@tevm/voltaire / primitives/BinaryTree

primitives/BinaryTree

Classes

InvalidAddressLengthError

Defined in: src/primitives/BinaryTree/errors.js:19 Error thrown when an invalid address length is provided

Example

throw new InvalidAddressLengthError(
  'Address must be 20 bytes',
  {
    value: addr.length,
    expected: '20 bytes',
    code: 'BINARY_TREE_INVALID_ADDRESS_LENGTH',
    docsPath: '/primitives/binary-tree/address-to-key#error-handling'
  }
)

Extends

Constructors

Constructor
new InvalidAddressLengthError(message?, options?): InvalidAddressLengthError
Defined in: src/primitives/BinaryTree/errors.js:30
Parameters
message?
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidAddressLengthError
Overrides
InvalidLengthError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidLengthError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
InvalidLengthError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
InvalidLengthError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
InvalidLengthError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidLengthError.expected
name
name: string
Defined in: src/primitives/BinaryTree/errors.js:41
Inherited from
InvalidLengthError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidLengthError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidLengthError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidLengthError.toJSON

InvalidKeyLengthError

Defined in: src/primitives/BinaryTree/errors.js:61 Error thrown when an invalid key length is provided

Example

throw new InvalidKeyLengthError(
  'Key must be 32 bytes',
  {
    value: key.length,
    expected: '32 bytes',
    code: 'BINARY_TREE_INVALID_KEY_LENGTH',
    docsPath: '/primitives/binary-tree/split-key#error-handling'
  }
)

Extends

Constructors

Constructor
new InvalidKeyLengthError(message?, options?): InvalidKeyLengthError
Defined in: src/primitives/BinaryTree/errors.js:72
Parameters
message?
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidKeyLengthError
Overrides
InvalidLengthError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
InvalidLengthError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
InvalidLengthError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
InvalidLengthError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
InvalidLengthError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
InvalidLengthError.expected
name
name: string
Defined in: src/primitives/BinaryTree/errors.js:82
Inherited from
InvalidLengthError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
InvalidLengthError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
InvalidLengthError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
InvalidLengthError.toJSON

InvalidTreeStateError

Defined in: src/primitives/BinaryTree/errors.js:102 Error thrown when tree is in invalid state

Example

throw new InvalidTreeStateError(
  'Cannot insert into leaf node',
  {
    value: node.type,
    expected: 'empty, stem, or internal',
    code: 'BINARY_TREE_INVALID_STATE',
    docsPath: '/primitives/binary-tree/insert#error-handling'
  }
)

Extends

Constructors

Constructor
new InvalidTreeStateError(message?, options?): InvalidTreeStateError
Defined in: src/primitives/BinaryTree/errors.js:113
Parameters
message?
string
options?
cause?
Error
code?
string
context?
Record<string, unknown>
docsPath?
string
expected?
string
value?
unknown
Returns
InvalidTreeStateError
Overrides
ValidationError.constructor

Properties

cause?
optional cause: Error
Defined in: src/primitives/errors/AbstractError.ts:56 Root cause of this error (for error chaining)
Inherited from
ValidationError.cause
code
code: string
Defined in: src/primitives/errors/AbstractError.ts:39 Machine-readable error code for programmatic handling
Example
'INVALID_FORMAT', 'INVALID_LENGTH'
Inherited from
ValidationError.code
context?
optional context: Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:45 Additional context metadata for debugging
Example
{ value: '0x123', expected: '20 bytes' }
Inherited from
ValidationError.context
docsPath?
optional docsPath: string
Defined in: src/primitives/errors/AbstractError.ts:51 Path to documentation for this error
Example
'/primitives/address/from-hex#error-handling'
Inherited from
ValidationError.docsPath
expected
expected: string
Defined in: src/primitives/errors/ValidationError.ts:19
Inherited from
ValidationError.expected
name
name: string
Defined in: src/primitives/BinaryTree/errors.js:122
Inherited from
ValidationError.name
value
value: unknown
Defined in: src/primitives/errors/ValidationError.ts:18
Inherited from
ValidationError.value

Methods

getErrorChain()
getErrorChain(): string
Defined in: src/primitives/errors/AbstractError.ts:94 Get full error chain as string for logging
Returns
string
Inherited from
ValidationError.getErrorChain
toJSON()
toJSON(): Record<string, unknown>
Defined in: src/primitives/errors/AbstractError.ts:110 Serialize error to JSON for logging/telemetry
Returns
Record<string, unknown>
Inherited from
ValidationError.toJSON

Interfaces

AccountData

Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:37 Account basic data layout at index 0
  • Version (1 byte)
  • Code size (3 bytes)
  • Nonce (8 bytes)
  • Balance (16 bytes)

Properties

balance
readonly balance: bigint
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:41
codeSize
readonly codeSize: number
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:39
nonce
readonly nonce: bigint
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:40
version
readonly version: number
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:38

BinaryTreeType

Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:7 Binary State Tree (EIP-7864) - Unified tree structure for Ethereum state

See

https://eips.ethereum.org/EIPS/eip-7864

Properties

root
readonly root: Node
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:8

Type Aliases

EmptyNode

EmptyNode = Extract<Node, { type: "empty"; }>
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:28

InternalNode

InternalNode = Extract<Node, { type: "internal"; }>
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:25

LeafNode

LeafNode = Extract<Node, { type: "leaf"; }>
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:27

Node

Node = { type: "empty"; } | { left: Uint8Array; right: Uint8Array; type: "internal"; } | { stem: Uint8Array; type: "stem"; values: (Uint8Array | null)[]; } | { type: "leaf"; value: Uint8Array; }
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:11

StemNode

StemNode = Extract<Node, { type: "stem"; }>
Defined in: src/primitives/BinaryTree/BinaryTreeType.ts:26

Variables

addressToKey()

const addressToKey: (address) => Uint8Array = _addressToKey
Defined in: src/primitives/BinaryTree/index.ts:56

Parameters

address
Uint8Array

Returns

Uint8Array

BinaryTree

const BinaryTree: object
Defined in: src/primitives/BinaryTree/index.ts:76

Type Declaration

addressToKey()
addressToKey: (address) => Uint8Array
Parameters
address
Uint8Array
Returns
Uint8Array
get()
get: (tree, key) => Uint8Array<ArrayBufferLike> | null
Parameters
tree
BinaryTreeType
key
Uint8Array
Returns
Uint8Array<ArrayBufferLike> | null
getStemBit()
getStemBit: (stem, index) => 0 | 1
Parameters
stem
Uint8Array
index
number
Returns
0 | 1
hashInternal()
hashInternal: (l, r) => Uint8Array
Parameters
l
Uint8Array
r
Uint8Array
Returns
Uint8Array
hashLeaf()
hashLeaf: (node) => Uint8Array
Parameters
node
type
"leaf"
value
Uint8Array
Returns
Uint8Array
hashNode()
hashNode: (node) => Uint8Array
Parameters
node
Node
Returns
Uint8Array
hashStem()
hashStem: (node) => Uint8Array
Parameters
node
stem
Uint8Array
type
"stem"
values
(Uint8Array<ArrayBufferLike> | null)[]
Returns
Uint8Array
init()
init: () => BinaryTreeType
Returns
BinaryTreeType
insert()
insert: (tree, key, value) => BinaryTreeType
Parameters
tree
BinaryTreeType
key
Uint8Array
value
Uint8Array
Returns
BinaryTreeType
rootHash()
rootHash: (tree) => Uint8Array
Parameters
tree
BinaryTreeType
Returns
Uint8Array
rootHashHex()
rootHashHex: (tree) => HexType
Parameters
tree
BinaryTreeType
Returns
HexType
splitKey()
splitKey: (key) => object
Parameters
key
Uint8Array
Returns
object
idx
idx: number
stem
stem: Uint8Array

get()

const get: (tree, key) => Uint8Array | null = _get
Defined in: src/primitives/BinaryTree/index.ts:67

Parameters

tree
BinaryTreeType
key
Uint8Array

Returns

Uint8Array | null

getStemBit()

const getStemBit: (stem, index) => 0 | 1 = _getStemBit
Defined in: src/primitives/BinaryTree/index.ts:59

Parameters

stem
Uint8Array
index
number

Returns

0 | 1

hashInternal()

const hashInternal: (l, r) => Uint8Array
Defined in: src/primitives/BinaryTree/index.ts:49

Parameters

l
Uint8Array
r
Uint8Array

Returns

Uint8Array

HashInternal()

const HashInternal: (deps) => (l, r) => Uint8Array = _HashInternal
Defined in: src/primitives/BinaryTree/index.ts:38

Parameters

deps
Blake3Deps

Returns

(l, r): Uint8Array
Parameters
l
Uint8Array
r
Uint8Array
Returns
Uint8Array

hashLeaf()

const hashLeaf: (node) => Uint8Array
Defined in: src/primitives/BinaryTree/index.ts:52

Parameters

node
LeafNode

Returns

Uint8Array

HashLeaf()

const HashLeaf: (deps) => (node) => Uint8Array = _HashLeaf
Defined in: src/primitives/BinaryTree/index.ts:43

Parameters

deps
Blake3Deps

Returns

(node): Uint8Array
Parameters
node
LeafNode
Returns
Uint8Array

hashNode()

const hashNode: (node) => Uint8Array
Defined in: src/primitives/BinaryTree/index.ts:53

Parameters

node
Node

Returns

Uint8Array

HashNode()

const HashNode: (deps) => (node) => Uint8Array = _HashNode
Defined in: src/primitives/BinaryTree/index.ts:45

Parameters

deps
Blake3Deps

Returns

(node): Uint8Array
Parameters
node
Node
Returns
Uint8Array

hashStem()

const hashStem: (node) => Uint8Array
Defined in: src/primitives/BinaryTree/index.ts:51

Parameters

node
StemNode

Returns

Uint8Array

HashStem()

const HashStem: (deps) => (node) => Uint8Array = _HashStem
Defined in: src/primitives/BinaryTree/index.ts:41

Parameters

deps
Blake3Deps

Returns

(node): Uint8Array
Parameters
node
StemNode
Returns
Uint8Array

init()

const init: () => BinaryTreeType = _init
Defined in: src/primitives/BinaryTree/index.ts:61

Returns

BinaryTreeType

insert()

const insert: (tree, key, value) => BinaryTreeType
Defined in: src/primitives/BinaryTree/index.ts:62

Parameters

tree
BinaryTreeType
key
Uint8Array
value
Uint8Array

Returns

BinaryTreeType

rootHash()

const rootHash: (tree) => Uint8Array = _rootHash
Defined in: src/primitives/BinaryTree/index.ts:71

Parameters

tree
BinaryTreeType

Returns

Uint8Array

rootHashHex()

const rootHashHex: (tree) => HexType = _rootHashHex
Defined in: src/primitives/BinaryTree/index.ts:72

Parameters

tree
BinaryTreeType

Returns

HexType

splitKey()

const splitKey: (key) => object = _splitKey
Defined in: src/primitives/BinaryTree/index.ts:57

Parameters

key
Uint8Array

Returns

object
idx
idx: number
stem
stem: Uint8Array