Skip to main content

AccountUpdateForest

Defined in: lib/mina/v1/account-update.ts:1282

Class which represents a forest (list of trees) of account updates, in a compressed way which allows iterating and selectively witnessing the account updates.

The (recursive) type signature is:

type AccountUpdateForest = MerkleList<AccountUpdateTree>;
type AccountUpdateTree = {
accountUpdate: Hashed<AccountUpdate>;
children: AccountUpdateForest;
};

Extends

Constructors

Constructor

new AccountUpdateForest(__namedParameters: MerkleListBase<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>): AccountUpdateForest;

Defined in: lib/provable/merkle-list.ts:85

Parameters

__namedParameters

MerkleListBase<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Returns

AccountUpdateForest

Inherited from

MerkleList.constructor

Properties

data

data: Unconstrained<WithHash<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>[]>;

Defined in: lib/provable/merkle-list.ts:83

Inherited from

MerkleList.data


hash

hash: Field;

Defined in: lib/provable/merkle-list.ts:82

Inherited from

MerkleList.hash


_emptyHash

static _emptyHash: undefined | Field;

Defined in: lib/provable/merkle-list.ts:348

Inherited from

MerkleList._emptyHash


_innerProvable

static _innerProvable: 
| undefined
| ProvableHashable<any>;

Defined in: lib/provable/merkle-list.ts:351

Inherited from

MerkleList._innerProvable


_nextHash

static _nextHash: 
| undefined
| (hash: Field, t: any) => Field;

Defined in: lib/provable/merkle-list.ts:347

Inherited from

MerkleList._nextHash


_provable

static _provable: 
| undefined
| ProvableHashable<MerkleList<any>>;

Defined in: lib/provable/merkle-list.ts:350

Inherited from

MerkleList._provable


provable

static provable: {
check: void;
empty: AccountUpdateForest;
fromFields: AccountUpdateForest;
fromValue: AccountUpdateForest;
sizeInFields: number;
toAuxiliary: any[];
toFields: Field[];
toInput: HashInput;
toValue: any;
};

Defined in: lib/mina/v1/account-update.ts:1283

check()

check(value: 
| AccountUpdateForest
| MerkleList<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>): void;
Parameters
value

AccountUpdateForest | MerkleList<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Returns

void

empty()

empty(): AccountUpdateForest;
Returns

AccountUpdateForest

fromFields()

fromFields(fields: Field[], aux: any[]): AccountUpdateForest;
Parameters
fields

Field[]

aux

any[]

Returns

AccountUpdateForest

fromValue()

fromValue(value: any): AccountUpdateForest;
Parameters
value

any

Returns

AccountUpdateForest

sizeInFields()

sizeInFields(): number;
Returns

number

toAuxiliary()

toAuxiliary(value?: 
| AccountUpdateForest
| MerkleList<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>): any[];
Parameters
value?

AccountUpdateForest | MerkleList<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Returns

any[]

toFields()

toFields(value: 
| AccountUpdateForest
| MerkleList<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>): Field[];
Parameters
value

AccountUpdateForest | MerkleList<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Returns

Field[]

toInput()

toInput(value: 
| AccountUpdateForest
| MerkleList<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>): HashInput;
Parameters
value

AccountUpdateForest | MerkleList<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Returns

HashInput

toValue()

toValue(value: 
| AccountUpdateForest
| MerkleList<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>): any;
Parameters
value

AccountUpdateForest | MerkleList<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Returns

any

Overrides

MerkleList.create(AccountUpdateTreeBase, merkleListHash).provable

Accessors

Constructor

Get Signature

get Constructor(): typeof MerkleList;

Defined in: lib/provable/merkle-list.ts:353

Returns

typeof MerkleList

Inherited from

MerkleList.Constructor


innerProvable

Get Signature

get innerProvable(): ProvableHashable<T>;

Defined in: lib/provable/merkle-list.ts:367

Returns

ProvableHashable<T>

Inherited from

MerkleList.innerProvable


emptyHash

Get Signature

get static emptyHash(): Field;

Defined in: lib/provable/merkle-list.ts:362

Returns

Field

Inherited from

MerkleList.emptyHash

Methods

clone()

clone(): MerkleList<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>;

Defined in: lib/provable/merkle-list.ts:236

Returns

MerkleList<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Inherited from

MerkleList.clone


forEach()

forEach(length: number, callback: (element: {
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}, isDummy: Bool, i: number) => void): void;

Defined in: lib/provable/merkle-list.ts:250

Iterate through the list in a fixed number of steps any apply a given callback on each element.

Proves that the iteration traverses the entire list. Once past the last element, dummy elements will be passed to the callback.

Note: There are no guarantees about the contents of dummy elements, so the callback is expected to handle the isDummy flag separately.

Parameters

length

number

callback

(element: { accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }, isDummy: Bool, i: number) => void

Returns

void

Inherited from

MerkleList.forEach


isEmpty()

isEmpty(): Bool;

Defined in: lib/provable/merkle-list.ts:90

Returns

Bool

Inherited from

MerkleList.isEmpty


lengthUnconstrained()

lengthUnconstrained(): Unconstrained<number>;

Defined in: lib/provable/merkle-list.ts:273

Returns

Unconstrained<number>

Inherited from

MerkleList.lengthUnconstrained


nextHash()

nextHash(hash: Field, value: {
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}): Field;

Defined in: lib/provable/merkle-list.ts:357

Parameters

hash

Field

value
accountUpdate

Hashed<AccountUpdate> = HashedAccountUpdate

children

MerkleListBase<AccountUpdateTreeBase> = ...

id

number = RandomId

Returns

Field

Inherited from

MerkleList.nextHash


pop()

pop(): {
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
};

Defined in: lib/provable/merkle-list.ts:152

Remove the last element from the list and return it.

If the list is empty, returns a dummy element.

Returns

{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.pop


popExn()

popExn(): {
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
};

Defined in: lib/provable/merkle-list.ts:137

Remove the last element from the list and return it.

This proves that the list is non-empty, and fails otherwise.

Returns

{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.popExn


popIf()

popIf(condition: Bool): {
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
};

Defined in: lib/provable/merkle-list.ts:192

Return the last element, but only remove it if condition is true.

If the list is empty, returns a dummy element.

Parameters

condition

Bool

Returns

{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.popIf


popIfUnsafe()

popIfUnsafe(shouldPop: Bool): {
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
};

Defined in: lib/provable/merkle-list.ts:216

Low-level, minimal version of pop() which lets the caller decide whether there is an element to pop.

I.e. this proves:

  • If the input condition is true, this returns the last element and removes it from the list.
  • If the input condition is false, the list is unchanged and the return value is garbage.

Note that if the caller passes true but the list is empty, this will fail. If the caller passes false but the list is non-empty, this succeeds and just doesn't pop off an element.

Parameters

shouldPop

Bool

Returns

{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;

Inherited from

MerkleList.popIfUnsafe


popOption()

popOption(): Option<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>;

Defined in: lib/provable/merkle-list.ts:172

Remove the last element from the list and return it as an option: Some(element) if the list is non-empty, None if the list is empty.

Warning: If the list is empty, the the option's .value is entirely unconstrained.

Returns

Option<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Inherited from

MerkleList.popOption


push()

push(update: AccountUpdate | AccountUpdateTreeBase): void;

Defined in: lib/mina/v1/account-update.ts:1285

Push a new element to the list.

Parameters

update

AccountUpdate | AccountUpdateTreeBase

Returns

void

Overrides

MerkleList.push


pushIf()

pushIf(condition: Bool, update: AccountUpdate | AccountUpdateTreeBase): void;

Defined in: lib/mina/v1/account-update.ts:1288

Push a new element to the list, if the condition is true.

Parameters

condition

Bool

update

AccountUpdate | AccountUpdateTreeBase

Returns

void

Overrides

MerkleList.pushIf


startIterating()

startIterating(): MerkleListIterator<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>;

Defined in: lib/provable/merkle-list.ts:259

Returns

MerkleListIterator<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Inherited from

MerkleList.startIterating


startIteratingFromLast()

startIteratingFromLast(): MerkleListIterator<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>;

Defined in: lib/provable/merkle-list.ts:264

Returns

MerkleListIterator<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }>

Inherited from

MerkleList.startIteratingFromLast


toArrayUnconstrained()

toArrayUnconstrained(): Unconstrained<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}[]>;

Defined in: lib/provable/merkle-list.ts:269

Returns

Unconstrained<{ accountUpdate: Hashed<AccountUpdate>; children: MerkleListBase<AccountUpdateTreeBase>; id: number; }[]>

Inherited from

MerkleList.toArrayUnconstrained


toFlatArray()

toFlatArray(mutate: boolean, depth: number): AccountUpdate[];

Defined in: lib/mina/v1/account-update.ts:1300

Parameters

mutate

boolean = true

depth

number = 0

Returns

AccountUpdate[]


assertConstant()

static assertConstant(forest: AccountUpdateForestBase): void;

Defined in: lib/mina/v1/account-update.ts:1325

Parameters

forest

AccountUpdateForestBase

Returns

void


create()

static create<T>(
type: WithProvable<ProvableHashable<T>>,
nextHash: (hash: Field, value: T) => Field,
emptyHash_: Field): typeof MerkleList & {
empty: () => MerkleList<T>;
from: (array: T[]) => MerkleList<T>;
fromReverse: (array: T[]) => MerkleList<T>;
provable: ProvableHashable<MerkleList<T>>;
};

Defined in: lib/provable/merkle-list.ts:289

Create a Merkle list type

Optionally, you can tell create() how to do the hash that pushes a new list element, by passing a nextHash function.

Type Parameters

T

T

Parameters

type

WithProvable<ProvableHashable<T>>

nextHash

(hash: Field, value: T) => Field

emptyHash_

Field = emptyHash

Returns

typeof MerkleList & { empty: () => MerkleList<T>; from: (array: T[]) => MerkleList<T>; fromReverse: (array: T[]) => MerkleList<T>; provable: ProvableHashable<MerkleList<T>>; }

Example

class MyList extends MerkleList.create(Field, (hash, x) =>
Poseidon.hashWithPrefix('custom', [hash, x])
) {}

Inherited from

MerkleList.create


empty()

static empty(): AccountUpdateForest;

Defined in: lib/mina/v1/account-update.ts:1338

Returns

AccountUpdateForest

Overrides

MerkleList.create(AccountUpdateTreeBase, merkleListHash).empty

from()

static from(array: AccountUpdateTreeBase[]): AccountUpdateForest;

Defined in: lib/mina/v1/account-update.ts:1341

Parameters

array

AccountUpdateTreeBase[]

Returns

AccountUpdateForest

Overrides

MerkleList.create(AccountUpdateTreeBase, merkleListHash).from

fromFlatArray()

static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest;

Defined in: lib/mina/v1/account-update.ts:1295

Parameters

updates

AccountUpdate[]

Returns

AccountUpdateForest


fromReverse()

static fromReverse(array: AccountUpdateTreeBase[]): AccountUpdateForest;

Defined in: lib/mina/v1/account-update.ts:1344

Parameters

array

AccountUpdateTreeBase[]

Returns

AccountUpdateForest

Overrides

MerkleList.create(AccountUpdateTreeBase, merkleListHash).fromReverse

toFlatArray()

static toFlatArray(
forest: AccountUpdateForestBase,
mutate: boolean,
depth: number): AccountUpdate[];

Defined in: lib/mina/v1/account-update.ts:1304

Parameters

forest

AccountUpdateForestBase

mutate

boolean = true

depth

number = 0

Returns

AccountUpdate[]