AccountUpdateForest
Defined in: lib/mina/v1/account-update.ts:1279
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
:Hashed
<AccountUpdate
>;children
:MerkleListBase
<AccountUpdateTreeBase
>;id
:number
; },this
>
Constructors
new AccountUpdateForest()
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
Inherited from
Properties
data
data: Unconstrained<WithHash<{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}>[]>;
Defined in: lib/provable/merkle-list.ts:83
Inherited from
hash
hash: Field;
Defined in: lib/provable/merkle-list.ts:82
Inherited from
_emptyHash
static _emptyHash: undefined | Field;
Defined in: lib/provable/merkle-list.ts:348
Inherited from
_innerProvable
static _innerProvable:
| undefined
| ProvableHashable<any>;
Defined in: lib/provable/merkle-list.ts:351
Inherited from
_nextHash
static _nextHash:
| undefined
| (hash: Field, t: any) => Field;
Defined in: lib/provable/merkle-list.ts:347
Inherited from
_provable
static _provable:
| undefined
| ProvableHashable<MerkleList<any>>;
Defined in: lib/provable/merkle-list.ts:350
Inherited from
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:1280
check()
Parameters
value
AccountUpdateForest
| MerkleList
<{
accountUpdate
: Hashed
<AccountUpdate
>;
children
: MerkleListBase
<AccountUpdateTreeBase
>;
id
: number
;
}>
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
: Hashed
<AccountUpdate
>;
children
: MerkleListBase
<AccountUpdateTreeBase
>;
id
: number
;
}>
Returns
any
[]
toFields()
Parameters
value
AccountUpdateForest
| MerkleList
<{
accountUpdate
: Hashed
<AccountUpdate
>;
children
: MerkleListBase
<AccountUpdateTreeBase
>;
id
: number
;
}>
Returns
Field
[]
toInput()
Parameters
value
AccountUpdateForest
| MerkleList
<{
accountUpdate
: Hashed
<AccountUpdate
>;
children
: MerkleListBase
<AccountUpdateTreeBase
>;
id
: number
;
}>
Returns
HashInput
toValue()
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
innerProvable
Get Signature
get innerProvable(): ProvableHashable<T>
Defined in: lib/provable/merkle-list.ts:367
Returns
Inherited from
emptyHash
Get Signature
get static emptyHash(): Field
Defined in: lib/provable/merkle-list.ts:362
Returns
Inherited from
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
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
isEmpty()
isEmpty(): Bool
Defined in: lib/provable/merkle-list.ts:90
Returns
Inherited from
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
value
accountUpdate
Hashed
<AccountUpdate
> = HashedAccountUpdate
children
MerkleListBase
<AccountUpdateTreeBase
> = ...
id
number
= RandomId
Returns
Inherited from
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
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
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
Returns
{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
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
Returns
{
accountUpdate: Hashed<AccountUpdate>;
children: MerkleListBase<AccountUpdateTreeBase>;
id: number;
}
accountUpdate
accountUpdate: Hashed<AccountUpdate> = HashedAccountUpdate;
children
children: MerkleListBase<AccountUpdateTreeBase>;
id
id: number = RandomId;
Inherited from
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
push()
push(update: AccountUpdate | AccountUpdateTreeBase): void
Defined in: lib/mina/v1/account-update.ts:1282
Push a new element to the list.
Parameters
update
AccountUpdate
| AccountUpdateTreeBase
Returns
void
Overrides
pushIf()
pushIf(condition: Bool, update: AccountUpdate | AccountUpdateTreeBase): void
Defined in: lib/mina/v1/account-update.ts:1285
Push a new element to the list, if the condition
is true.
Parameters
condition
update
AccountUpdate
| AccountUpdateTreeBase
Returns
void
Overrides
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
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:1297
Parameters
mutate
boolean
= true
depth
number
= 0
Returns
assertConstant()
static assertConstant(forest: AccountUpdateForestBase): void
Defined in: lib/mina/v1/account-update.ts:1322
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
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
empty()
static empty(): AccountUpdateForest
Defined in: lib/mina/v1/account-update.ts:1335
Returns
Overrides
MerkleList.create(AccountUpdateTreeBase, merkleListHash).empty
from()
static from(array: AccountUpdateTreeBase[]): AccountUpdateForest
Defined in: lib/mina/v1/account-update.ts:1338
Parameters
array
AccountUpdateTreeBase
[]
Returns
Overrides
MerkleList.create(AccountUpdateTreeBase, merkleListHash).from
fromFlatArray()
static fromFlatArray(updates: AccountUpdate[]): AccountUpdateForest
Defined in: lib/mina/v1/account-update.ts:1292
Parameters
updates
Returns
fromReverse()
static fromReverse(array: AccountUpdateTreeBase[]): AccountUpdateForest
Defined in: lib/mina/v1/account-update.ts:1341
Parameters
array
AccountUpdateTreeBase
[]
Returns
Overrides
MerkleList.create(AccountUpdateTreeBase, merkleListHash).fromReverse
toFlatArray()
static toFlatArray(
forest: AccountUpdateForestBase,
mutate: boolean,
depth: number): AccountUpdate[]
Defined in: lib/mina/v1/account-update.ts:1301
Parameters
forest
AccountUpdateForestBase
mutate
boolean
= true
depth
number
= 0