@proto-kit/protocol 0.1.1-develop.267 → 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/assert/assert.d.ts +1 -1
- package/dist/state/assert/assert.d.ts.map +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.d.ts.map +1 -1
- package/dist/state/context/RuntimeMethodExecutionContext.js +2 -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/RollupMerkleTree.d.ts +16 -16
- package/dist/utils/merkletree/RollupMerkleTree.d.ts.map +1 -1
- package/dist/utils/merkletree/RollupMerkleTree.js +1 -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/assert/assert.test.ts +1 -1
- package/src/state/assert/assert.ts +1 -1
- package/src/state/context/RuntimeMethodExecutionContext.ts +5 -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/RollupMerkleTree.ts +1 -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
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
|
@@ -1,6 +1,9 @@
|
|
|
1
|
-
import { Bool } from "
|
|
1
|
+
import { Bool } from "o1js";
|
|
2
2
|
import { singleton } from "tsyringe";
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
ProvableMethodExecutionContext,
|
|
5
|
+
ProvableMethodExecutionResult,
|
|
6
|
+
} from "@proto-kit/common";
|
|
4
7
|
import { StateTransition } from "../../model/StateTransition";
|
|
5
8
|
import { RuntimeTransaction } from "../../model/transaction/RuntimeTransaction";
|
|
6
9
|
import { NetworkState } from "../../model/network/NetworkState";
|
|
@@ -21,7 +21,9 @@ const errors = {
|
|
|
21
21
|
* underlying values to improve developer experience.
|
|
22
22
|
*/
|
|
23
23
|
export function protocolState() {
|
|
24
|
-
return <
|
|
24
|
+
return <
|
|
25
|
+
TargetTransitioningModule extends TransitioningProtocolModule<unknown>
|
|
26
|
+
>(
|
|
25
27
|
target: TargetTransitioningModule,
|
|
26
28
|
propertyKey: string
|
|
27
29
|
) => {
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
/* eslint-disable line-comment-position */
|
|
3
3
|
/* eslint-disable no-inline-comments */
|
|
4
4
|
/* eslint-disable @typescript-eslint/no-magic-numbers */
|
|
5
|
-
import { Bool, Field, Poseidon, Provable, Struct } from "
|
|
5
|
+
import { Bool, Field, Poseidon, Provable, Struct } from "o1js";
|
|
6
6
|
import { range } from "@proto-kit/common";
|
|
7
7
|
|
|
8
8
|
import { notInCircuit } from "../utils";
|
package/src/utils/utils.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
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
|
|
2
|
+
/* eslint-disable @typescript-eslint/no-explicit-any,@typescript-eslint/ban-types, @typescript-eslint/no-unsafe-return */
|
|
3
3
|
|
|
4
|
-
import { Field, Poseidon, Provable } from "
|
|
4
|
+
import { Field, Poseidon, Provable } from "o1js";
|
|
5
5
|
import floor from "lodash/floor";
|
|
6
6
|
|
|
7
7
|
export type ReturnType<FunctionType extends Function> = FunctionType extends (
|
|
@@ -82,5 +82,3 @@ export function singleFieldToString(value: Field | bigint): string {
|
|
|
82
82
|
}
|
|
83
83
|
return value.toString();
|
|
84
84
|
}
|
|
85
|
-
|
|
86
|
-
export function noop(): void {}
|
package/test/BlockProver.test.ts
CHANGED
|
@@ -1,12 +1,5 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import {
|
|
3
|
-
Bool,
|
|
4
|
-
Experimental,
|
|
5
|
-
Field,
|
|
6
|
-
PrivateKey,
|
|
7
|
-
Proof,
|
|
8
|
-
UInt64,
|
|
9
|
-
} from "snarkyjs";
|
|
2
|
+
import { Bool, Experimental, Field, PrivateKey, Proof, UInt64 } from "o1js";
|
|
10
3
|
|
|
11
4
|
import {
|
|
12
5
|
BlockProver,
|
|
@@ -29,12 +22,16 @@ import { UnsignedTransaction } from "@proto-kit/sequencer";
|
|
|
29
22
|
import { AccountStateModule } from "../src/blockmodules/AccountStateModule";
|
|
30
23
|
import { container } from "tsyringe";
|
|
31
24
|
import {
|
|
32
|
-
BlockModule,
|
|
25
|
+
BlockModule,
|
|
26
|
+
DefaultProvableHashList,
|
|
33
27
|
MethodPublicOutput,
|
|
34
28
|
NetworkState,
|
|
35
|
-
Protocol,
|
|
36
|
-
|
|
37
|
-
|
|
29
|
+
Protocol,
|
|
30
|
+
ProtocolMethodExecutionContext,
|
|
31
|
+
ProtocolTransaction,
|
|
32
|
+
ProvableStateTransition,
|
|
33
|
+
RuntimeTransaction,
|
|
34
|
+
StateTransitionProver,
|
|
38
35
|
} from "../src";
|
|
39
36
|
|
|
40
37
|
type BlockProverProofPair = [
|
package/test/State.test.ts
CHANGED
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import "reflect-metadata";
|
|
2
|
-
import { Bool, Field } from "
|
|
2
|
+
import { Bool, Field } from "o1js";
|
|
3
3
|
import { container } from "tsyringe";
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
6
|
Option,
|
|
7
7
|
ProvableStateTransition,
|
|
8
8
|
DefaultProvableHashList,
|
|
9
|
-
StateTransitionProvableBatch,
|
|
9
|
+
StateTransitionProvableBatch,
|
|
10
|
+
CachedMerkleTreeStore,
|
|
11
|
+
InMemoryMerkleTreeStorage,
|
|
10
12
|
} from "../src/index";
|
|
11
13
|
import {
|
|
12
14
|
RollupMerkleTree,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { MockAsyncMerkleTreeStore } from "@proto-kit/module/test/state/MockAsyncMerkleStore";
|
|
2
|
-
import { Field, Provable } from "
|
|
2
|
+
import { Field, Provable } from "o1js";
|
|
3
3
|
|
|
4
4
|
import { CachedMerkleTreeStore, RollupMerkleTree } from "../../src";
|
|
5
5
|
import { log } from "@proto-kit/common";
|
package/test/utils.test.ts
CHANGED