AccountUpdateForest
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
MerkleList
\<{"accountUpdate"
:HashedAccountUpdate
;"children"
:MerkleListBase
\<AccountUpdateTreeBase
>;"id"
:RandomId
; },this
>
Constructors
new AccountUpdateForest()
new AccountUpdateForest(__namedParameters: MerkleListBase<{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>): AccountUpdateForest
Parameters
• __namedParameters: MerkleListBase
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
Returns
Inherited from
Source
lib/provable/merkle-list.ts:84
Properties
data
data: Unconstrained<WithHash<{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>[]>;
Inherited from
Source
lib/provable/merkle-list.ts:82
hash
hash: Field;
Inherited from
Source
lib/provable/merkle-list.ts:81
_emptyHash
static _emptyHash: undefined | Field;
Inherited from
Source
lib/provable/merkle-list.ts:350
_innerProvable
static _innerProvable: undefined | ProvableHashable<any>;
Inherited from
Source
lib/provable/merkle-list.ts:353
_nextHash
static _nextHash: undefined | (hash: Field, t: any) => Field;
Inherited from
Source
lib/provable/merkle-list.ts:349
_provable
static _provable: undefined | ProvableHashable<MerkleList<any>>;
Inherited from
Source
lib/provable/merkle-list.ts:352
provable
static provable: {
"check": void;
"empty": AccountUpdateForest;
"fromFields": AccountUpdateForest;
"fromValue": AccountUpdateForest;
"sizeInFields": number;
"toAuxiliary": any[];
"toFields": Field[];
"toInput": HashInput;
"toValue": any;
};
check()
Parameters
• value: AccountUpdateForest
| MerkleList
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
Returns
void
empty()
Returns
fromFields()
Parameters
• fields: Field
[]
• aux: any
[]
Returns
fromValue()
Parameters
• value: any
Returns
sizeInFields()
Returns
number
toAuxiliary()
Parameters
• value?: AccountUpdateForest
| MerkleList
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
Returns
any
[]
toFields()
Parameters
• value: AccountUpdateForest
| MerkleList
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
Returns
Field
[]
toInput()
Parameters
• value: AccountUpdateForest
| MerkleList
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
Returns
HashInput
toValue()
Parameters
• value: AccountUpdateForest
| MerkleList
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
Returns
any
Overrides
MerkleList.create(
AccountUpdateTreeBase,
merkleListHash
).provable
Source
lib/mina/account-update.ts:1379
Accessors
Constructor
get Constructor(): typeof MerkleList
Returns
typeof MerkleList
Source
lib/provable/merkle-list.ts:355
innerProvable
get innerProvable(): ProvableHashable<T>
Returns
ProvableHashable
\<T
>
Source
lib/provable/merkle-list.ts:372
emptyHash
get static emptyHash(): Field
Returns
Source
lib/provable/merkle-list.ts:367
Methods
clone()
clone(): MerkleList<{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>
Returns
MerkleList
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
Source
lib/provable/merkle-list.ts:223
forEach()
forEach(length: number, callback: (element: {
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}, isDummy: Bool, i: number) => void): void
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
Returns
void
Inherited from
Source
lib/provable/merkle-list.ts:237
isEmpty()
isEmpty(): Bool
Returns
Inherited from
Source
lib/provable/merkle-list.ts:89
lengthUnconstrained()
lengthUnconstrained(): Unconstrained<number>
Returns
Unconstrained
\<number
>
Inherited from
MerkleList
.lengthUnconstrained
Source
lib/provable/merkle-list.ts:267
nextHash()
nextHash(hash: Field, value: {
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}): Field
Parameters
• hash: Field
• value
• value.accountUpdate: Hashed
\<AccountUpdate
>= HashedAccountUpdate
• value.children: MerkleListBase
\<AccountUpdateTreeBase
>= undefined
• value.id: number
= RandomId
Returns
Inherited from
Source
lib/provable/merkle-list.ts:359
pop()
pop(): {
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
Remove the last element from the list and return it.
If the list is empty, returns a dummy element.
Returns
{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
Source
lib/provable/merkle-list.ts:155
popExn()
popExn(): {
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
Remove the last element from the list and return it.
This proves that the list is non-empty, and fails otherwise.
Returns
{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
Source
lib/provable/merkle-list.ts:140
popIf()
popIf(condition: Bool): {
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
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": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
Source
lib/provable/merkle-list.ts:174
popIfUnsafe()
popIfUnsafe(shouldPop: Bool): {
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
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": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
Source
lib/provable/merkle-list.ts:200
push()
push(update: AccountUpdate | AccountUpdateTreeBase): void
Push a new element to the list.
Parameters
• update: AccountUpdate
| AccountUpdateTreeBase
Returns
void
Overrides
Source
lib/mina/account-update.ts:1381
pushIf()
pushIf(condition: Bool, update: AccountUpdate | AccountUpdateTreeBase): void
Push a new element to the list, if the condition
is true.
Parameters
• condition: Bool
• update: AccountUpdate
| AccountUpdateTreeBase
Returns
void
Overrides
Source
lib/mina/account-update.ts:1386
startIterating()
startIterating(): MerkleListIterator<{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>
Returns
MerkleListIterator
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
Source
lib/provable/merkle-list.ts:251
startIteratingFromLast()
startIteratingFromLast(): MerkleListIterator<{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}>
Returns
MerkleListIterator
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}>
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
MerkleList
.startIteratingFromLast
Source
lib/provable/merkle-list.ts:256
toArrayUnconstrained()
toArrayUnconstrained(): Unconstrained<{
"accountUpdate": HashedAccountUpdate;
"children": MerkleListBase<AccountUpdateTreeBase>;
"id": RandomId;
}[]>
Returns
Unconstrained
\<{
"accountUpdate"
: HashedAccountUpdate
;
"children"
: MerkleListBase
\<AccountUpdateTreeBase
>;
"id"
: RandomId
;
}[]>
Inherited from
MerkleList
.toArrayUnconstrained
Source
lib/provable/merkle-list.ts:261
toFlatArray()
toFlatArray(mutate: boolean, depth: number): AccountUpdate[]
Parameters
• mutate: boolean
= true
• depth: number
= 0
Returns
Source
lib/mina/account-update.ts:1398
assertConstant()
static assertConstant(forest: AccountUpdateForestBase): void
Parameters
• forest: AccountUpdateForestBase
Returns
void
Source
lib/mina/account-update.ts:1429
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>>;
}
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
Parameters
• type: WithProvable
\<ProvableHashable
\<T
>>
• nextHash= undefined
• emptyHash_: Field
= emptyHash
Returns
typeof MerkleList
& {
"empty"
: () => MerkleList
\<T
>;
"from"
: (array
: T
[]) => MerkleList
\<T
>;
"fromReverse"
: (array
: T
[]) => MerkleList
\<T
>;
"provable"
: ProvableHashable
\<MerkleList
\<T
>>;
}
Inherited from
Example
class MyList extends MerkleList.create(Field, (hash, x) =>
Poseidon.hashWithPrefix('custom', [hash, x])
) {}
Source
lib/provable/merkle-list.ts:283
empty()
static empty(): AccountUpdateForest
Returns
Overrides
MerkleList.create(
AccountUpdateTreeBase,
merkleListHash
).empty
Source
lib/mina/account-update.ts:1442
from()
static from(array: AccountUpdateTreeBase[]): AccountUpdateForest
Parameters
• array: AccountUpdateTreeBase
[]
Returns
Overrides
MerkleList.create(
AccountUpdateTreeBase,
merkleListHash
).from
Source
lib/mina/account-update.ts:1445
fromFlatArray()
static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest
Parameters
• updates: AccountUpdate
[]
Returns
Source
lib/mina/account-update.ts:1393
fromReverse()
static fromReverse(array: AccountUpdateTreeBase[]): AccountUpdateForest
Parameters
• array: AccountUpdateTreeBase
[]
Returns
Overrides
MerkleList.create(
AccountUpdateTreeBase,
merkleListHash
).fromReverse
Source
lib/mina/account-update.ts:1448
toFlatArray()
static toFlatArray(
forest: AccountUpdateForestBase,
mutate: boolean,
depth: number): AccountUpdate[]
Parameters
• forest: AccountUpdateForestBase
• mutate: boolean
= true
• depth: number
= 0