@proto-kit/protocol 0.1.1-develop.651 → 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 +9 -10
- package/dist/hooks/BlockHeightHook.d.ts +2 -2
- package/dist/hooks/BlockHeightHook.d.ts.map +1 -1
- package/dist/hooks/BlockHeightHook.js +3 -3
- package/dist/hooks/LastStateRootBlockHook.d.ts +2 -2
- package/dist/hooks/LastStateRootBlockHook.d.ts.map +1 -1
- package/dist/hooks/LastStateRootBlockHook.js +2 -2
- package/dist/hooks/NoopBlockHook.d.ts +3 -3
- package/dist/hooks/NoopBlockHook.d.ts.map +1 -1
- package/dist/hooks/NoopBlockHook.js +2 -2
- package/dist/hooks/NoopSettlementHook.d.ts +1 -1
- package/dist/hooks/NoopSettlementHook.d.ts.map +1 -1
- package/dist/hooks/NoopSettlementHook.js +2 -3
- 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 +0 -2
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +0 -2
- package/dist/model/MethodPublicOutput.d.ts +68 -34
- package/dist/model/MethodPublicOutput.d.ts.map +1 -1
- package/dist/model/Option.d.ts +39 -20
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +1 -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/StateTransition.d.ts +48 -12
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransitionProvableBatch.d.ts +71 -14
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -1
- package/dist/model/StateTransitionReduction.d.ts +2 -2
- package/dist/model/StateTransitionReduction.js +26 -26
- 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 +6 -5
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/Protocol.js +12 -3
- 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 +3 -1
- 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 +48 -40
- 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/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 +8 -8
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +17 -22
- package/dist/prover/statetransition/StateTransitionWitnessProvider.js +1 -2
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.js +1 -2
- 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 +1 -0
- package/dist/settlement/SettlementContractModule.d.ts.map +1 -1
- package/dist/settlement/SettlementContractModule.js +7 -4
- 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.js +1 -2
- package/dist/settlement/contracts/DispatchSmartContract.d.ts +8 -8
- package/dist/settlement/contracts/DispatchSmartContract.d.ts.map +1 -1
- package/dist/settlement/contracts/DispatchSmartContract.js +14 -14
- 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.map +1 -1
- package/dist/settlement/contracts/SettlementContractProtocolModule.js +4 -4
- package/dist/settlement/contracts/SettlementSmartContract.d.ts +18 -17
- package/dist/settlement/contracts/SettlementSmartContract.d.ts.map +1 -1
- package/dist/settlement/contracts/SettlementSmartContract.js +46 -35
- package/dist/settlement/messages/Deposit.d.ts +29 -4
- package/dist/settlement/messages/Deposit.d.ts.map +1 -1
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts +94 -14
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts.map +1 -1
- package/dist/settlement/messages/Withdrawal.d.ts +29 -4
- package/dist/settlement/messages/Withdrawal.d.ts.map +1 -1
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts +2 -2
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts.map +1 -1
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts +1 -1
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts.map +1 -1
- package/dist/settlement/modules/NetworkStateSettlementModule.js +3 -1
- package/dist/state/State.d.ts +4 -3
- package/dist/state/State.d.ts.map +1 -1
- package/dist/state/State.js +16 -11
- 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 +4 -1
- 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 +54 -3
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.js +4 -5
- 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.map +1 -1
- package/dist/utils/MinaPrefixedProvableHashList.js +1 -0
- package/dist/utils/ProvableHashList.d.ts +1 -1
- package/dist/utils/StateTransitionReductionList.d.ts +1 -1
- package/dist/utils/StateTransitionReductionList.d.ts.map +1 -1
- package/dist/utils/StateTransitionReductionList.js +3 -3
- 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/hooks/AccountStateHook.ts +11 -9
- package/src/hooks/BlockHeightHook.ts +3 -4
- package/src/hooks/LastStateRootBlockHook.ts +4 -4
- package/src/hooks/NoopBlockHook.ts +6 -5
- package/src/hooks/NoopSettlementHook.ts +2 -2
- package/src/hooks/NoopTransactionHook.ts +5 -1
- package/src/index.ts +0 -2
- package/src/model/MethodPublicOutput.ts +2 -2
- package/src/model/Option.ts +5 -1
- package/src/model/Path.ts +1 -3
- package/src/model/StateTransition.ts +1 -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 +24 -13
- package/src/protocol/ProtocolEnvironment.ts +7 -6
- package/src/protocol/ProtocolModule.ts +5 -2
- 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 +78 -55
- package/src/prover/block/accummulators/BlockHashMerkleTree.ts +1 -1
- package/src/prover/statetransition/StateTransitionProvable.ts +3 -3
- package/src/prover/statetransition/StateTransitionProver.ts +23 -27
- package/src/settlement/ContractModule.ts +1 -1
- package/src/settlement/SettlementContractModule.ts +14 -9
- package/src/settlement/contracts/DispatchSmartContract.ts +15 -14
- package/src/settlement/contracts/SettlementContractProtocolModule.ts +6 -4
- package/src/settlement/contracts/SettlementSmartContract.ts +55 -34
- package/src/settlement/messages/OutgoingMessageArgument.ts +1 -0
- package/src/settlement/modularity/ProvableSettlementHook.ts +3 -4
- package/src/settlement/modules/NetworkStateSettlementModule.ts +5 -2
- package/src/state/State.ts +19 -12
- 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 +6 -2
- package/src/state/context/RuntimeMethodExecutionContext.ts +5 -2
- package/src/state/context/TransitionMethodExecutionContext.ts +0 -1
- package/src/state/protocol/ProtocolState.ts +1 -4
- package/src/utils/MinaPrefixedProvableHashList.ts +2 -1
- package/src/utils/ProvableHashList.ts +1 -1
- package/src/utils/StateTransitionReductionList.ts +4 -3
- package/src/utils/utils.ts +4 -9
- package/test/BlockProver.test.ts +110 -128
- package/test/Protocol.test.ts +8 -20
- 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 +5 -2
- 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/dist/hooks/TransactionFeeHook.js +0 -39
- package/src/hooks/SequenceStateTransactionModule.ts +0 -25
- package/src/model/Option.test.ts +0 -21
- package/src/state/context/ProtocolMethodExecutionContext.ts +0 -36
- package/test/Option.test.ts +0 -64
- package/test/settlement/SettlementContract.test.ts +0 -45
- 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";
|
|
@@ -38,9 +37,7 @@ function maxField() {
|
|
|
38
37
|
return Field(Field.ORDER - 1n);
|
|
39
38
|
}
|
|
40
39
|
export class BlockProverProgrammable extends ZkProgrammable {
|
|
41
|
-
constructor(
|
|
42
|
-
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
43
|
-
prover, stateTransitionProver, runtime, transactionHooks, blockHooks) {
|
|
40
|
+
constructor(prover, stateTransitionProver, runtime, transactionHooks, blockHooks) {
|
|
44
41
|
super();
|
|
45
42
|
this.prover = prover;
|
|
46
43
|
this.stateTransitionProver = stateTransitionProver;
|
|
@@ -61,9 +58,9 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
61
58
|
* @param executionData
|
|
62
59
|
* @returns The new BlockProver-state to be used as public output
|
|
63
60
|
*/
|
|
64
|
-
applyTransaction(state, stateTransitionProof, runtimeProof, executionData) {
|
|
61
|
+
async applyTransaction(state, stateTransitionProof, runtimeProof, executionData) {
|
|
65
62
|
const { transaction, networkState, signature } = executionData;
|
|
66
|
-
const isMessage = runtimeProof.publicOutput
|
|
63
|
+
const { isMessage } = runtimeProof.publicOutput;
|
|
67
64
|
runtimeProof.verify();
|
|
68
65
|
stateTransitionProof.verify();
|
|
69
66
|
const stateTo = { ...state };
|
|
@@ -75,7 +72,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
75
72
|
state.stateRoot.assertEquals(stateTransitionProof.publicInput.stateRoot, errors.propertyNotMatching("from state root"));
|
|
76
73
|
state.stateRoot.assertEquals(stateTransitionProof.publicInput.protocolStateRoot, errors.propertyNotMatching("from protocol state root"));
|
|
77
74
|
// Apply protocol state transitions
|
|
78
|
-
this.assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof);
|
|
75
|
+
await this.assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof);
|
|
79
76
|
// Apply state if status success
|
|
80
77
|
stateTo.stateRoot = Provable.if(runtimeProof.publicOutput.status, stateTransitionProof.publicOutput.stateRoot, stateTransitionProof.publicOutput.protocolStateRoot);
|
|
81
78
|
// Check transaction integrity against appProof
|
|
@@ -96,9 +93,9 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
96
93
|
state.networkStateHash.assertEquals(networkState.hash(), "Network state provided to BlockProver does not match the publicInput");
|
|
97
94
|
return stateTo;
|
|
98
95
|
}
|
|
99
|
-
// eslint-disable-next-line
|
|
96
|
+
// eslint-disable-next-line max-len
|
|
100
97
|
// TODO How does this interact with the RuntimeMethodExecutionContext when executing runtimemethods?
|
|
101
|
-
assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof) {
|
|
98
|
+
async assertProtocolTransitions(stateTransitionProof, executionData, runtimeProof) {
|
|
102
99
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
103
100
|
executionContext.clear();
|
|
104
101
|
// Setup context for potential calls to runtime methods.
|
|
@@ -110,9 +107,10 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
110
107
|
networkState: executionData.networkState,
|
|
111
108
|
});
|
|
112
109
|
executionContext.beforeMethod("", "", []);
|
|
113
|
-
this.transactionHooks
|
|
114
|
-
|
|
115
|
-
|
|
110
|
+
for (const module of this.transactionHooks) {
|
|
111
|
+
// eslint-disable-next-line no-await-in-loop
|
|
112
|
+
await module.onTransaction(executionData);
|
|
113
|
+
}
|
|
116
114
|
executionContext.afterMethod();
|
|
117
115
|
const { stateTransitions, status, statusMessage } = executionContext.current().result;
|
|
118
116
|
status.assertTrue(statusMessage);
|
|
@@ -123,11 +121,12 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
123
121
|
});
|
|
124
122
|
stateTransitionProof.publicOutput.protocolTransitionsHash.assertEquals(hashList.commitment, "ProtocolTransitionsHash not matching the generated protocol transitions");
|
|
125
123
|
}
|
|
126
|
-
executeBlockHooks(state, inputNetworkState, type) {
|
|
124
|
+
async executeBlockHooks(state, inputNetworkState, type) {
|
|
127
125
|
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
128
126
|
executionContext.clear();
|
|
129
127
|
executionContext.beforeMethod("", "", []);
|
|
130
|
-
const resultingNetworkState = this.blockHooks.reduce((
|
|
128
|
+
const resultingNetworkState = await this.blockHooks.reduce(async (networkStatePromise, blockHook) => {
|
|
129
|
+
const networkState = await networkStatePromise;
|
|
131
130
|
// Setup context for potential calls to runtime methods.
|
|
132
131
|
// With the special case that we set the new networkstate for every hook
|
|
133
132
|
// We also have to put in a dummy transaction for network.transaction
|
|
@@ -136,15 +135,13 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
136
135
|
networkState,
|
|
137
136
|
});
|
|
138
137
|
if (type === "beforeBlock") {
|
|
139
|
-
return blockHook.beforeBlock(networkState, state);
|
|
140
|
-
}
|
|
141
|
-
else if (type === "afterBlock") {
|
|
142
|
-
return blockHook.afterBlock(networkState, state);
|
|
138
|
+
return await blockHook.beforeBlock(networkState, state);
|
|
143
139
|
}
|
|
144
|
-
|
|
145
|
-
|
|
140
|
+
if (type === "afterBlock") {
|
|
141
|
+
return await blockHook.afterBlock(networkState, state);
|
|
146
142
|
}
|
|
147
|
-
|
|
143
|
+
throw new Error("Unreachable");
|
|
144
|
+
}, Promise.resolve(inputNetworkState));
|
|
148
145
|
executionContext.afterMethod();
|
|
149
146
|
const { stateTransitions, status, statusMessage } = executionContext.current().result;
|
|
150
147
|
status.assertTrue(`Block hook call failed: ${statusMessage ?? "-"}`);
|
|
@@ -163,7 +160,6 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
163
160
|
transactionList.pushIf(transactionHash, isMessage.not());
|
|
164
161
|
stateTo.transactionsHash = transactionList.commitment;
|
|
165
162
|
// Append tx to eternal transaction list
|
|
166
|
-
// eslint-disable-next-line no-warning-comments
|
|
167
163
|
// TODO Change that to the a sequence-state compatible transaction struct
|
|
168
164
|
const eternalTransactionList = new DefaultProvableHashList(Field, state.eternalTransactionsHash);
|
|
169
165
|
eternalTransactionList.pushIf(transactionHash, isMessage.not());
|
|
@@ -175,13 +171,13 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
175
171
|
stateTo.incomingMessagesHash = incomingMessagesList.commitment;
|
|
176
172
|
return stateTo;
|
|
177
173
|
}
|
|
178
|
-
proveTransaction(publicInput, stateProof, runtimeProof, executionData) {
|
|
174
|
+
async proveTransaction(publicInput, stateProof, runtimeProof, executionData) {
|
|
179
175
|
const state = {
|
|
180
176
|
...publicInput,
|
|
181
177
|
};
|
|
182
178
|
state.networkStateHash.assertEquals(executionData.networkState.hash(), "ExecutionData Networkstate doesn't equal public input hash");
|
|
183
179
|
const bundleInclusionState = this.addTransactionToBundle(state, runtimeProof.publicOutput.isMessage, executionData.transaction);
|
|
184
|
-
const stateTo = this.applyTransaction(bundleInclusionState, stateProof, runtimeProof, executionData);
|
|
180
|
+
const stateTo = await this.applyTransaction(bundleInclusionState, stateProof, runtimeProof, executionData);
|
|
185
181
|
return new BlockProverPublicOutput({
|
|
186
182
|
...stateTo,
|
|
187
183
|
blockNumber: maxField(),
|
|
@@ -194,7 +190,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
194
190
|
// Assert from state roots
|
|
195
191
|
stateRoot.assertEquals(stateTransitionProof.publicInput.stateRoot, errors.propertyNotMatching("from state root"));
|
|
196
192
|
}
|
|
197
|
-
proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, transactionProof) {
|
|
193
|
+
async proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, transactionProof) {
|
|
198
194
|
const state = {
|
|
199
195
|
...publicInput,
|
|
200
196
|
};
|
|
@@ -221,7 +217,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
221
217
|
const verifyTransactionProof = txProofOutput.equals(transactionProof.publicInput, txProofOutput.closed, txProofOutput.blockNumber);
|
|
222
218
|
transactionProof.verifyIf(verifyTransactionProof);
|
|
223
219
|
// 2. Execute beforeBlock hooks
|
|
224
|
-
const beforeBlockResult = this.executeBlockHooks(state, networkState, "beforeBlock");
|
|
220
|
+
const beforeBlockResult = await this.executeBlockHooks(state, networkState, "beforeBlock");
|
|
225
221
|
const beforeBlockHashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
226
222
|
beforeBlockResult.stateTransitions.forEach((st) => {
|
|
227
223
|
beforeBlockHashList.push(st.toProvable());
|
|
@@ -246,7 +242,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
246
242
|
transactionProof.publicOutput.incomingMessagesHash;
|
|
247
243
|
// 5. Execute afterBlock hooks
|
|
248
244
|
this.assertSTProofInput(stateTransitionProof, state.stateRoot);
|
|
249
|
-
const afterBlockResult = this.executeBlockHooks(state, beforeBlockResult.networkState, "afterBlock");
|
|
245
|
+
const afterBlockResult = await this.executeBlockHooks(state, beforeBlockResult.networkState, "afterBlock");
|
|
250
246
|
const afterBlockHashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
251
247
|
afterBlockResult.stateTransitions.forEach((st) => {
|
|
252
248
|
afterBlockHashList.push(st.toProvable());
|
|
@@ -272,7 +268,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
272
268
|
closed: Bool(true),
|
|
273
269
|
});
|
|
274
270
|
}
|
|
275
|
-
merge(publicInput, proof1, proof2) {
|
|
271
|
+
async merge(publicInput, proof1, proof2) {
|
|
276
272
|
proof1.verify();
|
|
277
273
|
proof2.verify();
|
|
278
274
|
// Check state
|
|
@@ -352,8 +348,10 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
352
348
|
const StateTransitionProofClass = stateTransitionProver.zkProgram.Proof;
|
|
353
349
|
const RuntimeProofClass = runtime.zkProgram.Proof;
|
|
354
350
|
const proveTransaction = prover.proveTransaction.bind(prover);
|
|
351
|
+
const proveBlock = prover.proveBlock.bind(prover);
|
|
355
352
|
const merge = prover.merge.bind(prover);
|
|
356
|
-
const program =
|
|
353
|
+
const program = ZkProgram({
|
|
354
|
+
name: "BlockProver",
|
|
357
355
|
publicInput: BlockProverPublicInput,
|
|
358
356
|
publicOutput: BlockProverPublicOutput,
|
|
359
357
|
methods: {
|
|
@@ -363,8 +361,19 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
363
361
|
RuntimeProofClass,
|
|
364
362
|
BlockProverExecutionData,
|
|
365
363
|
],
|
|
366
|
-
method(publicInput, stateProof, appProof, executionData) {
|
|
367
|
-
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);
|
|
368
377
|
},
|
|
369
378
|
},
|
|
370
379
|
merge: {
|
|
@@ -372,8 +381,8 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
372
381
|
(SelfProof),
|
|
373
382
|
(SelfProof),
|
|
374
383
|
],
|
|
375
|
-
method(publicInput, proof1, proof2) {
|
|
376
|
-
return merge(publicInput, proof1, proof2);
|
|
384
|
+
async method(publicInput, proof1, proof2) {
|
|
385
|
+
return await merge(publicInput, proof1, proof2);
|
|
377
386
|
},
|
|
378
387
|
},
|
|
379
388
|
},
|
|
@@ -382,7 +391,7 @@ export class BlockProverProgrammable extends ZkProgrammable {
|
|
|
382
391
|
proveTransaction: program.proveTransaction,
|
|
383
392
|
merge: program.merge,
|
|
384
393
|
};
|
|
385
|
-
const SelfProofClass =
|
|
394
|
+
const SelfProofClass = ZkProgram.Proof(program);
|
|
386
395
|
return {
|
|
387
396
|
compile: program.compile.bind(program),
|
|
388
397
|
verify: program.verify.bind(program),
|
|
@@ -396,7 +405,7 @@ __decorate([
|
|
|
396
405
|
provableMethod(),
|
|
397
406
|
__metadata("design:type", Function),
|
|
398
407
|
__metadata("design:paramtypes", [BlockProverPublicInput, Object, Object, BlockProverExecutionData]),
|
|
399
|
-
__metadata("design:returntype",
|
|
408
|
+
__metadata("design:returntype", Promise)
|
|
400
409
|
], BlockProverProgrammable.prototype, "proveTransaction", null);
|
|
401
410
|
__decorate([
|
|
402
411
|
provableMethod(),
|
|
@@ -404,20 +413,20 @@ __decorate([
|
|
|
404
413
|
__metadata("design:paramtypes", [BlockProverPublicInput,
|
|
405
414
|
NetworkState,
|
|
406
415
|
BlockHashMerkleTreeWitness, Object, Object]),
|
|
407
|
-
__metadata("design:returntype",
|
|
416
|
+
__metadata("design:returntype", Promise)
|
|
408
417
|
], BlockProverProgrammable.prototype, "proveBlock", null);
|
|
409
418
|
__decorate([
|
|
410
419
|
provableMethod(),
|
|
411
420
|
__metadata("design:type", Function),
|
|
412
421
|
__metadata("design:paramtypes", [BlockProverPublicInput, Object, Object]),
|
|
413
|
-
__metadata("design:returntype",
|
|
422
|
+
__metadata("design:returntype", Promise)
|
|
414
423
|
], BlockProverProgrammable.prototype, "merge", null);
|
|
415
424
|
/**
|
|
416
425
|
* BlockProver class, which aggregates a AppChainProof and
|
|
417
426
|
* a StateTransitionProof into a single BlockProof, that can
|
|
418
427
|
* then be merged to be committed to the base-layer contract
|
|
419
428
|
*/
|
|
420
|
-
let BlockProver = class BlockProver extends ProtocolModule {
|
|
429
|
+
export let BlockProver = class BlockProver extends ProtocolModule {
|
|
421
430
|
constructor(stateTransitionProver, runtime, transactionHooks, blockHooks) {
|
|
422
431
|
super();
|
|
423
432
|
this.stateTransitionProver = stateTransitionProver;
|
|
@@ -442,4 +451,3 @@ BlockProver = __decorate([
|
|
|
442
451
|
__param(3, injectAll("ProvableBlockHook")),
|
|
443
452
|
__metadata("design:paramtypes", [Object, Object, Array, Array])
|
|
444
453
|
], BlockProver);
|
|
445
|
-
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"}
|
|
@@ -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
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BlockHashMerkleTree.d.ts","sourceRoot":"","sources":["../../../../src/prover/block/acummulators/BlockHashMerkleTree.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,EAA8B,MAAM,MAAM,CAAC;;AAE/D,qBAAa,mBAAoB,SAAQ,wBAAmB;CAAG;AAC/D,qBAAa,0BAA2B,SAAQ,mBAAmB,CAAC,OAAO;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAE9E,qBAAa,kBAAmB,SAAQ,uBAKtC;IACO,IAAI,IAAI,KAAK;CAGrB"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { createMerkleTree } from "@proto-kit/common";
|
|
2
|
+
import { Bool, Field, Poseidon, Struct } from "o1js";
|
|
3
|
+
export class BlockHashMerkleTree extends createMerkleTree(8) {
|
|
4
|
+
}
|
|
5
|
+
export class BlockHashMerkleTreeWitness extends BlockHashMerkleTree.WITNESS {
|
|
6
|
+
}
|
|
7
|
+
export class BlockHashTreeEntry extends Struct({
|
|
8
|
+
transactionsHash: Field,
|
|
9
|
+
closed: Bool,
|
|
10
|
+
// TODO We could add startingEternalTransactionsHash here to offer
|
|
11
|
+
// a more trivial connection to the sequence state
|
|
12
|
+
}) {
|
|
13
|
+
hash() {
|
|
14
|
+
return Poseidon.hash([this.transactionsHash, ...this.closed.toFields()]);
|
|
15
|
+
}
|
|
16
|
+
}
|