BatchReducer
Defined in: index.ts:207
A reducer to process actions in fixed-size batches.
let batchReducer = new BatchReducer({ actionType: Action, batchSize: 5 });
// in contract: concurrent dispatching of actions
batchReducer.dispatch(action);
// reducer logic
// outside contract: prepare a list of { batch, proof } objects which cover all pending actions
let batches = await batchReducer.prepareBatches();
// in contract: process a single batch
// create one transaction that does this for each batch!
batchReducer.processBatch({ batch, proof }, (action, isDummy) => {
// ...
});
Extends
BatchReducer
<ActionType
,BatchSize
,Action
>
Type Parameters
• ActionType extends Actionable
<any
>
• BatchSize extends number
= number
• Action = InferProvable
<ActionType
>
Constructors
new BatchReducer()
new BatchReducer<ActionType, BatchSize, Action>(__namedParameters: {
actionType: ActionType;
batchSize: BatchSize;
maxActionsPerUpdate: number;
maxUpdatesFinalProof: number;
maxUpdatesPerProof: number;
}): BatchReducer<ActionType, BatchSize, Action>
Defined in: lib/mina/v1/actions/batch-reducer.ts:75
Parameters
__namedParameters
actionType
ActionType
The provable type of actions submitted by this reducer.
batchSize
BatchSize
The number of actions in a batch. The idea is to process one batch per transaction, by calling processBatch()
.
The motivation for processing actions in small batches is to work around the protocol limit on the number of account updates. If every action should result in an account update, then you have to set the batch size low enough to not exceed the limit.
If transaction limits are no concern, the batchSize
could be set based on amount of logic you do per action.
A smaller batch size will make proofs faster, but you might need more individual transactions as more batches are needed to process all pending actions.
maxActionsPerUpdate
number
= ...
The maximum number of actions dispatched in any of the zkApp methods on the contract.
Note: This number just has to be an upper bound of the actual maximum, but if it's the precise number, fewer constraints will be used. (The overhead of a higher number is fairly small though.)
A restriction is that the number has to be less or equal than the batchSize
.
The reason is that actions in one account update are always processed together, so if you'd have more actions in one than the batch size, we couldn't process them at all.
By default, this is set to Math.min(batchSize, 5)
which should be sensible for most applications.
maxUpdatesFinalProof
number
= 100
The maximum number of action lists (= all actions on an account update) to process inside processBatch()
,
i.e. in your zkApp method.
Default: 100, which will take up about 3000 constraints.
The current default should be sensible for most applications, but here are some trade-offs to consider when changing it:
- Using a smaller number means a smaller circuit, so proofs of your method will be faster.
- Using a bigger number means it's more likely that you can prove all actions in the method call and won't need a recursive proof.
So, go lower if you expect very few actions, and higher if you expect a lot of actions.
maxUpdatesPerProof
number
= 300
The maximum number of action lists (= all actions on an account update) to process in a single recursive proof, in prepareBatches()
.
Default: 300, which will take up about 9000 constraints.
The current default should be sensible for most applications, but here are some trade-offs to consider when changing it:
- Using a smaller number means a smaller circuit, so recursive proofs will be faster.
- Using a bigger number means you'll need fewer recursive proofs in the case a lot of actions are pending.
So, go lower if you expect very few actions, and higher if you expect a lot of actions. (Note: A larger circuit causes longer compilation and proof times for your zkApp even if you never need a recursive proof)
Returns
BatchReducer
<ActionType
, BatchSize
, Action
>
Inherited from
BatchReducer_.BatchReducer<ActionType, BatchSize, Action>.constructor
Properties
_contract?
optional _contract: BatchReducerContract;
Defined in: lib/mina/v1/actions/batch-reducer.ts:164
Inherited from
BatchReducer_.BatchReducer._contract
_contractClass?
optional _contractClass: BatchReducerContractClass;
Defined in: lib/mina/v1/actions/batch-reducer.ts:165
Inherited from
BatchReducer_.BatchReducer._contractClass
actionType
actionType: Provable<Action, any> & {
empty: () => Action;
} & {
toInput: (x: Action) => HashInput;
} & Omit<Provable<Action, any>, "fromFields"> & {
fromFields: (fields: Field[]) => Action;
};
Defined in: lib/mina/v1/actions/batch-reducer.ts:66
Type declaration
empty()
empty: () => Action;
Returns
Action
Type declaration
toInput()
toInput: (x: Action) => HashInput;
Parameters
x
Action
Returns
HashInput
Type declaration
fromFields()
fromFields: (fields: Field[]) => Action;
Parameters
fields
Field
[]
Returns
Action
Inherited from
BatchReducer_.BatchReducer.actionType
Batch
Batch: (value: {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}) => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
} & {
_isStruct: true;
} & Provable<{
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}, {
isRecursive: boolean;
onchainActionState: bigint;
onchainStack: bigint;
processedActionState: bigint;
stack: any;
useOnchainStack: boolean;
witnesses: ActionWitnesses;
}> & {
empty: () => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
};
fromJSON: (x: {
isRecursive: boolean;
onchainActionState: string;
onchainStack: string;
processedActionState: string;
stack: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
empty: {};
emptyHash: string;
from: {};
fromReverse: {};
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
create: ;
};
useOnchainStack: boolean;
witnesses: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
}) => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
};
fromValue: (value: {
isRecursive: boolean | Bool;
onchainActionState: string | number | bigint | Field;
onchainStack: string | number | bigint | Field;
processedActionState: string | number | bigint | Field;
stack: any;
useOnchainStack: boolean | Bool;
witnesses: | ActionWitnesses
| Unconstrained<ActionWitnesses>;
}) => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
};
toInput: (x: {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}) => {
fields: Field[];
packed: [Field, number][];
};
toJSON: (x: {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}) => {
isRecursive: boolean;
onchainActionState: string;
onchainStack: string;
processedActionState: string;
stack: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
empty: {};
emptyHash: string;
from: {};
fromReverse: {};
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
create: ;
};
useOnchainStack: boolean;
witnesses: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
};
};
Defined in: lib/mina/v1/actions/batch-reducer.ts:67
Type declaration
_isStruct
_isStruct: true;
Type declaration
empty()
empty: () => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
};
Returns
{
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}
isRecursive
isRecursive: Bool = Bool;
onchainActionState
onchainActionState: Field = Field;
onchainStack
onchainStack: Field = Field;
processedActionState
processedActionState: Field = Field;
stack
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack
useOnchainStack: Bool = Bool;
witnesses
witnesses: Unconstrained<ActionWitnesses>;
fromJSON()
fromJSON: (x: {
isRecursive: boolean;
onchainActionState: string;
onchainStack: string;
processedActionState: string;
stack: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
empty: {};
emptyHash: string;
from: {};
fromReverse: {};
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
create: ;
};
useOnchainStack: boolean;
witnesses: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
}) => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
};
Parameters
x
isRecursive
boolean
= Bool
onchainActionState
string
= Field
onchainStack
string
= Field
processedActionState
string
= Field
stack
{
_emptyHash
: null
| string
;
_innerProvable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
_nextHash
: null
| {};
_provable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
empty
: {};
emptyHash
: string
;
from
: {};
fromReverse
: {};
prototype
: {
Constructor
: {
_emptyHash
: null
| string
;
_innerProvable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
_nextHash
: null
| {};
_provable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
emptyHash
: string
;
prototype
: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create
: ;
};
data
: {
get
: ;
set
: ;
setTo
: ;
updateAsProver
: ;
};
hash
: string
;
innerProvable
: {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
clone
: ;
forEach
: ;
isEmpty
: ;
lengthUnconstrained
: ;
nextHash
: ;
pop
: ;
popExn
: ;
popIf
: ;
popIfUnsafe
: ;
popOption
: ;
push
: ;
pushIf
: ;
startIterating
: ;
startIteratingFromLast
: ;
toArrayUnconstrained
: ;
};
provable
: {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
create
: ;
} = ...
stack._emptyHash
null
| string
stack._innerProvable
| null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack._nextHash
null
| {}
stack._provable
| null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.empty
{}
stack.emptyHash
string
stack.from
{}
stack.fromReverse
{}
stack.prototype
{
Constructor
: {
_emptyHash
: null
| string
;
_innerProvable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
_nextHash
: null
| {};
_provable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
emptyHash
: string
;
prototype
: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create
: ;
};
data
: {
get
: ;
set
: ;
setTo
: ;
updateAsProver
: ;
};
hash
: string
;
innerProvable
: {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
clone
: ;
forEach
: ;
isEmpty
: ;
lengthUnconstrained
: ;
nextHash
: ;
pop
: ;
popExn
: ;
popIf
: ;
popIfUnsafe
: ;
popOption
: ;
push
: ;
pushIf
: ;
startIterating
: ;
startIteratingFromLast
: ;
toArrayUnconstrained
: ;
}
stack.prototype.Constructor
{
_emptyHash
: null
| string
;
_innerProvable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
_nextHash
: null
| {};
_provable
: | null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
};
emptyHash
: string
;
prototype
: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create
: ;
}
stack.prototype.Constructor._emptyHash
null
| string
stack.prototype.Constructor._innerProvable
| null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.prototype.Constructor._nextHash
null
| {}
stack.prototype.Constructor._provable
| null
| {
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.prototype.Constructor.emptyHash
string
stack.prototype.Constructor.prototype
{ hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; }
stack.prototype.Constructor.create
stack.prototype.data
{
get
: ;
set
: ;
setTo
: ;
updateAsProver
: ;
}
stack.prototype.data.get
stack.prototype.data.set
stack.prototype.data.setTo
stack.prototype.data.updateAsProver
stack.prototype.hash
string
stack.prototype.innerProvable
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.prototype.innerProvable.check
{}
Add assertions to the proof to check if value
is a valid member of type T
.
This function does not return anything, instead it creates any number of assertions to prove that value
is a valid member of the type T
.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Param
the element of type T
to put assertions on.
stack.prototype.innerProvable.empty
{}
stack.prototype.innerProvable.fromFields
{}
A function that returns an element of type T
from the given provable and "auxiliary" data.
This function is the reverse operation of calling toFields and toAuxiliary methods on an element of type T
.
Param
an array of Field elements describing the provable data of the new T
element.
Param
an array of any type describing the "auxiliary" data of the new T
element, optional.
stack.prototype.innerProvable.fromValue
{}
Convert provable type from a normal JS type.
stack.prototype.innerProvable.toAuxiliary
{}
A function that takes value
(optional), an element of type T
, as argument and
returns an array of any type that make up the "auxiliary" (non-provable) data of value
.
Param
the element of type T
to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
stack.prototype.innerProvable.toCanonical
null
| {}
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField
class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical()
converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical()
is not present on a type.
stack.prototype.innerProvable.toFields
{}
A function that takes value
, an element of type T
, as argument and returns
an array of Field elements that make up the provable data of value
.
Param
the element of type T
to generate the Field array from.
stack.prototype.innerProvable.toInput
{}
stack.prototype.innerProvable.toValue
{}
Convert provable type to a normal JS type.
stack.prototype.innerProvable.sizeInFields
stack.prototype.clone
stack.prototype.forEach
stack.prototype.isEmpty
stack.prototype.lengthUnconstrained
stack.prototype.nextHash
stack.prototype.pop
stack.prototype.popExn
stack.prototype.popIf
stack.prototype.popIfUnsafe
stack.prototype.popOption
stack.prototype.push
stack.prototype.pushIf
stack.prototype.startIterating
stack.prototype.startIteratingFromLast
stack.prototype.toArrayUnconstrained
stack.provable
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.provable.check
{}
Add assertions to the proof to check if value
is a valid member of type T
.
This function does not return anything, instead it creates any number of assertions to prove that value
is a valid member of the type T
.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Param
the element of type T
to put assertions on.
stack.provable.empty
{}
stack.provable.fromFields
{}
A function that returns an element of type T
from the given provable and "auxiliary" data.
This function is the reverse operation of calling toFields and toAuxiliary methods on an element of type T
.
Param
an array of Field elements describing the provable data of the new T
element.
Param
an array of any type describing the "auxiliary" data of the new T
element, optional.
stack.provable.fromValue
{}
Convert provable type from a normal JS type.
stack.provable.toAuxiliary
{}
A function that takes value
(optional), an element of type T
, as argument and
returns an array of any type that make up the "auxiliary" (non-provable) data of value
.
Param
the element of type T
to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
stack.provable.toCanonical
null
| {}
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField
class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical()
converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical()
is not present on a type.
stack.provable.toFields
{}
A function that takes value
, an element of type T
, as argument and returns
an array of Field elements that make up the provable data of value
.
Param
the element of type T
to generate the Field array from.
stack.provable.toInput
{}
stack.provable.toValue
{}
Convert provable type to a normal JS type.
stack.provable.sizeInFields
stack.create
useOnchainStack
boolean
= Bool
witnesses
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
} = ...
witnesses.check
{}
Add assertions to the proof to check if value
is a valid member of type T
.
This function does not return anything, instead it creates any number of assertions to prove that value
is a valid member of the type T
.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Param
the element of type T
to put assertions on.
witnesses.empty
{}
witnesses.fromFields
{}
A function that returns an element of type T
from the given provable and "auxiliary" data.
This function is the reverse operation of calling toFields and toAuxiliary methods on an element of type T
.
Param
an array of Field elements describing the provable data of the new T
element.
Param
an array of any type describing the "auxiliary" data of the new T
element, optional.
witnesses.fromValue
{}
Convert provable type from a normal JS type.
witnesses.toAuxiliary
{}
A function that takes value
(optional), an element of type T
, as argument and
returns an array of any type that make up the "auxiliary" (non-provable) data of value
.
Param
the element of type T
to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
witnesses.toCanonical
null
| {}
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField
class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical()
converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical()
is not present on a type.
witnesses.toFields
{}
A function that takes value
, an element of type T
, as argument and returns
an array of Field elements that make up the provable data of value
.
Param
the element of type T
to generate the Field array from.
witnesses.toInput
{}
witnesses.toValue
{}
Convert provable type to a normal JS type.
witnesses.sizeInFields
Returns
{
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}
isRecursive
isRecursive: Bool = Bool;
onchainActionState
onchainActionState: Field = Field;
onchainStack
onchainStack: Field = Field;
processedActionState
processedActionState: Field = Field;
stack
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack
useOnchainStack: Bool = Bool;
witnesses
witnesses: Unconstrained<ActionWitnesses>;
fromValue()
fromValue: (value: {
isRecursive: boolean | Bool;
onchainActionState: string | number | bigint | Field;
onchainStack: string | number | bigint | Field;
processedActionState: string | number | bigint | Field;
stack: any;
useOnchainStack: boolean | Bool;
witnesses: | ActionWitnesses
| Unconstrained<ActionWitnesses>;
}) => {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
};
Parameters
value
isRecursive
boolean
| Bool
= Bool
onchainActionState
string
| number
| bigint
| Field
= Field
onchainStack
string
| number
| bigint
| Field
= Field
processedActionState
string
| number
| bigint
| Field
= Field
stack
any
= ...
useOnchainStack
boolean
| Bool
= Bool
witnesses
| ActionWitnesses
| Unconstrained
<ActionWitnesses
> = ...
Returns
{
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}
isRecursive
isRecursive: Bool = Bool;
onchainActionState
onchainActionState: Field = Field;
onchainStack
onchainStack: Field = Field;
processedActionState
processedActionState: Field = Field;
stack
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack
useOnchainStack: Bool = Bool;
witnesses
witnesses: Unconstrained<ActionWitnesses>;
toInput()
toInput: (x: {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}) => {
fields: Field[];
packed: [Field, number][];
};
Parameters
x
isRecursive
Bool
= Bool
onchainActionState
Field
= Field
onchainStack
Field
= Field
processedActionState
Field
= Field
stack
MerkleList
<MerkleList
<Hashed
<any
>>> = ...
useOnchainStack
Bool
= Bool
witnesses
Unconstrained
<ActionWitnesses
> = ...
Returns
{
fields: Field[];
packed: [Field, number][];
}
fields?
optional fields: Field[];
packed?
optional packed: [Field, number][];
toJSON()
toJSON: (x: {
isRecursive: Bool;
onchainActionState: Field;
onchainStack: Field;
processedActionState: Field;
stack: MerkleList<MerkleList<Hashed<any>>>;
useOnchainStack: Bool;
witnesses: Unconstrained<ActionWitnesses>;
}) => {
isRecursive: boolean;
onchainActionState: string;
onchainStack: string;
processedActionState: string;
stack: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
empty: {};
emptyHash: string;
from: {};
fromReverse: {};
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
create: ;
};
useOnchainStack: boolean;
witnesses: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
};
Parameters
x
isRecursive
Bool
= Bool
onchainActionState
Field
= Field
onchainStack
Field
= Field
processedActionState
Field
= Field
stack
MerkleList
<MerkleList
<Hashed
<any
>>> = ...
useOnchainStack
Bool
= Bool
witnesses
Unconstrained
<ActionWitnesses
> = ...
Returns
{
isRecursive: boolean;
onchainActionState: string;
onchainStack: string;
processedActionState: string;
stack: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
empty: {};
emptyHash: string;
from: {};
fromReverse: {};
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
create: ;
};
useOnchainStack: boolean;
witnesses: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
}
isRecursive
isRecursive: boolean = Bool;
onchainActionState
onchainActionState: string = Field;
onchainStack
onchainStack: string = Field;
processedActionState
processedActionState: string = Field;
stack
stack: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
empty: {};
emptyHash: string;
from: {};
fromReverse: {};
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
create: ;
};
stack._emptyHash
_emptyHash: null | string;
stack._innerProvable
_innerProvable:
| null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
Type declaration
null
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack._nextHash
_nextHash: null | {};
stack._provable
_provable:
| null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
Type declaration
null
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.empty
empty: {};
stack.emptyHash
emptyHash: string;
stack.from
from: {};
stack.fromReverse
fromReverse: {};
stack.prototype
prototype: {
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
hash: string;
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
clone: ;
forEach: ;
isEmpty: ;
lengthUnconstrained: ;
nextHash: ;
pop: ;
popExn: ;
popIf: ;
popIfUnsafe: ;
popOption: ;
push: ;
pushIf: ;
startIterating: ;
startIteratingFromLast: ;
toArrayUnconstrained: ;
};
stack.prototype.Constructor
Constructor: {
_emptyHash: null | string;
_innerProvable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
_nextHash: null | {};
_provable: | null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
emptyHash: string;
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
create: ;
};
stack.prototype.Constructor._emptyHash
_emptyHash: null | string;
stack.prototype.Constructor._innerProvable
_innerProvable:
| null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
Type declaration
null
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.prototype.Constructor._nextHash
_nextHash: null | {};
stack.prototype.Constructor._provable
_provable:
| null
| {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
Type declaration
null
{
check
: {};
empty
: {};
fromFields
: {};
fromValue
: {};
toAuxiliary
: {};
toCanonical
: null
| {};
toFields
: {};
toInput
: {};
toValue
: {};
sizeInFields
: ;
}
stack.prototype.Constructor.emptyHash
emptyHash: string;
stack.prototype.Constructor.prototype
prototype: { hash: string; data: { get: {}; set: {}; setTo: {}; updateAsProver: {}; }; isEmpty: {}; push: {}; pushIf: {}; popExn: {}; pop: {}; popOption: {}; popIf: {}; popIfUnsafe: {}; clone: {}; forEach: {}; startIterating: {}; ... 5 more ...; readonly innerProvable: { ...; }; };
stack.prototype.Constructor.create
create;
stack.prototype.data
data: {
get: ;
set: ;
setTo: ;
updateAsProver: ;
};
stack.prototype.data.get
get;
stack.prototype.data.set
set;
stack.prototype.data.setTo
setTo;
stack.prototype.data.updateAsProver
updateAsProver;
stack.prototype.hash
hash: string;
stack.prototype.innerProvable
innerProvable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
stack.prototype.innerProvable.check
check: {};
Add assertions to the proof to check if value
is a valid member of type T
.
This function does not return anything, instead it creates any number of assertions to prove that value
is a valid member of the type T
.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Param
the element of type T
to put assertions on.
stack.prototype.innerProvable.empty
empty: {};
stack.prototype.innerProvable.fromFields
fromFields: {};
A function that returns an element of type T
from the given provable and "auxiliary" data.
This function is the reverse operation of calling toFields and toAuxiliary methods on an element of type T
.
Param
an array of Field elements describing the provable data of the new T
element.
Param
an array of any type describing the "auxiliary" data of the new T
element, optional.
Returns
An element of type T
generated from the given provable and "auxiliary" data.
stack.prototype.innerProvable.fromValue
fromValue: {};
Convert provable type from a normal JS type.
stack.prototype.innerProvable.toAuxiliary
toAuxiliary: {};
A function that takes value
(optional), an element of type T
, as argument and
returns an array of any type that make up the "auxiliary" (non-provable) data of value
.
Param
the element of type T
to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
Returns
An array of any type describing how this T
element is made up of "auxiliary" (non-provable) data.
stack.prototype.innerProvable.toCanonical?
optional toCanonical: null | {};
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField
class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical()
converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical()
is not present on a type.
stack.prototype.innerProvable.toFields
toFields: {};
A function that takes value
, an element of type T
, as argument and returns
an array of Field elements that make up the provable data of value
.
Param
the element of type T
to generate the Field array from.
Returns
A Field array describing how this T
element is made up of Field elements.
stack.prototype.innerProvable.toInput
toInput: {};
stack.prototype.innerProvable.toValue
toValue: {};
Convert provable type to a normal JS type.
stack.prototype.innerProvable.sizeInFields
sizeInFields;
stack.prototype.clone
clone;
stack.prototype.forEach
forEach;
stack.prototype.isEmpty
isEmpty;
stack.prototype.lengthUnconstrained
lengthUnconstrained;
stack.prototype.nextHash
nextHash;
stack.prototype.pop
pop;
stack.prototype.popExn
popExn;
stack.prototype.popIf
popIf;
stack.prototype.popIfUnsafe
popIfUnsafe;
stack.prototype.popOption
popOption;
stack.prototype.push
push;
stack.prototype.pushIf
pushIf;
stack.prototype.startIterating
startIterating;
stack.prototype.startIteratingFromLast
startIteratingFromLast;
stack.prototype.toArrayUnconstrained
toArrayUnconstrained;
stack.provable
provable: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
stack.provable.check
check: {};
Add assertions to the proof to check if value
is a valid member of type T
.
This function does not return anything, instead it creates any number of assertions to prove that value
is a valid member of the type T
.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Param
the element of type T
to put assertions on.
stack.provable.empty
empty: {};
stack.provable.fromFields
fromFields: {};
A function that returns an element of type T
from the given provable and "auxiliary" data.
This function is the reverse operation of calling toFields and toAuxiliary methods on an element of type T
.
Param
an array of Field elements describing the provable data of the new T
element.
Param
an array of any type describing the "auxiliary" data of the new T
element, optional.
Returns
An element of type T
generated from the given provable and "auxiliary" data.
stack.provable.fromValue
fromValue: {};
Convert provable type from a normal JS type.
stack.provable.toAuxiliary
toAuxiliary: {};
A function that takes value
(optional), an element of type T
, as argument and
returns an array of any type that make up the "auxiliary" (non-provable) data of value
.
Param
the element of type T
to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
Returns
An array of any type describing how this T
element is made up of "auxiliary" (non-provable) data.
stack.provable.toCanonical?
optional toCanonical: null | {};
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField
class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical()
converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical()
is not present on a type.
stack.provable.toFields
toFields: {};
A function that takes value
, an element of type T
, as argument and returns
an array of Field elements that make up the provable data of value
.
Param
the element of type T
to generate the Field array from.
Returns
A Field array describing how this T
element is made up of Field elements.
stack.provable.toInput
toInput: {};
stack.provable.toValue
toValue: {};
Convert provable type to a normal JS type.
stack.provable.sizeInFields
sizeInFields;
stack.create
create;
useOnchainStack
useOnchainStack: boolean = Bool;
witnesses
witnesses: {
check: {};
empty: {};
fromFields: {};
fromValue: {};
toAuxiliary: {};
toCanonical: null | {};
toFields: {};
toInput: {};
toValue: {};
sizeInFields: ;
};
witnesses.check
check: {};
Add assertions to the proof to check if value
is a valid member of type T
.
This function does not return anything, instead it creates any number of assertions to prove that value
is a valid member of the type T
.
For instance, calling check function on the type Bool asserts that the value of the element is either 1 or 0.
Param
the element of type T
to put assertions on.
witnesses.empty
empty: {};
witnesses.fromFields
fromFields: {};
A function that returns an element of type T
from the given provable and "auxiliary" data.
This function is the reverse operation of calling toFields and toAuxiliary methods on an element of type T
.
Param
an array of Field elements describing the provable data of the new T
element.
Param
an array of any type describing the "auxiliary" data of the new T
element, optional.
Returns
An element of type T
generated from the given provable and "auxiliary" data.
witnesses.fromValue
fromValue: {};
Convert provable type from a normal JS type.
witnesses.toAuxiliary
toAuxiliary: {};
A function that takes value
(optional), an element of type T
, as argument and
returns an array of any type that make up the "auxiliary" (non-provable) data of value
.
Param
the element of type T
to generate the auxiliary data array from, optional.
If not provided, a default value for auxiliary data is returned.
Returns
An array of any type describing how this T
element is made up of "auxiliary" (non-provable) data.
witnesses.toCanonical?
optional toCanonical: null | {};
Optional method which transforms a provable type into its canonical representation.
This is needed for types that have multiple representations of the same underlying value, and might even not have perfect completeness for some of those representations.
An example is the ForeignField
class, which allows non-native field elements to exist in unreduced form.
The unreduced form is not perfectly complete, for example, addition of two unreduced field elements can cause a prover error.
Specific protocols need to be able to protect themselves against incomplete operations at all costs.
For example, when using actions and reducer, the reducer must be able to produce a proof regardless of the input action.
toCanonical()
converts any input into a safe form and enables us to handle cases like this generically.
Note: For most types, this method is the identity function.
The identity function will also be used when the toCanonical()
is not present on a type.
witnesses.toFields
toFields: {};
A function that takes value
, an element of type T
, as argument and returns
an array of Field elements that make up the provable data of value
.
Param
the element of type T
to generate the Field array from.
Returns
A Field array describing how this T
element is made up of Field elements.
witnesses.toInput
toInput: {};
witnesses.toValue
toValue: {};
Convert provable type to a normal JS type.
witnesses.sizeInFields
sizeInFields;
Inherited from
BatchReducer_.BatchReducer.Batch
BatchProof
BatchProof: typeof Proof;
Defined in: lib/mina/v1/actions/batch-reducer.ts:70
Inherited from
BatchReducer_.BatchReducer.BatchProof
batchSize
batchSize: BatchSize;
Defined in: lib/mina/v1/actions/batch-reducer.ts:65
Inherited from
BatchReducer_.BatchReducer.batchSize
maxActionsPerUpdate
maxActionsPerUpdate: number;
Defined in: lib/mina/v1/actions/batch-reducer.ts:73
Inherited from
BatchReducer_.BatchReducer.maxActionsPerUpdate
maxUpdatesFinalProof
maxUpdatesFinalProof: number;
Defined in: lib/mina/v1/actions/batch-reducer.ts:72
Inherited from
BatchReducer_.BatchReducer.maxUpdatesFinalProof
program
program: ActionStackProgram;
Defined in: lib/mina/v1/actions/batch-reducer.ts:69
Inherited from
BatchReducer_.BatchReducer.program
Accessors
initialActionStack
Get Signature
get static initialActionStack(): Field
Defined in: lib/mina/v1/actions/batch-reducer.ts:160
Returns
Inherited from
BatchReducer_.BatchReducer.initialActionStack
initialActionState
Get Signature
get static initialActionState(): Field
Defined in: lib/mina/v1/actions/batch-reducer.ts:157
Returns
Inherited from
BatchReducer_.BatchReducer.initialActionState
Methods
compile()
compile(): Promise<{
verificationKey: {
data: string;
hash: Field;
};
}>
Defined in: lib/mina/v1/actions/batch-reducer.ts:367
Compile the recursive action stack prover.
Returns
Promise
<{
verificationKey
: {
data
: string
;
hash
: Field
;
};
}>
Inherited from
BatchReducer_.BatchReducer.compile
contract()
contract(): BatchReducerContract
Defined in: lib/mina/v1/actions/batch-reducer.ts:174
Returns
BatchReducerContract
Inherited from
BatchReducer_.BatchReducer.contract
contractClass()
contractClass(): BatchReducerContractClass
Defined in: lib/mina/v1/actions/batch-reducer.ts:167
Returns
BatchReducerContractClass
Inherited from
BatchReducer_.BatchReducer.contractClass
dispatch()
dispatch(action: From<ActionType>): void
Defined in: lib/mina/v1/actions/batch-reducer.ts:202
Submit an action.
Parameters
action
From
<ActionType
>
Returns
void
Inherited from
BatchReducer_.BatchReducer.dispatch
dispatchIf()
dispatchIf(condition: Bool, action: From<ActionType>): void
Defined in: lib/mina/v1/actions/batch-reducer.ts:212
Conditionally submit an action.
Parameters
condition
action
From
<ActionType
>
Returns
void
Inherited from
BatchReducer_.BatchReducer.dispatchIf
prepareBatches()
prepareBatches(): Promise<{
batch: ActionBatch<Action>;
proof: ActionStackProof;
}[]>
Defined in: lib/mina/v1/actions/batch-reducer.ts:374
Create a proof which returns the next actions batch(es) to process and helps guarantee their correctness.
Returns
Promise
<{
batch
: ActionBatch
<Action
>;
proof
: ActionStackProof
;
}[]>
Inherited from
BatchReducer_.BatchReducer.prepareBatches
processBatch()
processBatch(__namedParameters: {
batch: ActionBatch<Action>;
proof: Proof<Field, ActionStackState>;
}, callback: (action: Action, isDummy: Bool, i: number) => void): void
Defined in: lib/mina/v1/actions/batch-reducer.ts:242
Process a batch of actions which was created by prepareBatches()
.
Important: The callback exposes the action's value along with an isDummy
flag.
This is necessary because we process a dynamically-sized list in a fixed number of steps.
Dummies will be passed to your callback once the actual actions are exhausted.
Make sure to write your code to account for dummies. For example, when sending MINA from your contract for every action,
you probably want to zero out the balance decrease in the isDummy
case:
processBatch({ batch, proof }, (action, isDummy) => {
// ... other logic ...
let amountToSend = Provable.if(isDummy, UInt64.zero, action.amount);
this.balance.subInPlace(amountToSend);
});
Warning: Don't call processBatch()
on two different batches within the same method. The second call
would override the preconditions set by the first call, which would leave the method insecure.
To process more actions per method call, increase the batchSize
.
Parameters
__namedParameters
batch
ActionBatch
<Action
>
proof
Proof
<Field
, ActionStackState
>
callback
(action
: Action
, isDummy
: Bool
, i
: number
) => void
Returns
void
Inherited from
BatchReducer_.BatchReducer.processBatch
setContractClass()
setContractClass(contractClass: BatchReducerContractClass): void
Defined in: lib/mina/v1/actions/batch-reducer.ts:195
Set the smart contract class this reducer is connected with.
Note: You can use either this method or setContractInstance()
before calling compile()
.
However, setContractInstance()
is required for proveNextBatch()
.
Parameters
contractClass
BatchReducerContractClass
Returns
void
Inherited from
BatchReducer_.BatchReducer.setContractClass
setContractInstance()
setContractInstance(contract: BatchReducerContract): void
Defined in: lib/mina/v1/actions/batch-reducer.ts:184
Set the smart contract instance this reducer is connected with.
Note: This is a required step before using dispatch()
, proveNextBatch()
or processNextBatch()
.
Parameters
contract
BatchReducerContract
Returns
void
Inherited from
BatchReducer_.BatchReducer.setContractInstance