@proto-kit/protocol 0.1.1-develop.600 → 0.1.1-develop.833
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE.md +201 -201
- package/dist/blockmodules/AccountStateModule.d.ts +37 -37
- package/dist/blockmodules/AccountStateModule.js +43 -43
- package/dist/blockmodules/BlockHeightHook.d.ts +6 -6
- package/dist/blockmodules/BlockHeightHook.js +15 -15
- package/dist/blockmodules/LastStateRootBlockHook.d.ts +7 -7
- package/dist/blockmodules/LastStateRootBlockHook.js +15 -15
- package/dist/blockmodules/NoopBlockHook.d.ts +8 -8
- package/dist/blockmodules/NoopBlockHook.js +9 -9
- package/dist/blockmodules/NoopSettlementHook.d.ts +5 -5
- package/dist/blockmodules/NoopSettlementHook.d.ts.map +1 -1
- package/dist/blockmodules/NoopSettlementHook.js +18 -18
- package/dist/blockmodules/NoopTransactionHook.d.ts +5 -5
- package/dist/blockmodules/NoopTransactionHook.js +4 -4
- package/dist/hooks/AccountStateHook.d.ts +19 -5
- package/dist/hooks/AccountStateHook.d.ts.map +1 -1
- package/dist/hooks/AccountStateHook.js +15 -9
- package/dist/hooks/BlockHeightHook.d.ts +3 -3
- package/dist/hooks/BlockHeightHook.d.ts.map +1 -1
- package/dist/hooks/BlockHeightHook.js +5 -4
- package/dist/hooks/LastStateRootBlockHook.d.ts +8 -0
- package/dist/hooks/LastStateRootBlockHook.d.ts.map +1 -0
- package/dist/hooks/LastStateRootBlockHook.js +15 -0
- package/dist/hooks/NoopBlockHook.d.ts +6 -4
- package/dist/hooks/NoopBlockHook.d.ts.map +1 -1
- package/dist/hooks/NoopBlockHook.js +4 -4
- package/dist/hooks/NoopSettlementHook.d.ts +6 -0
- package/dist/hooks/NoopSettlementHook.d.ts.map +1 -0
- package/dist/hooks/NoopSettlementHook.js +17 -0
- package/dist/hooks/NoopTransactionHook.d.ts +1 -1
- package/dist/hooks/NoopTransactionHook.d.ts.map +1 -1
- package/dist/hooks/NoopTransactionHook.js +4 -1
- package/dist/index.d.ts +18 -8
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +18 -8
- package/dist/model/MethodPublicOutput.d.ts +68 -34
- package/dist/model/MethodPublicOutput.d.ts.map +1 -1
- package/dist/model/Option.d.ts +39 -19
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +6 -0
- package/dist/model/Path.d.ts +1 -1
- package/dist/model/Path.d.ts.map +1 -1
- package/dist/model/Path.js +0 -2
- package/dist/model/RuntimeLike.d.ts +11 -0
- package/dist/model/RuntimeLike.d.ts.map +1 -0
- package/dist/model/RuntimeLike.js +1 -0
- package/dist/model/StateTransition.d.ts +51 -14
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransition.js +3 -0
- package/dist/model/StateTransitionProvableBatch.d.ts +71 -14
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -1
- package/dist/model/StateTransitionReduction.d.ts +3 -0
- package/dist/model/StateTransitionReduction.d.ts.map +1 -0
- package/dist/model/StateTransitionReduction.js +26 -0
- package/dist/model/network/NetworkState.d.ts +73 -18
- package/dist/model/network/NetworkState.d.ts.map +1 -1
- package/dist/model/network/NetworkState.js +2 -2
- package/dist/model/transaction/ProtocolTransaction.d.ts +69 -69
- package/dist/model/transaction/ProtocolTransaction.js +18 -18
- package/dist/model/transaction/RuntimeTransaction.d.ts +50 -16
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -1
- package/dist/model/transaction/RuntimeTransaction.js +4 -4
- package/dist/model/transaction/SignedTransaction.d.ts +39 -3
- package/dist/model/transaction/SignedTransaction.d.ts.map +1 -1
- package/dist/model/transaction/SignedTransaction.js +1 -1
- package/dist/model/transaction/ValueOption.d.ts +86 -32
- package/dist/model/transaction/ValueOption.d.ts.map +1 -1
- package/dist/model/transaction/ValueOption.js +1 -1
- package/dist/protocol/Protocol.d.ts +14 -20
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/Protocol.js +13 -27
- package/dist/protocol/ProtocolEnvironment.d.ts +3 -3
- package/dist/protocol/ProtocolEnvironment.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.d.ts +1 -0
- package/dist/protocol/ProtocolModule.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.js +4 -2
- package/dist/protocol/ProvableBlockHook.d.ts +2 -2
- package/dist/protocol/ProvableBlockHook.d.ts.map +1 -1
- package/dist/protocol/ProvableTransactionHook.d.ts +1 -1
- package/dist/protocol/ProvableTransactionHook.d.ts.map +1 -1
- package/dist/prover/block/BlockProvable.d.ts +240 -98
- package/dist/prover/block/BlockProvable.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.d.ts +8 -8
- package/dist/prover/block/BlockProver.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.js +55 -45
- package/dist/prover/block/BlockTransactionPosition.d.ts +35 -35
- package/dist/prover/block/BlockTransactionPosition.js +25 -25
- package/dist/prover/block/BundleTransactionPosition.d.ts +36 -0
- package/dist/prover/block/BundleTransactionPosition.d.ts.map +1 -0
- package/dist/prover/block/BundleTransactionPosition.js +25 -0
- package/dist/prover/block/SplitPrefilledStateService.d.ts +11 -0
- package/dist/prover/block/SplitPrefilledStateService.d.ts.map +1 -0
- package/dist/prover/block/SplitPrefilledStateService.js +1 -0
- package/dist/prover/block/SplitStateService.d.ts +11 -0
- package/dist/prover/block/SplitStateService.d.ts.map +1 -0
- package/dist/prover/block/SplitStateService.js +1 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.d.ts +35 -16
- package/dist/prover/block/accummulators/BlockHashMerkleTree.d.ts.map +1 -1
- package/dist/prover/block/accummulators/BlockHashMerkleTree.js +1 -1
- package/dist/prover/block/acummulators/BlockHashMerkleTree.d.ts +45 -0
- package/dist/prover/block/acummulators/BlockHashMerkleTree.d.ts.map +1 -0
- package/dist/prover/block/acummulators/BlockHashMerkleTree.js +16 -0
- package/dist/prover/statetransition/StateTransitionProvable.d.ts +116 -58
- package/dist/prover/statetransition/StateTransitionProvable.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.d.ts +10 -9
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +18 -22
- package/dist/prover/statetransition/StateTransitionWitnessProvider.js +1 -2
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.js +1 -2
- package/dist/settlement/ContractModule.d.ts +15 -0
- package/dist/settlement/ContractModule.d.ts.map +1 -0
- package/dist/settlement/ContractModule.js +11 -0
- package/dist/settlement/DispatchContract.d.ts +20 -0
- package/dist/settlement/DispatchContract.d.ts.map +1 -0
- package/dist/settlement/DispatchContract.js +112 -0
- package/dist/settlement/OutgoingMessageArgument.d.ts +109 -0
- package/dist/settlement/OutgoingMessageArgument.d.ts.map +1 -0
- package/dist/settlement/OutgoingMessageArgument.js +32 -0
- package/dist/settlement/ProvableSettlementHook.d.ts +25 -25
- package/dist/settlement/ProvableSettlementHook.js +3 -3
- package/dist/settlement/SettlementContract.d.ts +229 -229
- package/dist/settlement/SettlementContract.js +346 -346
- package/dist/settlement/SettlementContractModule.d.ts +40 -0
- package/dist/settlement/SettlementContractModule.d.ts.map +1 -0
- package/dist/settlement/SettlementContractModule.js +71 -0
- package/dist/settlement/contracts/DispatchContract.d.ts +21 -0
- package/dist/settlement/contracts/DispatchContract.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchContract.js +111 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts +12 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts.map +1 -0
- package/dist/{hooks/TransactionFeeHook.js → settlement/contracts/DispatchContractProtocolModule.js} +17 -21
- package/dist/settlement/contracts/DispatchSmartContract.d.ts +22 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchSmartContract.js +110 -0
- package/dist/settlement/contracts/SettlementContract.d.ts +19 -0
- package/dist/settlement/contracts/SettlementContract.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementContract.js +43 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.d.ts +19 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.js +44 -0
- package/dist/settlement/contracts/SettlementSmartContract.d.ts +42 -0
- package/dist/settlement/contracts/SettlementSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementSmartContract.js +246 -0
- package/dist/settlement/messages/Deposit.d.ts +64 -0
- package/dist/settlement/messages/Deposit.d.ts.map +1 -0
- package/dist/settlement/messages/Deposit.js +6 -0
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts +189 -0
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts.map +1 -0
- package/dist/settlement/messages/OutgoingMessageArgument.js +32 -0
- package/dist/settlement/messages/Withdrawal.d.ts +65 -0
- package/dist/settlement/messages/Withdrawal.d.ts.map +1 -0
- package/dist/settlement/messages/Withdrawal.js +13 -0
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts +24 -0
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts.map +1 -0
- package/dist/settlement/modularity/ProvableSettlementHook.js +3 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts +3 -3
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts.map +1 -1
- package/dist/settlement/modules/NetworkStateSettlementModule.js +4 -2
- package/dist/state/State.d.ts +4 -3
- package/dist/state/State.d.ts.map +1 -1
- package/dist/state/State.js +18 -12
- package/dist/state/StateMap.d.ts +3 -3
- package/dist/state/StateMap.d.ts.map +1 -1
- package/dist/state/StateMap.js +4 -5
- package/dist/state/StateService.d.ts +3 -3
- package/dist/state/StateService.d.ts.map +1 -1
- package/dist/state/StateServiceProvider.d.ts +3 -3
- package/dist/state/StateServiceProvider.d.ts.map +1 -1
- package/dist/state/StateServiceProvider.js +1 -3
- package/dist/state/assert/assert.d.ts +1 -1
- package/dist/state/assert/assert.d.ts.map +1 -1
- package/dist/state/assert/assert.js +11 -5
- package/dist/state/context/ProtocolMethodExecutionContext.d.ts +1 -1
- package/dist/state/context/ProtocolMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/ProtocolMethodExecutionContext.js +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts +55 -4
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.js +6 -6
- package/dist/state/context/TransitionMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/TransitionMethodExecutionContext.js +0 -1
- package/dist/state/context/contextExecution.d.ts +14 -0
- package/dist/state/context/contextExecution.d.ts.map +1 -0
- package/dist/state/context/contextExecution.js +30 -0
- package/dist/state/protocol/ProtocolState.d.ts.map +1 -1
- package/dist/state/protocol/ProtocolState.js +0 -3
- package/dist/utils/AppliedBatchHashList.d.ts +17 -0
- package/dist/utils/AppliedBatchHashList.d.ts.map +1 -0
- package/dist/utils/AppliedBatchHashList.js +24 -0
- package/dist/utils/MinaPrefixedProvableHashList.d.ts +2 -2
- package/dist/utils/MinaPrefixedProvableHashList.d.ts.map +1 -1
- package/dist/utils/MinaPrefixedProvableHashList.js +1 -0
- package/dist/utils/PrefixedProvableHashList.d.ts +2 -2
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableHashList.d.ts +4 -4
- package/dist/utils/ProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableReductionHashList.d.ts +14 -0
- package/dist/utils/ProvableReductionHashList.d.ts.map +1 -0
- package/dist/utils/ProvableReductionHashList.js +50 -0
- package/dist/utils/StateTransitionReductionList.d.ts +11 -0
- package/dist/utils/StateTransitionReductionList.d.ts.map +1 -0
- package/dist/utils/StateTransitionReductionList.js +60 -0
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts +11 -0
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts.map +1 -0
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.js +12 -0
- package/dist/utils/merkletree/MerkleTreeStore.d.ts +5 -0
- package/dist/utils/merkletree/MerkleTreeStore.d.ts.map +1 -0
- package/dist/utils/merkletree/MerkleTreeStore.js +1 -0
- package/dist/utils/merkletree/RollupMerkleTree.d.ts +133 -0
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +1 -0
- package/dist/utils/merkletree/RollupMerkleTree.js +255 -0
- package/dist/utils/utils.d.ts +1 -1
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +5 -10
- package/package.json +5 -5
- package/src/{blockmodules/AccountStateModule.ts → hooks/AccountStateHook.ts} +13 -9
- package/src/{blockmodules → hooks}/BlockHeightHook.ts +3 -4
- package/src/{blockmodules → hooks}/LastStateRootBlockHook.ts +4 -4
- package/src/{blockmodules → hooks}/NoopBlockHook.ts +6 -5
- package/src/{blockmodules → hooks}/NoopSettlementHook.ts +3 -4
- package/src/{blockmodules → hooks}/NoopTransactionHook.ts +5 -1
- package/src/index.ts +18 -8
- package/src/model/MethodPublicOutput.ts +2 -2
- package/src/model/Option.ts +21 -1
- package/src/model/Path.ts +1 -3
- package/src/model/RuntimeLike.ts +12 -0
- package/src/model/StateTransition.ts +9 -1
- package/src/model/Transaction.ts +2 -0
- package/src/model/network/NetworkState.ts +2 -2
- package/src/model/transaction/RuntimeTransaction.ts +5 -12
- package/src/model/transaction/SignedTransaction.ts +1 -8
- package/src/model/transaction/ValueOption.ts +1 -1
- package/src/protocol/Protocol.ts +34 -48
- package/src/protocol/ProtocolEnvironment.ts +7 -6
- package/src/protocol/ProtocolModule.ts +8 -4
- package/src/protocol/ProvableBlockHook.ts +3 -3
- package/src/protocol/ProvableTransactionHook.ts +4 -2
- package/src/protocol/TransitioningProtocolModule.ts +1 -1
- package/src/prover/block/BlockProvable.ts +3 -3
- package/src/prover/block/BlockProver.ts +98 -63
- package/src/prover/block/accummulators/BlockHashMerkleTree.ts +2 -2
- package/src/prover/statetransition/StateTransitionProvable.ts +3 -3
- package/src/prover/statetransition/StateTransitionProver.ts +26 -28
- package/src/settlement/ContractModule.ts +24 -0
- package/src/settlement/SettlementContractModule.ts +132 -0
- package/src/settlement/contracts/DispatchContractProtocolModule.ts +39 -0
- package/src/settlement/contracts/DispatchSmartContract.ts +136 -0
- package/src/settlement/contracts/SettlementContractProtocolModule.ts +67 -0
- package/src/settlement/contracts/SettlementSmartContract.ts +350 -0
- package/src/settlement/messages/Deposit.ts +6 -0
- package/src/settlement/messages/OutgoingMessageArgument.ts +42 -0
- package/src/settlement/messages/Withdrawal.ts +14 -0
- package/src/settlement/{ProvableSettlementHook.ts → modularity/ProvableSettlementHook.ts} +9 -13
- package/src/settlement/modules/NetworkStateSettlementModule.ts +8 -5
- package/src/state/State.ts +21 -13
- package/src/state/StateMap.ts +4 -5
- package/src/state/StateService.ts +3 -3
- package/src/state/StateServiceProvider.ts +6 -7
- package/src/state/assert/assert.ts +13 -7
- package/src/state/context/RuntimeMethodExecutionContext.ts +13 -7
- package/src/state/context/TransitionMethodExecutionContext.ts +0 -1
- package/src/state/protocol/ProtocolState.ts +1 -4
- package/src/utils/MinaPrefixedProvableHashList.ts +4 -3
- package/src/utils/PrefixedProvableHashList.ts +2 -2
- package/src/utils/ProvableHashList.ts +2 -2
- package/src/utils/ProvableReductionHashList.ts +68 -0
- package/src/utils/StateTransitionReductionList.ts +89 -0
- package/src/utils/utils.ts +4 -9
- package/test/BlockProver.test.ts +110 -128
- package/test/Protocol.test.ts +14 -21
- package/test/State.test.ts +8 -8
- package/test/StateTransition.test.ts +56 -66
- package/test/TestingProtocol.ts +48 -0
- package/test/model/Option.test.ts +72 -0
- package/{src → test}/state/assert/assert.test.ts +4 -4
- package/test/tsconfig.json +7 -0
- package/test/utils/ProvableReductionHashList.test.ts +117 -0
- package/test/utils.test.ts +0 -3
- package/dist/hooks/TransactionFeeHook.d.ts +0 -16
- package/dist/hooks/TransactionFeeHook.d.ts.map +0 -1
- package/src/blockmodules/SequenceStateTransactionModule.ts +0 -25
- package/src/model/Option.test.ts +0 -21
- package/src/settlement/SettlementContract.ts +0 -444
- package/src/state/context/ProtocolMethodExecutionContext.ts +0 -36
- package/test/Option.test.ts +0 -64
- package/tsconfig.test.json +0 -9
|
@@ -10,8 +10,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
10
10
|
var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
|
-
|
|
14
|
-
import { Bool, Experimental, Field, Poseidon, Provable, SelfProof } from "o1js";
|
|
13
|
+
import { Bool, Field, Poseidon, Provable, SelfProof, ZkProgram, } from "o1js";
|
|
15
14
|
import { container, inject, injectable, injectAll } from "tsyringe";
|
|
16
15
|
import { provableMethod, ZkProgrammable, } from "@proto-kit/common";
|
|
17
16
|
import { DefaultProvableHashList } from "../../utils/ProvableHashList";
|
|
@@ -21,7 +20,8 @@ import { ProvableStateTransition, } from "../../model/StateTransition";
|
|
|
21
20
|
import { RuntimeMethodExecutionContext } from "../../state/context/RuntimeMethodExecutionContext";
|
|
22
21
|
import { NetworkState } from "../../model/network/NetworkState";
|
|
23
22
|
import { SignedTransaction } from "../../model/transaction/SignedTransaction";
|
|
24
|
-
import { MinaActions, MinaActionsHashList } from "../../utils/MinaPrefixedProvableHashList";
|
|
23
|
+
import { MinaActions, MinaActionsHashList, } from "../../utils/MinaPrefixedProvableHashList";
|
|
24
|
+
import { StateTransitionReductionList } from "../../utils/StateTransitionReductionList";
|
|
25
25
|
import { BlockProverExecutionData, BlockProverPublicInput, BlockProverPublicOutput, } from "./BlockProvable";
|
|
26
26
|
import { BlockHashMerkleTreeWitness, BlockHashTreeEntry, } from "./accummulators/BlockHashMerkleTree";
|
|
27
27
|
const errors = {
|
|
@@ -37,9 +37,7 @@ function maxField() {
|
|
|
37
37
|
return Field(Field.ORDER - 1n);
|
|
38
38
|
}
|
|
39
39
|
export class BlockProverProgrammable extends ZkProgrammable {
|
|
40
|
-
constructor(
|
|
41
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
42
|
-
prover, stateTransitionProver, runtime, transactionHooks, blockHooks) {
|
|
40
|
+
constructor(prover, stateTransitionProver, runtime, transactionHooks, blockHooks) {
|
|
43
41
|
super();
|
|
44
42
|
this.prover = prover;
|
|
45
43
|
this.stateTransitionProver = stateTransitionProver;
|
|
@@ -60,9 +58,9 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
60
58
|
* @param executionData
|
|
61
59
|
* @returns The new BlockProver-state to be used as public output
|
|
62
60
|
*/
|
|
63
|
-
applyTransaction(state, stateTransitionProof, runtimeProof, executionData) {
|
|
61
|
+
async applyTransaction(state, stateTransitionProof, runtimeProof, executionData) {
|
|
64
62
|
const { transaction, networkState, signature } = executionData;
|
|
65
|
-
const isMessage = runtimeProof.publicOutput
|
|
63
|
+
const { isMessage } = runtimeProof.publicOutput;
|
|
66
64
|
runtimeProof.verify();
|
|
67
65
|
stateTransitionProof.verify();
|
|
68
66
|
const stateTo = { ...state };
|
|
@@ -74,7 +72,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
74
72
|
state.stateRoot.assertEquals(stateTransitionProof.publicInput.stateRoot, errors.propertyNotMatching("from state root"));
|
|
75
73
|
state.stateRoot.assertEquals(stateTransitionProof.publicInput.protocolStateRoot, errors.propertyNotMatching("from protocol state root"));
|
|
76
74
|
// Apply protocol state transitions
|
|
77
|
-
this.assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof);
|
|
75
|
+
await this.assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof);
|
|
78
76
|
// Apply state if status success
|
|
79
77
|
stateTo.stateRoot = Provable.if(runtimeProof.publicOutput.status, stateTransitionProof.publicOutput.stateRoot, stateTransitionProof.publicOutput.protocolStateRoot);
|
|
80
78
|
// Check transaction integrity against appProof
|
|
@@ -95,9 +93,9 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
95
93
|
state.networkStateHash.assertEquals(networkState.hash(), "Network state provided to BlockProver does not match the publicInput");
|
|
96
94
|
return stateTo;
|
|
97
95
|
}
|
|
98
|
-
// eslint-disable-next-line
|
|
96
|
+
// eslint-disable-next-line max-len
|
|
99
97
|
// TODO How does this interact with the RuntimeMethodExecutionContext when executing runtimemethods?
|
|
100
|
-
assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof) {
|
|
98
|
+
async assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof) {
|
|
101
99
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
102
100
|
executionContext.clear();
|
|
103
101
|
// Setup context for potential calls to runtime methods.
|
|
@@ -109,24 +107,26 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
109
107
|
networkState: executionData.networkState,
|
|
110
108
|
});
|
|
111
109
|
executionContext.beforeMethod("", "", []);
|
|
112
|
-
this.transactionHooks
|
|
113
|
-
|
|
114
|
-
|
|
110
|
+
for (const module of this.transactionHooks) {
|
|
111
|
+
// eslint-disable-next-line no-await-in-loop
|
|
112
|
+
await module.onTransaction(executionData);
|
|
113
|
+
}
|
|
115
114
|
executionContext.afterMethod();
|
|
116
115
|
const { stateTransitions, status, statusMessage } = executionContext.current().result;
|
|
117
116
|
status.assertTrue(statusMessage);
|
|
118
117
|
const transitions = stateTransitions.map((transition) => transition.toProvable());
|
|
119
|
-
const hashList = new
|
|
118
|
+
const hashList = new StateTransitionReductionList(ProvableStateTransition, stateTransitionProof.publicInput.protocolTransitionsHash);
|
|
120
119
|
transitions.forEach((transition) => {
|
|
121
120
|
hashList.push(transition);
|
|
122
121
|
});
|
|
123
122
|
stateTransitionProof.publicOutput.protocolTransitionsHash.assertEquals(hashList.commitment, "ProtocolTransitionsHash not matching the generated protocol transitions");
|
|
124
123
|
}
|
|
125
|
-
executeBlockHooks(state, inputNetworkState, type) {
|
|
124
|
+
async executeBlockHooks(state, inputNetworkState, type) {
|
|
126
125
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
127
126
|
executionContext.clear();
|
|
128
127
|
executionContext.beforeMethod("", "", []);
|
|
129
|
-
const resultingNetworkState = this.blockHooks.reduce((
|
|
128
|
+
const resultingNetworkState = await this.blockHooks.reduce(async (networkStatePromise, blockHook) => {
|
|
129
|
+
const networkState = await networkStatePromise;
|
|
130
130
|
// Setup context for potential calls to runtime methods.
|
|
131
131
|
// With the special case that we set the new networkstate for every hook
|
|
132
132
|
// We also have to put in a dummy transaction for network.transaction
|
|
@@ -135,15 +135,13 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
135
135
|
networkState,
|
|
136
136
|
});
|
|
137
137
|
if (type === "beforeBlock") {
|
|
138
|
-
return blockHook.beforeBlock(networkState, state);
|
|
139
|
-
}
|
|
140
|
-
else if (type === "afterBlock") {
|
|
141
|
-
return blockHook.afterBlock(networkState, state);
|
|
138
|
+
return await blockHook.beforeBlock(networkState, state);
|
|
142
139
|
}
|
|
143
|
-
|
|
144
|
-
|
|
140
|
+
if (type === "afterBlock") {
|
|
141
|
+
return await blockHook.afterBlock(networkState, state);
|
|
145
142
|
}
|
|
146
|
-
|
|
143
|
+
throw new Error("Unreachable");
|
|
144
|
+
}, Promise.resolve(inputNetworkState));
|
|
147
145
|
executionContext.afterMethod();
|
|
148
146
|
const { stateTransitions, status, statusMessage } = executionContext.current().result;
|
|
149
147
|
status.assertTrue(`Block hook call failed: ${statusMessage ?? "-"}`);
|
|
@@ -162,7 +160,6 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
162
160
|
transactionList.pushIf(transactionHash, isMessage.not());
|
|
163
161
|
stateTo.transactionsHash = transactionList.commitment;
|
|
164
162
|
// Append tx to eternal transaction list
|
|
165
|
-
// eslint-disable-next-line no-warning-comments
|
|
166
163
|
// TODO Change that to the a sequence-state compatible transaction struct
|
|
167
164
|
const eternalTransactionList = new DefaultProvableHashList(Field, state.eternalTransactionsHash);
|
|
168
165
|
eternalTransactionList.pushIf(transactionHash, isMessage.not());
|
|
@@ -174,13 +171,13 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
174
171
|
stateTo.incomingMessagesHash = incomingMessagesList.commitment;
|
|
175
172
|
return stateTo;
|
|
176
173
|
}
|
|
177
|
-
proveTransaction(publicInput, stateProof, runtimeProof, executionData) {
|
|
174
|
+
async proveTransaction(publicInput, stateProof, runtimeProof, executionData) {
|
|
178
175
|
const state = {
|
|
179
176
|
...publicInput,
|
|
180
177
|
};
|
|
181
178
|
state.networkStateHash.assertEquals(executionData.networkState.hash(), "ExecutionData Networkstate doesn't equal public input hash");
|
|
182
179
|
const bundleInclusionState = this.addTransactionToBundle(state, runtimeProof.publicOutput.isMessage, executionData.transaction);
|
|
183
|
-
const stateTo = this.applyTransaction(bundleInclusionState, stateProof, runtimeProof, executionData);
|
|
180
|
+
const stateTo = await this.applyTransaction(bundleInclusionState, stateProof, runtimeProof, executionData);
|
|
184
181
|
return new BlockProverPublicOutput({
|
|
185
182
|
...stateTo,
|
|
186
183
|
blockNumber: maxField(),
|
|
@@ -193,7 +190,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
193
190
|
// Assert from state roots
|
|
194
191
|
stateRoot.assertEquals(stateTransitionProof.publicInput.stateRoot, errors.propertyNotMatching("from state root"));
|
|
195
192
|
}
|
|
196
|
-
proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, transactionProof) {
|
|
193
|
+
async proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, transactionProof) {
|
|
197
194
|
const state = {
|
|
198
195
|
...publicInput,
|
|
199
196
|
};
|
|
@@ -220,8 +217,8 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
220
217
|
const verifyTransactionProof = txProofOutput.equals(transactionProof.publicInput, txProofOutput.closed, txProofOutput.blockNumber);
|
|
221
218
|
transactionProof.verifyIf(verifyTransactionProof);
|
|
222
219
|
// 2. Execute beforeBlock hooks
|
|
223
|
-
const beforeBlockResult = this.executeBlockHooks(state, networkState, "beforeBlock");
|
|
224
|
-
const beforeBlockHashList = new
|
|
220
|
+
const beforeBlockResult = await this.executeBlockHooks(state, networkState, "beforeBlock");
|
|
221
|
+
const beforeBlockHashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
225
222
|
beforeBlockResult.stateTransitions.forEach((st) => {
|
|
226
223
|
beforeBlockHashList.push(st.toProvable());
|
|
227
224
|
});
|
|
@@ -245,15 +242,15 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
245
242
|
transactionProof.publicOutput.incomingMessagesHash;
|
|
246
243
|
// 5. Execute afterBlock hooks
|
|
247
244
|
this.assertSTProofInput(stateTransitionProof, state.stateRoot);
|
|
248
|
-
const afterBlockResult = this.executeBlockHooks(state, beforeBlockResult.networkState, "afterBlock");
|
|
249
|
-
const afterBlockHashList = new
|
|
245
|
+
const afterBlockResult = await this.executeBlockHooks(state, beforeBlockResult.networkState, "afterBlock");
|
|
246
|
+
const afterBlockHashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
250
247
|
afterBlockResult.stateTransitions.forEach((st) => {
|
|
251
248
|
afterBlockHashList.push(st.toProvable());
|
|
252
249
|
});
|
|
253
250
|
state.networkStateHash = afterBlockResult.networkState.hash();
|
|
254
251
|
// We are reusing runtime STs here as afterBlock STs
|
|
255
252
|
stateTransitionProof.publicInput.stateTransitionsHash.assertEquals(afterBlockHashList.commitment, "STProof from-ST-hash not matching generated ST-hash from afterBlock hooks");
|
|
256
|
-
state.stateRoot = stateTransitionProof.
|
|
253
|
+
state.stateRoot = Provable.if(stsEmitted, stateTransitionProof.publicOutput.stateRoot, state.stateRoot);
|
|
257
254
|
// 6. Close block
|
|
258
255
|
// Calculate the new block index
|
|
259
256
|
const blockIndex = blockWitness.calculateIndex();
|
|
@@ -271,7 +268,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
271
268
|
closed: Bool(true),
|
|
272
269
|
});
|
|
273
270
|
}
|
|
274
|
-
merge(publicInput, proof1, proof2) {
|
|
271
|
+
async merge(publicInput, proof1, proof2) {
|
|
275
272
|
proof1.verify();
|
|
276
273
|
proof2.verify();
|
|
277
274
|
// Check state
|
|
@@ -351,8 +348,10 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
351
348
|
const StateTransitionProofClass = stateTransitionProver.zkProgram.Proof;
|
|
352
349
|
const RuntimeProofClass = runtime.zkProgram.Proof;
|
|
353
350
|
const proveTransaction = prover.proveTransaction.bind(prover);
|
|
351
|
+
const proveBlock = prover.proveBlock.bind(prover);
|
|
354
352
|
const merge = prover.merge.bind(prover);
|
|
355
|
-
const program =
|
|
353
|
+
const program = ZkProgram({
|
|
354
|
+
name: "BlockProver",
|
|
356
355
|
publicInput: BlockProverPublicInput,
|
|
357
356
|
publicOutput: BlockProverPublicOutput,
|
|
358
357
|
methods: {
|
|
@@ -362,8 +361,19 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
362
361
|
RuntimeProofClass,
|
|
363
362
|
BlockProverExecutionData,
|
|
364
363
|
],
|
|
365
|
-
method(publicInput, stateProof, appProof, executionData) {
|
|
366
|
-
return proveTransaction(publicInput, stateProof, appProof, executionData);
|
|
364
|
+
async method(publicInput, stateProof, appProof, executionData) {
|
|
365
|
+
return await proveTransaction(publicInput, stateProof, appProof, executionData);
|
|
366
|
+
},
|
|
367
|
+
},
|
|
368
|
+
proveBlock: {
|
|
369
|
+
privateInputs: [
|
|
370
|
+
NetworkState,
|
|
371
|
+
BlockHashMerkleTreeWitness,
|
|
372
|
+
StateTransitionProofClass,
|
|
373
|
+
(SelfProof),
|
|
374
|
+
],
|
|
375
|
+
async method(publicInput, networkState, blockWitness, stateTransitionProof, transactionProof) {
|
|
376
|
+
return await proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, transactionProof);
|
|
367
377
|
},
|
|
368
378
|
},
|
|
369
379
|
merge: {
|
|
@@ -371,8 +381,8 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
371
381
|
(SelfProof),
|
|
372
382
|
(SelfProof),
|
|
373
383
|
],
|
|
374
|
-
method(publicInput, proof1, proof2) {
|
|
375
|
-
return merge(publicInput, proof1, proof2);
|
|
384
|
+
async method(publicInput, proof1, proof2) {
|
|
385
|
+
return await merge(publicInput, proof1, proof2);
|
|
376
386
|
},
|
|
377
387
|
},
|
|
378
388
|
},
|
|
@@ -381,10 +391,11 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
381
391
|
proveTransaction: program.proveTransaction,
|
|
382
392
|
merge: program.merge,
|
|
383
393
|
};
|
|
384
|
-
const SelfProofClass =
|
|
394
|
+
const SelfProofClass = ZkProgram.Proof(program);
|
|
385
395
|
return {
|
|
386
396
|
compile: program.compile.bind(program),
|
|
387
397
|
verify: program.verify.bind(program),
|
|
398
|
+
analyzeMethods: program.analyzeMethods.bind(program),
|
|
388
399
|
Proof: SelfProofClass,
|
|
389
400
|
methods,
|
|
390
401
|
};
|
|
@@ -394,7 +405,7 @@ __decorate([
|
|
|
394
405
|
provableMethod(),
|
|
395
406
|
__metadata("design:type", Function),
|
|
396
407
|
__metadata("design:paramtypes", [BlockProverPublicInput, Object, Object, BlockProverExecutionData]),
|
|
397
|
-
__metadata("design:returntype",
|
|
408
|
+
__metadata("design:returntype", Promise)
|
|
398
409
|
], BlockProverProgrammable.prototype, "proveTransaction", null);
|
|
399
410
|
__decorate([
|
|
400
411
|
provableMethod(),
|
|
@@ -402,20 +413,20 @@ __decorate([
|
|
|
402
413
|
__metadata("design:paramtypes", [BlockProverPublicInput,
|
|
403
414
|
NetworkState,
|
|
404
415
|
BlockHashMerkleTreeWitness, Object, Object]),
|
|
405
|
-
__metadata("design:returntype",
|
|
416
|
+
__metadata("design:returntype", Promise)
|
|
406
417
|
], BlockProverProgrammable.prototype, "proveBlock", null);
|
|
407
418
|
__decorate([
|
|
408
419
|
provableMethod(),
|
|
409
420
|
__metadata("design:type", Function),
|
|
410
421
|
__metadata("design:paramtypes", [BlockProverPublicInput, Object, Object]),
|
|
411
|
-
__metadata("design:returntype",
|
|
422
|
+
__metadata("design:returntype", Promise)
|
|
412
423
|
], BlockProverProgrammable.prototype, "merge", null);
|
|
413
424
|
/**
|
|
414
425
|
* BlockProver class, which aggregates a AppChainProof and
|
|
415
426
|
* a StateTransitionProof into a single BlockProof, that can
|
|
416
427
|
* then be merged to be committed to the base-layer contract
|
|
417
428
|
*/
|
|
418
|
-
let BlockProver = class BlockProver extends ProtocolModule {
|
|
429
|
+
export let BlockProver = class BlockProver extends ProtocolModule {
|
|
419
430
|
constructor(stateTransitionProver, runtime, transactionHooks, blockHooks) {
|
|
420
431
|
super();
|
|
421
432
|
this.stateTransitionProver = stateTransitionProver;
|
|
@@ -440,4 +451,3 @@ BlockProver = __decorate([
|
|
|
440
451
|
__param(3, injectAll("ProvableBlockHook")),
|
|
441
452
|
__metadata("design:paramtypes", [Object, Object, Array, Array])
|
|
442
453
|
], BlockProver);
|
|
443
|
-
export { BlockProver };
|
|
@@ -1,36 +1,36 @@
|
|
|
1
|
-
import { Bool } from "o1js";
|
|
2
|
-
export type BlockTransactionPositionType = "FIRST" | "LAST" | "MIDDLE";
|
|
3
|
-
declare const BlockTransactionPosition_base: (new (value: {
|
|
4
|
-
type: import("o1js/dist/node/lib/field").Field;
|
|
5
|
-
}) => {
|
|
6
|
-
type: import("o1js/dist/node/lib/field").Field;
|
|
7
|
-
}) & {
|
|
8
|
-
_isStruct: true;
|
|
9
|
-
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
10
|
-
type: import("o1js/dist/node/lib/field").Field;
|
|
11
|
-
}> & {
|
|
12
|
-
toInput: (x: {
|
|
13
|
-
type: import("o1js/dist/node/lib/field").Field;
|
|
14
|
-
}) => {
|
|
15
|
-
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
16
|
-
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
17
|
-
};
|
|
18
|
-
toJSON: (x: {
|
|
19
|
-
type: import("o1js/dist/node/lib/field").Field;
|
|
20
|
-
}) => {
|
|
21
|
-
type: string;
|
|
22
|
-
};
|
|
23
|
-
fromJSON: (x: {
|
|
24
|
-
type: string;
|
|
25
|
-
}) => {
|
|
26
|
-
type: import("o1js/dist/node/lib/field").Field;
|
|
27
|
-
};
|
|
28
|
-
};
|
|
29
|
-
export declare class BlockTransactionPosition extends BlockTransactionPosition_base {
|
|
30
|
-
private static readonly fieldMapping;
|
|
31
|
-
static fromPositionType(type: BlockTransactionPositionType): BlockTransactionPosition;
|
|
32
|
-
static positionTypeFromIndex(index: number, bundleLength: number): BlockTransactionPositionType;
|
|
33
|
-
equals(type: BlockTransactionPosition): Bool;
|
|
34
|
-
}
|
|
35
|
-
export {};
|
|
1
|
+
import { Bool } from "o1js";
|
|
2
|
+
export type BlockTransactionPositionType = "FIRST" | "LAST" | "MIDDLE";
|
|
3
|
+
declare const BlockTransactionPosition_base: (new (value: {
|
|
4
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
5
|
+
}) => {
|
|
6
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
7
|
+
}) & {
|
|
8
|
+
_isStruct: true;
|
|
9
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
10
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
11
|
+
}> & {
|
|
12
|
+
toInput: (x: {
|
|
13
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
14
|
+
}) => {
|
|
15
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
16
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
17
|
+
};
|
|
18
|
+
toJSON: (x: {
|
|
19
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
20
|
+
}) => {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
fromJSON: (x: {
|
|
24
|
+
type: string;
|
|
25
|
+
}) => {
|
|
26
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare class BlockTransactionPosition extends BlockTransactionPosition_base {
|
|
30
|
+
private static readonly fieldMapping;
|
|
31
|
+
static fromPositionType(type: BlockTransactionPositionType): BlockTransactionPosition;
|
|
32
|
+
static positionTypeFromIndex(index: number, bundleLength: number): BlockTransactionPositionType;
|
|
33
|
+
equals(type: BlockTransactionPosition): Bool;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
36
|
//# sourceMappingURL=BlockTransactionPosition.d.ts.map
|
|
@@ -1,25 +1,25 @@
|
|
|
1
|
-
import { Field, Struct } from "o1js";
|
|
2
|
-
import { match } from "ts-pattern";
|
|
3
|
-
export class BlockTransactionPosition extends Struct({
|
|
4
|
-
type: Field,
|
|
5
|
-
}) {
|
|
6
|
-
static fromPositionType(type) {
|
|
7
|
-
return new BlockTransactionPosition({
|
|
8
|
-
type: Field(BlockTransactionPosition.fieldMapping[type]).toConstant(),
|
|
9
|
-
});
|
|
10
|
-
}
|
|
11
|
-
static positionTypeFromIndex(index, bundleLength) {
|
|
12
|
-
return match(index)
|
|
13
|
-
.with(0, () => "FIRST")
|
|
14
|
-
.with(bundleLength - 1, () => "LAST")
|
|
15
|
-
.otherwise(() => "MIDDLE");
|
|
16
|
-
}
|
|
17
|
-
equals(type) {
|
|
18
|
-
return this.type.equals(type.type);
|
|
19
|
-
}
|
|
20
|
-
}
|
|
21
|
-
BlockTransactionPosition.fieldMapping = {
|
|
22
|
-
FIRST: 0,
|
|
23
|
-
MIDDLE: 1,
|
|
24
|
-
LAST: 2,
|
|
25
|
-
};
|
|
1
|
+
import { Field, Struct } from "o1js";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
export class BlockTransactionPosition extends Struct({
|
|
4
|
+
type: Field,
|
|
5
|
+
}) {
|
|
6
|
+
static fromPositionType(type) {
|
|
7
|
+
return new BlockTransactionPosition({
|
|
8
|
+
type: Field(BlockTransactionPosition.fieldMapping[type]).toConstant(),
|
|
9
|
+
});
|
|
10
|
+
}
|
|
11
|
+
static positionTypeFromIndex(index, bundleLength) {
|
|
12
|
+
return match(index)
|
|
13
|
+
.with(0, () => "FIRST")
|
|
14
|
+
.with(bundleLength - 1, () => "LAST")
|
|
15
|
+
.otherwise(() => "MIDDLE");
|
|
16
|
+
}
|
|
17
|
+
equals(type) {
|
|
18
|
+
return this.type.equals(type.type);
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
BlockTransactionPosition.fieldMapping = {
|
|
22
|
+
FIRST: 0,
|
|
23
|
+
MIDDLE: 1,
|
|
24
|
+
LAST: 2,
|
|
25
|
+
};
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { Bool } from "o1js";
|
|
2
|
+
export type BundleTransactionPositionType = "FIRST" | "LAST" | "MIDDLE";
|
|
3
|
+
declare const BundleTransactionPosition_base: (new (value: {
|
|
4
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
5
|
+
}) => {
|
|
6
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
7
|
+
}) & {
|
|
8
|
+
_isStruct: true;
|
|
9
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
10
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
11
|
+
}> & {
|
|
12
|
+
toInput: (x: {
|
|
13
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
14
|
+
}) => {
|
|
15
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
16
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
17
|
+
};
|
|
18
|
+
toJSON: (x: {
|
|
19
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
20
|
+
}) => {
|
|
21
|
+
type: string;
|
|
22
|
+
};
|
|
23
|
+
fromJSON: (x: {
|
|
24
|
+
type: string;
|
|
25
|
+
}) => {
|
|
26
|
+
type: import("o1js/dist/node/lib/field").Field;
|
|
27
|
+
};
|
|
28
|
+
};
|
|
29
|
+
export declare class BundleTransactionPosition extends BundleTransactionPosition_base {
|
|
30
|
+
private static fieldMapping;
|
|
31
|
+
equals(type: BundleTransactionPosition): Bool;
|
|
32
|
+
static fromPositionType(type: BundleTransactionPositionType): BundleTransactionPosition;
|
|
33
|
+
static positionTypeFromIndex(index: number, bundleLength: number): BundleTransactionPositionType;
|
|
34
|
+
}
|
|
35
|
+
export {};
|
|
36
|
+
//# sourceMappingURL=BundleTransactionPosition.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BundleTransactionPosition.d.ts","sourceRoot":"","sources":["../../../src/prover/block/BundleTransactionPosition.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAiB,MAAM,MAAM,CAAC;AAG3C,MAAM,MAAM,6BAA6B,GAAG,OAAO,GAAG,MAAM,GAAG,QAAQ,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;AAExE,qBAAa,yBAA0B,SAAQ,8BAE7C;IACA,OAAO,CAAC,MAAM,CAAC,YAAY,CAIzB;IAEK,MAAM,CAAC,IAAI,EAAE,yBAAyB,GAAG,IAAI;WAItC,gBAAgB,CAAC,IAAI,EAAE,6BAA6B;WAMpD,qBAAqB,CAAC,KAAK,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM;CAMxE"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
import { Field, Struct } from "o1js";
|
|
2
|
+
import { match } from "ts-pattern";
|
|
3
|
+
export class BundleTransactionPosition extends Struct({
|
|
4
|
+
type: Field,
|
|
5
|
+
}) {
|
|
6
|
+
equals(type) {
|
|
7
|
+
return this.type.equals(type.type);
|
|
8
|
+
}
|
|
9
|
+
static fromPositionType(type) {
|
|
10
|
+
return new BundleTransactionPosition({
|
|
11
|
+
type: Field(BundleTransactionPosition.fieldMapping[type]).toConstant(),
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
static positionTypeFromIndex(index, bundleLength) {
|
|
15
|
+
return match(index)
|
|
16
|
+
.with(0, () => "FIRST")
|
|
17
|
+
.with(bundleLength - 1, () => "LAST")
|
|
18
|
+
.otherwise(() => "MIDDLE");
|
|
19
|
+
}
|
|
20
|
+
}
|
|
21
|
+
BundleTransactionPosition.fieldMapping = {
|
|
22
|
+
FIRST: 0,
|
|
23
|
+
MIDDLE: 1,
|
|
24
|
+
LAST: 2,
|
|
25
|
+
};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateService } from "../../state/StateService";
|
|
2
|
+
/**
|
|
3
|
+
* This is an extension of the StateService, that allows the BlockProver
|
|
4
|
+
* to get state based on two different starting states. This is needed
|
|
5
|
+
* because the BlockProver executed before and after hooks on different roots
|
|
6
|
+
* and therefore needs the corresponding states, which change during execution
|
|
7
|
+
*/
|
|
8
|
+
export interface SplitPrefilledStateService extends StateService {
|
|
9
|
+
changeStateService: (index: number) => void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=SplitPrefilledStateService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitPrefilledStateService.d.ts","sourceRoot":"","sources":["../../../src/prover/block/SplitPrefilledStateService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,0BAA2B,SAAQ,YAAY;IAC9D,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import { StateService } from "../../state/StateService";
|
|
2
|
+
/**
|
|
3
|
+
* This is an extension of the StateService, that allows the BlockProver
|
|
4
|
+
* to get state based on two different starting states. This is needed
|
|
5
|
+
* because the BlockProver executed before and after hooks on different roots
|
|
6
|
+
* and therefore needs the corresponding states, which change during execution
|
|
7
|
+
*/
|
|
8
|
+
export interface SplitStateService extends StateService {
|
|
9
|
+
changeStateService: (index: number) => void;
|
|
10
|
+
}
|
|
11
|
+
//# sourceMappingURL=SplitStateService.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"SplitStateService.d.ts","sourceRoot":"","sources":["../../../src/prover/block/SplitStateService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAC;AAExD;;;;;GAKG;AACH,MAAM,WAAW,iBAAkB,SAAQ,YAAY;IACrD,kBAAkB,EAAE,CAAC,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;CAC7C"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export {};
|
|
@@ -5,27 +5,42 @@ export declare class BlockHashMerkleTree extends BlockHashMerkleTree_base {
|
|
|
5
5
|
export declare class BlockHashMerkleTreeWitness extends BlockHashMerkleTree.WITNESS {
|
|
6
6
|
}
|
|
7
7
|
declare const BlockHashTreeEntry_base: (new (value: {
|
|
8
|
-
blockHash: import("o1js/dist/node/lib/field").Field;
|
|
9
|
-
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
8
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
9
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
10
10
|
}) => {
|
|
11
|
-
blockHash: import("o1js/dist/node/lib/field").Field;
|
|
12
|
-
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
11
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
12
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
13
13
|
}) & {
|
|
14
14
|
_isStruct: true;
|
|
15
|
-
} & import("o1js/dist/node/
|
|
16
|
-
blockHash: import("o1js/dist/node/lib/field").Field;
|
|
17
|
-
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
18
|
-
}
|
|
15
|
+
} & Omit<import("o1js/dist/node/lib/provable/types/provable-intf").Provable<{
|
|
16
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
17
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
18
|
+
}, {
|
|
19
|
+
blockHash: bigint;
|
|
20
|
+
closed: boolean;
|
|
21
|
+
}>, "fromFields"> & {
|
|
22
|
+
fromFields: (fields: import("o1js/dist/node/lib/provable/field").Field[]) => {
|
|
23
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
24
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
25
|
+
};
|
|
26
|
+
} & {
|
|
27
|
+
fromValue: (value: {
|
|
28
|
+
blockHash: string | number | bigint | import("o1js/dist/node/lib/provable/field").Field;
|
|
29
|
+
closed: boolean | import("o1js/dist/node/lib/provable/bool").Bool;
|
|
30
|
+
}) => {
|
|
31
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
32
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
33
|
+
};
|
|
19
34
|
toInput: (x: {
|
|
20
|
-
blockHash: import("o1js/dist/node/lib/field").Field;
|
|
21
|
-
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
35
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
36
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
22
37
|
}) => {
|
|
23
|
-
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
24
|
-
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
38
|
+
fields?: import("o1js/dist/node/lib/provable/field").Field[] | undefined;
|
|
39
|
+
packed?: [import("o1js/dist/node/lib/provable/field").Field, number][] | undefined;
|
|
25
40
|
};
|
|
26
41
|
toJSON: (x: {
|
|
27
|
-
blockHash: import("o1js/dist/node/lib/field").Field;
|
|
28
|
-
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
42
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
43
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
29
44
|
}) => {
|
|
30
45
|
blockHash: string;
|
|
31
46
|
closed: boolean;
|
|
@@ -34,8 +49,12 @@ declare const BlockHashTreeEntry_base: (new (value: {
|
|
|
34
49
|
blockHash: string;
|
|
35
50
|
closed: boolean;
|
|
36
51
|
}) => {
|
|
37
|
-
blockHash: import("o1js/dist/node/lib/field").Field;
|
|
38
|
-
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
52
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
53
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
54
|
+
};
|
|
55
|
+
empty: () => {
|
|
56
|
+
blockHash: import("o1js/dist/node/lib/provable/field").Field;
|
|
57
|
+
closed: import("o1js/dist/node/lib/provable/bool").Bool;
|
|
39
58
|
};
|
|
40
59
|
};
|
|
41
60
|
export declare class BlockHashTreeEntry extends BlockHashTreeEntry_base {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"BlockHashMerkleTree.d.ts","sourceRoot":"","sources":["../../../../src/prover/block/accummulators/BlockHashMerkleTree.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,
|
|
1
|
+
{"version":3,"file":"BlockHashMerkleTree.d.ts","sourceRoot":"","sources":["../../../../src/prover/block/accummulators/BlockHashMerkleTree.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,EAAoB,MAAM,MAAM,CAAC;;AAErD,qBAAa,mBAAoB,SAAQ,wBAAoB;CAAG;AAChE,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,OAAO;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9E,qBAAa,kBAAmB,SAAQ,uBAKtC;IACO,IAAI,IAAI,KAAK;CAGrB"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { createMerkleTree } from "@proto-kit/common";
|
|
2
2
|
import { Bool, Field, Poseidon, Struct } from "o1js";
|
|
3
|
-
export class BlockHashMerkleTree extends createMerkleTree(
|
|
3
|
+
export class BlockHashMerkleTree extends createMerkleTree(40) {
|
|
4
4
|
}
|
|
5
5
|
export class BlockHashMerkleTreeWitness extends BlockHashMerkleTree.WITNESS {
|
|
6
6
|
}
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
import { Field } from "o1js";
|
|
2
|
+
declare const BlockHashMerkleTree_base: import("@proto-kit/common").AbstractMerkleTreeClass;
|
|
3
|
+
export declare class BlockHashMerkleTree extends BlockHashMerkleTree_base {
|
|
4
|
+
}
|
|
5
|
+
export declare class BlockHashMerkleTreeWitness extends BlockHashMerkleTree.WITNESS {
|
|
6
|
+
}
|
|
7
|
+
declare const BlockHashTreeEntry_base: (new (value: {
|
|
8
|
+
transactionsHash: import("o1js/dist/node/lib/field").Field;
|
|
9
|
+
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
10
|
+
}) => {
|
|
11
|
+
transactionsHash: import("o1js/dist/node/lib/field").Field;
|
|
12
|
+
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
13
|
+
}) & {
|
|
14
|
+
_isStruct: true;
|
|
15
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
16
|
+
transactionsHash: import("o1js/dist/node/lib/field").Field;
|
|
17
|
+
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
18
|
+
}> & {
|
|
19
|
+
toInput: (x: {
|
|
20
|
+
transactionsHash: import("o1js/dist/node/lib/field").Field;
|
|
21
|
+
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
22
|
+
}) => {
|
|
23
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
24
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
25
|
+
};
|
|
26
|
+
toJSON: (x: {
|
|
27
|
+
transactionsHash: import("o1js/dist/node/lib/field").Field;
|
|
28
|
+
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
29
|
+
}) => {
|
|
30
|
+
transactionsHash: string;
|
|
31
|
+
closed: boolean;
|
|
32
|
+
};
|
|
33
|
+
fromJSON: (x: {
|
|
34
|
+
transactionsHash: string;
|
|
35
|
+
closed: boolean;
|
|
36
|
+
}) => {
|
|
37
|
+
transactionsHash: import("o1js/dist/node/lib/field").Field;
|
|
38
|
+
closed: import("o1js/dist/node/lib/bool").Bool;
|
|
39
|
+
};
|
|
40
|
+
};
|
|
41
|
+
export declare class BlockHashTreeEntry extends BlockHashTreeEntry_base {
|
|
42
|
+
hash(): Field;
|
|
43
|
+
}
|
|
44
|
+
export {};
|
|
45
|
+
//# sourceMappingURL=BlockHashMerkleTree.d.ts.map
|