@proto-kit/protocol 0.1.1-develop.263 → 0.1.1-develop.298
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/blockmodules/AccountStateModule.d.ts +5 -5
- package/dist/blockmodules/AccountStateModule.d.ts.map +1 -1
- package/dist/blockmodules/AccountStateModule.js +1 -1
- package/dist/blockmodules/NoopTransactionHook.d.ts +1 -1
- package/dist/blockmodules/NoopTransactionHook.d.ts.map +1 -1
- package/dist/model/MethodPublicOutput.d.ts +27 -27
- package/dist/model/MethodPublicOutput.js +1 -1
- package/dist/model/Option.d.ts +19 -19
- package/dist/model/Option.d.ts.map +1 -1
- package/dist/model/Option.js +1 -1
- package/dist/model/Path.d.ts +2 -2
- package/dist/model/Path.d.ts.map +1 -1
- package/dist/model/Path.js +1 -1
- package/dist/model/StateTransition.d.ts +12 -12
- package/dist/model/StateTransition.d.ts.map +1 -1
- package/dist/model/StateTransition.js +1 -1
- package/dist/model/StateTransitionProvableBatch.d.ts +13 -13
- package/dist/model/StateTransitionProvableBatch.d.ts.map +1 -1
- package/dist/model/StateTransitionProvableBatch.js +1 -1
- package/dist/model/network/NetworkState.d.ts +7 -7
- package/dist/model/network/NetworkState.d.ts.map +1 -1
- package/dist/model/network/NetworkState.js +1 -1
- package/dist/model/transaction/ProtocolTransaction.d.ts +16 -16
- package/dist/model/transaction/ProtocolTransaction.d.ts.map +1 -1
- package/dist/model/transaction/ProtocolTransaction.js +1 -1
- package/dist/model/transaction/RuntimeTransaction.d.ts +16 -16
- package/dist/model/transaction/RuntimeTransaction.d.ts.map +1 -1
- package/dist/model/transaction/RuntimeTransaction.js +1 -1
- package/dist/protocol/Protocol.d.ts +17 -10
- package/dist/protocol/Protocol.d.ts.map +1 -1
- package/dist/protocol/Protocol.js +30 -32
- package/dist/protocol/ProtocolEnvironment.d.ts +9 -0
- package/dist/protocol/ProtocolEnvironment.d.ts.map +1 -0
- package/dist/protocol/ProtocolEnvironment.js +1 -0
- package/dist/protocol/ProtocolModule.d.ts +5 -5
- package/dist/protocol/ProtocolModule.d.ts.map +1 -1
- package/dist/protocol/ProtocolModule.js +7 -5
- package/dist/protocol/ProvableTransactionHook.d.ts +1 -1
- package/dist/protocol/ProvableTransactionHook.d.ts.map +1 -1
- package/dist/protocol/TransitioningProtocolModule.d.ts +1 -1
- package/dist/protocol/TransitioningProtocolModule.d.ts.map +1 -1
- package/dist/prover/block/BlockProvable.d.ts +40 -40
- package/dist/prover/block/BlockProvable.d.ts.map +1 -1
- package/dist/prover/block/BlockProvable.js +1 -1
- package/dist/prover/block/BlockProver.d.ts +4 -4
- package/dist/prover/block/BlockProver.d.ts.map +1 -1
- package/dist/prover/block/BlockProver.js +1 -1
- package/dist/prover/statetransition/StateTransitionProvable.d.ts +55 -55
- package/dist/prover/statetransition/StateTransitionProvable.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProvable.js +1 -1
- package/dist/prover/statetransition/StateTransitionProver.d.ts +2 -2
- package/dist/prover/statetransition/StateTransitionProver.d.ts.map +1 -1
- package/dist/prover/statetransition/StateTransitionProver.js +1 -6
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts +1 -1
- package/dist/prover/statetransition/StateTransitionWitnessProvider.d.ts.map +1 -1
- package/dist/state/State.d.ts +1 -1
- package/dist/state/State.d.ts.map +1 -1
- package/dist/state/State.js +1 -1
- package/dist/state/StateMap.d.ts +1 -1
- package/dist/state/StateMap.d.ts.map +1 -1
- package/dist/state/StateService.d.ts +1 -1
- package/dist/state/StateService.d.ts.map +1 -1
- package/dist/state/StateServiceProvider.d.ts +4 -4
- package/dist/state/StateServiceProvider.d.ts.map +1 -1
- package/dist/state/StateServiceProvider.js +19 -11
- package/dist/state/assert/assert.d.ts +1 -1
- package/dist/state/assert/assert.d.ts.map +1 -1
- package/dist/state/assert/assert.js +3 -1
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts +2 -1
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.js +3 -2
- package/dist/state/protocol/ProtocolState.d.ts +1 -1
- package/dist/state/protocol/ProtocolState.d.ts.map +1 -1
- package/dist/utils/PrefixedProvableHashList.d.ts +1 -1
- package/dist/utils/PrefixedProvableHashList.d.ts.map +1 -1
- package/dist/utils/PrefixedProvableHashList.js +1 -1
- package/dist/utils/ProvableHashList.d.ts +2 -2
- package/dist/utils/ProvableHashList.d.ts.map +1 -1
- package/dist/utils/ProvableHashList.js +1 -1
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts +1 -15
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.d.ts.map +1 -1
- package/dist/utils/merkletree/InMemoryMerkleTreeStorage.js +0 -71
- package/dist/utils/merkletree/MerkleTreeStore.d.ts +2 -2
- package/dist/utils/merkletree/MerkleTreeStore.d.ts.map +1 -1
- package/dist/utils/merkletree/RollupMerkleTree.d.ts +17 -16
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +1 -1
- package/dist/utils/merkletree/RollupMerkleTree.js +7 -1
- package/dist/utils/utils.d.ts +2 -3
- package/dist/utils/utils.d.ts.map +1 -1
- package/dist/utils/utils.js +2 -3
- package/package.json +3 -3
- package/src/blockmodules/AccountStateModule.ts +2 -2
- package/src/blockmodules/NoopTransactionHook.ts +1 -1
- package/src/model/MethodPublicOutput.ts +1 -1
- package/src/model/Option.test.ts +1 -1
- package/src/model/Option.ts +1 -1
- package/src/model/Path.ts +1 -1
- package/src/model/StateTransition.ts +1 -1
- package/src/model/StateTransitionProvableBatch.ts +1 -1
- package/src/model/Transaction.ts +1 -1
- package/src/model/network/NetworkState.ts +1 -1
- package/src/model/transaction/ProtocolTransaction.ts +1 -1
- package/src/model/transaction/RuntimeTransaction.ts +1 -1
- package/src/protocol/Protocol.ts +72 -63
- package/src/protocol/ProtocolEnvironment.ts +9 -0
- package/src/protocol/ProtocolModule.ts +14 -11
- package/src/protocol/ProvableTransactionHook.ts +1 -1
- package/src/protocol/TransitioningProtocolModule.ts +3 -1
- package/src/prover/block/BlockProvable.ts +1 -1
- package/src/prover/block/BlockProver.ts +4 -4
- package/src/prover/statetransition/StateTransitionProvable.ts +1 -1
- package/src/prover/statetransition/StateTransitionProver.ts +2 -8
- package/src/prover/statetransition/StateTransitionWitnessProvider.ts +1 -1
- package/src/state/State.ts +1 -1
- package/src/state/StateMap.ts +1 -1
- package/src/state/StateService.ts +2 -2
- package/src/state/StateServiceProvider.ts +21 -12
- package/src/state/assert/assert.test.ts +1 -1
- package/src/state/assert/assert.ts +4 -2
- package/src/state/context/RuntimeMethodExecutionContext.ts +6 -2
- package/src/state/protocol/ProtocolState.ts +3 -1
- package/src/utils/PrefixedProvableHashList.ts +1 -1
- package/src/utils/ProvableHashList.ts +1 -1
- package/src/utils/merkletree/InMemoryMerkleTreeStorage.ts +1 -97
- package/src/utils/merkletree/MerkleTreeStore.ts +2 -2
- package/src/utils/merkletree/RollupMerkleTree.ts +10 -1
- package/src/utils/utils.ts +2 -4
- package/test/BlockProver.test.ts +9 -12
- package/test/State.test.ts +1 -1
- package/test/StateTransition.test.ts +4 -2
- package/test/utils/MerkleTree.test.ts +1 -1
- package/test/utils.test.ts +1 -1
|
@@ -1,39 +1,39 @@
|
|
|
1
|
-
import { Proof } from "
|
|
1
|
+
import { Proof } from "o1js";
|
|
2
2
|
import { WithZkProgrammable } from "@proto-kit/common";
|
|
3
3
|
import { StateTransitionProvableBatch } from "../../model/StateTransitionProvableBatch";
|
|
4
4
|
import { StateTransitionWitnessProviderReference } from "./StateTransitionWitnessProviderReference";
|
|
5
5
|
declare const StateTransitionProverPublicInput_base: (new (value: {
|
|
6
|
-
stateTransitionsHash: import("
|
|
7
|
-
protocolTransitionsHash: import("
|
|
8
|
-
stateRoot: import("
|
|
9
|
-
protocolStateRoot: import("
|
|
6
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
7
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
8
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
9
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
10
10
|
}) => {
|
|
11
|
-
stateTransitionsHash: import("
|
|
12
|
-
protocolTransitionsHash: import("
|
|
13
|
-
stateRoot: import("
|
|
14
|
-
protocolStateRoot: import("
|
|
11
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
12
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
13
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
14
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
15
15
|
}) & {
|
|
16
16
|
_isStruct: true;
|
|
17
|
-
} & import("
|
|
18
|
-
stateTransitionsHash: import("
|
|
19
|
-
protocolTransitionsHash: import("
|
|
20
|
-
stateRoot: import("
|
|
21
|
-
protocolStateRoot: import("
|
|
17
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
18
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
19
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
20
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
21
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
22
22
|
}> & {
|
|
23
23
|
toInput: (x: {
|
|
24
|
-
stateTransitionsHash: import("
|
|
25
|
-
protocolTransitionsHash: import("
|
|
26
|
-
stateRoot: import("
|
|
27
|
-
protocolStateRoot: import("
|
|
24
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
25
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
26
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
27
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
28
28
|
}) => {
|
|
29
|
-
fields?: import("
|
|
30
|
-
packed?: [import("
|
|
29
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
30
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
31
31
|
};
|
|
32
32
|
toJSON: (x: {
|
|
33
|
-
stateTransitionsHash: import("
|
|
34
|
-
protocolTransitionsHash: import("
|
|
35
|
-
stateRoot: import("
|
|
36
|
-
protocolStateRoot: import("
|
|
33
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
34
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
35
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
36
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
37
37
|
}) => {
|
|
38
38
|
stateTransitionsHash: string;
|
|
39
39
|
protocolTransitionsHash: string;
|
|
@@ -46,46 +46,46 @@ declare const StateTransitionProverPublicInput_base: (new (value: {
|
|
|
46
46
|
stateRoot: string;
|
|
47
47
|
protocolStateRoot: string;
|
|
48
48
|
}) => {
|
|
49
|
-
stateTransitionsHash: import("
|
|
50
|
-
protocolTransitionsHash: import("
|
|
51
|
-
stateRoot: import("
|
|
52
|
-
protocolStateRoot: import("
|
|
49
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
50
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
51
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
52
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
53
53
|
};
|
|
54
54
|
};
|
|
55
55
|
export declare class StateTransitionProverPublicInput extends StateTransitionProverPublicInput_base {
|
|
56
56
|
}
|
|
57
57
|
declare const StateTransitionProverPublicOutput_base: (new (value: {
|
|
58
|
-
stateTransitionsHash: import("
|
|
59
|
-
protocolTransitionsHash: import("
|
|
60
|
-
stateRoot: import("
|
|
61
|
-
protocolStateRoot: import("
|
|
58
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
59
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
60
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
61
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
62
62
|
}) => {
|
|
63
|
-
stateTransitionsHash: import("
|
|
64
|
-
protocolTransitionsHash: import("
|
|
65
|
-
stateRoot: import("
|
|
66
|
-
protocolStateRoot: import("
|
|
63
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
64
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
65
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
66
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
67
67
|
}) & {
|
|
68
68
|
_isStruct: true;
|
|
69
|
-
} & import("
|
|
70
|
-
stateTransitionsHash: import("
|
|
71
|
-
protocolTransitionsHash: import("
|
|
72
|
-
stateRoot: import("
|
|
73
|
-
protocolStateRoot: import("
|
|
69
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
70
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
71
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
72
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
73
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
74
74
|
}> & {
|
|
75
75
|
toInput: (x: {
|
|
76
|
-
stateTransitionsHash: import("
|
|
77
|
-
protocolTransitionsHash: import("
|
|
78
|
-
stateRoot: import("
|
|
79
|
-
protocolStateRoot: import("
|
|
76
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
77
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
78
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
79
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
80
80
|
}) => {
|
|
81
|
-
fields?: import("
|
|
82
|
-
packed?: [import("
|
|
81
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
82
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
83
83
|
};
|
|
84
84
|
toJSON: (x: {
|
|
85
|
-
stateTransitionsHash: import("
|
|
86
|
-
protocolTransitionsHash: import("
|
|
87
|
-
stateRoot: import("
|
|
88
|
-
protocolStateRoot: import("
|
|
85
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
86
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
87
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
88
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
89
89
|
}) => {
|
|
90
90
|
stateTransitionsHash: string;
|
|
91
91
|
protocolTransitionsHash: string;
|
|
@@ -98,10 +98,10 @@ declare const StateTransitionProverPublicOutput_base: (new (value: {
|
|
|
98
98
|
stateRoot: string;
|
|
99
99
|
protocolStateRoot: string;
|
|
100
100
|
}) => {
|
|
101
|
-
stateTransitionsHash: import("
|
|
102
|
-
protocolTransitionsHash: import("
|
|
103
|
-
stateRoot: import("
|
|
104
|
-
protocolStateRoot: import("
|
|
101
|
+
stateTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
102
|
+
protocolTransitionsHash: import("o1js/dist/node/lib/field").Field;
|
|
103
|
+
stateRoot: import("o1js/dist/node/lib/field").Field;
|
|
104
|
+
protocolStateRoot: import("o1js/dist/node/lib/field").Field;
|
|
105
105
|
};
|
|
106
106
|
};
|
|
107
107
|
export declare class StateTransitionProverPublicOutput extends StateTransitionProverPublicOutput_base {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTransitionProvable.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionProvable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAU,MAAM,
|
|
1
|
+
{"version":3,"file":"StateTransitionProvable.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionProvable.ts"],"names":[],"mappings":"AAAA,OAAO,EAAS,KAAK,EAAU,MAAM,MAAM,CAAC;AAC5C,OAAO,EAAE,kBAAkB,EAAkB,MAAM,mBAAmB,CAAC;AAEvE,OAAO,EAAE,4BAA4B,EAAE,MAAM,0CAA0C,CAAC;AAExF,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEpG,qBAAa,gCAAiC,SAAQ,qCAKpD;CAAG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEL,qBAAa,iCAAkC,SAAQ,sCAKrD;CAAG;AAEL,MAAM,MAAM,oBAAoB,GAAG,KAAK,CACtC,gCAAgC,EAChC,iCAAiC,CAClC,CAAC;AAEF,MAAM,WAAW,uBACf,SAAQ,kBAAkB,CACxB,gCAAgC,EAChC,iCAAiC,CAClC;IACD,wBAAwB,EAAE,uCAAuC,CAAC;IAElE,QAAQ,EAAE,CACR,WAAW,EAAE,gCAAgC,EAC7C,KAAK,EAAE,4BAA4B,KAChC,iCAAiC,CAAC;IAEvC,KAAK,EAAE,CACL,WAAW,EAAE,gCAAgC,EAC7C,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,KACzB,iCAAiC,CAAC;CACxC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field } from "
|
|
1
|
+
import { Field } from "o1js";
|
|
2
2
|
import { AreProofsEnabled, PlainZkProgram, ZkProgrammable } from "@proto-kit/common";
|
|
3
3
|
import { ProvableHashList } from "../../utils/ProvableHashList";
|
|
4
4
|
import { ProvableStateTransition } from "../../model/StateTransition";
|
|
@@ -39,7 +39,7 @@ export declare class StateTransitionProverProgrammable extends ZkProgrammable<St
|
|
|
39
39
|
runBatch(publicInput: StateTransitionProverPublicInput, batch: StateTransitionProvableBatch): StateTransitionProverPublicOutput;
|
|
40
40
|
merge(publicInput: StateTransitionProverPublicInput, proof1: StateTransitionProof, proof2: StateTransitionProof): StateTransitionProverPublicOutput;
|
|
41
41
|
}
|
|
42
|
-
export declare class StateTransitionProver extends ProtocolModule implements StateTransitionProvable {
|
|
42
|
+
export declare class StateTransitionProver extends ProtocolModule<object> implements StateTransitionProvable {
|
|
43
43
|
readonly witnessProviderReference: StateTransitionWitnessProviderReference;
|
|
44
44
|
readonly zkProgrammable: StateTransitionProverProgrammable;
|
|
45
45
|
constructor(witnessProviderReference: StateTransitionWitnessProviderReference);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTransitionProver.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionProver.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,EAAuB,MAAM,
|
|
1
|
+
{"version":3,"file":"StateTransitionProver.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionProver.ts"],"names":[],"mappings":"AACA,OAAO,EAAsB,KAAK,EAAuB,MAAM,MAAM,CAAC;AAEtE,OAAO,EACL,gBAAgB,EAEhB,cAAc,EAEd,cAAc,EACf,MAAM,mBAAmB,CAAC;AAM3B,OAAO,EAEL,gBAAgB,EACjB,MAAM,8BAA8B,CAAC;AACtC,OAAO,EAAE,uBAAuB,EAAE,MAAM,6BAA6B,CAAC;AACtE,OAAO,EACL,2BAA2B,EAC3B,4BAA4B,EAC7B,MAAM,0CAA0C,CAAC;AAElD,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAC;AAG/D,OAAO,EACL,uBAAuB,EACvB,gCAAgC,EAChC,oBAAoB,EACpB,iCAAiC,EAClC,MAAM,2BAA2B,CAAC;AACnC,OAAO,EAAE,uCAAuC,EAAE,MAAM,2CAA2C,CAAC;AAepG,UAAU,mCAAmC;IAC3C,SAAS,EAAE,KAAK,CAAC;IACjB,iBAAiB,EAAE,KAAK,CAAC;IACzB,mBAAmB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;IAC/D,sBAAsB,EAAE,gBAAgB,CAAC,uBAAuB,CAAC,CAAC;CACnE;AAOD;;;GAGG;AACH,qBAAa,iCAAkC,SAAQ,cAAc,CACnE,gCAAgC,EAChC,iCAAiC,CAClC;IAGG,OAAO,CAAC,QAAQ,CAAC,qBAAqB;aACtB,wBAAwB,EAAE,uCAAuC;gBADhE,qBAAqB,EAAE,qBAAqB,EAC7C,wBAAwB,EAAE,uCAAuC;IAKnF,IAAW,QAAQ,IAAI,gBAAgB,GAAG,SAAS,CAElD;IAEM,gBAAgB,IAAI,cAAc,CACvC,gCAAgC,EAChC,iCAAiC,CAClC;IAqDD,OAAO,KAAK,eAAe,GAM1B;IAED;;;OAGG;IACI,gBAAgB,CACrB,SAAS,EAAE,KAAK,EAChB,iBAAiB,EAAE,KAAK,EACxB,6BAA6B,EAAE,KAAK,EACpC,gCAAgC,EAAE,KAAK,EACvC,eAAe,EAAE,4BAA4B,GAC5C,mCAAmC;IA6BtC;;;OAGG;IACI,eAAe,CACpB,KAAK,EAAE,mCAAmC,EAC1C,UAAU,EAAE,uBAAuB,EACnC,IAAI,EAAE,2BAA2B,EACjC,KAAK,SAAI;IAqDX;;OAEG;IAEI,QAAQ,CACb,WAAW,EAAE,gCAAgC,EAC7C,KAAK,EAAE,4BAA4B,GAClC,iCAAiC;IAkB7B,KAAK,CACV,WAAW,EAAE,gCAAgC,EAC7C,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,iCAAiC;CAqErC;AAED,qBACa,qBACX,SAAQ,cAAc,CAAC,MAAM,CAC7B,YAAW,uBAAuB;aAMhB,wBAAwB,EAAE,uCAAuC;IAJnF,SAAgB,cAAc,EAAE,iCAAiC,CAAC;gBAIhD,wBAAwB,EAAE,uCAAuC;IAS5E,QAAQ,CACb,WAAW,EAAE,gCAAgC,EAC7C,KAAK,EAAE,4BAA4B,GAClC,iCAAiC;IAI7B,KAAK,CACV,WAAW,EAAE,gCAAgC,EAC7C,MAAM,EAAE,oBAAoB,EAC5B,MAAM,EAAE,oBAAoB,GAC3B,iCAAiC;CAGrC"}
|
|
@@ -8,7 +8,7 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
8
8
|
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
9
9
|
};
|
|
10
10
|
/* eslint-disable max-lines */
|
|
11
|
-
import { Experimental, Field, Provable, SelfProof } from "
|
|
11
|
+
import { Experimental, Field, Provable, SelfProof } from "o1js";
|
|
12
12
|
import { injectable } from "tsyringe";
|
|
13
13
|
import { provableMethod, ZkProgrammable, } from "@proto-kit/common";
|
|
14
14
|
import { MerkleTreeUtils, RollupMerkleWitness, } from "../../utils/merkletree/RollupMerkleTree.js";
|
|
@@ -109,11 +109,6 @@ export class StateTransitionProverProgrammable extends ZkProgrammable {
|
|
|
109
109
|
applyTransition(state, transition, type, index = 0) {
|
|
110
110
|
const treeWitness = Provable.witness(RollupMerkleWitness, () => this.witnessProvider.getWitness(transition.path));
|
|
111
111
|
const membershipValid = MerkleTreeUtils.checkMembership(treeWitness, state.stateRoot, transition.path, transition.from.value);
|
|
112
|
-
// if (!membershipValid.toBoolean()) {
|
|
113
|
-
// console.log(
|
|
114
|
-
// `Merklewitness error ${root1.toString()} ${root2.toString()}`
|
|
115
|
-
// );
|
|
116
|
-
// }
|
|
117
112
|
membershipValid
|
|
118
113
|
.or(transition.from.isSome.not())
|
|
119
114
|
.assertTrue(errors.merkleWitnessNotCorrect(index, type.isNormal().toBoolean() ? "normal" : "protocol"));
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateTransitionWitnessProvider.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionWitnessProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"StateTransitionWitnessProvider.d.ts","sourceRoot":"","sources":["../../../src/prover/statetransition/StateTransitionWitnessProvider.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAGlC,OAAO,EAAE,mBAAmB,EAAE,MAAM,4CAA4C,CAAC;AAEjF;;GAEG;AACH,MAAM,WAAW,8BAA8B;IAC7C;;;OAGG;IACH,UAAU,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,mBAAmB,CAAC;CACjD;AAED,qBACa,kCACX,YAAW,8BAA8B;IAElC,UAAU,IAAI,mBAAmB;CAGzC"}
|
package/dist/state/State.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../src/state/State.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,EAAY,KAAK,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"State.d.ts","sourceRoot":"","sources":["../../src/state/State.ts"],"names":[],"mappings":"AACA,OAAO,EAAQ,KAAK,EAAY,KAAK,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAIxE,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AACrC,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAGzC,OAAO,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAC;AAG9D,qBAAa,QAAQ;IACZ,IAAI,CAAC,EAAE,KAAK,CAAC;IAEb,aAAa,IAAI,OAAO,CAAC,IAAI,IAAI;QAAE,IAAI,EAAE,IAAI,CAAA;KAAE;CAOvD;AAED,qBAAa,wBAAwB;IAC5B,oBAAoB,CAAC,EAAE,oBAAoB,CAAC;IAE5C,qBAAqB,IAAI,OAAO,CAAC,IAAI,IAAI;QAC9C,oBAAoB,EAAE,oBAAoB,CAAC;KAC5C;CAOF;;AAED;;GAEG;AACH,qBAAa,KAAK,CAAC,KAAK,CAAE,SAAQ,UAAyC;IAW/C,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAVhE;;;;;OAKG;WACW,IAAI,CAAC,KAAK,EAAE,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;gBAItC,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC;IAIhE,OAAO,CAAC,QAAQ;IAuChB;;;;;OAKG;IACH,OAAO,CAAC,YAAY;IAUpB;;;;;OAKG;IACI,GAAG,IAAI,MAAM,CAAC,KAAK,CAAC;IAc3B;;;;;;;;;;OAUG;IACI,GAAG,CAAC,KAAK,EAAE,KAAK;CAiBxB"}
|
package/dist/state/State.js
CHANGED
package/dist/state/StateMap.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type { Field, FlexibleProvablePure } from "
|
|
1
|
+
import type { Field, FlexibleProvablePure } from "o1js";
|
|
2
2
|
import { Option } from "../model/Option";
|
|
3
3
|
import { WithStateServiceProvider, WithPath } from "./State";
|
|
4
4
|
declare const StateMap_base: import("ts-mixer/dist/types/types").Class<any[], WithPath & WithStateServiceProvider, typeof WithPath & typeof WithStateServiceProvider, false>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateMap.d.ts","sourceRoot":"","sources":["../../src/state/StateMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"StateMap.d.ts","sourceRoot":"","sources":["../../src/state/StateMap.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,KAAK,EAAE,oBAAoB,EAAE,MAAM,MAAM,CAAC;AAIxD,OAAO,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAC;AAEzC,OAAO,EAAS,wBAAwB,EAAE,QAAQ,EAAE,MAAM,SAAS,CAAC;;AAEpE;;GAEG;AAEH,qBAAa,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAE,SAAQ,aAGjD;IAgBU,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC;IACtC,SAAS,EAAE,oBAAoB,CAAC,SAAS,CAAC;IAhBnD;;;;;;OAMG;WACW,IAAI,CAAC,OAAO,EAAE,SAAS,EACnC,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACtC,SAAS,EAAE,oBAAoB,CAAC,SAAS,CAAC,GACzC,QAAQ,CAAC,OAAO,EAAE,SAAS,CAAC;gBAKtB,OAAO,EAAE,oBAAoB,CAAC,OAAO,CAAC,EACtC,SAAS,EAAE,oBAAoB,CAAC,SAAS,CAAC;IAK5C,OAAO,CAAC,GAAG,EAAE,OAAO,GAAG,KAAK;IAKnC;;;;;OAKG;IACI,GAAG,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAAC,SAAS,CAAC;IAU3C;;;;;OAKG;IACI,GAAG,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,SAAS,GAAG,IAAI;CASjD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateService.d.ts","sourceRoot":"","sources":["../../src/state/StateService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"StateService.d.ts","sourceRoot":"","sources":["../../src/state/StateService.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE7B,MAAM,WAAW,YAAY;IAC3B,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,KAAK,KAAK,EAAE,GAAG,SAAS,CAAC;IACzC,GAAG,EAAE,CAAC,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,KAAK,IAAI,CAAC;CACvD"}
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { StateService } from "./StateService";
|
|
2
2
|
export declare class StateServiceProvider {
|
|
3
|
-
private
|
|
4
|
-
private readonly
|
|
5
|
-
constructor(
|
|
3
|
+
private readonly baseStateService?;
|
|
4
|
+
private readonly stateServiceStack;
|
|
5
|
+
constructor(baseStateService?: StateService | undefined);
|
|
6
6
|
get stateService(): StateService;
|
|
7
7
|
setCurrentStateService(service: StateService): void;
|
|
8
|
-
|
|
8
|
+
popCurrentStateService(): void;
|
|
9
9
|
}
|
|
10
10
|
//# sourceMappingURL=StateServiceProvider.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"StateServiceProvider.d.ts","sourceRoot":"","sources":["../../src/state/StateServiceProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;
|
|
1
|
+
{"version":3,"file":"StateServiceProvider.d.ts","sourceRoot":"","sources":["../../src/state/StateServiceProvider.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,gBAAgB,CAAC;AAU9C,qBACa,oBAAoB;IAIL,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC;IAH5D,OAAO,CAAC,QAAQ,CAAC,iBAAiB,CAAsB;gBAGb,gBAAgB,CAAC,0BAAc;IAO1E,IAAW,YAAY,IAAI,YAAY,CAQtC;IAEM,sBAAsB,CAAC,OAAO,EAAE,YAAY;IAI5C,sBAAsB;CAO9B"}
|
|
@@ -11,27 +11,35 @@ var __param = (this && this.__param) || function (paramIndex, decorator) {
|
|
|
11
11
|
return function (target, key) { decorator(target, key, paramIndex); }
|
|
12
12
|
};
|
|
13
13
|
import { inject, injectable } from "tsyringe";
|
|
14
|
+
import { log } from "@proto-kit/common";
|
|
14
15
|
const errors = {
|
|
15
|
-
stateServiceNotSet: () => new Error(
|
|
16
|
-
protocol function by creating them with an AppChain or by setting the
|
|
17
|
-
stateService manually.`),
|
|
16
|
+
stateServiceNotSet: () => new Error("StateService has not been set yet. Be sure to either call your runtime or protocol function by creating them with an AppChain or by setting the stateService manually."),
|
|
18
17
|
};
|
|
19
18
|
let StateServiceProvider = class StateServiceProvider {
|
|
20
|
-
constructor(
|
|
21
|
-
this.
|
|
22
|
-
this.
|
|
19
|
+
constructor(baseStateService) {
|
|
20
|
+
this.baseStateService = baseStateService;
|
|
21
|
+
this.stateServiceStack = [];
|
|
22
|
+
if (baseStateService !== undefined) {
|
|
23
|
+
this.stateServiceStack.push(baseStateService);
|
|
24
|
+
}
|
|
23
25
|
}
|
|
24
26
|
get stateService() {
|
|
25
|
-
if (this.
|
|
27
|
+
if (this.stateServiceStack.length === 0) {
|
|
26
28
|
throw errors.stateServiceNotSet();
|
|
27
29
|
}
|
|
28
|
-
|
|
30
|
+
// Assertion here is ok, because we check that the array is not empty above
|
|
31
|
+
// eslint-disable-next-line @typescript-eslint/no-non-null-assertion
|
|
32
|
+
return this.stateServiceStack.at(-1);
|
|
29
33
|
}
|
|
30
34
|
setCurrentStateService(service) {
|
|
31
|
-
this.
|
|
35
|
+
this.stateServiceStack.push(service);
|
|
32
36
|
}
|
|
33
|
-
|
|
34
|
-
this.
|
|
37
|
+
popCurrentStateService() {
|
|
38
|
+
if (this.stateServiceStack.length === 1) {
|
|
39
|
+
log.trace("Trying to pop last available (root) stateservice");
|
|
40
|
+
return;
|
|
41
|
+
}
|
|
42
|
+
this.stateServiceStack.pop();
|
|
35
43
|
}
|
|
36
44
|
};
|
|
37
45
|
StateServiceProvider = __decorate([
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/state/assert/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"assert.d.ts","sourceRoot":"","sources":["../../../src/state/assert/assert.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAM5B;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,SAAS,EAAE,IAAI,EAAE,OAAO,CAAC,EAAE,MAAM,QAavD"}
|
|
@@ -15,7 +15,9 @@ export function assert(condition, message) {
|
|
|
15
15
|
const previousStatus = executionContext.current().result.status;
|
|
16
16
|
const status = condition.and(previousStatus);
|
|
17
17
|
if (!condition.toBoolean()) {
|
|
18
|
-
|
|
18
|
+
if (!executionContext.current().isSimulated) {
|
|
19
|
+
log.debug("Assertion failed: ", message);
|
|
20
|
+
}
|
|
19
21
|
executionContext.setStatusMessage(message);
|
|
20
22
|
}
|
|
21
23
|
executionContext.setStatus(status);
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Bool } from "
|
|
1
|
+
import { Bool } from "o1js";
|
|
2
2
|
import { ProvableMethodExecutionContext, ProvableMethodExecutionResult } from "@proto-kit/common";
|
|
3
3
|
import { StateTransition } from "../../model/StateTransition";
|
|
4
4
|
import { RuntimeTransaction } from "../../model/transaction/RuntimeTransaction";
|
|
@@ -55,6 +55,7 @@ export declare class RuntimeMethodExecutionContext extends ProvableMethodExecuti
|
|
|
55
55
|
isFinished: boolean;
|
|
56
56
|
result: RuntimeProvableMethodExecutionResult;
|
|
57
57
|
input: RuntimeMethodExecutionData | undefined;
|
|
58
|
+
isSimulated: boolean;
|
|
58
59
|
};
|
|
59
60
|
}
|
|
60
61
|
//# sourceMappingURL=RuntimeMethodExecutionContext.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RuntimeMethodExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/state/context/RuntimeMethodExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"RuntimeMethodExecutionContext.d.ts","sourceRoot":"","sources":["../../../src/state/context/RuntimeMethodExecutionContext.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,IAAI,EAAE,MAAM,MAAM,CAAC;AAE5B,OAAO,EACL,8BAA8B,EAC9B,6BAA6B,EAC9B,MAAM,mBAAmB,CAAC;AAC3B,OAAO,EAAE,eAAe,EAAE,MAAM,6BAA6B,CAAC;AAC9D,OAAO,EAAE,kBAAkB,EAAE,MAAM,4CAA4C,CAAC;AAChF,OAAO,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAC;AAShE,qBAAa,oCAAqC,SAAQ,6BAA6B;IAE9E,gBAAgB,EAAE,eAAe,CAAC,GAAG,CAAC,EAAE,CAAM;IAE9C,MAAM,EAAE,IAAI,CAAc;IAE1B,aAAa,CAAC,EAAE,MAAM,CAAC;CAC/B;AAED,MAAM,WAAW,0BAA0B;IACzC,WAAW,EAAE,kBAAkB,CAAC;IAChC,YAAY,EAAE,YAAY,CAAC;CAC5B;AAED;;;;GAIG;AACH,qBACa,6BAA8B,SAAQ,8BAA8B;IACxE,OAAO,EAAE,MAAM,EAAE,CAAM;IAEvB,KAAK,EAAE,0BAA0B,GAAG,SAAS,CAAC;IAGrD,OAAO,CAAC,SAAS,CAAyC;IAE1C,MAAM,uCAA8C;IAEpE,OAAO,CAAC,WAAW,CAAkB;IAErC,OAAO,CAAC,iBAAiB;IAQzB;;;OAGG;IACI,kBAAkB,CAAC,KAAK,EAAE,eAAe,EAAE,eAAe,CAAC,KAAK,CAAC;IAKxE;;OAEG;IACI,gBAAgB,CAAC,OAAO,CAAC,EAAE,MAAM;IAQxC;;OAEG;IACI,SAAS,CAAC,MAAM,EAAE,IAAI;IAQ7B;;OAEG;IACI,KAAK,CAAC,KAAK,EAAE,0BAA0B;IAIvC,YAAY,CAAC,SAAS,EAAE,OAAO;IAItC;;OAEG;IACI,KAAK;IAIL,WAAW;IASlB;;;OAGG;IACI,OAAO;;;;;;CAQf"}
|
|
@@ -4,9 +4,9 @@ var __decorate = (this && this.__decorate) || function (decorators, target, key,
|
|
|
4
4
|
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
5
5
|
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
6
6
|
};
|
|
7
|
-
import { Bool } from "
|
|
7
|
+
import { Bool } from "o1js";
|
|
8
8
|
import { singleton } from "tsyringe";
|
|
9
|
-
import { ProvableMethodExecutionContext, ProvableMethodExecutionResult } from "@proto-kit/common";
|
|
9
|
+
import { ProvableMethodExecutionContext, ProvableMethodExecutionResult, } from "@proto-kit/common";
|
|
10
10
|
const errors = {
|
|
11
11
|
setupNotCalled: () => new Error("Setup has not been called prior to executing a runtime method. Be sure to do that so that the Runtime is setup property for execution"),
|
|
12
12
|
};
|
|
@@ -96,6 +96,7 @@ let RuntimeMethodExecutionContext = class RuntimeMethodExecutionContext extends
|
|
|
96
96
|
isFinished: this.isFinished,
|
|
97
97
|
result: this.result,
|
|
98
98
|
input: this.lastInput,
|
|
99
|
+
isSimulated: this.isSimulated,
|
|
99
100
|
};
|
|
100
101
|
}
|
|
101
102
|
};
|
|
@@ -3,5 +3,5 @@ import { TransitioningProtocolModule } from "../../protocol/TransitioningProtoco
|
|
|
3
3
|
* Decorates a runtime module property as state, passing down some
|
|
4
4
|
* underlying values to improve developer experience.
|
|
5
5
|
*/
|
|
6
|
-
export declare function protocolState(): <TargetTransitioningModule extends TransitioningProtocolModule
|
|
6
|
+
export declare function protocolState(): <TargetTransitioningModule extends TransitioningProtocolModule<unknown>>(target: TargetTransitioningModule, propertyKey: string) => void;
|
|
7
7
|
//# sourceMappingURL=ProtocolState.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProtocolState.d.ts","sourceRoot":"","sources":["../../../src/state/protocol/ProtocolState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAgBzF;;;GAGG;AACH,wBAAgB,aAAa,
|
|
1
|
+
{"version":3,"file":"ProtocolState.d.ts","sourceRoot":"","sources":["../../../src/state/protocol/ProtocolState.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,2BAA2B,EAAE,MAAM,4CAA4C,CAAC;AAgBzF;;;GAGG;AACH,wBAAgB,aAAa,6HAKZ,MAAM,UAoCtB"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field, FlexibleProvablePure } from "
|
|
1
|
+
import { Field, FlexibleProvablePure } from "o1js";
|
|
2
2
|
import { ProvableHashList } from "./ProvableHashList.js";
|
|
3
3
|
export declare class PrefixedProvableHashList<Value> extends ProvableHashList<Value> {
|
|
4
4
|
private readonly prefix;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PrefixedProvableHashList.d.ts","sourceRoot":"","sources":["../../src/utils/PrefixedProvableHashList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"PrefixedProvableHashList.d.ts","sourceRoot":"","sources":["../../src/utils/PrefixedProvableHashList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,oBAAoB,EAAY,MAAM,MAAM,CAAC;AAE7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,uBAAuB,CAAC;AAGzD,qBAAa,wBAAwB,CAAC,KAAK,CAAE,SAAQ,gBAAgB,CAAC,KAAK,CAAC;IAC1E,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAQ;gBAG7B,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,EACtC,MAAM,EAAE,MAAM,EACd,kBAAkB,GAAE,KAAgB;IAMtC,SAAS,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK;CAGzC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field, FlexibleProvablePure, Bool } from "
|
|
1
|
+
import { Field, FlexibleProvablePure, Bool } from "o1js";
|
|
2
2
|
/**
|
|
3
3
|
* Utilities for creating a hash list from a given value type.
|
|
4
4
|
*/
|
|
@@ -19,7 +19,7 @@ export declare abstract class ProvableHashList<Value> {
|
|
|
19
19
|
/**
|
|
20
20
|
* @returns Traling hash of the current hashlist.
|
|
21
21
|
*/
|
|
22
|
-
toField(): import("
|
|
22
|
+
toField(): import("o1js/dist/node/lib/field").Field;
|
|
23
23
|
}
|
|
24
24
|
export declare class DefaultProvableHashList<Value> extends ProvableHashList<Value> {
|
|
25
25
|
hash(elements: Field[]): Field;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProvableHashList.d.ts","sourceRoot":"","sources":["../../src/utils/ProvableHashList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,oBAAoB,EAAE,IAAI,EAAY,MAAM,
|
|
1
|
+
{"version":3,"file":"ProvableHashList.d.ts","sourceRoot":"","sources":["../../src/utils/ProvableHashList.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAY,oBAAoB,EAAE,IAAI,EAAY,MAAM,MAAM,CAAC;AAE7E;;GAEG;AACH,8BAAsB,gBAAgB,CAAC,KAAK;IAExC,OAAO,CAAC,QAAQ,CAAC,SAAS;IACnB,UAAU,EAAE,KAAK;gBADP,SAAS,EAAE,oBAAoB,CAAC,KAAK,CAAC,EAChD,UAAU,GAAE,KAAgB;IAGrC,SAAS,CAAC,QAAQ,CAAC,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK;IAEjD;;;;;;OAMG;IACI,IAAI,CAAC,KAAK,EAAE,KAAK;IAQjB,MAAM,CAAC,KAAK,EAAE,KAAK,EAAE,SAAS,EAAE,IAAI;IAS3C;;OAEG;IACI,OAAO;CAGf;AAED,qBAAa,uBAAuB,CAAC,KAAK,CAAE,SAAQ,gBAAgB,CAAC,KAAK,CAAC;IAClE,IAAI,CAAC,QAAQ,EAAE,KAAK,EAAE,GAAG,KAAK;CAGtC"}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { MerkleTreeStore } from "./MerkleTreeStore";
|
|
2
2
|
export declare class InMemoryMerkleTreeStorage implements MerkleTreeStore {
|
|
3
3
|
protected readonly nodes: {
|
|
4
4
|
[key: number]: {
|
|
@@ -8,18 +8,4 @@ export declare class InMemoryMerkleTreeStorage implements MerkleTreeStore {
|
|
|
8
8
|
getNode(key: bigint, level: number): bigint | undefined;
|
|
9
9
|
setNode(key: bigint, level: number, value: bigint): void;
|
|
10
10
|
}
|
|
11
|
-
export declare class CachedMerkleTreeStore extends InMemoryMerkleTreeStorage {
|
|
12
|
-
private readonly parent;
|
|
13
|
-
private writeCache;
|
|
14
|
-
constructor(parent: AsyncMerkleTreeStore);
|
|
15
|
-
setNode(key: bigint, level: number, value: bigint): void;
|
|
16
|
-
getWrittenNodes(): {
|
|
17
|
-
[key: number]: {
|
|
18
|
-
[key: string]: bigint;
|
|
19
|
-
};
|
|
20
|
-
};
|
|
21
|
-
resetWrittenNodes(): void;
|
|
22
|
-
preloadKey(index: bigint): Promise<void>;
|
|
23
|
-
mergeIntoParent(): Promise<void>;
|
|
24
|
-
}
|
|
25
11
|
//# sourceMappingURL=InMemoryMerkleTreeStorage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"InMemoryMerkleTreeStorage.d.ts","sourceRoot":"","sources":["../../../src/utils/merkletree/InMemoryMerkleTreeStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"InMemoryMerkleTreeStorage.d.ts","sourceRoot":"","sources":["../../../src/utils/merkletree/InMemoryMerkleTreeStorage.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAEpD,qBAAa,yBAA0B,YAAW,eAAe;IAC/D,SAAS,CAAC,QAAQ,CAAC,KAAK,EAAE;QACxB,CAAC,GAAG,EAAE,MAAM,GAAG;YACb,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;SACvB,CAAC;KACH,CAAM;IAEA,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,MAAM,GAAG,SAAS;IAIvD,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,IAAI;CAGhE"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
2
|
-
import { log } from "@proto-kit/common";
|
|
3
|
-
import { RollupMerkleTree } from "./RollupMerkleTree.js";
|
|
4
1
|
export class InMemoryMerkleTreeStorage {
|
|
5
2
|
constructor() {
|
|
6
3
|
this.nodes = {};
|
|
@@ -13,71 +10,3 @@ export class InMemoryMerkleTreeStorage {
|
|
|
13
10
|
((_a = this.nodes)[level] ?? (_a[level] = {}))[key.toString()] = value;
|
|
14
11
|
}
|
|
15
12
|
}
|
|
16
|
-
export class CachedMerkleTreeStore extends InMemoryMerkleTreeStorage {
|
|
17
|
-
constructor(parent) {
|
|
18
|
-
super();
|
|
19
|
-
this.parent = parent;
|
|
20
|
-
this.writeCache = {};
|
|
21
|
-
}
|
|
22
|
-
setNode(key, level, value) {
|
|
23
|
-
var _a;
|
|
24
|
-
super.setNode(key, level, value);
|
|
25
|
-
((_a = this.writeCache)[level] ?? (_a[level] = {}))[key.toString()] = value;
|
|
26
|
-
}
|
|
27
|
-
getWrittenNodes() {
|
|
28
|
-
return this.writeCache;
|
|
29
|
-
}
|
|
30
|
-
resetWrittenNodes() {
|
|
31
|
-
this.writeCache = {};
|
|
32
|
-
}
|
|
33
|
-
// eslint-disable-next-line sonarjs/cognitive-complexity
|
|
34
|
-
async preloadKey(index) {
|
|
35
|
-
// Algo from RollupMerkleTree.getWitness()
|
|
36
|
-
const { leafCount, height } = RollupMerkleTree;
|
|
37
|
-
if (index >= leafCount) {
|
|
38
|
-
index %= leafCount;
|
|
39
|
-
}
|
|
40
|
-
// eslint-disable-next-line no-warning-comments,max-len
|
|
41
|
-
// TODO Not practical at the moment. Improve pattern when implementing DB storage
|
|
42
|
-
for (let level = 0; level < height; level++) {
|
|
43
|
-
const key = index;
|
|
44
|
-
const isLeft = index % 2n === 0n;
|
|
45
|
-
const siblingKey = isLeft ? index + 1n : index - 1n;
|
|
46
|
-
// Only preload node if it is not already preloaded.
|
|
47
|
-
// We also don't want to overwrite because changes will get lost (tracing)
|
|
48
|
-
if (this.getNode(key, level) === undefined) {
|
|
49
|
-
// eslint-disable-next-line no-await-in-loop
|
|
50
|
-
const value = await this.parent.getNode(key, level);
|
|
51
|
-
if (level === 0) {
|
|
52
|
-
log.debug(`Preloaded ${key} @ ${level} -> ${value ?? "-"}`);
|
|
53
|
-
}
|
|
54
|
-
if (value !== undefined) {
|
|
55
|
-
this.setNode(key, level, value);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
if (this.getNode(siblingKey, level) === undefined) {
|
|
59
|
-
// eslint-disable-next-line no-await-in-loop
|
|
60
|
-
const sibling = await this.parent.getNode(siblingKey, level);
|
|
61
|
-
if (sibling !== undefined) {
|
|
62
|
-
this.setNode(siblingKey, level, sibling);
|
|
63
|
-
}
|
|
64
|
-
}
|
|
65
|
-
index /= 2n;
|
|
66
|
-
}
|
|
67
|
-
}
|
|
68
|
-
async mergeIntoParent() {
|
|
69
|
-
// In case no state got set we can skip this step
|
|
70
|
-
if (Object.keys(this.writeCache).length === 0) {
|
|
71
|
-
return;
|
|
72
|
-
}
|
|
73
|
-
this.parent.openTransaction();
|
|
74
|
-
const { height } = RollupMerkleTree;
|
|
75
|
-
const nodes = this.getWrittenNodes();
|
|
76
|
-
const promises = Array.from({ length: height }).flatMap((ignored, level) => Object.entries(nodes[level]).map(async (entry) => {
|
|
77
|
-
await this.parent.setNode(BigInt(entry[0]), level, entry[1]);
|
|
78
|
-
}));
|
|
79
|
-
await Promise.all(promises);
|
|
80
|
-
this.parent.commit();
|
|
81
|
-
this.resetWrittenNodes();
|
|
82
|
-
}
|
|
83
|
-
}
|