@proto-kit/protocol 0.1.1-develop.191 → 0.1.1-develop.2024
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 +56 -0
- package/dist/hooks/AccountStateHook.d.ts.map +1 -0
- package/dist/hooks/AccountStateHook.js +62 -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 +59 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +60 -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 -28
- 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 -46
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +62 -57
- 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 +58 -18
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransition.js +13 -4
- 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 +87 -10
- 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 +22 -2
- package/dist/model/network/NetworkState.js.map +1 -0
- package/dist/model/transaction/AuthorizedTransaction.d.ts +122 -0
- package/dist/model/transaction/AuthorizedTransaction.d.ts.map +1 -0
- package/dist/model/transaction/AuthorizedTransaction.js +39 -0
- package/dist/model/transaction/AuthorizedTransaction.js.map +1 -0
- package/dist/model/transaction/RuntimeTransaction.d.ts +94 -34
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -1
- package/dist/model/transaction/RuntimeTransaction.js +72 -11
- package/dist/model/transaction/RuntimeTransaction.js.map +1 -0
- package/dist/model/transaction/SignedTransaction.d.ts +110 -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 +187 -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 +47 -21
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/Protocol.js +127 -26
- 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 +29 -0
- package/dist/protocol/ProvableBlockHook.d.ts.map +1 -0
- package/dist/protocol/ProvableBlockHook.js +20 -0
- package/dist/protocol/ProvableBlockHook.js.map +1 -0
- package/dist/protocol/ProvableTransactionHook.d.ts +35 -0
- package/dist/protocol/ProvableTransactionHook.d.ts.map +1 -0
- package/dist/protocol/ProvableTransactionHook.js +28 -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/BlockHashList.d.ts +263 -0
- package/dist/prover/accumulators/BlockHashList.d.ts.map +1 -0
- package/dist/prover/accumulators/BlockHashList.js +97 -0
- package/dist/prover/accumulators/BlockHashList.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 +123 -0
- package/dist/prover/accumulators/WitnessedRootHashList.d.ts.map +1 -0
- package/dist/prover/accumulators/WitnessedRootHashList.js +51 -0
- package/dist/prover/accumulators/WitnessedRootHashList.js.map +1 -0
- package/dist/prover/block/BlockProvable.d.ts +565 -96
- package/dist/prover/block/BlockProvable.d.ts.map +1 -1
- package/dist/prover/block/BlockProvable.js +196 -12
- package/dist/prover/block/BlockProvable.js.map +1 -0
- package/dist/prover/block/BlockProver.d.ts +52 -37
- package/dist/prover/block/BlockProver.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.js +327 -107
- 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 +29 -17
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +171 -73
- package/dist/prover/statetransition/StateTransitionProver.js.map +1 -0
- package/dist/prover/transaction/TransactionProvable.d.ts +626 -0
- package/dist/prover/transaction/TransactionProvable.d.ts.map +1 -0
- package/dist/prover/transaction/TransactionProvable.js +87 -0
- package/dist/prover/transaction/TransactionProvable.js.map +1 -0
- package/dist/prover/transaction/TransactionProver.d.ts +68 -0
- package/dist/prover/transaction/TransactionProver.d.ts.map +1 -0
- package/dist/prover/transaction/TransactionProver.js +301 -0
- package/dist/prover/transaction/TransactionProver.js.map +1 -0
- package/dist/prover/utils.d.ts +19 -0
- package/dist/prover/utils.d.ts.map +1 -0
- package/dist/prover/utils.js +67 -0
- package/dist/prover/utils.js.map +1 -0
- package/dist/settlement/ContractArgsRegistry.d.ts +13 -0
- package/dist/settlement/ContractArgsRegistry.d.ts.map +1 -0
- package/dist/settlement/ContractArgsRegistry.js +53 -0
- package/dist/settlement/ContractArgsRegistry.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 +47 -0
- package/dist/settlement/SettlementContractModule.d.ts.map +1 -0
- package/dist/settlement/SettlementContractModule.js +81 -0
- package/dist/settlement/SettlementContractModule.js.map +1 -0
- package/dist/settlement/contracts/BridgeContract.d.ts +119 -0
- package/dist/settlement/contracts/BridgeContract.d.ts.map +1 -0
- package/dist/settlement/contracts/BridgeContract.js +269 -0
- package/dist/settlement/contracts/BridgeContract.js.map +1 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.d.ts +18 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.js +42 -0
- package/dist/settlement/contracts/BridgeContractProtocolModule.js.map +1 -0
- package/dist/settlement/contracts/BridgingSettlementContractModule.d.ts +21 -0
- package/dist/settlement/contracts/BridgingSettlementContractModule.d.ts.map +1 -0
- package/dist/settlement/contracts/BridgingSettlementContractModule.js +81 -0
- package/dist/settlement/contracts/BridgingSettlementContractModule.js.map +1 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts +23 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.js +55 -0
- package/dist/settlement/contracts/DispatchContractProtocolModule.js.map +1 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts +50 -0
- package/dist/settlement/contracts/DispatchSmartContract.d.ts.map +1 -0
- package/dist/settlement/contracts/DispatchSmartContract.js +234 -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/SettlementSmartContractModule.d.ts +20 -0
- package/dist/settlement/contracts/SettlementSmartContractModule.d.ts.map +1 -0
- package/dist/settlement/contracts/SettlementSmartContractModule.js +56 -0
- package/dist/settlement/contracts/SettlementSmartContractModule.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/contracts/settlement/BridgingSettlementContract.d.ts +107 -0
- package/dist/settlement/contracts/settlement/BridgingSettlementContract.d.ts.map +1 -0
- package/dist/settlement/contracts/settlement/BridgingSettlementContract.js +188 -0
- package/dist/settlement/contracts/settlement/BridgingSettlementContract.js.map +1 -0
- package/dist/settlement/contracts/settlement/SettlementBase.d.ts +41 -0
- package/dist/settlement/contracts/settlement/SettlementBase.d.ts.map +1 -0
- package/dist/settlement/contracts/settlement/SettlementBase.js +105 -0
- package/dist/settlement/contracts/settlement/SettlementBase.js.map +1 -0
- package/dist/settlement/contracts/settlement/SettlementContract.d.ts +15 -0
- package/dist/settlement/contracts/settlement/SettlementContract.d.ts.map +1 -0
- package/dist/settlement/contracts/settlement/SettlementContract.js +72 -0
- package/dist/settlement/contracts/settlement/SettlementContract.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 +494 -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/messages/Withdrawal.d.ts +2 -0
- package/dist/settlement/messages/Withdrawal.d.ts.map +1 -0
- package/dist/settlement/messages/Withdrawal.js +3 -0
- package/dist/settlement/messages/Withdrawal.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 +9 -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/SimpleAsyncStateService.d.ts +6 -0
- package/dist/state/SimpleAsyncStateService.d.ts.map +1 -0
- package/dist/state/SimpleAsyncStateService.js +2 -0
- package/dist/state/SimpleAsyncStateService.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 +141 -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/WitnessBlockContext.d.ts +5 -0
- package/dist/state/WitnessBlockContext.d.ts.map +1 -0
- package/dist/state/WitnessBlockContext.js +42 -0
- package/dist/state/WitnessBlockContext.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 +20 -0
- package/dist/utils/MinaPrefixedProvableHashList.d.ts.map +1 -0
- package/dist/utils/MinaPrefixedProvableHashList.js +49 -0
- package/dist/utils/MinaPrefixedProvableHashList.js.map +1 -0
- package/dist/utils/PrefixedProvableHashList.d.ts +3 -2
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -1
- package/dist/utils/PrefixedProvableHashList.js +5 -1
- package/dist/utils/PrefixedProvableHashList.js.map +1 -0
- package/dist/utils/ProvableHashList.d.ts +27 -4
- package/dist/utils/ProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableHashList.js +51 -3
- 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/StateTransitionReductionList.d.ts +11 -0
- package/dist/utils/StateTransitionReductionList.d.ts.map +1 -0
- package/dist/utils/StateTransitionReductionList.js +61 -0
- package/dist/utils/StateTransitionReductionList.js.map +1 -0
- package/dist/utils/utils.d.ts +11 -5
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +13 -13
- 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 +80 -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 +59 -9
- package/src/model/AppliedStateTransitionBatch.ts +16 -0
- package/src/model/MethodPublicOutput.ts +3 -1
- package/src/model/Option.ts +99 -73
- package/src/model/Path.ts +9 -5
- package/src/model/RuntimeLike.ts +12 -0
- package/src/model/StateTransition.ts +19 -5
- package/src/model/StateTransitionProvableBatch.ts +114 -12
- package/src/model/Transaction.ts +3 -1
- package/src/model/network/NetworkState.ts +22 -2
- package/src/model/transaction/AuthorizedTransaction.ts +50 -0
- package/src/model/transaction/RuntimeTransaction.ts +86 -15
- package/src/model/transaction/ValueOption.ts +28 -0
- package/src/protocol/Protocol.ts +201 -69
- package/src/protocol/ProtocolEnvironment.ts +10 -0
- package/src/protocol/ProtocolModule.ts +16 -15
- package/src/protocol/ProvableBlockHook.ts +67 -0
- package/src/protocol/ProvableTransactionHook.ts +96 -0
- package/src/protocol/TransitioningProtocolModule.ts +12 -0
- package/src/prover/accumulators/AppliedBatchHashList.ts +32 -0
- package/src/prover/accumulators/BlockHashList.ts +117 -0
- package/src/prover/accumulators/StateTransitionReductionList.ts +92 -0
- package/src/prover/accumulators/TransactionHashList.ts +9 -0
- package/src/prover/accumulators/WitnessedRootHashList.ts +62 -0
- package/src/prover/block/BlockProvable.ts +360 -28
- package/src/prover/block/BlockProver.ts +721 -186
- 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 +337 -126
- package/src/prover/transaction/TransactionProvable.ts +183 -0
- package/src/prover/transaction/TransactionProver.ts +561 -0
- package/src/prover/utils.ts +108 -0
- package/src/settlement/ContractArgsRegistry.ts +60 -0
- package/src/settlement/ContractModule.ts +31 -0
- package/src/settlement/SettlementContractModule.ts +150 -0
- package/src/settlement/contracts/BridgeContract.ts +385 -0
- package/src/settlement/contracts/BridgeContractProtocolModule.ts +49 -0
- package/src/settlement/contracts/BridgingSettlementContractModule.ts +116 -0
- package/src/settlement/contracts/DispatchContractProtocolModule.ts +77 -0
- package/src/settlement/contracts/DispatchSmartContract.ts +359 -0
- package/src/settlement/contracts/SettlementSmartContractModule.ts +79 -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/contracts/settlement/BridgingSettlementContract.ts +283 -0
- package/src/settlement/contracts/settlement/SettlementBase.ts +249 -0
- package/src/settlement/contracts/settlement/SettlementContract.ts +75 -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 +23 -0
- package/src/settlement/modules/NetworkStateSettlementModule.ts +42 -0
- package/src/state/State.ts +190 -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/WitnessBlockContext.ts +50 -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 +70 -0
- package/src/utils/PrefixedProvableHashList.ts +6 -2
- package/src/utils/ProvableHashList.ts +109 -4
- package/src/utils/ProvableReductionHashList.ts +77 -0
- package/src/utils/utils.ts +21 -16
- 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 +36 -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 +0 -3
- package/LICENSE.md +0 -201
- 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/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/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/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 -255
- package/src/utils/merkletree/VirtualMerkleTreeStore.ts +0 -21
- package/tsconfig.test.json +0 -9
|
@@ -0,0 +1,561 @@
|
|
|
1
|
+
import {
|
|
2
|
+
AreProofsEnabled,
|
|
3
|
+
CompilableModule,
|
|
4
|
+
CompileArtifact,
|
|
5
|
+
CompileRegistry,
|
|
6
|
+
PlainZkProgram,
|
|
7
|
+
provableMethod,
|
|
8
|
+
WithZkProgrammable,
|
|
9
|
+
ZkProgrammable,
|
|
10
|
+
} from "@proto-kit/common";
|
|
11
|
+
import { Bool, Field, SelfProof, VerificationKey, ZkProgram } from "o1js";
|
|
12
|
+
import { inject, injectable, injectAll } from "tsyringe";
|
|
13
|
+
|
|
14
|
+
import { NetworkState } from "../../model/network/NetworkState";
|
|
15
|
+
import { ProtocolModule } from "../../protocol/ProtocolModule";
|
|
16
|
+
import { MethodPublicOutput } from "../../model/MethodPublicOutput";
|
|
17
|
+
import {
|
|
18
|
+
AfterTransactionHookArguments,
|
|
19
|
+
BeforeTransactionHookArguments,
|
|
20
|
+
ProvableTransactionHook,
|
|
21
|
+
toAfterTransactionHookArgument,
|
|
22
|
+
toBeforeTransactionHookArgument,
|
|
23
|
+
} from "../../protocol/ProvableTransactionHook";
|
|
24
|
+
import { StateServiceProvider } from "../../state/StateServiceProvider";
|
|
25
|
+
import { RuntimeVerificationKeyRootService } from "../block/services/RuntimeVerificationKeyRootService";
|
|
26
|
+
import { addTransactionToBundle, executeHooks } from "../utils";
|
|
27
|
+
import { AuthorizedTransaction } from "../../model/transaction/AuthorizedTransaction";
|
|
28
|
+
import {
|
|
29
|
+
MethodVKConfigData,
|
|
30
|
+
MinimalVKTreeService,
|
|
31
|
+
RuntimeVerificationKeyAttestation,
|
|
32
|
+
} from "../block/accummulators/RuntimeVerificationKeyTree";
|
|
33
|
+
|
|
34
|
+
import {
|
|
35
|
+
TransactionProverExecutionData,
|
|
36
|
+
DynamicRuntimeProof,
|
|
37
|
+
TransactionProof,
|
|
38
|
+
TransactionProvable,
|
|
39
|
+
TransactionProverArguments,
|
|
40
|
+
TransactionProverPublicInput,
|
|
41
|
+
TransactionProverPublicOutput,
|
|
42
|
+
TransactionProverState,
|
|
43
|
+
TransactionProverTransactionArguments,
|
|
44
|
+
} from "./TransactionProvable";
|
|
45
|
+
|
|
46
|
+
const errors = {
|
|
47
|
+
invalidZkProgramTreeRoot: () =>
|
|
48
|
+
"Root hash of the provided zkProgram config witness is invalid",
|
|
49
|
+
|
|
50
|
+
propertyNotMatchingStep: (propertyName: string, step: string) =>
|
|
51
|
+
`${propertyName} not matching: ${step}`,
|
|
52
|
+
|
|
53
|
+
transactionsHashNotMatching: (step: string) =>
|
|
54
|
+
errors.propertyNotMatchingStep("Transactions hash", step),
|
|
55
|
+
|
|
56
|
+
bundlesHashNotMatching: (step: string) =>
|
|
57
|
+
errors.propertyNotMatchingStep("Bundles hash", step),
|
|
58
|
+
};
|
|
59
|
+
|
|
60
|
+
type ApplyTransactionArguments = Omit<
|
|
61
|
+
TransactionProverTransactionArguments,
|
|
62
|
+
"verificationKeyAttestation"
|
|
63
|
+
>;
|
|
64
|
+
|
|
65
|
+
type TransactionHookArgument<T extends "before" | "after"> = T extends "before"
|
|
66
|
+
? BeforeTransactionHookArguments
|
|
67
|
+
: AfterTransactionHookArguments;
|
|
68
|
+
|
|
69
|
+
export class TransactionProverZkProgrammable extends ZkProgrammable<
|
|
70
|
+
TransactionProverPublicInput,
|
|
71
|
+
TransactionProverPublicOutput
|
|
72
|
+
> {
|
|
73
|
+
public constructor(
|
|
74
|
+
private readonly prover: TransactionProver,
|
|
75
|
+
private readonly transactionHooks: ProvableTransactionHook<unknown>[],
|
|
76
|
+
private readonly stateServiceProvider: StateServiceProvider,
|
|
77
|
+
private readonly verificationKeyService: MinimalVKTreeService
|
|
78
|
+
) {
|
|
79
|
+
super();
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
name = "TransactionProver";
|
|
83
|
+
|
|
84
|
+
public get areProofsEnabled(): AreProofsEnabled | undefined {
|
|
85
|
+
return this.prover.areProofsEnabled;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/**
|
|
89
|
+
* Applies and checks the two proofs and applies the corresponding state
|
|
90
|
+
* changes to the given state.
|
|
91
|
+
*
|
|
92
|
+
* The rough high level workflow of this function:
|
|
93
|
+
* 1. Execute beforeTransaction hooks, pushing the ST batch
|
|
94
|
+
* 2. Add Transaction to bundle, meaning appending it to all the respective commitments
|
|
95
|
+
* 3. Push the runtime ST batch
|
|
96
|
+
* 4. Execute afterTransaction hooks, pushing the ST batch
|
|
97
|
+
* 5. Some consistency checks and signature verification
|
|
98
|
+
*
|
|
99
|
+
* @param fromState The from-state of the BlockProver
|
|
100
|
+
* @param runtimeOutput
|
|
101
|
+
* @param executionData
|
|
102
|
+
* @param networkState
|
|
103
|
+
* @param bundleListPreimage
|
|
104
|
+
* @returns The new BlockProver-state to be used as public output
|
|
105
|
+
*/
|
|
106
|
+
public async applyTransaction(
|
|
107
|
+
fromState: TransactionProverState,
|
|
108
|
+
runtimeOutput: MethodPublicOutput,
|
|
109
|
+
executionData: ApplyTransactionArguments,
|
|
110
|
+
networkState: NetworkState
|
|
111
|
+
): Promise<TransactionProverState> {
|
|
112
|
+
const { transaction, signature } = executionData;
|
|
113
|
+
|
|
114
|
+
let state = { ...fromState };
|
|
115
|
+
|
|
116
|
+
const { isMessage } = runtimeOutput;
|
|
117
|
+
|
|
118
|
+
const authorizedTransaction = new AuthorizedTransaction({
|
|
119
|
+
transaction,
|
|
120
|
+
signature,
|
|
121
|
+
isMessage,
|
|
122
|
+
});
|
|
123
|
+
|
|
124
|
+
const beforeTxHookArguments = toBeforeTransactionHookArgument(
|
|
125
|
+
authorizedTransaction,
|
|
126
|
+
networkState,
|
|
127
|
+
state
|
|
128
|
+
);
|
|
129
|
+
|
|
130
|
+
// Apply beforeTransaction hook state transitions
|
|
131
|
+
const beforeBatch = await this.executeTransactionHooks(
|
|
132
|
+
"before",
|
|
133
|
+
async (module, args) => await module.beforeTransaction(args),
|
|
134
|
+
beforeTxHookArguments,
|
|
135
|
+
isMessage
|
|
136
|
+
);
|
|
137
|
+
|
|
138
|
+
state.pendingSTBatches.push(beforeBatch);
|
|
139
|
+
|
|
140
|
+
state.pendingSTBatches.push({
|
|
141
|
+
batchHash: runtimeOutput.stateTransitionsHash,
|
|
142
|
+
applied: runtimeOutput.status,
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
state = addTransactionToBundle(state, runtimeOutput.isMessage, transaction);
|
|
146
|
+
|
|
147
|
+
// Apply afterTransaction hook state transitions
|
|
148
|
+
const afterTxHookArguments = toAfterTransactionHookArgument(
|
|
149
|
+
authorizedTransaction,
|
|
150
|
+
networkState,
|
|
151
|
+
state,
|
|
152
|
+
runtimeOutput
|
|
153
|
+
);
|
|
154
|
+
|
|
155
|
+
// Switch to different state set for afterTx hooks
|
|
156
|
+
this.stateServiceProvider.popCurrentStateService();
|
|
157
|
+
|
|
158
|
+
const afterBatch = await this.executeTransactionHooks(
|
|
159
|
+
"after",
|
|
160
|
+
async (module, args) => await module.afterTransaction(args),
|
|
161
|
+
afterTxHookArguments,
|
|
162
|
+
isMessage
|
|
163
|
+
);
|
|
164
|
+
state.pendingSTBatches.push(afterBatch);
|
|
165
|
+
|
|
166
|
+
// Check transaction integrity against appProof
|
|
167
|
+
const blockTransactionHash = transaction.hash();
|
|
168
|
+
|
|
169
|
+
blockTransactionHash.assertEquals(
|
|
170
|
+
runtimeOutput.transactionHash,
|
|
171
|
+
"Transactions provided in AppProof and BlockProof do not match"
|
|
172
|
+
);
|
|
173
|
+
|
|
174
|
+
// Check transaction signature or isMessage
|
|
175
|
+
authorizedTransaction
|
|
176
|
+
.validateAuthorization()
|
|
177
|
+
.assertTrue("Transaction authorization not valid");
|
|
178
|
+
|
|
179
|
+
// Validate layout of transaction witness
|
|
180
|
+
transaction.assertTransactionType(isMessage);
|
|
181
|
+
|
|
182
|
+
return new TransactionProverState(state);
|
|
183
|
+
}
|
|
184
|
+
|
|
185
|
+
private verifyVerificationKeyAttestation(
|
|
186
|
+
attestation: RuntimeVerificationKeyAttestation,
|
|
187
|
+
methodId: Field
|
|
188
|
+
): VerificationKey {
|
|
189
|
+
// Verify the [methodId, vk] tuple against the baked-in vk tree root
|
|
190
|
+
const { verificationKey, witness: verificationKeyTreeWitness } =
|
|
191
|
+
attestation;
|
|
192
|
+
|
|
193
|
+
const root = Field(this.verificationKeyService.getRoot());
|
|
194
|
+
const calculatedRoot = verificationKeyTreeWitness.calculateRoot(
|
|
195
|
+
new MethodVKConfigData({
|
|
196
|
+
methodId: methodId,
|
|
197
|
+
vkHash: verificationKey.hash,
|
|
198
|
+
}).hash()
|
|
199
|
+
);
|
|
200
|
+
root.assertEquals(calculatedRoot, errors.invalidZkProgramTreeRoot());
|
|
201
|
+
|
|
202
|
+
return verificationKey;
|
|
203
|
+
}
|
|
204
|
+
|
|
205
|
+
private async executeTransactionHooks<T extends "before" | "after">(
|
|
206
|
+
type: T,
|
|
207
|
+
hook: (
|
|
208
|
+
module: ProvableTransactionHook<unknown>,
|
|
209
|
+
args: TransactionHookArgument<T>
|
|
210
|
+
) => Promise<void>,
|
|
211
|
+
hookArguments: TransactionHookArgument<T>,
|
|
212
|
+
isMessage: Bool
|
|
213
|
+
) {
|
|
214
|
+
const { batch, rawStatus } = await executeHooks(
|
|
215
|
+
{
|
|
216
|
+
transaction: hookArguments.transaction.transaction,
|
|
217
|
+
networkState: hookArguments.networkState,
|
|
218
|
+
},
|
|
219
|
+
`${type}Transaction`,
|
|
220
|
+
async () => {
|
|
221
|
+
for (const module of this.transactionHooks) {
|
|
222
|
+
// eslint-disable-next-line no-await-in-loop
|
|
223
|
+
await hook(module, hookArguments);
|
|
224
|
+
}
|
|
225
|
+
},
|
|
226
|
+
isMessage
|
|
227
|
+
);
|
|
228
|
+
|
|
229
|
+
// This is going to set applied to false in case the hook fails
|
|
230
|
+
// (that's only possible for messages though as others are hard-asserted)
|
|
231
|
+
batch.applied = rawStatus;
|
|
232
|
+
|
|
233
|
+
return batch;
|
|
234
|
+
}
|
|
235
|
+
|
|
236
|
+
public async proveTransactionInternal(
|
|
237
|
+
publicInput: TransactionProverPublicInput,
|
|
238
|
+
runtimeProof: DynamicRuntimeProof,
|
|
239
|
+
transaction: TransactionProverTransactionArguments,
|
|
240
|
+
args: TransactionProverArguments
|
|
241
|
+
): Promise<TransactionProverPublicOutput> {
|
|
242
|
+
const state = TransactionProverState.fromCommitments(publicInput, args);
|
|
243
|
+
|
|
244
|
+
state.bundleList.checkLastBundleElement(state, args.networkState);
|
|
245
|
+
|
|
246
|
+
const verificationKey = this.verifyVerificationKeyAttestation(
|
|
247
|
+
transaction.verificationKeyAttestation,
|
|
248
|
+
transaction.transaction.methodId
|
|
249
|
+
);
|
|
250
|
+
|
|
251
|
+
runtimeProof.verify(verificationKey);
|
|
252
|
+
|
|
253
|
+
const result = await this.applyTransaction(
|
|
254
|
+
state,
|
|
255
|
+
runtimeProof.publicOutput,
|
|
256
|
+
transaction,
|
|
257
|
+
args.networkState
|
|
258
|
+
);
|
|
259
|
+
|
|
260
|
+
result.bundleList.addToBundle(result, args.networkState);
|
|
261
|
+
|
|
262
|
+
return result.toCommitments();
|
|
263
|
+
}
|
|
264
|
+
|
|
265
|
+
@provableMethod()
|
|
266
|
+
public async proveTransaction(
|
|
267
|
+
publicInput: TransactionProverPublicInput,
|
|
268
|
+
runtimeProof: DynamicRuntimeProof,
|
|
269
|
+
executionData: TransactionProverExecutionData
|
|
270
|
+
): Promise<TransactionProverPublicOutput> {
|
|
271
|
+
return await this.proveTransactionInternal(
|
|
272
|
+
publicInput,
|
|
273
|
+
runtimeProof,
|
|
274
|
+
executionData.transaction,
|
|
275
|
+
executionData.args
|
|
276
|
+
);
|
|
277
|
+
}
|
|
278
|
+
|
|
279
|
+
@provableMethod()
|
|
280
|
+
public async proveTransactions(
|
|
281
|
+
publicInput: TransactionProverPublicInput,
|
|
282
|
+
runtimeProof1: DynamicRuntimeProof,
|
|
283
|
+
runtimeProof2: DynamicRuntimeProof,
|
|
284
|
+
executionData1: TransactionProverExecutionData,
|
|
285
|
+
executionData2: TransactionProverExecutionData
|
|
286
|
+
): Promise<TransactionProverPublicOutput> {
|
|
287
|
+
const state1 = await this.proveTransactionInternal(
|
|
288
|
+
publicInput,
|
|
289
|
+
runtimeProof1,
|
|
290
|
+
executionData1.transaction,
|
|
291
|
+
executionData1.args
|
|
292
|
+
);
|
|
293
|
+
|
|
294
|
+
// Switch to next state record for 2nd tx beforeTx hook
|
|
295
|
+
this.stateServiceProvider.popCurrentStateService();
|
|
296
|
+
|
|
297
|
+
return await this.proveTransactionInternal(
|
|
298
|
+
state1,
|
|
299
|
+
runtimeProof2,
|
|
300
|
+
executionData2.transaction,
|
|
301
|
+
executionData2.args
|
|
302
|
+
);
|
|
303
|
+
}
|
|
304
|
+
|
|
305
|
+
@provableMethod()
|
|
306
|
+
public async dummy(
|
|
307
|
+
publicInput: TransactionProverPublicInput
|
|
308
|
+
): Promise<TransactionProverPublicOutput> {
|
|
309
|
+
return publicInput;
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
@provableMethod()
|
|
313
|
+
public async merge(
|
|
314
|
+
publicInput: TransactionProverPublicInput,
|
|
315
|
+
proof1: TransactionProof,
|
|
316
|
+
proof2: TransactionProof
|
|
317
|
+
): Promise<TransactionProverPublicOutput> {
|
|
318
|
+
proof1.verify();
|
|
319
|
+
proof2.verify();
|
|
320
|
+
|
|
321
|
+
// Check bundlesHash
|
|
322
|
+
publicInput.bundlesHash.assertEquals(
|
|
323
|
+
proof1.publicInput.bundlesHash,
|
|
324
|
+
errors.bundlesHashNotMatching("publicInput.from -> proof1.from")
|
|
325
|
+
);
|
|
326
|
+
proof1.publicOutput.bundlesHash.assertEquals(
|
|
327
|
+
proof2.publicInput.bundlesHash,
|
|
328
|
+
errors.bundlesHashNotMatching("proof1.to -> proof2.from")
|
|
329
|
+
);
|
|
330
|
+
|
|
331
|
+
// Check eternalTransactionsHash
|
|
332
|
+
publicInput.eternalTransactionsHash.assertEquals(
|
|
333
|
+
proof1.publicInput.eternalTransactionsHash,
|
|
334
|
+
errors.transactionsHashNotMatching("publicInput.from -> proof1.from")
|
|
335
|
+
);
|
|
336
|
+
proof1.publicOutput.eternalTransactionsHash.assertEquals(
|
|
337
|
+
proof2.publicInput.eternalTransactionsHash,
|
|
338
|
+
errors.transactionsHashNotMatching("proof1.to -> proof2.from")
|
|
339
|
+
);
|
|
340
|
+
|
|
341
|
+
// Check incomingMessagesHash
|
|
342
|
+
publicInput.incomingMessagesHash.assertEquals(
|
|
343
|
+
proof1.publicInput.incomingMessagesHash,
|
|
344
|
+
errors.propertyNotMatchingStep(
|
|
345
|
+
"IncomingMessagesHash",
|
|
346
|
+
"publicInput.from -> proof1.from"
|
|
347
|
+
)
|
|
348
|
+
);
|
|
349
|
+
proof1.publicOutput.incomingMessagesHash.assertEquals(
|
|
350
|
+
proof2.publicInput.incomingMessagesHash,
|
|
351
|
+
errors.propertyNotMatchingStep(
|
|
352
|
+
"IncomingMessagesHash",
|
|
353
|
+
"proof1.to -> proof2.from"
|
|
354
|
+
)
|
|
355
|
+
);
|
|
356
|
+
|
|
357
|
+
return new TransactionProverPublicOutput({
|
|
358
|
+
bundlesHash: proof2.publicOutput.bundlesHash,
|
|
359
|
+
eternalTransactionsHash: proof2.publicOutput.eternalTransactionsHash,
|
|
360
|
+
incomingMessagesHash: proof2.publicOutput.incomingMessagesHash,
|
|
361
|
+
});
|
|
362
|
+
}
|
|
363
|
+
|
|
364
|
+
/**
|
|
365
|
+
* Creates the BlockProver ZkProgram.
|
|
366
|
+
* Recursive linking of proofs is done via the previously
|
|
367
|
+
* injected StateTransitionProver and the required AppChainProof class
|
|
368
|
+
*/
|
|
369
|
+
public zkProgramFactory(): PlainZkProgram<
|
|
370
|
+
TransactionProverPublicInput,
|
|
371
|
+
TransactionProverPublicOutput
|
|
372
|
+
>[] {
|
|
373
|
+
const { prover } = this;
|
|
374
|
+
const proveTransaction = prover.proveTransaction.bind(prover);
|
|
375
|
+
const proveTransactions = prover.proveTransactions.bind(prover);
|
|
376
|
+
const merge = prover.merge.bind(prover);
|
|
377
|
+
const dummy = prover.dummy.bind(prover);
|
|
378
|
+
|
|
379
|
+
const program = ZkProgram({
|
|
380
|
+
name: "TransactionProver",
|
|
381
|
+
publicInput: TransactionProverPublicInput,
|
|
382
|
+
publicOutput: TransactionProverPublicOutput,
|
|
383
|
+
|
|
384
|
+
methods: {
|
|
385
|
+
proveTransaction: {
|
|
386
|
+
privateInputs: [DynamicRuntimeProof, TransactionProverExecutionData],
|
|
387
|
+
|
|
388
|
+
async method(
|
|
389
|
+
publicInput: TransactionProverPublicInput,
|
|
390
|
+
runtimeProof: DynamicRuntimeProof,
|
|
391
|
+
executionData: TransactionProverExecutionData
|
|
392
|
+
) {
|
|
393
|
+
return {
|
|
394
|
+
publicOutput: await proveTransaction(
|
|
395
|
+
publicInput,
|
|
396
|
+
runtimeProof,
|
|
397
|
+
executionData
|
|
398
|
+
),
|
|
399
|
+
};
|
|
400
|
+
},
|
|
401
|
+
},
|
|
402
|
+
|
|
403
|
+
proveTransactions: {
|
|
404
|
+
privateInputs: [
|
|
405
|
+
DynamicRuntimeProof,
|
|
406
|
+
DynamicRuntimeProof,
|
|
407
|
+
TransactionProverExecutionData,
|
|
408
|
+
TransactionProverExecutionData,
|
|
409
|
+
],
|
|
410
|
+
|
|
411
|
+
async method(
|
|
412
|
+
publicInput: TransactionProverPublicInput,
|
|
413
|
+
runtimeProof1: DynamicRuntimeProof,
|
|
414
|
+
runtimeProof2: DynamicRuntimeProof,
|
|
415
|
+
executionData1: TransactionProverExecutionData,
|
|
416
|
+
executionData2: TransactionProverExecutionData
|
|
417
|
+
) {
|
|
418
|
+
return {
|
|
419
|
+
publicOutput: await proveTransactions(
|
|
420
|
+
publicInput,
|
|
421
|
+
runtimeProof1,
|
|
422
|
+
runtimeProof2,
|
|
423
|
+
executionData1,
|
|
424
|
+
executionData2
|
|
425
|
+
),
|
|
426
|
+
};
|
|
427
|
+
},
|
|
428
|
+
},
|
|
429
|
+
|
|
430
|
+
dummy: {
|
|
431
|
+
privateInputs: [],
|
|
432
|
+
async method(publicInput: TransactionProverPublicInput) {
|
|
433
|
+
return { publicOutput: await dummy(publicInput) };
|
|
434
|
+
},
|
|
435
|
+
},
|
|
436
|
+
|
|
437
|
+
merge: {
|
|
438
|
+
privateInputs: [
|
|
439
|
+
SelfProof<
|
|
440
|
+
TransactionProverPublicInput,
|
|
441
|
+
TransactionProverPublicOutput
|
|
442
|
+
>,
|
|
443
|
+
SelfProof<
|
|
444
|
+
TransactionProverPublicInput,
|
|
445
|
+
TransactionProverPublicOutput
|
|
446
|
+
>,
|
|
447
|
+
],
|
|
448
|
+
|
|
449
|
+
async method(
|
|
450
|
+
publicInput: TransactionProverPublicInput,
|
|
451
|
+
proof1: TransactionProof,
|
|
452
|
+
proof2: TransactionProof
|
|
453
|
+
) {
|
|
454
|
+
return { publicOutput: await merge(publicInput, proof1, proof2) };
|
|
455
|
+
},
|
|
456
|
+
},
|
|
457
|
+
},
|
|
458
|
+
});
|
|
459
|
+
|
|
460
|
+
const methods = {
|
|
461
|
+
proveTransaction: program.proveTransaction,
|
|
462
|
+
proveTransactions: program.proveTransactions,
|
|
463
|
+
dummy: program.dummy,
|
|
464
|
+
merge: program.merge,
|
|
465
|
+
};
|
|
466
|
+
|
|
467
|
+
const SelfProofClass = ZkProgram.Proof(program);
|
|
468
|
+
|
|
469
|
+
return [
|
|
470
|
+
{
|
|
471
|
+
name: program.name,
|
|
472
|
+
compile: program.compile.bind(program),
|
|
473
|
+
verify: program.verify.bind(program),
|
|
474
|
+
analyzeMethods: program.analyzeMethods.bind(program),
|
|
475
|
+
Proof: SelfProofClass,
|
|
476
|
+
methods,
|
|
477
|
+
},
|
|
478
|
+
];
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
/**
|
|
483
|
+
* BlockProver class, which aggregates a AppChainProof and
|
|
484
|
+
* a StateTransitionProof into a single BlockProof, that can
|
|
485
|
+
* then be merged to be committed to the base-layer contract
|
|
486
|
+
*/
|
|
487
|
+
@injectable()
|
|
488
|
+
export class TransactionProver
|
|
489
|
+
extends ProtocolModule
|
|
490
|
+
implements TransactionProvable, CompilableModule
|
|
491
|
+
{
|
|
492
|
+
public zkProgrammable: TransactionProverZkProgrammable;
|
|
493
|
+
|
|
494
|
+
public constructor(
|
|
495
|
+
@inject("Runtime")
|
|
496
|
+
public readonly runtime: WithZkProgrammable<undefined, MethodPublicOutput> &
|
|
497
|
+
CompilableModule,
|
|
498
|
+
@injectAll("ProvableTransactionHook")
|
|
499
|
+
transactionHooks: ProvableTransactionHook<unknown>[],
|
|
500
|
+
@inject("StateServiceProvider")
|
|
501
|
+
stateServiceProvider: StateServiceProvider,
|
|
502
|
+
verificationKeyService: RuntimeVerificationKeyRootService
|
|
503
|
+
) {
|
|
504
|
+
super();
|
|
505
|
+
this.zkProgrammable = new TransactionProverZkProgrammable(
|
|
506
|
+
this,
|
|
507
|
+
transactionHooks,
|
|
508
|
+
stateServiceProvider,
|
|
509
|
+
verificationKeyService
|
|
510
|
+
);
|
|
511
|
+
}
|
|
512
|
+
|
|
513
|
+
public async compile(
|
|
514
|
+
registry: CompileRegistry
|
|
515
|
+
): Promise<Record<string, CompileArtifact> | undefined> {
|
|
516
|
+
return await registry.forceProverExists(async () => {
|
|
517
|
+
await this.runtime.compile(registry);
|
|
518
|
+
return await this.zkProgrammable.compile(registry);
|
|
519
|
+
});
|
|
520
|
+
}
|
|
521
|
+
|
|
522
|
+
public proveTransaction(
|
|
523
|
+
publicInput: TransactionProverPublicInput,
|
|
524
|
+
runtimeProof: DynamicRuntimeProof,
|
|
525
|
+
executionData: TransactionProverExecutionData
|
|
526
|
+
): Promise<TransactionProverPublicOutput> {
|
|
527
|
+
return this.zkProgrammable.proveTransaction(
|
|
528
|
+
publicInput,
|
|
529
|
+
runtimeProof,
|
|
530
|
+
executionData
|
|
531
|
+
);
|
|
532
|
+
}
|
|
533
|
+
|
|
534
|
+
public proveTransactions(
|
|
535
|
+
publicInput: TransactionProverPublicInput,
|
|
536
|
+
runtimeProof1: DynamicRuntimeProof,
|
|
537
|
+
runtimeProof2: DynamicRuntimeProof,
|
|
538
|
+
executionData1: TransactionProverExecutionData,
|
|
539
|
+
executionData2: TransactionProverExecutionData
|
|
540
|
+
): Promise<TransactionProverPublicOutput> {
|
|
541
|
+
return this.zkProgrammable.proveTransactions(
|
|
542
|
+
publicInput,
|
|
543
|
+
runtimeProof1,
|
|
544
|
+
runtimeProof2,
|
|
545
|
+
executionData1,
|
|
546
|
+
executionData2
|
|
547
|
+
);
|
|
548
|
+
}
|
|
549
|
+
|
|
550
|
+
public dummy(publicInput: TransactionProverPublicInput) {
|
|
551
|
+
return this.zkProgrammable.dummy(publicInput);
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
public merge(
|
|
555
|
+
publicInput: TransactionProverPublicInput,
|
|
556
|
+
proof1: TransactionProof,
|
|
557
|
+
proof2: TransactionProof
|
|
558
|
+
): Promise<TransactionProverPublicOutput> {
|
|
559
|
+
return this.zkProgrammable.merge(publicInput, proof1, proof2);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
@@ -0,0 +1,108 @@
|
|
|
1
|
+
import { Bool } from "o1js";
|
|
2
|
+
import { container } from "tsyringe";
|
|
3
|
+
|
|
4
|
+
import {
|
|
5
|
+
ProvableStateTransition,
|
|
6
|
+
StateTransition,
|
|
7
|
+
} from "../model/StateTransition";
|
|
8
|
+
import { AppliedStateTransitionBatch } from "../model/AppliedStateTransitionBatch";
|
|
9
|
+
import {
|
|
10
|
+
RuntimeMethodExecutionContext,
|
|
11
|
+
RuntimeMethodExecutionData,
|
|
12
|
+
} from "../state/context/RuntimeMethodExecutionContext";
|
|
13
|
+
import { RuntimeTransaction } from "../model/transaction/RuntimeTransaction";
|
|
14
|
+
import { MinaActions } from "../utils/MinaPrefixedProvableHashList";
|
|
15
|
+
|
|
16
|
+
import { StateTransitionReductionList } from "./accumulators/StateTransitionReductionList";
|
|
17
|
+
import { TransactionProverState } from "./transaction/TransactionProvable";
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Constructs a AppliedBatch based on a list of STs and the flag whether to
|
|
21
|
+
* be applied or not. The AppliedBatch is a condensed commitment to a batch
|
|
22
|
+
* of STs.
|
|
23
|
+
*/
|
|
24
|
+
export function constructBatch(
|
|
25
|
+
stateTransitions: StateTransition<any>[],
|
|
26
|
+
applied: Bool
|
|
27
|
+
) {
|
|
28
|
+
const transitions = stateTransitions.map((transition) =>
|
|
29
|
+
transition.toProvable()
|
|
30
|
+
);
|
|
31
|
+
|
|
32
|
+
const hashList = new StateTransitionReductionList(ProvableStateTransition);
|
|
33
|
+
transitions.forEach((transition) => {
|
|
34
|
+
hashList.push(transition);
|
|
35
|
+
});
|
|
36
|
+
|
|
37
|
+
return new AppliedStateTransitionBatch({
|
|
38
|
+
batchHash: hashList.commitment,
|
|
39
|
+
applied,
|
|
40
|
+
});
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
// TODO How does this interact with the RuntimeMethodExecutionContext when executing runtimemethods?
|
|
44
|
+
export async function executeHooks<T>(
|
|
45
|
+
contextArguments: RuntimeMethodExecutionData,
|
|
46
|
+
hookName: string,
|
|
47
|
+
method: () => Promise<T>,
|
|
48
|
+
// This can be either that the tx is a message, or we are inside a dummy block hook
|
|
49
|
+
skipEnforceStatus: Bool | undefined = undefined
|
|
50
|
+
) {
|
|
51
|
+
const executionContext = container.resolve(RuntimeMethodExecutionContext);
|
|
52
|
+
executionContext.clear();
|
|
53
|
+
|
|
54
|
+
// Setup context for potential calls to runtime methods.
|
|
55
|
+
// This way they can use this.transaction etc. while still having provable
|
|
56
|
+
// integrity between data
|
|
57
|
+
executionContext.setup(contextArguments);
|
|
58
|
+
executionContext.beforeMethod("", "", []);
|
|
59
|
+
|
|
60
|
+
const result = await method();
|
|
61
|
+
|
|
62
|
+
executionContext.afterMethod();
|
|
63
|
+
|
|
64
|
+
const { stateTransitions, status, statusMessage } =
|
|
65
|
+
executionContext.current().result;
|
|
66
|
+
|
|
67
|
+
// See https://github.com/proto-kit/framework/issues/321 for why we do this here
|
|
68
|
+
if (skipEnforceStatus !== undefined) {
|
|
69
|
+
// isMessage is defined for all tx hooks
|
|
70
|
+
status
|
|
71
|
+
.or(skipEnforceStatus)
|
|
72
|
+
.assertTrue(
|
|
73
|
+
`${hookName} hook call failed for non-message tx: ${statusMessage ?? "-"}`
|
|
74
|
+
);
|
|
75
|
+
} else {
|
|
76
|
+
// isMessage is undefined for all block hooks
|
|
77
|
+
status.assertTrue(`${hookName} hook call failed: ${statusMessage ?? "-"}`);
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
return {
|
|
81
|
+
batch: constructBatch(stateTransitions, Bool(true)),
|
|
82
|
+
result,
|
|
83
|
+
rawStatus: status,
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export function addTransactionToBundle<
|
|
88
|
+
T extends Pick<
|
|
89
|
+
TransactionProverState,
|
|
90
|
+
"transactionList" | "eternalTransactionsList" | "incomingMessages"
|
|
91
|
+
>,
|
|
92
|
+
>(state: T, isMessage: Bool, transaction: RuntimeTransaction): T {
|
|
93
|
+
const transactionHash = transaction.hash();
|
|
94
|
+
|
|
95
|
+
// Append tx to transaction list
|
|
96
|
+
state.transactionList.push(transactionHash);
|
|
97
|
+
|
|
98
|
+
// Append tx to eternal transaction list
|
|
99
|
+
// TODO Change that to the a sequence-state compatible transaction struct
|
|
100
|
+
state.eternalTransactionsList.push(transactionHash);
|
|
101
|
+
|
|
102
|
+
// Append tx to incomingMessagesHash
|
|
103
|
+
const actionHash = MinaActions.actionHash(transaction.hashData());
|
|
104
|
+
|
|
105
|
+
state.incomingMessages.pushIf(actionHash, isMessage);
|
|
106
|
+
|
|
107
|
+
return state;
|
|
108
|
+
}
|