@proto-kit/protocol 0.1.1-develop.165 → 0.1.1-develop.1665
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/dist/Constants.js +1 -0
- package/dist/Constants.js.map +1 -0
- package/dist/hashing/mina-prefixes.d.ts +10 -0
- package/dist/hashing/mina-prefixes.d.ts.map +1 -0
- package/dist/hashing/mina-prefixes.js +10 -0
- package/dist/hashing/mina-prefixes.js.map +1 -0
- package/dist/hashing/protokit-prefixes.d.ts +10 -0
- package/dist/hashing/protokit-prefixes.d.ts.map +1 -0
- package/dist/hashing/protokit-prefixes.js +24 -0
- package/dist/hashing/protokit-prefixes.js.map +1 -0
- package/dist/hooks/AccountStateHook.d.ts +52 -0
- package/dist/hooks/AccountStateHook.d.ts.map +1 -0
- package/dist/hooks/AccountStateHook.js +52 -0
- package/dist/hooks/AccountStateHook.js.map +1 -0
- package/dist/hooks/BlockHeightHook.d.ts +7 -0
- package/dist/hooks/BlockHeightHook.d.ts.map +1 -0
- package/dist/hooks/BlockHeightHook.js +16 -0
- package/dist/hooks/BlockHeightHook.js.map +1 -0
- package/dist/hooks/LastStateRootBlockHook.d.ts +7 -0
- package/dist/hooks/LastStateRootBlockHook.d.ts.map +1 -0
- package/dist/hooks/LastStateRootBlockHook.js +16 -0
- package/dist/hooks/LastStateRootBlockHook.js.map +1 -0
- package/dist/hooks/NoopBlockHook.d.ts +8 -0
- package/dist/hooks/NoopBlockHook.d.ts.map +1 -0
- package/dist/hooks/NoopBlockHook.js +10 -0
- package/dist/hooks/NoopBlockHook.js.map +1 -0
- package/dist/hooks/NoopSettlementHook.d.ts +6 -0
- package/dist/hooks/NoopSettlementHook.d.ts.map +1 -0
- package/dist/{prover/statetransition/StateTransitionWitnessProvider.js → hooks/NoopSettlementHook.js} +8 -7
- package/dist/hooks/NoopSettlementHook.js.map +1 -0
- package/dist/hooks/NoopTransactionHook.d.ts +6 -0
- package/dist/hooks/NoopTransactionHook.d.ts.map +1 -0
- package/dist/hooks/NoopTransactionHook.js +11 -0
- package/dist/hooks/NoopTransactionHook.js.map +1 -0
- package/dist/index.d.ts +51 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +52 -9
- package/dist/index.js.map +1 -0
- package/dist/model/AppliedStateTransitionBatch.d.ts +114 -0
- package/dist/model/AppliedStateTransitionBatch.d.ts.map +1 -0
- package/dist/model/AppliedStateTransitionBatch.js +16 -0
- package/dist/model/AppliedStateTransitionBatch.js.map +1 -0
- package/dist/model/MethodPublicOutput.d.ts +83 -29
- package/dist/model/MethodPublicOutput.d.ts.map +1 -1
- package/dist/model/MethodPublicOutput.js +4 -1
- package/dist/model/MethodPublicOutput.js.map +1 -0
- package/dist/model/Option.d.ts +70 -42
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +62 -47
- package/dist/model/Option.js.map +1 -0
- package/dist/model/Path.d.ts +4 -3
- package/dist/model/Path.d.ts.map +1 -1
- package/dist/model/Path.js +6 -5
- package/dist/model/Path.js.map +1 -0
- package/dist/model/RuntimeLike.d.ts +11 -0
- package/dist/model/RuntimeLike.d.ts.map +1 -0
- package/dist/model/RuntimeLike.js +2 -0
- package/dist/model/RuntimeLike.js.map +1 -0
- package/dist/model/StateTransition.d.ts +67 -16
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransition.js +18 -2
- package/dist/model/StateTransition.js.map +1 -0
- package/dist/model/StateTransitionProvableBatch.d.ts +389 -16
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -1
- package/dist/model/StateTransitionProvableBatch.js +88 -11
- package/dist/model/StateTransitionProvableBatch.js.map +1 -0
- package/dist/model/network/NetworkState.d.ts +105 -9
- package/dist/model/network/NetworkState.d.ts.map +1 -1
- package/dist/model/network/NetworkState.js +20 -2
- package/dist/model/network/NetworkState.js.map +1 -0
- package/dist/model/transaction/RuntimeTransaction.d.ts +96 -28
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -1
- package/dist/model/transaction/RuntimeTransaction.js +75 -11
- package/dist/model/transaction/RuntimeTransaction.js.map +1 -0
- package/dist/model/transaction/SignedTransaction.d.ts +107 -0
- package/dist/model/transaction/SignedTransaction.d.ts.map +1 -0
- package/dist/model/transaction/SignedTransaction.js +34 -0
- package/dist/model/transaction/SignedTransaction.js.map +1 -0
- package/dist/model/transaction/ValueOption.d.ts +173 -0
- package/dist/model/transaction/ValueOption.d.ts.map +1 -0
- package/dist/model/transaction/ValueOption.js +25 -0
- package/dist/model/transaction/ValueOption.js.map +1 -0
- package/dist/protocol/Protocol.d.ts +27 -25
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/Protocol.js +98 -28
- package/dist/protocol/Protocol.js.map +1 -0
- package/dist/protocol/ProtocolEnvironment.d.ts +9 -0
- package/dist/protocol/ProtocolEnvironment.d.ts.map +1 -0
- package/dist/protocol/ProtocolEnvironment.js +2 -0
- package/dist/protocol/ProtocolEnvironment.js.map +1 -0
- package/dist/protocol/ProtocolModule.d.ts +7 -7
- package/dist/protocol/ProtocolModule.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.js +10 -7
- package/dist/protocol/ProtocolModule.js.map +1 -0
- package/dist/protocol/ProvableBlockHook.d.ts +19 -0
- package/dist/protocol/ProvableBlockHook.d.ts.map +1 -0
- package/dist/protocol/ProvableBlockHook.js +21 -0
- package/dist/protocol/ProvableBlockHook.js.map +1 -0
- package/dist/protocol/ProvableTransactionHook.d.ts +34 -0
- package/dist/protocol/ProvableTransactionHook.d.ts.map +1 -0
- package/dist/protocol/ProvableTransactionHook.js +13 -0
- package/dist/protocol/ProvableTransactionHook.js.map +1 -0
- package/dist/protocol/TransitioningProtocolModule.d.ts +10 -0
- package/dist/protocol/TransitioningProtocolModule.d.ts.map +1 -0
- package/dist/protocol/TransitioningProtocolModule.js +9 -0
- package/dist/protocol/TransitioningProtocolModule.js.map +1 -0
- package/dist/prover/accumulators/AppliedBatchHashList.d.ts +18 -0
- package/dist/prover/accumulators/AppliedBatchHashList.d.ts.map +1 -0
- package/dist/prover/accumulators/AppliedBatchHashList.js +25 -0
- package/dist/prover/accumulators/AppliedBatchHashList.js.map +1 -0
- package/dist/prover/accumulators/StateTransitionReductionList.d.ts +12 -0
- package/dist/prover/accumulators/StateTransitionReductionList.d.ts.map +1 -0
- package/dist/prover/accumulators/StateTransitionReductionList.js +64 -0
- package/dist/prover/accumulators/StateTransitionReductionList.js.map +1 -0
- package/dist/prover/accumulators/TransactionHashList.d.ts +6 -0
- package/dist/prover/accumulators/TransactionHashList.d.ts.map +1 -0
- package/dist/prover/accumulators/TransactionHashList.js +8 -0
- package/dist/prover/accumulators/TransactionHashList.js.map +1 -0
- package/dist/prover/accumulators/WitnessedRootHashList.d.ts +137 -0
- package/dist/prover/accumulators/WitnessedRootHashList.d.ts.map +1 -0
- package/dist/prover/accumulators/WitnessedRootHashList.js +50 -0
- package/dist/prover/accumulators/WitnessedRootHashList.js.map +1 -0
- package/dist/prover/block/BlockProvable.d.ts +869 -65
- package/dist/prover/block/BlockProvable.d.ts.map +1 -1
- package/dist/prover/block/BlockProvable.js +86 -6
- package/dist/prover/block/BlockProvable.js.map +1 -0
- package/dist/prover/block/BlockProver.d.ts +82 -34
- package/dist/prover/block/BlockProver.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.js +505 -86
- package/dist/prover/block/BlockProver.js.map +1 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.d.ts +106 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.d.ts.map +1 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.js +25 -0
- package/dist/prover/block/accummulators/BlockHashMerkleTree.js.map +1 -0
- package/dist/prover/block/accummulators/RuntimeVerificationKeyTree.d.ts +139 -0
- package/dist/prover/block/accummulators/RuntimeVerificationKeyTree.d.ts.map +1 -0
- package/dist/prover/block/accummulators/RuntimeVerificationKeyTree.js +21 -0
- package/dist/prover/block/accummulators/RuntimeVerificationKeyTree.js.map +1 -0
- package/dist/prover/block/services/RuntimeVerificationKeyRootService.d.ts +7 -0
- package/dist/prover/block/services/RuntimeVerificationKeyRootService.d.ts.map +1 -0
- package/dist/prover/{statetransition/StateTransitionWitnessProviderReference.js → block/services/RuntimeVerificationKeyRootService.js} +11 -8
- package/dist/prover/block/services/RuntimeVerificationKeyRootService.js.map +1 -0
- package/dist/prover/statetransition/StateTransitionProvable.d.ts +137 -48
- package/dist/prover/statetransition/StateTransitionProvable.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProvable.js +10 -5
- package/dist/prover/statetransition/StateTransitionProvable.js.map +1 -0
- package/dist/prover/statetransition/StateTransitionProver.d.ts +30 -17
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +169 -74
- package/dist/prover/statetransition/StateTransitionProver.js.map +1 -0
- package/dist/settlement/ContractModule.d.ts +16 -0
- package/dist/settlement/ContractModule.d.ts.map +1 -0
- package/dist/settlement/ContractModule.js +12 -0
- package/dist/settlement/ContractModule.js.map +1 -0
- package/dist/settlement/SettlementContractModule.d.ts +51 -0
- package/dist/settlement/SettlementContractModule.d.ts.map +1 -0
- package/dist/settlement/SettlementContractModule.js +80 -0
- package/dist/settlement/SettlementContractModule.js.map +1 -0
- package/dist/settlement/contracts/BridgeContract.d.ts +116 -0
- package/dist/settlement/contracts/BridgeContract.d.ts.map +1 -0
- package/dist/settlement/contracts/BridgeContract.js +259 -0
- package/dist/settlement/contracts/BridgeContract.js.map +1 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.d.ts +16 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.js +41 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.js.map +1 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts +21 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.js +57 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.js.map +1 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts +44 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchSmartContract.js +229 -0
- package/dist/settlement/contracts/DispatchSmartContract.js.map +1 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.d.ts +21 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.js +84 -0
- package/dist/settlement/contracts/SettlementContractProtocolModule.js.map +1 -0
- package/dist/settlement/contracts/SettlementSmartContract.d.ts +123 -0
- package/dist/settlement/contracts/SettlementSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementSmartContract.js +310 -0
- package/dist/settlement/contracts/SettlementSmartContract.js.map +1 -0
- package/dist/settlement/contracts/TokenBridgeTree.d.ts +228 -0
- package/dist/settlement/contracts/TokenBridgeTree.d.ts.map +1 -0
- package/dist/settlement/contracts/TokenBridgeTree.js +60 -0
- package/dist/settlement/contracts/TokenBridgeTree.js.map +1 -0
- package/dist/settlement/contracts/authorizations/ContractAuthorization.d.ts +10 -0
- package/dist/settlement/contracts/authorizations/ContractAuthorization.d.ts.map +1 -0
- package/dist/settlement/contracts/authorizations/ContractAuthorization.js +2 -0
- package/dist/settlement/contracts/authorizations/ContractAuthorization.js.map +1 -0
- package/dist/settlement/contracts/authorizations/TokenBridgeDeploymentAuth.d.ts +85 -0
- package/dist/settlement/contracts/authorizations/TokenBridgeDeploymentAuth.d.ts.map +1 -0
- package/dist/settlement/contracts/authorizations/TokenBridgeDeploymentAuth.js +11 -0
- package/dist/settlement/contracts/authorizations/TokenBridgeDeploymentAuth.js.map +1 -0
- package/dist/settlement/contracts/authorizations/UpdateMessagesHashAuth.d.ts +79 -0
- package/dist/settlement/contracts/authorizations/UpdateMessagesHashAuth.d.ts.map +1 -0
- package/dist/settlement/contracts/authorizations/UpdateMessagesHashAuth.js +11 -0
- package/dist/settlement/contracts/authorizations/UpdateMessagesHashAuth.js.map +1 -0
- package/dist/settlement/messages/Deposit.d.ts +77 -0
- package/dist/settlement/messages/Deposit.d.ts.map +1 -0
- package/dist/settlement/messages/Deposit.js +8 -0
- package/dist/settlement/messages/Deposit.js.map +1 -0
- package/dist/settlement/messages/OutgoingMessage.d.ts +67 -0
- package/dist/settlement/messages/OutgoingMessage.d.ts.map +1 -0
- package/dist/settlement/messages/OutgoingMessage.js +7 -0
- package/dist/settlement/messages/OutgoingMessage.js.map +1 -0
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts +462 -0
- package/dist/settlement/messages/OutgoingMessageArgument.d.ts.map +1 -0
- package/dist/settlement/messages/OutgoingMessageArgument.js +40 -0
- package/dist/settlement/messages/OutgoingMessageArgument.js.map +1 -0
- package/dist/settlement/modularity/OutgoingMessageProcessor.d.ts +25 -0
- package/dist/settlement/modularity/OutgoingMessageProcessor.d.ts.map +1 -0
- package/dist/settlement/modularity/OutgoingMessageProcessor.js +30 -0
- package/dist/settlement/modularity/OutgoingMessageProcessor.js.map +1 -0
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts +26 -0
- package/dist/settlement/modularity/ProvableSettlementHook.d.ts.map +1 -0
- package/dist/settlement/modularity/ProvableSettlementHook.js +4 -0
- package/dist/settlement/modularity/ProvableSettlementHook.js.map +1 -0
- package/dist/settlement/modularity/types.d.ts +8 -0
- package/dist/settlement/modularity/types.d.ts.map +1 -0
- package/dist/settlement/modularity/types.js +2 -0
- package/dist/settlement/modularity/types.js.map +1 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts +11 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.d.ts.map +1 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.js +15 -0
- package/dist/settlement/modules/NetworkStateSettlementModule.js.map +1 -0
- package/dist/state/State.d.ts +68 -0
- package/dist/state/State.d.ts.map +1 -0
- package/dist/state/State.js +131 -0
- package/dist/state/State.js.map +1 -0
- package/dist/state/StateMap.d.ts +37 -0
- package/dist/state/StateMap.d.ts.map +1 -0
- package/dist/state/StateMap.js +56 -0
- package/dist/state/StateMap.js.map +1 -0
- package/dist/state/StateService.d.ts +6 -0
- package/dist/state/StateService.d.ts.map +1 -0
- package/dist/state/StateService.js +2 -0
- package/dist/state/StateService.js.map +1 -0
- package/dist/state/StateServiceProvider.d.ts +8 -0
- package/dist/state/StateServiceProvider.d.ts.map +1 -0
- package/dist/state/StateServiceProvider.js +37 -0
- package/dist/state/StateServiceProvider.js.map +1 -0
- package/dist/state/assert/assert.d.ts +12 -0
- package/dist/state/assert/assert.d.ts.map +1 -0
- package/dist/state/assert/assert.js +33 -0
- package/dist/state/assert/assert.js.map +1 -0
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts +193 -0
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -0
- package/dist/state/context/RuntimeMethodExecutionContext.js +138 -0
- package/dist/state/context/RuntimeMethodExecutionContext.js.map +1 -0
- package/dist/state/context/TransitionMethodExecutionContext.d.ts +23 -0
- package/dist/state/context/TransitionMethodExecutionContext.d.ts.map +1 -0
- package/dist/state/context/TransitionMethodExecutionContext.js +6 -0
- package/dist/state/context/TransitionMethodExecutionContext.js.map +1 -0
- package/dist/state/protocol/ProtocolState.d.ts +13 -0
- package/dist/state/protocol/ProtocolState.d.ts.map +1 -0
- package/dist/state/protocol/ProtocolState.js +58 -0
- package/dist/state/protocol/ProtocolState.js.map +1 -0
- package/dist/utils/FieldOptions.d.ts +62 -0
- package/dist/utils/FieldOptions.d.ts.map +1 -0
- package/dist/utils/FieldOptions.js +13 -0
- package/dist/utils/FieldOptions.js.map +1 -0
- package/dist/utils/MinaPrefixedProvableHashList.d.ts +19 -0
- package/dist/utils/MinaPrefixedProvableHashList.d.ts.map +1 -0
- package/dist/utils/MinaPrefixedProvableHashList.js +46 -0
- package/dist/utils/MinaPrefixedProvableHashList.js.map +1 -0
- package/dist/utils/PrefixedProvableHashList.d.ts +2 -2
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -1
- package/dist/utils/PrefixedProvableHashList.js +2 -1
- package/dist/utils/PrefixedProvableHashList.js.map +1 -0
- package/dist/utils/ProvableHashList.d.ts +23 -4
- package/dist/utils/ProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableHashList.js +38 -2
- package/dist/utils/ProvableHashList.js.map +1 -0
- package/dist/utils/ProvableReductionHashList.d.ts +18 -0
- package/dist/utils/ProvableReductionHashList.d.ts.map +1 -0
- package/dist/utils/ProvableReductionHashList.js +54 -0
- package/dist/utils/ProvableReductionHashList.js.map +1 -0
- package/dist/utils/utils.d.ts +20 -0
- package/dist/utils/utils.d.ts.map +1 -0
- package/dist/utils/utils.js +51 -0
- package/dist/utils/utils.js.map +1 -0
- package/jest.config.cjs +12 -1
- package/package.json +11 -9
- package/src/hashing/mina-prefixes.ts +10 -0
- package/src/hashing/protokit-prefixes.ts +37 -0
- package/src/hooks/AccountStateHook.ts +57 -0
- package/src/hooks/BlockHeightHook.ts +17 -0
- package/src/hooks/LastStateRootBlockHook.ts +25 -0
- package/src/hooks/NoopBlockHook.ts +24 -0
- package/src/hooks/NoopSettlementHook.ts +20 -0
- package/src/hooks/NoopTransactionHook.ts +13 -0
- package/src/index.ts +51 -9
- package/src/model/AppliedStateTransitionBatch.ts +16 -0
- package/src/model/MethodPublicOutput.ts +3 -1
- package/src/model/Option.ts +99 -60
- package/src/model/Path.ts +9 -5
- package/src/model/RuntimeLike.ts +12 -0
- package/src/model/StateTransition.ts +25 -3
- package/src/model/StateTransitionProvableBatch.ts +117 -14
- package/src/model/Transaction.ts +3 -1
- package/src/model/network/NetworkState.ts +21 -3
- package/src/model/transaction/RuntimeTransaction.ts +90 -15
- package/src/model/transaction/SignedTransaction.ts +47 -0
- package/src/model/transaction/ValueOption.ts +28 -0
- package/src/protocol/Protocol.ts +166 -74
- package/src/protocol/ProtocolEnvironment.ts +10 -0
- package/src/protocol/ProtocolModule.ts +16 -16
- package/src/protocol/ProvableBlockHook.ts +68 -0
- package/src/protocol/ProvableTransactionHook.ts +77 -0
- package/src/protocol/TransitioningProtocolModule.ts +12 -0
- package/src/prover/accumulators/AppliedBatchHashList.ts +32 -0
- package/src/prover/accumulators/StateTransitionReductionList.ts +92 -0
- package/src/prover/accumulators/TransactionHashList.ts +9 -0
- package/src/prover/accumulators/WitnessedRootHashList.ts +61 -0
- package/src/prover/block/BlockProvable.ts +188 -15
- package/src/prover/block/BlockProver.ts +979 -143
- package/src/prover/block/accummulators/BlockHashMerkleTree.ts +24 -0
- package/src/prover/block/accummulators/RuntimeVerificationKeyTree.ts +24 -0
- package/src/prover/block/services/RuntimeVerificationKeyRootService.ts +20 -0
- package/src/prover/statetransition/StateTransitionProvable.ts +26 -19
- package/src/prover/statetransition/StateTransitionProver.ts +338 -130
- package/src/settlement/ContractModule.ts +31 -0
- package/src/settlement/SettlementContractModule.ts +145 -0
- package/src/settlement/contracts/BridgeContract.ts +366 -0
- package/src/settlement/contracts/BridgeContractProtocolModule.ts +48 -0
- package/src/settlement/contracts/DispatchContractProtocolModule.ts +75 -0
- package/src/settlement/contracts/DispatchSmartContract.ts +325 -0
- package/src/settlement/contracts/SettlementContractProtocolModule.ts +113 -0
- package/src/settlement/contracts/SettlementSmartContract.ts +502 -0
- package/src/settlement/contracts/TokenBridgeTree.ts +73 -0
- package/src/settlement/contracts/authorizations/ContractAuthorization.ts +11 -0
- package/src/settlement/contracts/authorizations/TokenBridgeDeploymentAuth.ts +16 -0
- package/src/settlement/contracts/authorizations/UpdateMessagesHashAuth.ts +16 -0
- package/src/settlement/messages/Deposit.ts +7 -0
- package/src/settlement/messages/OutgoingMessage.ts +17 -0
- package/src/settlement/messages/OutgoingMessageArgument.ts +53 -0
- package/src/settlement/modularity/OutgoingMessageProcessor.ts +65 -0
- package/src/settlement/modularity/ProvableSettlementHook.ts +36 -0
- package/src/settlement/modularity/types.ts +22 -0
- package/src/settlement/modules/NetworkStateSettlementModule.ts +42 -0
- package/src/state/State.ts +177 -0
- package/src/state/StateMap.ts +73 -0
- package/src/state/StateService.ts +6 -0
- package/src/state/StateServiceProvider.ts +37 -0
- package/src/state/assert/assert.ts +38 -0
- package/src/state/context/RuntimeMethodExecutionContext.ts +181 -0
- package/src/state/context/TransitionMethodExecutionContext.ts +26 -0
- package/src/state/protocol/ProtocolState.ts +98 -0
- package/src/utils/FieldOptions.ts +13 -0
- package/src/utils/MinaPrefixedProvableHashList.ts +66 -0
- package/src/utils/PrefixedProvableHashList.ts +2 -2
- package/src/utils/ProvableHashList.ts +78 -3
- package/src/utils/ProvableReductionHashList.ts +77 -0
- package/src/utils/utils.ts +44 -55
- package/test/BlockProver.test.ts +161 -74
- package/test/Protocol.test.ts +20 -10
- package/test/State.test.ts +45 -0
- package/test/StateTransition.test.ts +57 -65
- package/test/TestingProtocol.ts +56 -0
- package/test/compiling/types.ts +28 -0
- package/test/model/Option.test.ts +72 -0
- package/test/model/StateTransitionProvableBatch.test.ts +137 -0
- package/test/modularity/types.ts +35 -0
- package/test/prover/block/BlockProver.test.ts +18 -0
- package/test/prover/statetransition/StateTransitionProver.test.ts +261 -0
- package/test/state/assert/assert.test.ts +56 -0
- package/test/tsconfig.json +7 -0
- package/test/utils/ProvableHashList.test.ts +44 -0
- package/test/utils/ProvableReductionHashList.test.ts +117 -0
- package/test/utils.test.ts +27 -0
- package/dist/config/ConfigurableModule.d.ts +0 -18
- package/dist/config/ConfigurableModule.d.ts.map +0 -1
- package/dist/config/ConfigurableModule.js +0 -20
- package/dist/config/ConfigurationAggregator.d.ts +0 -10
- package/dist/config/ConfigurationAggregator.d.ts.map +0 -1
- package/dist/config/ConfigurationAggregator.js +0 -35
- package/dist/config/ConfigurationReceiver.d.ts +0 -25
- package/dist/config/ConfigurationReceiver.d.ts.map +0 -1
- package/dist/config/ConfigurationReceiver.js +0 -36
- package/dist/config/ModuleContainer.d.ts +0 -44
- package/dist/config/ModuleContainer.d.ts.map +0 -1
- package/dist/config/ModuleContainer.js +0 -89
- package/dist/config/types.d.ts +0 -2
- package/dist/config/types.d.ts.map +0 -1
- package/dist/config/types.js +0 -1
- package/dist/model/MethodPublicInput.d.ts +0 -51
- package/dist/model/MethodPublicInput.d.ts.map +0 -1
- package/dist/model/MethodPublicInput.js +0 -11
- package/dist/model/transaction/ProtocolTransaction.d.ts +0 -70
- package/dist/model/transaction/ProtocolTransaction.d.ts.map +0 -1
- package/dist/model/transaction/ProtocolTransaction.js +0 -18
- package/dist/prover/block/BlockScopedModule.d.ts +0 -3
- package/dist/prover/block/BlockScopedModule.d.ts.map +0 -1
- package/dist/prover/block/BlockScopedModule.js +0 -6
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts +0 -16
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts.map +0 -1
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.d.ts +0 -7
- package/dist/prover/statetransition/StateTransitionWitnessProviderReference.d.ts.map +0 -1
- package/dist/src/model/Option.d.ts +0 -158
- package/dist/src/model/Option.d.ts.map +0 -1
- package/dist/src/model/Option.js +0 -53
- package/dist/src/model/Path.d.ts +0 -35
- package/dist/src/model/Path.d.ts.map +0 -1
- package/dist/src/model/Path.js +0 -51
- package/dist/src/model/StateTransition.d.ts +0 -201
- package/dist/src/model/StateTransition.d.ts.map +0 -1
- package/dist/src/model/StateTransition.js +0 -43
- package/dist/src/utils/PrefixedHashList.d.ts +0 -15
- package/dist/src/utils/PrefixedHashList.d.ts.map +0 -1
- package/dist/src/utils/PrefixedHashList.js +0 -28
- package/dist/src/utils/ProvableHashList.d.ts +0 -30
- package/dist/src/utils/ProvableHashList.d.ts.map +0 -1
- package/dist/src/utils/ProvableHashList.js +0 -43
- package/dist/utils/PrefixedHashList.d.ts +0 -14
- package/dist/utils/PrefixedHashList.d.ts.map +0 -1
- package/dist/utils/PrefixedHashList.js +0 -12
- package/dist/utils/Utils.d.ts +0 -17
- package/dist/utils/Utils.d.ts.map +0 -1
- package/dist/utils/Utils.js +0 -64
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts +0 -25
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts.map +0 -1
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.js +0 -77
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts +0 -26
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.d.ts.map +0 -1
- package/dist/utils/merkletree/MemoryMerkleTreeStorage.js +0 -79
- package/dist/utils/merkletree/MerkleTreeStore.d.ts +0 -11
- package/dist/utils/merkletree/MerkleTreeStore.d.ts.map +0 -1
- package/dist/utils/merkletree/MerkleTreeStore.js +0 -1
- package/dist/utils/merkletree/RollupMerkleTree.d.ts +0 -130
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +0 -1
- package/dist/utils/merkletree/RollupMerkleTree.js +0 -244
- package/src/model/Option.test.ts +0 -21
- package/src/model/transaction/ProtocolTransaction.ts +0 -25
- package/src/prover/statetransition/StateTransitionWitnessProvider.ts +0 -24
- package/src/prover/statetransition/StateTransitionWitnessProviderReference.ts +0 -17
- package/src/utils/merkletree/InMemoryMerkleTreeStorage.ts +0 -106
- package/src/utils/merkletree/MerkleTreeStore.ts +0 -15
- package/src/utils/merkletree/RollupMerkleTree.ts +0 -250
- package/src/utils/merkletree/VirtualMerkleTreeStore.ts +0 -21
- package/tsconfig.test.json +0 -9
|
@@ -10,96 +10,428 @@ 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 {
|
|
15
|
-
import {
|
|
16
|
-
import { provableMethod, ZkProgrammable, } from "@proto-kit/common";
|
|
17
|
-
import { DefaultProvableHashList } from "../../utils/ProvableHashList";
|
|
13
|
+
import { Bool, Field, Provable, SelfProof, ZkProgram, } from "o1js";
|
|
14
|
+
import { container, inject, injectable, injectAll } from "tsyringe";
|
|
15
|
+
import { log, MAX_FIELD, provableMethod, ZkProgrammable, } from "@proto-kit/common";
|
|
18
16
|
import { ProtocolModule } from "../../protocol/ProtocolModule";
|
|
19
17
|
import { RuntimeTransaction } from "../../model/transaction/RuntimeTransaction";
|
|
20
|
-
import {
|
|
18
|
+
import { ProvableStateTransition, } from "../../model/StateTransition";
|
|
19
|
+
import { toProvableHookBlockState, } from "../../protocol/ProvableTransactionHook";
|
|
20
|
+
import { RuntimeMethodExecutionContext, } from "../../state/context/RuntimeMethodExecutionContext";
|
|
21
|
+
import { toAfterTransactionHookArgument, toBeforeTransactionHookArgument, } from "../../protocol/ProvableBlockHook";
|
|
22
|
+
import { NetworkState } from "../../model/network/NetworkState";
|
|
23
|
+
import { SignedTransaction } from "../../model/transaction/SignedTransaction";
|
|
24
|
+
import { MinaActions } from "../../utils/MinaPrefixedProvableHashList";
|
|
25
|
+
import { StateTransitionReductionList } from "../accumulators/StateTransitionReductionList";
|
|
26
|
+
import { assertEqualsIf } from "../../utils/utils";
|
|
27
|
+
import { WitnessedRootWitness } from "../accumulators/WitnessedRootHashList";
|
|
28
|
+
import { StateServiceProvider } from "../../state/StateServiceProvider";
|
|
29
|
+
import { AppliedStateTransitionBatch } from "../../model/AppliedStateTransitionBatch";
|
|
30
|
+
import { BlockProverPublicInput, BlockProverPublicOutput, DynamicRuntimeProof, BlockProverMultiTransactionExecutionData, BlockProverSingleTransactionExecutionData, BlockProverStateCommitments, } from "./BlockProvable";
|
|
31
|
+
import { BlockHashMerkleTreeWitness, BlockHashTreeEntry, } from "./accummulators/BlockHashMerkleTree";
|
|
32
|
+
import { MethodVKConfigData, } from "./accummulators/RuntimeVerificationKeyTree";
|
|
33
|
+
import { RuntimeVerificationKeyRootService } from "./services/RuntimeVerificationKeyRootService";
|
|
21
34
|
const errors = {
|
|
22
|
-
|
|
23
|
-
stateTransitionsHashNotEqual: () => "StateTransition list commitments are not equal",
|
|
35
|
+
propertyNotMatchingStep: (propertyName, step) => `${propertyName} not matching: ${step}`,
|
|
24
36
|
propertyNotMatching: (propertyName) => `${propertyName} not matching`,
|
|
25
|
-
stateRootNotMatching: (step) =>
|
|
26
|
-
transactionsHashNotMatching: (step) =>
|
|
37
|
+
stateRootNotMatching: (step) => errors.propertyNotMatchingStep("StateRoots", step),
|
|
38
|
+
transactionsHashNotMatching: (step) => errors.propertyNotMatchingStep("Transactions hash", step),
|
|
39
|
+
networkStateHashNotMatching: (step) => errors.propertyNotMatchingStep("Network state hash", step),
|
|
40
|
+
invalidZkProgramTreeRoot: () => "Root hash of the provided zkProgram config witness is invalid",
|
|
27
41
|
};
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
* a StateTransitionProof into a single BlockProof, that can
|
|
31
|
-
* then be merged to be committed to the base-layer contract
|
|
32
|
-
*/
|
|
33
|
-
let BlockProver = class BlockProver extends ProtocolModule {
|
|
34
|
-
constructor(stateTransitionProver, runtime) {
|
|
42
|
+
export class BlockProverProgrammable extends ZkProgrammable {
|
|
43
|
+
constructor(prover, stateTransitionProver, transactionHooks, blockHooks, stateServiceProvider, verificationKeyService) {
|
|
35
44
|
super();
|
|
45
|
+
this.prover = prover;
|
|
36
46
|
this.stateTransitionProver = stateTransitionProver;
|
|
37
|
-
this.
|
|
47
|
+
this.transactionHooks = transactionHooks;
|
|
48
|
+
this.blockHooks = blockHooks;
|
|
49
|
+
this.stateServiceProvider = stateServiceProvider;
|
|
50
|
+
this.verificationKeyService = verificationKeyService;
|
|
51
|
+
this.name = "BlockProver";
|
|
52
|
+
}
|
|
53
|
+
get areProofsEnabled() {
|
|
54
|
+
return this.prover.areProofsEnabled;
|
|
38
55
|
}
|
|
39
56
|
/**
|
|
40
57
|
* Applies and checks the two proofs and applies the corresponding state
|
|
41
|
-
* changes to the given state
|
|
58
|
+
* changes to the given state.
|
|
59
|
+
*
|
|
60
|
+
* The rough high level workflow of this function:
|
|
61
|
+
* 1. Execute beforeTransaction hooks, pushing the ST batch
|
|
62
|
+
* 2. Add Transaction to bundle, meaning appending it to all the respective commitments
|
|
63
|
+
* 3. Push the runtime ST batch
|
|
64
|
+
* 4. Execute afterTransaction hooks, pushing the ST batch
|
|
65
|
+
* 5. Some consistency checks and signature verification
|
|
42
66
|
*
|
|
43
|
-
* @param
|
|
44
|
-
* @param
|
|
45
|
-
* @param
|
|
67
|
+
* @param fromState The from-state of the BlockProver
|
|
68
|
+
* @param runtimeOutput
|
|
69
|
+
* @param executionData
|
|
70
|
+
* @param networkState
|
|
46
71
|
* @returns The new BlockProver-state to be used as public output
|
|
47
72
|
*/
|
|
48
|
-
applyTransaction(
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
const
|
|
52
|
-
|
|
53
|
-
//
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
73
|
+
async applyTransaction(fromState, runtimeOutput, executionData, networkState) {
|
|
74
|
+
const { transaction, signature } = executionData;
|
|
75
|
+
let state = { ...fromState };
|
|
76
|
+
const { isMessage } = runtimeOutput;
|
|
77
|
+
const beforeTxHookArguments = toBeforeTransactionHookArgument(executionData, networkState, state);
|
|
78
|
+
// Apply beforeTransaction hook state transitions
|
|
79
|
+
const beforeBatch = await this.executeTransactionHooks(async (module, args) => await module.beforeTransaction(args), beforeTxHookArguments);
|
|
80
|
+
state = this.addTransactionToBundle(state, runtimeOutput.isMessage, transaction);
|
|
81
|
+
state.pendingSTBatches.push(beforeBatch);
|
|
82
|
+
state.pendingSTBatches.push({
|
|
83
|
+
batchHash: runtimeOutput.stateTransitionsHash,
|
|
84
|
+
applied: runtimeOutput.status,
|
|
85
|
+
});
|
|
86
|
+
// Apply afterTransaction hook state transitions
|
|
87
|
+
const afterTxHookArguments = toAfterTransactionHookArgument(executionData, networkState, state, runtimeOutput);
|
|
88
|
+
// Switch to different state set for afterTx hooks
|
|
89
|
+
this.stateServiceProvider.popCurrentStateService();
|
|
90
|
+
const afterBatch = await this.executeTransactionHooks(async (module, args) => await module.afterTransaction(args), afterTxHookArguments);
|
|
91
|
+
state.pendingSTBatches.push(afterBatch);
|
|
92
|
+
// Check transaction integrity against appProof
|
|
93
|
+
const blockTransactionHash = transaction.hash();
|
|
94
|
+
blockTransactionHash.assertEquals(runtimeOutput.transactionHash, "Transactions provided in AppProof and BlockProof do not match");
|
|
60
95
|
// Check transaction signature
|
|
61
|
-
|
|
96
|
+
new SignedTransaction({
|
|
97
|
+
transaction,
|
|
98
|
+
signature,
|
|
99
|
+
})
|
|
62
100
|
.validateSignature()
|
|
101
|
+
.or(isMessage)
|
|
63
102
|
.assertTrue("Transaction signature not valid");
|
|
64
|
-
//
|
|
65
|
-
|
|
66
|
-
// Check transaction integrity against appProof
|
|
67
|
-
const blockTransactionHash = RuntimeTransaction.fromProtocolTransaction(transaction).hash();
|
|
68
|
-
blockTransactionHash.assertEquals(appProof.publicOutput.transactionHash, "Transactions provided in AppProof and BlockProof do not match");
|
|
103
|
+
// Validate layout of transaction witness
|
|
104
|
+
transaction.assertTransactionType(isMessage);
|
|
69
105
|
// Check network state integrity against appProof
|
|
70
|
-
state.
|
|
71
|
-
|
|
106
|
+
state.networkState
|
|
107
|
+
.hash()
|
|
108
|
+
.assertEquals(runtimeOutput.networkStateHash, "Network state does not match state used in AppProof");
|
|
109
|
+
return state;
|
|
110
|
+
}
|
|
111
|
+
// eslint-disable-next-line max-len
|
|
112
|
+
// TODO How does this interact with the RuntimeMethodExecutionContext when executing runtimemethods?
|
|
113
|
+
/**
|
|
114
|
+
* Constructs a AppliedBatch based on a list of STs and the flag whether to
|
|
115
|
+
* be applied or not. The AppliedBatch is a condensed commitment to a batch
|
|
116
|
+
* of STs.
|
|
117
|
+
*/
|
|
118
|
+
constructBatch(stateTransitions, applied) {
|
|
119
|
+
const transitions = stateTransitions.map((transition) => transition.toProvable());
|
|
120
|
+
const hashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
121
|
+
transitions.forEach((transition) => {
|
|
122
|
+
hashList.push(transition);
|
|
123
|
+
});
|
|
124
|
+
return new AppliedStateTransitionBatch({
|
|
125
|
+
batchHash: hashList.commitment,
|
|
126
|
+
applied,
|
|
127
|
+
});
|
|
128
|
+
}
|
|
129
|
+
async executeTransactionHooks(hook, hookArguments) {
|
|
130
|
+
const { batch } = await this.executeHooks(hookArguments, async () => {
|
|
131
|
+
for (const module of this.transactionHooks) {
|
|
132
|
+
// eslint-disable-next-line no-await-in-loop
|
|
133
|
+
await hook(module, hookArguments);
|
|
134
|
+
}
|
|
135
|
+
});
|
|
136
|
+
return batch;
|
|
137
|
+
}
|
|
138
|
+
async executeHooks(contextArguments, method) {
|
|
139
|
+
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
140
|
+
executionContext.clear();
|
|
141
|
+
// Setup context for potential calls to runtime methods.
|
|
142
|
+
// This way they can use this.transaction etc. while still having provable
|
|
143
|
+
// integrity between data
|
|
144
|
+
executionContext.setup(contextArguments);
|
|
145
|
+
executionContext.beforeMethod("", "", []);
|
|
146
|
+
const result = await method();
|
|
147
|
+
executionContext.afterMethod();
|
|
148
|
+
const { stateTransitions, status, statusMessage } = executionContext.current().result;
|
|
149
|
+
status.assertTrue(`Transaction hook call failed: ${statusMessage ?? "-"}`);
|
|
150
|
+
return {
|
|
151
|
+
batch: this.constructBatch(stateTransitions, Bool(true)),
|
|
152
|
+
result,
|
|
153
|
+
};
|
|
154
|
+
}
|
|
155
|
+
async executeBlockHooks(hook, hookArguments, inputNetworkState) {
|
|
156
|
+
const transaction = RuntimeTransaction.dummyTransaction();
|
|
157
|
+
const startingInputs = {
|
|
158
|
+
transaction,
|
|
159
|
+
networkState: inputNetworkState,
|
|
160
|
+
};
|
|
161
|
+
return await this.executeHooks(startingInputs, async () => {
|
|
162
|
+
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
163
|
+
return await this.blockHooks.reduce(async (networkStatePromise, blockHook) => {
|
|
164
|
+
const networkState = await networkStatePromise;
|
|
165
|
+
// Setup context for potential calls to runtime methods.
|
|
166
|
+
// With the special case that we set the new networkstate for every hook
|
|
167
|
+
// We also have to put in a dummy transaction for network.transaction
|
|
168
|
+
executionContext.setup({
|
|
169
|
+
transaction: RuntimeTransaction.dummyTransaction(),
|
|
170
|
+
networkState,
|
|
171
|
+
});
|
|
172
|
+
return await hook(blockHook, networkState, hookArguments);
|
|
173
|
+
}, Promise.resolve(inputNetworkState));
|
|
174
|
+
});
|
|
175
|
+
}
|
|
176
|
+
addTransactionToBundle(state, isMessage, transaction) {
|
|
177
|
+
const transactionHash = transaction.hash();
|
|
72
178
|
// Append tx to transaction list
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
179
|
+
state.transactionList.pushIf(transactionHash, isMessage.not());
|
|
180
|
+
// Append tx to eternal transaction list
|
|
181
|
+
// TODO Change that to the a sequence-state compatible transaction struct
|
|
182
|
+
state.eternalTransactionsList.push(transactionHash);
|
|
183
|
+
// Append tx to incomingMessagesHash
|
|
184
|
+
const actionHash = MinaActions.actionHash(transaction.hashData());
|
|
185
|
+
state.incomingMessages.pushIf(actionHash, isMessage);
|
|
186
|
+
return state;
|
|
187
|
+
}
|
|
188
|
+
verifyVerificationKeyAttestation(attestation, methodId) {
|
|
189
|
+
// Verify the [methodId, vk] tuple against the baked-in vk tree root
|
|
190
|
+
const { verificationKey, witness: verificationKeyTreeWitness } = attestation;
|
|
191
|
+
const root = Field(this.verificationKeyService.getRoot());
|
|
192
|
+
const calculatedRoot = verificationKeyTreeWitness.calculateRoot(new MethodVKConfigData({
|
|
193
|
+
methodId: methodId,
|
|
194
|
+
vkHash: verificationKey.hash,
|
|
195
|
+
}).hash());
|
|
196
|
+
root.assertEquals(calculatedRoot, errors.invalidZkProgramTreeRoot());
|
|
197
|
+
return verificationKey;
|
|
198
|
+
}
|
|
199
|
+
async proveTransactionInternal(fromState, runtimeProof, { transaction, networkState }) {
|
|
200
|
+
const verificationKey = this.verifyVerificationKeyAttestation(transaction.verificationKeyAttestation, transaction.transaction.methodId);
|
|
201
|
+
runtimeProof.verify(verificationKey);
|
|
202
|
+
return await this.applyTransaction(fromState, runtimeProof.publicOutput, transaction, networkState);
|
|
203
|
+
}
|
|
204
|
+
staticChecks(publicInput) {
|
|
205
|
+
publicInput.blockNumber.assertEquals(MAX_FIELD, "blockNumber has to be MAX for transaction proofs");
|
|
206
|
+
}
|
|
207
|
+
async proveTransaction(publicInput, runtimeProof, executionData) {
|
|
208
|
+
const state = BlockProverStateCommitments.toBlockProverState(publicInput, executionData.networkState);
|
|
209
|
+
this.staticChecks(publicInput);
|
|
210
|
+
const stateTo = await this.proveTransactionInternal(state, runtimeProof, executionData);
|
|
211
|
+
return new BlockProverPublicOutput({
|
|
212
|
+
...BlockProverStateCommitments.fromBlockProverState(stateTo),
|
|
213
|
+
closed: Bool(false),
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
async proveTransactions(publicInput, runtimeProof1, runtimeProof2, executionData) {
|
|
217
|
+
const state = BlockProverStateCommitments.toBlockProverState(publicInput, executionData.networkState);
|
|
218
|
+
this.staticChecks(publicInput);
|
|
219
|
+
const state1 = await this.proveTransactionInternal(state, runtimeProof1, {
|
|
220
|
+
transaction: executionData.transaction1,
|
|
221
|
+
networkState: executionData.networkState,
|
|
222
|
+
});
|
|
223
|
+
// Switch to next state record for 2nd tx beforeTx hook
|
|
224
|
+
// TODO Can be prevented by merging 1st afterTx + 2nd beforeTx
|
|
225
|
+
this.stateServiceProvider.popCurrentStateService();
|
|
226
|
+
const stateTo = await this.proveTransactionInternal(state1, runtimeProof2, {
|
|
227
|
+
transaction: executionData.transaction2,
|
|
228
|
+
networkState: executionData.networkState,
|
|
229
|
+
});
|
|
230
|
+
return new BlockProverPublicOutput({
|
|
231
|
+
...BlockProverStateCommitments.fromBlockProverState(stateTo),
|
|
232
|
+
closed: Bool(false),
|
|
233
|
+
});
|
|
234
|
+
}
|
|
235
|
+
includeSTProof(stateTransitionProof, apply, stateRoot, pendingSTBatchesHash, witnessedRootsHash) {
|
|
236
|
+
assertEqualsIf(stateTransitionProof.publicInput.currentBatchStateHash, Field(0), apply, "State for STProof has to be empty at the start");
|
|
237
|
+
assertEqualsIf(stateTransitionProof.publicOutput.currentBatchStateHash, Field(0), apply, "State for STProof has to be empty at the end");
|
|
238
|
+
assertEqualsIf(stateTransitionProof.publicInput.batchesHash, Field(0), apply, "Batcheshash doesn't start at 0");
|
|
239
|
+
// Assert from state root
|
|
240
|
+
assertEqualsIf(stateRoot, stateTransitionProof.publicInput.root, apply, errors.propertyNotMatching("from state root"));
|
|
241
|
+
// Assert the stBatchesHash executed is the same
|
|
242
|
+
assertEqualsIf(pendingSTBatchesHash, stateTransitionProof.publicOutput.batchesHash, apply, "Pending STBatches are not the same that have been executed by the ST proof");
|
|
243
|
+
// Assert root Accumulator
|
|
244
|
+
assertEqualsIf(Field(0), stateTransitionProof.publicInput.witnessedRootsHash, apply, errors.propertyNotMatching("from state root"));
|
|
245
|
+
// Assert the witnessedRootsHash created is the same
|
|
246
|
+
assertEqualsIf(witnessedRootsHash, stateTransitionProof.publicOutput.witnessedRootsHash, apply, "Root accumulator Commitment is not the same that have been executed by the ST proof");
|
|
247
|
+
// update root only if we didn't defer
|
|
248
|
+
const newRoot = Provable.if(apply, stateTransitionProof.publicOutput.root, stateRoot);
|
|
249
|
+
// Reset only if we didn't defer
|
|
250
|
+
const newBatchesHash = Provable.if(apply, Field(0), pendingSTBatchesHash);
|
|
251
|
+
const newWitnessedRootsHash = Provable.if(apply, Field(0), witnessedRootsHash);
|
|
252
|
+
return {
|
|
253
|
+
stateRoot: newRoot,
|
|
254
|
+
pendingSTBatchesHash: newBatchesHash,
|
|
255
|
+
witnessedRootsHash: newWitnessedRootsHash,
|
|
84
256
|
};
|
|
85
|
-
|
|
257
|
+
}
|
|
258
|
+
async proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, deferSTProof, afterBlockRootWitness, transactionProof) {
|
|
259
|
+
// 1. Make assertions about the inputs
|
|
260
|
+
publicInput.transactionsHash.assertEquals(Field(0), "Transactionshash has to start at 0");
|
|
261
|
+
// TransactionProof format checks
|
|
262
|
+
transactionProof.publicInput.blockHashRoot.assertEquals(Field(0), "TransactionProof cannot carry the blockHashRoot - publicInput");
|
|
263
|
+
transactionProof.publicOutput.blockHashRoot.assertEquals(Field(0), "TransactionProof cannot carry the blockHashRoot - publicOutput");
|
|
264
|
+
transactionProof.publicInput.networkStateHash.assertEquals(transactionProof.publicOutput.networkStateHash, "TransactionProof cannot alter the network state");
|
|
265
|
+
const state = BlockProverStateCommitments.toBlockProverState(publicInput, networkState);
|
|
266
|
+
// Verify Transaction proof if it has at least 1 tx - i.e. the
|
|
267
|
+
// input and output doesn't match fully
|
|
268
|
+
// We have to compare the whole input and output because we can make no
|
|
269
|
+
// assumptions about the values, since it can be an arbitrary dummy-proof
|
|
270
|
+
const txProofOutput = transactionProof.publicOutput;
|
|
271
|
+
const isEmptyTransition = txProofOutput.equals(transactionProof.publicInput, txProofOutput.closed);
|
|
272
|
+
const skipTransactionProofVerification = isEmptyTransition;
|
|
273
|
+
const verifyTransactionProof = isEmptyTransition.not();
|
|
274
|
+
log.provable.debug("VerifyIf TxProof", verifyTransactionProof);
|
|
275
|
+
transactionProof.verifyIf(verifyTransactionProof);
|
|
276
|
+
// 2. Execute beforeBlock hooks
|
|
277
|
+
const beforeBlockArgs = toProvableHookBlockState(state);
|
|
278
|
+
const beforeBlockResult = await this.executeBlockHooks(async (module, networkStateArg, args) => await module.beforeBlock(networkStateArg, args), beforeBlockArgs, networkState);
|
|
279
|
+
state.pendingSTBatches.push(beforeBlockResult.batch);
|
|
280
|
+
// 4. Apply TX-type BlockProof
|
|
281
|
+
transactionProof.publicInput.networkStateHash
|
|
282
|
+
.equals(beforeBlockResult.result.hash())
|
|
283
|
+
.or(skipTransactionProofVerification)
|
|
284
|
+
.assertTrue("TransactionProof networkstate hash not matching beforeBlock hook result");
|
|
285
|
+
transactionProof.publicInput.stateRoot.assertEquals(transactionProof.publicOutput.stateRoot, "TransactionProofs can't change the state root");
|
|
286
|
+
// Check that the transaction proof's STs start after the beforeBlock hook
|
|
287
|
+
transactionProof.publicInput.pendingSTBatchesHash.assertEquals(state.pendingSTBatches.commitment, "Transaction proof doesn't start their STs after the beforeBlockHook");
|
|
288
|
+
// Fast-forward the stBatchHashList to after all transactions appended
|
|
289
|
+
state.pendingSTBatches.commitment =
|
|
290
|
+
transactionProof.publicOutput.pendingSTBatchesHash;
|
|
291
|
+
// Fast-forward block content commitments by the results of the aggregated transaction proof
|
|
292
|
+
// Implicitly, the 'from' values here are asserted against the publicInput, since the hashlists
|
|
293
|
+
// are created out of the public input
|
|
294
|
+
state.transactionList.fastForward({
|
|
295
|
+
from: transactionProof.publicInput.transactionsHash,
|
|
296
|
+
to: transactionProof.publicOutput.transactionsHash,
|
|
297
|
+
});
|
|
298
|
+
state.eternalTransactionsList.fastForward({
|
|
299
|
+
from: transactionProof.publicInput.eternalTransactionsHash,
|
|
300
|
+
to: transactionProof.publicOutput.eternalTransactionsHash,
|
|
301
|
+
});
|
|
302
|
+
state.incomingMessages.fastForward({
|
|
303
|
+
from: transactionProof.publicInput.incomingMessagesHash,
|
|
304
|
+
to: transactionProof.publicOutput.incomingMessagesHash,
|
|
305
|
+
});
|
|
306
|
+
// Witness root
|
|
307
|
+
const isEmpty = state.pendingSTBatches.commitment.equals(0);
|
|
308
|
+
isEmpty
|
|
309
|
+
.implies(state.stateRoot.equals(afterBlockRootWitness.witnessedRoot))
|
|
310
|
+
.assertTrue();
|
|
311
|
+
state.witnessedRoots.witnessRoot({
|
|
312
|
+
appliedBatchListState: state.pendingSTBatches.commitment,
|
|
313
|
+
root: afterBlockRootWitness.witnessedRoot,
|
|
314
|
+
}, afterBlockRootWitness.preimage, isEmpty.not());
|
|
315
|
+
// 5. Calculate the new block tree hash
|
|
316
|
+
const blockIndex = blockWitness.calculateIndex();
|
|
317
|
+
blockIndex.assertEquals(publicInput.blockNumber);
|
|
318
|
+
blockWitness
|
|
319
|
+
.calculateRoot(Field(0))
|
|
320
|
+
.assertEquals(publicInput.blockHashRoot, "Supplied block hash witness not matching state root");
|
|
321
|
+
state.blockHashRoot = blockWitness.calculateRoot(new BlockHashTreeEntry({
|
|
322
|
+
block: {
|
|
323
|
+
index: blockIndex,
|
|
324
|
+
transactionListHash: state.transactionList.commitment,
|
|
325
|
+
},
|
|
326
|
+
closed: Bool(true),
|
|
327
|
+
}).hash());
|
|
328
|
+
// 6. Execute afterBlock hooks
|
|
329
|
+
// Switch state service to afterBlock one
|
|
330
|
+
this.stateServiceProvider.popCurrentStateService();
|
|
331
|
+
const afterBlockHookArgs = toProvableHookBlockState(state);
|
|
332
|
+
const afterBlockResult = await this.executeBlockHooks(async (module, networkStateArg, args) => await module.afterBlock(networkStateArg, args), {
|
|
333
|
+
...afterBlockHookArgs,
|
|
334
|
+
stateRoot: afterBlockRootWitness.witnessedRoot,
|
|
335
|
+
}, beforeBlockResult.result);
|
|
336
|
+
state.pendingSTBatches.push(afterBlockResult.batch);
|
|
337
|
+
state.networkState = afterBlockResult.result;
|
|
338
|
+
// 7. Close block
|
|
339
|
+
// Verify ST Proof only if STs have been emitted,
|
|
340
|
+
// and we don't defer the verification of the STs
|
|
341
|
+
// otherwise we can input a dummy proof
|
|
342
|
+
const batchesEmpty = state.pendingSTBatches.commitment.equals(Field(0));
|
|
343
|
+
const verifyStProof = deferSTProof.not().and(batchesEmpty.not());
|
|
344
|
+
log.provable.debug("Verify STProof", verifyStProof);
|
|
345
|
+
stateTransitionProof.verifyIf(verifyStProof);
|
|
346
|
+
// Apply STProof if not deferred
|
|
347
|
+
const stateProofResult = this.includeSTProof(stateTransitionProof, verifyStProof, state.stateRoot, state.pendingSTBatches.commitment, state.witnessedRoots.commitment);
|
|
348
|
+
state.stateRoot = stateProofResult.stateRoot;
|
|
349
|
+
state.pendingSTBatches.commitment = stateProofResult.pendingSTBatchesHash;
|
|
350
|
+
state.witnessedRoots.commitment = stateProofResult.witnessedRootsHash;
|
|
351
|
+
state.blockNumber = blockIndex.add(1);
|
|
86
352
|
return new BlockProverPublicOutput({
|
|
87
|
-
|
|
88
|
-
|
|
353
|
+
...BlockProverStateCommitments.fromBlockProverState(state),
|
|
354
|
+
closed: Bool(true),
|
|
89
355
|
});
|
|
90
356
|
}
|
|
91
|
-
merge(publicInput, proof1, proof2) {
|
|
357
|
+
async merge(publicInput, proof1, proof2) {
|
|
92
358
|
proof1.verify();
|
|
93
359
|
proof2.verify();
|
|
94
360
|
// Check state
|
|
95
361
|
publicInput.stateRoot.assertEquals(proof1.publicInput.stateRoot, errors.stateRootNotMatching("publicInput.from -> proof1.from"));
|
|
96
362
|
proof1.publicOutput.stateRoot.assertEquals(proof2.publicInput.stateRoot, errors.stateRootNotMatching("proof1.to -> proof2.from"));
|
|
97
|
-
// Check transaction list
|
|
98
|
-
|
|
99
|
-
|
|
363
|
+
// Check transaction list hash.
|
|
364
|
+
// Only assert them if these are tx proofs, skip for closed proofs
|
|
365
|
+
publicInput.transactionsHash
|
|
366
|
+
.equals(proof1.publicInput.transactionsHash)
|
|
367
|
+
.or(proof1.publicOutput.closed)
|
|
368
|
+
.assertTrue(errors.transactionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
369
|
+
proof1.publicOutput.transactionsHash
|
|
370
|
+
.equals(proof2.publicInput.transactionsHash)
|
|
371
|
+
.or(proof1.publicOutput.closed)
|
|
372
|
+
.assertTrue(errors.transactionsHashNotMatching("proof1.to -> proof2.from"));
|
|
373
|
+
// Check networkhash
|
|
374
|
+
publicInput.networkStateHash.assertEquals(proof1.publicInput.networkStateHash, errors.networkStateHashNotMatching("publicInput.from -> proof1.from"));
|
|
375
|
+
proof1.publicOutput.networkStateHash.assertEquals(proof2.publicInput.networkStateHash, errors.networkStateHashNotMatching("proof1.to -> proof2.from"));
|
|
376
|
+
// Check blockHashRoot
|
|
377
|
+
publicInput.blockHashRoot.assertEquals(proof1.publicInput.blockHashRoot, errors.transactionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
378
|
+
proof1.publicOutput.blockHashRoot.assertEquals(proof2.publicInput.blockHashRoot, errors.transactionsHashNotMatching("proof1.to -> proof2.from"));
|
|
379
|
+
// Check eternalTransactionsHash
|
|
380
|
+
publicInput.eternalTransactionsHash.assertEquals(proof1.publicInput.eternalTransactionsHash, errors.transactionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
381
|
+
proof1.publicOutput.eternalTransactionsHash.assertEquals(proof2.publicInput.eternalTransactionsHash, errors.transactionsHashNotMatching("proof1.to -> proof2.from"));
|
|
382
|
+
// Check incomingMessagesHash
|
|
383
|
+
publicInput.incomingMessagesHash.assertEquals(proof1.publicInput.incomingMessagesHash, errors.propertyNotMatchingStep("IncomingMessagesHash", "publicInput.from -> proof1.from"));
|
|
384
|
+
proof1.publicOutput.incomingMessagesHash.assertEquals(proof2.publicInput.incomingMessagesHash, errors.propertyNotMatchingStep("IncomingMessagesHash", "proof1.to -> proof2.from"));
|
|
385
|
+
// Check pendingSTBatchesHash
|
|
386
|
+
publicInput.pendingSTBatchesHash.assertEquals(proof1.publicInput.pendingSTBatchesHash, errors.transactionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
387
|
+
proof1.publicOutput.pendingSTBatchesHash.assertEquals(proof2.publicInput.pendingSTBatchesHash, errors.transactionsHashNotMatching("proof1.to -> proof2.from"));
|
|
388
|
+
// Check witnessedRootsHash
|
|
389
|
+
publicInput.witnessedRootsHash.assertEquals(proof1.publicInput.witnessedRootsHash, errors.transactionsHashNotMatching("publicInput.from -> proof1.from"));
|
|
390
|
+
proof1.publicOutput.witnessedRootsHash.assertEquals(proof2.publicInput.witnessedRootsHash, errors.transactionsHashNotMatching("proof1.to -> proof2.from"));
|
|
391
|
+
// Assert closed indicator matches
|
|
392
|
+
// (i.e. we can only merge TX-Type and Block-Type with each other)
|
|
393
|
+
proof1.publicOutput.closed.assertEquals(proof2.publicOutput.closed, "Closed indicators not matching");
|
|
394
|
+
// Either
|
|
395
|
+
// blockNumbers are unset and proofs are unclosed or
|
|
396
|
+
// both blocks are closed, then they have to increment or
|
|
397
|
+
// one block is closed, then height has to be the same
|
|
398
|
+
// Imperative algo would look like
|
|
399
|
+
// if(proof1.height == MAX && proof2.height == MAX){
|
|
400
|
+
// assert !proof1.closed && !proof2.closed;
|
|
401
|
+
// }else if(proof1.closed && proof2.closed){
|
|
402
|
+
// assert proof1.height + 1 == proof2.height
|
|
403
|
+
// // next one is omitted for now
|
|
404
|
+
// }else if(proof1.closed || proof2.closed{
|
|
405
|
+
// assert proof1.height == proof2.height
|
|
406
|
+
// }
|
|
407
|
+
const proof1Closed = proof1.publicOutput.closed;
|
|
408
|
+
const proof2Closed = proof2.publicOutput.closed;
|
|
409
|
+
const blockNumberProgressionValid = publicInput.blockNumber
|
|
410
|
+
.equals(proof1.publicInput.blockNumber)
|
|
411
|
+
.and(proof1.publicOutput.blockNumber.equals(proof2.publicInput.blockNumber));
|
|
412
|
+
// For tx proofs, we check that the progression starts and end with MAX
|
|
413
|
+
// in addition to that both proofs are non-closed
|
|
414
|
+
const isValidTransactionMerge = publicInput.blockNumber
|
|
415
|
+
.equals(MAX_FIELD)
|
|
416
|
+
.and(blockNumberProgressionValid)
|
|
417
|
+
.and(proof1Closed.or(proof2Closed).not());
|
|
418
|
+
const isValidClosedMerge = proof1Closed
|
|
419
|
+
.and(proof2Closed)
|
|
420
|
+
.and(blockNumberProgressionValid);
|
|
421
|
+
isValidTransactionMerge
|
|
422
|
+
.or(isValidClosedMerge)
|
|
423
|
+
.assertTrue("Invalid BlockProof merge");
|
|
100
424
|
return new BlockProverPublicOutput({
|
|
101
425
|
stateRoot: proof2.publicOutput.stateRoot,
|
|
102
426
|
transactionsHash: proof2.publicOutput.transactionsHash,
|
|
427
|
+
networkStateHash: proof2.publicOutput.networkStateHash,
|
|
428
|
+
blockHashRoot: proof2.publicOutput.blockHashRoot,
|
|
429
|
+
eternalTransactionsHash: proof2.publicOutput.eternalTransactionsHash,
|
|
430
|
+
incomingMessagesHash: proof2.publicOutput.incomingMessagesHash,
|
|
431
|
+
closed: isValidClosedMerge,
|
|
432
|
+
blockNumber: proof2.publicOutput.blockNumber,
|
|
433
|
+
pendingSTBatchesHash: proof2.publicOutput.pendingSTBatchesHash,
|
|
434
|
+
witnessedRootsHash: proof2.publicOutput.witnessedRootsHash,
|
|
103
435
|
});
|
|
104
436
|
}
|
|
105
437
|
/**
|
|
@@ -108,22 +440,47 @@ let BlockProver = class BlockProver extends ProtocolModule {
|
|
|
108
440
|
* injected StateTransitionProver and the required AppChainProof class
|
|
109
441
|
*/
|
|
110
442
|
zkProgramFactory() {
|
|
111
|
-
const
|
|
112
|
-
const
|
|
113
|
-
const proveTransaction =
|
|
114
|
-
const
|
|
115
|
-
const
|
|
443
|
+
const { prover, stateTransitionProver } = this;
|
|
444
|
+
const StateTransitionProofClass = stateTransitionProver.zkProgram[0].Proof;
|
|
445
|
+
const proveTransaction = prover.proveTransaction.bind(prover);
|
|
446
|
+
const proveTransactions = prover.proveTransactions.bind(prover);
|
|
447
|
+
const proveBlock = prover.proveBlock.bind(prover);
|
|
448
|
+
const merge = prover.merge.bind(prover);
|
|
449
|
+
const program = ZkProgram({
|
|
450
|
+
name: "BlockProver",
|
|
116
451
|
publicInput: BlockProverPublicInput,
|
|
117
452
|
publicOutput: BlockProverPublicOutput,
|
|
118
453
|
methods: {
|
|
119
454
|
proveTransaction: {
|
|
120
455
|
privateInputs: [
|
|
456
|
+
DynamicRuntimeProof,
|
|
457
|
+
BlockProverSingleTransactionExecutionData,
|
|
458
|
+
],
|
|
459
|
+
async method(publicInput, runtimeProof, executionData) {
|
|
460
|
+
return await proveTransaction(publicInput, runtimeProof, executionData);
|
|
461
|
+
},
|
|
462
|
+
},
|
|
463
|
+
proveTransactions: {
|
|
464
|
+
privateInputs: [
|
|
465
|
+
DynamicRuntimeProof,
|
|
466
|
+
DynamicRuntimeProof,
|
|
467
|
+
BlockProverMultiTransactionExecutionData,
|
|
468
|
+
],
|
|
469
|
+
async method(publicInput, runtimeProof1, runtimeProof2, executionData) {
|
|
470
|
+
return await proveTransactions(publicInput, runtimeProof1, runtimeProof2, executionData);
|
|
471
|
+
},
|
|
472
|
+
},
|
|
473
|
+
proveBlock: {
|
|
474
|
+
privateInputs: [
|
|
475
|
+
NetworkState,
|
|
476
|
+
BlockHashMerkleTreeWitness,
|
|
121
477
|
StateTransitionProofClass,
|
|
122
|
-
|
|
123
|
-
|
|
478
|
+
Bool,
|
|
479
|
+
WitnessedRootWitness,
|
|
480
|
+
(SelfProof),
|
|
124
481
|
],
|
|
125
|
-
method(publicInput,
|
|
126
|
-
return
|
|
482
|
+
async method(publicInput, networkState, blockWitness, stateTransitionProof, deferSTs, afterBlockRootWitness, transactionProof) {
|
|
483
|
+
return await proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, deferSTs, afterBlockRootWitness, transactionProof);
|
|
127
484
|
},
|
|
128
485
|
},
|
|
129
486
|
merge: {
|
|
@@ -131,41 +488,103 @@ let BlockProver = class BlockProver extends ProtocolModule {
|
|
|
131
488
|
(SelfProof),
|
|
132
489
|
(SelfProof),
|
|
133
490
|
],
|
|
134
|
-
method(publicInput, proof1, proof2) {
|
|
135
|
-
return merge(publicInput, proof1, proof2);
|
|
491
|
+
async method(publicInput, proof1, proof2) {
|
|
492
|
+
return await merge(publicInput, proof1, proof2);
|
|
136
493
|
},
|
|
137
494
|
},
|
|
138
495
|
},
|
|
139
496
|
});
|
|
140
497
|
const methods = {
|
|
141
498
|
proveTransaction: program.proveTransaction,
|
|
499
|
+
proveTransactions: program.proveTransactions,
|
|
500
|
+
proveBlock: program.proveBlock,
|
|
142
501
|
merge: program.merge,
|
|
143
502
|
};
|
|
144
|
-
const SelfProofClass =
|
|
145
|
-
return
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
503
|
+
const SelfProofClass = ZkProgram.Proof(program);
|
|
504
|
+
return [
|
|
505
|
+
{
|
|
506
|
+
name: program.name,
|
|
507
|
+
compile: program.compile.bind(program),
|
|
508
|
+
verify: program.verify.bind(program),
|
|
509
|
+
analyzeMethods: program.analyzeMethods.bind(program),
|
|
510
|
+
Proof: SelfProofClass,
|
|
511
|
+
methods,
|
|
512
|
+
},
|
|
513
|
+
];
|
|
151
514
|
}
|
|
152
|
-
}
|
|
515
|
+
}
|
|
516
|
+
__decorate([
|
|
517
|
+
provableMethod(),
|
|
518
|
+
__metadata("design:type", Function),
|
|
519
|
+
__metadata("design:paramtypes", [BlockProverPublicInput,
|
|
520
|
+
DynamicRuntimeProof,
|
|
521
|
+
BlockProverSingleTransactionExecutionData]),
|
|
522
|
+
__metadata("design:returntype", Promise)
|
|
523
|
+
], BlockProverProgrammable.prototype, "proveTransaction", null);
|
|
153
524
|
__decorate([
|
|
154
525
|
provableMethod(),
|
|
155
526
|
__metadata("design:type", Function),
|
|
156
|
-
__metadata("design:paramtypes", [BlockProverPublicInput,
|
|
157
|
-
|
|
158
|
-
|
|
527
|
+
__metadata("design:paramtypes", [BlockProverPublicInput,
|
|
528
|
+
DynamicRuntimeProof,
|
|
529
|
+
DynamicRuntimeProof,
|
|
530
|
+
BlockProverMultiTransactionExecutionData]),
|
|
531
|
+
__metadata("design:returntype", Promise)
|
|
532
|
+
], BlockProverProgrammable.prototype, "proveTransactions", null);
|
|
533
|
+
__decorate([
|
|
534
|
+
provableMethod(),
|
|
535
|
+
__metadata("design:type", Function),
|
|
536
|
+
__metadata("design:paramtypes", [BlockProverPublicInput,
|
|
537
|
+
NetworkState,
|
|
538
|
+
BlockHashMerkleTreeWitness, Object, Bool,
|
|
539
|
+
WitnessedRootWitness, Object]),
|
|
540
|
+
__metadata("design:returntype", Promise)
|
|
541
|
+
], BlockProverProgrammable.prototype, "proveBlock", null);
|
|
159
542
|
__decorate([
|
|
160
543
|
provableMethod(),
|
|
161
544
|
__metadata("design:type", Function),
|
|
162
545
|
__metadata("design:paramtypes", [BlockProverPublicInput, Object, Object]),
|
|
163
|
-
__metadata("design:returntype",
|
|
164
|
-
],
|
|
546
|
+
__metadata("design:returntype", Promise)
|
|
547
|
+
], BlockProverProgrammable.prototype, "merge", null);
|
|
548
|
+
/**
|
|
549
|
+
* BlockProver class, which aggregates a AppChainProof and
|
|
550
|
+
* a StateTransitionProof into a single BlockProof, that can
|
|
551
|
+
* then be merged to be committed to the base-layer contract
|
|
552
|
+
*/
|
|
553
|
+
export let BlockProver = class BlockProver extends ProtocolModule {
|
|
554
|
+
constructor(stateTransitionProver, runtime, transactionHooks, blockHooks, stateServiceProvider, verificationKeyService) {
|
|
555
|
+
super();
|
|
556
|
+
this.stateTransitionProver = stateTransitionProver;
|
|
557
|
+
this.runtime = runtime;
|
|
558
|
+
this.zkProgrammable = new BlockProverProgrammable(this, stateTransitionProver.zkProgrammable, transactionHooks, blockHooks, stateServiceProvider, verificationKeyService);
|
|
559
|
+
}
|
|
560
|
+
async compile(registry) {
|
|
561
|
+
return await registry.forceProverExists(async () => {
|
|
562
|
+
await this.stateTransitionProver.compile(registry);
|
|
563
|
+
await this.runtime.compile(registry);
|
|
564
|
+
return await this.zkProgrammable.compile(registry);
|
|
565
|
+
});
|
|
566
|
+
}
|
|
567
|
+
proveTransaction(publicInput, runtimeProof, executionData) {
|
|
568
|
+
return this.zkProgrammable.proveTransaction(publicInput, runtimeProof, executionData);
|
|
569
|
+
}
|
|
570
|
+
proveTransactions(publicInput, runtimeProof1, runtimeProof2, executionData) {
|
|
571
|
+
return this.zkProgrammable.proveTransactions(publicInput, runtimeProof1, runtimeProof2, executionData);
|
|
572
|
+
}
|
|
573
|
+
proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, deferSTs, afterBlockRootWitness, transactionProof) {
|
|
574
|
+
return this.zkProgrammable.proveBlock(publicInput, networkState, blockWitness, stateTransitionProof, deferSTs, afterBlockRootWitness, transactionProof);
|
|
575
|
+
}
|
|
576
|
+
merge(publicInput, proof1, proof2) {
|
|
577
|
+
return this.zkProgrammable.merge(publicInput, proof1, proof2);
|
|
578
|
+
}
|
|
579
|
+
};
|
|
165
580
|
BlockProver = __decorate([
|
|
166
581
|
injectable(),
|
|
167
582
|
__param(0, inject("StateTransitionProver")),
|
|
168
583
|
__param(1, inject("Runtime")),
|
|
169
|
-
|
|
584
|
+
__param(2, injectAll("ProvableTransactionHook")),
|
|
585
|
+
__param(3, injectAll("ProvableBlockHook")),
|
|
586
|
+
__param(4, inject("StateServiceProvider")),
|
|
587
|
+
__metadata("design:paramtypes", [Object, Object, Array, Array, StateServiceProvider,
|
|
588
|
+
RuntimeVerificationKeyRootService])
|
|
170
589
|
], BlockProver);
|
|
171
|
-
|
|
590
|
+
//# sourceMappingURL=BlockProver.js.map
|