@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,8 +1,8 @@
|
|
|
1
1
|
export interface AsyncMerkleTreeStore {
|
|
2
2
|
openTransaction: () => void;
|
|
3
3
|
commit: () => void;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
setNodeAsync: (key: bigint, level: number, value: bigint) => Promise<void>;
|
|
5
|
+
getNodeAsync: (key: bigint, level: number) => Promise<bigint | undefined>;
|
|
6
6
|
}
|
|
7
7
|
export interface MerkleTreeStore {
|
|
8
8
|
setNode: (key: bigint, level: number, value: bigint) => void;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MerkleTreeStore.d.ts","sourceRoot":"","sources":["../../../src/utils/merkletree/MerkleTreeStore.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAE5B,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB,
|
|
1
|
+
{"version":3,"file":"MerkleTreeStore.d.ts","sourceRoot":"","sources":["../../../src/utils/merkletree/MerkleTreeStore.ts"],"names":[],"mappings":"AAAA,MAAM,WAAW,oBAAoB;IACnC,eAAe,EAAE,MAAM,IAAI,CAAC;IAE5B,MAAM,EAAE,MAAM,IAAI,CAAC;IAEnB,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,IAAI,CAAC,CAAC;IAE3E,YAAY,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,OAAO,CAAC,MAAM,GAAG,SAAS,CAAC,CAAC;CAC3E;AAED,MAAM,WAAW,eAAe;IAC9B,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,IAAI,CAAC;IAE7D,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,KAAK,MAAM,GAAG,SAAS,CAAC;CAC7D"}
|
|
@@ -1,29 +1,29 @@
|
|
|
1
|
-
import { Bool, Field } from "
|
|
1
|
+
import { Bool, Field } from "o1js";
|
|
2
2
|
import { MerkleTreeStore } from "./MerkleTreeStore";
|
|
3
3
|
export { RollupMerkleTree, RollupMerkleWitness };
|
|
4
4
|
export { maybeSwap };
|
|
5
5
|
declare const RollupMerkleWitness_base: (new (value: {
|
|
6
|
-
path: import("
|
|
7
|
-
isLeft: import("
|
|
6
|
+
path: import("o1js/dist/node/lib/field").Field[];
|
|
7
|
+
isLeft: import("o1js/dist/node/lib/bool").Bool[];
|
|
8
8
|
}) => {
|
|
9
|
-
path: import("
|
|
10
|
-
isLeft: import("
|
|
9
|
+
path: import("o1js/dist/node/lib/field").Field[];
|
|
10
|
+
isLeft: import("o1js/dist/node/lib/bool").Bool[];
|
|
11
11
|
}) & {
|
|
12
12
|
_isStruct: true;
|
|
13
|
-
} & import("
|
|
14
|
-
path: import("
|
|
15
|
-
isLeft: import("
|
|
13
|
+
} & import("o1js/dist/node/snarky").ProvablePure<{
|
|
14
|
+
path: import("o1js/dist/node/lib/field").Field[];
|
|
15
|
+
isLeft: import("o1js/dist/node/lib/bool").Bool[];
|
|
16
16
|
}> & {
|
|
17
17
|
toInput: (x: {
|
|
18
|
-
path: import("
|
|
19
|
-
isLeft: import("
|
|
18
|
+
path: import("o1js/dist/node/lib/field").Field[];
|
|
19
|
+
isLeft: import("o1js/dist/node/lib/bool").Bool[];
|
|
20
20
|
}) => {
|
|
21
|
-
fields?: import("
|
|
22
|
-
packed?: [import("
|
|
21
|
+
fields?: import("o1js/dist/node/lib/field").Field[] | undefined;
|
|
22
|
+
packed?: [import("o1js/dist/node/lib/field").Field, number][] | undefined;
|
|
23
23
|
};
|
|
24
24
|
toJSON: (x: {
|
|
25
|
-
path: import("
|
|
26
|
-
isLeft: import("
|
|
25
|
+
path: import("o1js/dist/node/lib/field").Field[];
|
|
26
|
+
isLeft: import("o1js/dist/node/lib/bool").Bool[];
|
|
27
27
|
}) => {
|
|
28
28
|
path: string[];
|
|
29
29
|
isLeft: boolean[];
|
|
@@ -32,8 +32,8 @@ declare const RollupMerkleWitness_base: (new (value: {
|
|
|
32
32
|
path: string[];
|
|
33
33
|
isLeft: boolean[];
|
|
34
34
|
}) => {
|
|
35
|
-
path: import("
|
|
36
|
-
isLeft: import("
|
|
35
|
+
path: import("o1js/dist/node/lib/field").Field[];
|
|
36
|
+
isLeft: import("o1js/dist/node/lib/bool").Bool[];
|
|
37
37
|
};
|
|
38
38
|
};
|
|
39
39
|
/**
|
|
@@ -54,6 +54,7 @@ declare class RollupMerkleWitness extends RollupMerkleWitness_base {
|
|
|
54
54
|
* @returns Index of the leaf.
|
|
55
55
|
*/
|
|
56
56
|
calculateIndex(): Field;
|
|
57
|
+
toShortenedEntries(): string[];
|
|
57
58
|
}
|
|
58
59
|
/**
|
|
59
60
|
* A [Merkle Tree](https://en.wikipedia.org/wiki/Merkle_tree) is a binary tree in
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"RollupMerkleTree.d.ts","sourceRoot":"","sources":["../../../src/utils/merkletree/RollupMerkleTree.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,KAAK,EAA8B,MAAM,
|
|
1
|
+
{"version":3,"file":"RollupMerkleTree.d.ts","sourceRoot":"","sources":["../../../src/utils/merkletree/RollupMerkleTree.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,IAAI,EAAE,KAAK,EAA8B,MAAM,MAAM,CAAC;AAK/D,OAAO,EAAE,eAAe,EAAE,MAAM,mBAAmB,CAAC;AAIpD,OAAO,EAAE,gBAAgB,EAAE,mBAAmB,EAAE,CAAC;AAIjD,OAAO,EAAE,SAAS,EAAE,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAErB;;;GAGG;AACH,cAAM,mBAAoB,SAAQ,wBAGhC;IACA,OAAc,MAAM,SAAO;IAEpB,MAAM,IAAI,MAAM;IAIvB;;;;OAIG;IACI,aAAa,CAAC,IAAI,EAAE,KAAK,GAAG,KAAK;IAaxC;;;OAGG;IACI,cAAc,IAAI,KAAK;IAkBvB,kBAAkB;CAO1B;AAED;;;;;;;;;;;;;GAaG;AACH,cAAM,gBAAgB;IACpB,OAAc,MAAM,SAAO;IAE3B,WAAkB,SAAS,IAAI,MAAM,CAEpC;IAED,OAAO,CAAC,QAAQ,CAAC,MAAM,CAAW;IAElC,SAAgB,KAAK,EAAE,eAAe,CAAC;gBAEpB,KAAK,EAAE,eAAe;IAYzC;;;;;OAKG;IAEI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,KAAK;IAInD;;;OAGG;IAEI,OAAO,IAAI,KAAK;IAMvB,OAAO,CAAC,OAAO;IAIf;;;OAGG;IAEH;;;;OAIG;IAEI,OAAO,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK;IAgBzC;;;;;;OAMG;IACI,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,mBAAmB;IAqBrD;;;OAGG;IAEI,IAAI,CAAC,MAAM,EAAE,KAAK,EAAE;IAM3B;;;OAGG;IACH,IAAW,SAAS,IAAI,MAAM,CAE7B;CACF;AAGD,yBAAiB,eAAe,CAAC;IAC/B,SAAgB,YAAY,CAAC,GAAG,EAAE,KAAK,GAAG,KAAK,CAS9C;IAED,SAAgB,eAAe,CAC7B,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,KAAK,EACV,KAAK,EAAE,KAAK,GACX,IAAI,CAKN;IAED,SAAgB,uBAAuB,CACrC,OAAO,EAAE,mBAAmB,EAC5B,IAAI,EAAE,KAAK,EACX,GAAG,EAAE,KAAK,EACV,KAAK,EAAE,KAAK,GACX,CAAC,IAAI,EAAE,KAAK,EAAE,KAAK,CAAC,CAKtB;IAED,SAAgB,WAAW,CACzB,OAAO,EAAE,mBAAmB,EAC5B,KAAK,EAAE,KAAK,GACX,KAAK,CAEP;CACF;AAED;;;GAGG;AACH,iBAAS,SAAS,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,EAAE,KAAK,GAAG,CAAC,KAAK,EAAE,KAAK,CAAC,CAK9D"}
|
|
@@ -11,7 +11,8 @@ var __metadata = (this && this.__metadata) || function (k, v) {
|
|
|
11
11
|
/* eslint-disable line-comment-position */
|
|
12
12
|
/* eslint-disable no-inline-comments */
|
|
13
13
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
14
|
-
import { Bool, Field, Poseidon, Provable, Struct } from "
|
|
14
|
+
import { Bool, Field, Poseidon, Provable, Struct } from "o1js";
|
|
15
|
+
import { range } from "@proto-kit/common";
|
|
15
16
|
import { notInCircuit } from "../utils";
|
|
16
17
|
// external API
|
|
17
18
|
// eslint-disable-next-line @typescript-eslint/no-use-before-define
|
|
@@ -60,6 +61,11 @@ class RollupMerkleWitness extends Struct({
|
|
|
60
61
|
}
|
|
61
62
|
return index;
|
|
62
63
|
}
|
|
64
|
+
toShortenedEntries() {
|
|
65
|
+
return range(0, 5)
|
|
66
|
+
.concat(range(251, 255))
|
|
67
|
+
.map((index) => [this.path[index].toString(), this.isLeft[index].toString()].toString());
|
|
68
|
+
}
|
|
63
69
|
}
|
|
64
70
|
RollupMerkleWitness.height = 256;
|
|
65
71
|
/**
|
package/dist/utils/utils.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Field } from "
|
|
1
|
+
import { Field } from "o1js";
|
|
2
2
|
export type ReturnType<FunctionType extends Function> = FunctionType extends (...args: any[]) => infer Return ? Return : any;
|
|
3
3
|
export type UnTypedClass = new (...args: any[]) => any;
|
|
4
4
|
export type TypedClass<Class> = new (...args: any[]) => Class;
|
|
@@ -8,7 +8,6 @@ export type Subclass<Class extends new (...args: any) => any> = (new (...args: a
|
|
|
8
8
|
prototype: InstanceType<Class>;
|
|
9
9
|
};
|
|
10
10
|
export declare function notInCircuit(): MethodDecorator;
|
|
11
|
-
export declare function stringToField(value: string): import("
|
|
11
|
+
export declare function stringToField(value: string): import("o1js/dist/node/lib/field").Field;
|
|
12
12
|
export declare function singleFieldToString(value: Field | bigint): string;
|
|
13
|
-
export declare function noop(): void;
|
|
14
13
|
//# sourceMappingURL=utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAsB,MAAM,
|
|
1
|
+
{"version":3,"file":"utils.d.ts","sourceRoot":"","sources":["../../src/utils/utils.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,KAAK,EAAsB,MAAM,MAAM,CAAC;AAGjD,MAAM,MAAM,UAAU,CAAC,YAAY,SAAS,QAAQ,IAAI,YAAY,SAAS,CAC3E,GAAG,IAAI,EAAE,GAAG,EAAE,KACX,MAAM,MAAM,GACb,MAAM,GACN,GAAG,CAAC;AAER,MAAM,MAAM,YAAY,GAAG,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,GAAG,CAAC;AAEvD,MAAM,MAAM,UAAU,CAAC,KAAK,IAAI,KAAK,GAAG,IAAI,EAAE,GAAG,EAAE,KAAK,KAAK,CAAC;AAE9D,MAAM,MAAM,QAAQ,CAAC,KAAK,SAAS,KAAK,GAAG,IAAI,EAAE,GAAG,KAAK,GAAG,IAAI,CAAC,KAC/D,GAAG,IAAI,EAAE,GAAG,KACT,YAAY,CAAC,KAAK,CAAC,CAAC,GAAG;KACzB,GAAG,IAAI,MAAM,KAAK,GAAG,KAAK,CAAC,GAAG,CAAC;CACjC,GAAG;IAAE,SAAS,EAAE,YAAY,CAAC,KAAK,CAAC,CAAA;CAAE,CAAC;AAEvC,wBAAgB,YAAY,IAAI,eAAe,CAoB9C;AAED,wBAAgB,aAAa,CAAC,KAAK,EAAE,MAAM,4CAgC1C;AAED,wBAAgB,mBAAmB,CAAC,KAAK,EAAE,KAAK,GAAG,MAAM,GAAG,MAAM,CAKjE"}
|
package/dist/utils/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
// eslint-disable-next-line max-len
|
|
2
|
-
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return
|
|
3
|
-
import { Field, Poseidon, Provable } from "
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return */
|
|
3
|
+
import { Field, Poseidon, Provable } from "o1js";
|
|
4
4
|
import floor from "lodash/floor";
|
|
5
5
|
export function notInCircuit() {
|
|
6
6
|
return function ReplacedFunction(target, propertyKey, descriptor) {
|
|
@@ -47,4 +47,3 @@ export function singleFieldToString(value) {
|
|
|
47
47
|
}
|
|
48
48
|
return value.toString();
|
|
49
49
|
}
|
|
50
|
-
export function noop() { }
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
"license": "MIT",
|
|
4
4
|
"private": false,
|
|
5
5
|
"type": "module",
|
|
6
|
-
"version": "0.1.1-develop.
|
|
6
|
+
"version": "0.1.1-develop.298+188a8c8",
|
|
7
7
|
"scripts": {
|
|
8
8
|
"build": "tsc -p tsconfig.json",
|
|
9
9
|
"dev": "tsc -p tsconfig.json --watch",
|
|
@@ -24,12 +24,12 @@
|
|
|
24
24
|
},
|
|
25
25
|
"peerDependencies": {
|
|
26
26
|
"@proto-kit/common": "*",
|
|
27
|
-
"
|
|
27
|
+
"o1js": "0.13.1",
|
|
28
28
|
"tsyringe": "^4.7.0"
|
|
29
29
|
},
|
|
30
30
|
"devDependencies": {
|
|
31
31
|
"@jest/globals": "^29.5.0",
|
|
32
32
|
"@types/lodash": "^4.14.194"
|
|
33
33
|
},
|
|
34
|
-
"gitHead": "
|
|
34
|
+
"gitHead": "188a8c85859be7432b5c196219589d559356171b"
|
|
35
35
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Provable, PublicKey, Struct, UInt64 } from "
|
|
1
|
+
import { Provable, PublicKey, Struct, UInt64 } from "o1js";
|
|
2
2
|
|
|
3
3
|
import { BlockProverExecutionData } from "../prover/block/BlockProvable";
|
|
4
4
|
import { StateMap } from "../state/StateMap";
|
|
@@ -10,7 +10,7 @@ export class AccountState extends Struct({
|
|
|
10
10
|
nonce: UInt64,
|
|
11
11
|
}) {}
|
|
12
12
|
|
|
13
|
-
export class AccountStateModule extends ProvableTransactionHook {
|
|
13
|
+
export class AccountStateModule extends ProvableTransactionHook<object> {
|
|
14
14
|
@protocolState() public accountState = StateMap.from<PublicKey, AccountState>(
|
|
15
15
|
PublicKey,
|
|
16
16
|
AccountState
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { ProvableTransactionHook } from "../protocol/ProvableTransactionHook";
|
|
2
2
|
import { BlockProverExecutionData } from "../prover/block/BlockProvable";
|
|
3
3
|
|
|
4
|
-
export class NoopTransactionHook extends ProvableTransactionHook {
|
|
4
|
+
export class NoopTransactionHook extends ProvableTransactionHook<object> {
|
|
5
5
|
public onTransaction(executionData: BlockProverExecutionData): void {
|
|
6
6
|
}
|
|
7
7
|
}
|
package/src/model/Option.test.ts
CHANGED
package/src/model/Option.ts
CHANGED
package/src/model/Path.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/* eslint-disable @typescript-eslint/no-extraneous-class */
|
|
2
2
|
/* eslint-disable @shopify/no-fully-static-classes */
|
|
3
|
-
import { Field, type FlexibleProvablePure, Poseidon } from "
|
|
3
|
+
import { Field, type FlexibleProvablePure, Poseidon } from "o1js";
|
|
4
4
|
|
|
5
5
|
import { stringToField } from "../utils/utils";
|
|
6
6
|
|
package/src/model/Transaction.ts
CHANGED
package/src/protocol/Protocol.ts
CHANGED
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
|
+
AreProofsEnabled,
|
|
3
|
+
ChildContainerProvider,
|
|
2
4
|
log,
|
|
3
5
|
ModuleContainer,
|
|
4
6
|
ModulesConfig,
|
|
@@ -18,15 +20,16 @@ import { StateService } from "../state/StateService";
|
|
|
18
20
|
import { ProtocolModule } from "./ProtocolModule";
|
|
19
21
|
import { ProvableTransactionHook } from "./ProvableTransactionHook";
|
|
20
22
|
import { NoopTransactionHook } from "../blockmodules/NoopTransactionHook";
|
|
23
|
+
import { ProtocolEnvironment } from "./ProtocolEnvironment";
|
|
21
24
|
|
|
22
25
|
export type GenericProtocolModuleRecord = ModulesRecord<
|
|
23
|
-
TypedClass<ProtocolModule
|
|
26
|
+
TypedClass<ProtocolModule<unknown>>
|
|
24
27
|
>;
|
|
25
28
|
|
|
26
|
-
interface BlockProverType extends ProtocolModule
|
|
29
|
+
interface BlockProverType extends ProtocolModule<object>, BlockProvable {}
|
|
27
30
|
|
|
28
31
|
interface StateTransitionProverType
|
|
29
|
-
extends ProtocolModule
|
|
32
|
+
extends ProtocolModule<object>,
|
|
30
33
|
StateTransitionProvable {}
|
|
31
34
|
|
|
32
35
|
export interface ProtocolCustomModulesRecord {
|
|
@@ -45,34 +48,22 @@ export interface ProtocolDefinition<Modules extends ProtocolModulesRecord> {
|
|
|
45
48
|
* @deprecated
|
|
46
49
|
*/
|
|
47
50
|
state?: StateService;
|
|
48
|
-
|
|
51
|
+
config?: ModulesConfig<Modules>;
|
|
49
52
|
}
|
|
50
53
|
|
|
51
|
-
export class Protocol<
|
|
52
|
-
|
|
53
|
-
|
|
54
|
+
export class Protocol<Modules extends ProtocolModulesRecord>
|
|
55
|
+
extends ModuleContainer<Modules>
|
|
56
|
+
implements ProtocolEnvironment
|
|
57
|
+
{
|
|
54
58
|
// .from() to create Protocol
|
|
55
59
|
public static from<Modules extends ProtocolModulesRecord>(
|
|
56
60
|
modules: ProtocolDefinition<Modules>
|
|
57
|
-
) {
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
const emptyConfig = Object.keys(modules.modules).reduce<any>(
|
|
64
|
-
(agg, item: string) => {
|
|
65
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-member-access
|
|
66
|
-
agg[item] = {};
|
|
67
|
-
// eslint-disable-next-line @typescript-eslint/no-unsafe-return
|
|
68
|
-
return agg;
|
|
69
|
-
},
|
|
70
|
-
{}
|
|
71
|
-
);
|
|
72
|
-
// eslint-disable-next-line @typescript-eslint/consistent-type-assertions
|
|
73
|
-
protocol.configure(emptyConfig as ModulesConfig<Modules>);
|
|
74
|
-
|
|
75
|
-
return protocol;
|
|
61
|
+
): TypedClass<Protocol<Modules>> {
|
|
62
|
+
return class ScopedProtocol extends Protocol<Modules> {
|
|
63
|
+
public constructor() {
|
|
64
|
+
super(modules);
|
|
65
|
+
}
|
|
66
|
+
};
|
|
76
67
|
}
|
|
77
68
|
|
|
78
69
|
public definition: ProtocolDefinition<Modules>;
|
|
@@ -85,32 +76,6 @@ export class Protocol<
|
|
|
85
76
|
public constructor(definition: ProtocolDefinition<Modules>) {
|
|
86
77
|
super(definition);
|
|
87
78
|
this.definition = definition;
|
|
88
|
-
|
|
89
|
-
// Register the BlockModules seperately since we need to
|
|
90
|
-
// inject them differently later
|
|
91
|
-
let atLeastOneTransactionHookRegistered = false;
|
|
92
|
-
Object.entries(definition.modules).forEach(([key, value]) => {
|
|
93
|
-
if (Object.prototype.isPrototypeOf.call(ProvableTransactionHook, value)) {
|
|
94
|
-
this.container.register(
|
|
95
|
-
"ProvableTransactionHook",
|
|
96
|
-
{ useToken: key },
|
|
97
|
-
{ lifecycle: Lifecycle.ContainerScoped }
|
|
98
|
-
);
|
|
99
|
-
atLeastOneTransactionHookRegistered = true;
|
|
100
|
-
}
|
|
101
|
-
});
|
|
102
|
-
|
|
103
|
-
// We need this so that tsyringe doesn't throw when no hooks are registered
|
|
104
|
-
if (!atLeastOneTransactionHookRegistered) {
|
|
105
|
-
this.container.register(
|
|
106
|
-
"ProvableTransactionHook",
|
|
107
|
-
{ useClass: NoopTransactionHook },
|
|
108
|
-
{ lifecycle: Lifecycle.ContainerScoped }
|
|
109
|
-
);
|
|
110
|
-
}
|
|
111
|
-
// this.container.afterResolution<ProvableTransactionHook>("ProvableTransactionHook", (token, result) => {
|
|
112
|
-
// if ()
|
|
113
|
-
// })
|
|
114
79
|
}
|
|
115
80
|
|
|
116
81
|
public get stateService(): StateService {
|
|
@@ -128,10 +93,6 @@ export class Protocol<
|
|
|
128
93
|
log.debug(`Decorated ${moduleName}`);
|
|
129
94
|
containedModule.protocol = this;
|
|
130
95
|
|
|
131
|
-
log.debug(
|
|
132
|
-
"Is instanceof:",
|
|
133
|
-
containedModule instanceof ProvableTransactionHook
|
|
134
|
-
);
|
|
135
96
|
if (containedModule instanceof ProvableTransactionHook) {
|
|
136
97
|
containedModule.name = moduleName;
|
|
137
98
|
}
|
|
@@ -162,21 +123,67 @@ export class Protocol<
|
|
|
162
123
|
InstanceType<Modules["StateTransitionProver"]>
|
|
163
124
|
>("StateTransitionProver");
|
|
164
125
|
}
|
|
126
|
+
|
|
127
|
+
public getAreProofsEnabled(): AreProofsEnabled {
|
|
128
|
+
return this.container.resolve<AreProofsEnabled>("AreProofsEnabled");
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
public create(childContainerProvider: ChildContainerProvider) {
|
|
132
|
+
super.create(childContainerProvider);
|
|
133
|
+
|
|
134
|
+
// Register the BlockModules seperately since we need to
|
|
135
|
+
// inject them differently later
|
|
136
|
+
let atLeastOneTransactionHookRegistered = false;
|
|
137
|
+
Object.entries(this.definition.modules).forEach(([key, value]) => {
|
|
138
|
+
if (Object.prototype.isPrototypeOf.call(ProvableTransactionHook, value)) {
|
|
139
|
+
this.container.register(
|
|
140
|
+
"ProvableTransactionHook",
|
|
141
|
+
{ useToken: key },
|
|
142
|
+
{ lifecycle: Lifecycle.ContainerScoped }
|
|
143
|
+
);
|
|
144
|
+
atLeastOneTransactionHookRegistered = true;
|
|
145
|
+
}
|
|
146
|
+
});
|
|
147
|
+
|
|
148
|
+
// We need this so that tsyringe doesn't throw when no hooks are registered
|
|
149
|
+
if (!atLeastOneTransactionHookRegistered) {
|
|
150
|
+
this.container.register(
|
|
151
|
+
"ProvableTransactionHook",
|
|
152
|
+
{ useClass: NoopTransactionHook },
|
|
153
|
+
{ lifecycle: Lifecycle.ContainerScoped }
|
|
154
|
+
);
|
|
155
|
+
}
|
|
156
|
+
}
|
|
165
157
|
}
|
|
166
158
|
|
|
167
159
|
export const VanillaProtocol = {
|
|
168
160
|
create(stateService?: StateService) {
|
|
169
|
-
return VanillaProtocol.from(
|
|
161
|
+
return VanillaProtocol.from(
|
|
162
|
+
{},
|
|
163
|
+
{
|
|
164
|
+
BlockProver: {},
|
|
165
|
+
StateTransitionProver: {},
|
|
166
|
+
},
|
|
167
|
+
stateService
|
|
168
|
+
);
|
|
170
169
|
},
|
|
171
170
|
|
|
172
171
|
from<AdditonalModules extends GenericProtocolModuleRecord>(
|
|
173
172
|
additionalModules: AdditonalModules,
|
|
173
|
+
config: ModulesConfig<
|
|
174
|
+
AdditonalModules & {
|
|
175
|
+
StateTransitionProver: typeof StateTransitionProver;
|
|
176
|
+
BlockProver: typeof BlockProver;
|
|
177
|
+
}
|
|
178
|
+
>,
|
|
174
179
|
stateService?: StateService
|
|
175
|
-
):
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
+
): TypedClass<
|
|
181
|
+
Protocol<
|
|
182
|
+
AdditonalModules & {
|
|
183
|
+
StateTransitionProver: typeof StateTransitionProver;
|
|
184
|
+
BlockProver: typeof BlockProver;
|
|
185
|
+
}
|
|
186
|
+
>
|
|
180
187
|
> {
|
|
181
188
|
return Protocol.from({
|
|
182
189
|
modules: {
|
|
@@ -184,7 +191,9 @@ export const VanillaProtocol = {
|
|
|
184
191
|
BlockProver,
|
|
185
192
|
...additionalModules,
|
|
186
193
|
},
|
|
194
|
+
|
|
195
|
+
config,
|
|
187
196
|
state: stateService,
|
|
188
197
|
});
|
|
189
198
|
},
|
|
190
|
-
};
|
|
199
|
+
};
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
import { StateService } from "../state/StateService";
|
|
2
|
+
import { StateServiceProvider } from "../state/StateServiceProvider";
|
|
3
|
+
import { AreProofsEnabled } from "@proto-kit/common";
|
|
4
|
+
|
|
5
|
+
export interface ProtocolEnvironment {
|
|
6
|
+
get stateService(): StateService
|
|
7
|
+
get stateServiceProvider(): StateServiceProvider
|
|
8
|
+
getAreProofsEnabled(): AreProofsEnabled
|
|
9
|
+
}
|
|
@@ -1,20 +1,23 @@
|
|
|
1
1
|
import {
|
|
2
2
|
AreProofsEnabled,
|
|
3
|
-
|
|
3
|
+
ChildContainerProvider,
|
|
4
|
+
ConfigurableModule,
|
|
5
|
+
noop,
|
|
4
6
|
} from "@proto-kit/common";
|
|
5
7
|
|
|
6
|
-
import
|
|
8
|
+
import { ProtocolEnvironment } from "./ProtocolEnvironment";
|
|
7
9
|
|
|
8
|
-
export abstract class ProtocolModule
|
|
9
|
-
|
|
10
|
-
{
|
|
11
|
-
public
|
|
12
|
-
|
|
13
|
-
public protocol?: Protocol<ProtocolModulesRecord>;
|
|
10
|
+
export abstract class ProtocolModule<
|
|
11
|
+
Config
|
|
12
|
+
> extends ConfigurableModule<Config> {
|
|
13
|
+
public protocol?: ProtocolEnvironment;
|
|
14
14
|
|
|
15
15
|
public get appChain(): AreProofsEnabled | undefined {
|
|
16
|
-
return this.protocol?.
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
return this.protocol?.getAreProofsEnabled();
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
// eslint-disable-next-line @typescript-eslint/no-unused-vars
|
|
20
|
+
public create(childContainerProvider: ChildContainerProvider): void {
|
|
21
|
+
noop();
|
|
19
22
|
}
|
|
20
23
|
}
|
|
@@ -2,6 +2,6 @@ import { BlockProverExecutionData } from "../prover/block/BlockProvable";
|
|
|
2
2
|
|
|
3
3
|
import { TransitioningProtocolModule } from "./TransitioningProtocolModule";
|
|
4
4
|
|
|
5
|
-
export abstract class ProvableTransactionHook extends TransitioningProtocolModule {
|
|
5
|
+
export abstract class ProvableTransactionHook<Config> extends TransitioningProtocolModule<Config> {
|
|
6
6
|
public abstract onTransaction(executionData: BlockProverExecutionData): void;
|
|
7
7
|
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
import { Experimental, Field, type Proof, Provable, SelfProof } from "
|
|
2
|
+
import { Experimental, Field, type Proof, Provable, SelfProof } from "o1js";
|
|
3
3
|
import { container, inject, injectable, injectAll } from "tsyringe";
|
|
4
4
|
import {
|
|
5
5
|
AreProofsEnabled,
|
|
@@ -75,7 +75,7 @@ export class BlockProverProgrammable extends ZkProgrammable<
|
|
|
75
75
|
StateTransitionProverPublicOutput
|
|
76
76
|
>,
|
|
77
77
|
public readonly runtime: ZkProgrammable<undefined, MethodPublicOutput>,
|
|
78
|
-
private readonly blockModules: ProvableTransactionHook[]
|
|
78
|
+
private readonly blockModules: ProvableTransactionHook<unknown>[]
|
|
79
79
|
) {
|
|
80
80
|
super();
|
|
81
81
|
}
|
|
@@ -377,7 +377,7 @@ export class BlockProverProgrammable extends ZkProgrammable<
|
|
|
377
377
|
* then be merged to be committed to the base-layer contract
|
|
378
378
|
*/
|
|
379
379
|
@injectable()
|
|
380
|
-
export class BlockProver extends ProtocolModule implements BlockProvable {
|
|
380
|
+
export class BlockProver extends ProtocolModule<object> implements BlockProvable {
|
|
381
381
|
public zkProgrammable: BlockProverProgrammable;
|
|
382
382
|
|
|
383
383
|
public constructor(
|
|
@@ -389,7 +389,7 @@ export class BlockProver extends ProtocolModule implements BlockProvable {
|
|
|
389
389
|
@inject("Runtime")
|
|
390
390
|
public readonly runtime: WithZkProgrammable<undefined, MethodPublicOutput>,
|
|
391
391
|
@injectAll("ProvableTransactionHook")
|
|
392
|
-
transactionHooks: ProvableTransactionHook[]
|
|
392
|
+
transactionHooks: ProvableTransactionHook<unknown>[]
|
|
393
393
|
) {
|
|
394
394
|
super();
|
|
395
395
|
this.zkProgrammable = new BlockProverProgrammable(
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/* eslint-disable max-lines */
|
|
2
|
-
import { Bool, Experimental, Field, Provable, SelfProof } from "
|
|
2
|
+
import { Bool, Experimental, Field, Provable, SelfProof } from "o1js";
|
|
3
3
|
import { injectable } from "tsyringe";
|
|
4
4
|
import {
|
|
5
5
|
AreProofsEnabled,
|
|
@@ -203,12 +203,6 @@ export class StateTransitionProverProgrammable extends ZkProgrammable<
|
|
|
203
203
|
transition.from.value
|
|
204
204
|
);
|
|
205
205
|
|
|
206
|
-
// if (!membershipValid.toBoolean()) {
|
|
207
|
-
// console.log(
|
|
208
|
-
// `Merklewitness error ${root1.toString()} ${root2.toString()}`
|
|
209
|
-
// );
|
|
210
|
-
// }
|
|
211
|
-
|
|
212
206
|
membershipValid
|
|
213
207
|
.or(transition.from.isSome.not())
|
|
214
208
|
.assertTrue(
|
|
@@ -351,7 +345,7 @@ export class StateTransitionProverProgrammable extends ZkProgrammable<
|
|
|
351
345
|
|
|
352
346
|
@injectable()
|
|
353
347
|
export class StateTransitionProver
|
|
354
|
-
extends ProtocolModule
|
|
348
|
+
extends ProtocolModule<object>
|
|
355
349
|
implements StateTransitionProvable
|
|
356
350
|
{
|
|
357
351
|
public readonly zkProgrammable: StateTransitionProverProgrammable;
|
package/src/state/State.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Mixin } from "ts-mixer";
|
|
2
|
-
import { Bool, Field, Provable, type FlexibleProvablePure } from "
|
|
2
|
+
import { Bool, Field, Provable, type FlexibleProvablePure } from "o1js";
|
|
3
3
|
import { container } from "tsyringe";
|
|
4
4
|
import { dummyValue } from "@proto-kit/common";
|
|
5
5
|
|
package/src/state/StateMap.ts
CHANGED