Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
57 commits
Select commit Hold shift + click to select a range
d2e2160
feat: add type alias for FieldString and helper function for it
saitunc Jan 7, 2026
4336578
refactor: change Field typed properties to FieldString type
saitunc Jan 7, 2026
be7c06e
refactor: update codebase to use string properties of Block
saitunc Jan 7, 2026
86f87db
refactor: allow Field in FieldString input
saitunc Jan 7, 2026
c29a51d
refactor: Infer JSON type of NetworkState and use in Block interface
saitunc Jan 7, 2026
adc99a0
refactor: update codebase for use of NetworkStateJson type
saitunc Jan 7, 2026
2483e82
refactor: remove unnecessary stringifications and type conversions
saitunc Jan 7, 2026
ae96af1
refactor: change use of NetworkState to NetworkStateJson in codebase
saitunc Jan 9, 2026
1093afe
refactor: refactor ClientBlock and used parts in codebase
saitunc Jan 9, 2026
0199877
refactor: update UntypedStateTransition with UntypedSTJson
saitunc Jan 12, 2026
76e1417
refactor: add utility function for hashing NetworkStateJson values
saitunc Jan 13, 2026
55d5dec
refactor: apply refactoring where NetworkStateJson is used
saitunc Jan 13, 2026
78aae19
refactor: add BlockHahMerkleTreewitnessJson and refactor with it
saitunc Jan 13, 2026
31db4aa
refactor: refactor BlockMapper and BlockResultMapper with new types
saitunc Jan 14, 2026
7706aa3
refactor: update methodId type to string
saitunc Jan 14, 2026
b46e81d
refactor: add minor change to use methodId
saitunc Jan 14, 2026
5934a13
refactor: rename UntypedSTJson to UntypedStateTranisitionJson
saitunc Jan 14, 2026
b017bb5
refactor: implement TransactionExecutionResultJson and use it for Block
saitunc Jan 14, 2026
d3c9336
refactor: refactor PrivateMempool to use PendingTransactionJson type
saitunc Jan 14, 2026
08f95bb
refactor: add serialization utility functions for non-provable types
saitunc Jan 15, 2026
d8558f9
refactor: use non-provable types in storage and mempool interfaces
saitunc Jan 15, 2026
564ba7a
refactor:use non-provable types in execution and tracing services
saitunc Jan 15, 2026
6905b36
refactor: update Prisma interactions to use non-provable types
saitunc Jan 15, 2026
fb4c854
refactor: use non-provable types in object mappers
saitunc Jan 15, 2026
d5b6d7b
refactor: update PendingTransaction related code PendingTransactionJs…
saitunc Jan 15, 2026
57ad69d
refactor(test): update with changes in codebase
saitunc Jan 15, 2026
a4ac392
refactor: use non-provable types in tracing and task layers
saitunc Jan 15, 2026
bc53d88
refactor: use non-provable types in tracing services
saitunc Jan 15, 2026
57c3520
style: run lint fix
saitunc Jan 15, 2026
08e7d35
Merge branch 'develop' into refactor/refactor-provable-types
saitunc Jan 15, 2026
2a37bb7
style: run lint fix
saitunc Jan 15, 2026
f041a12
Delete planning file
saitunc Jan 15, 2026
1989a19
refactor: rename NetworkState to ProvableNetworkState
saitunc Jan 16, 2026
9b8bd33
refactor: remove hashNetworkState, use .hash() of ProvableNetworkState
saitunc Jan 17, 2026
ffdf8dd
refactor: change type of block height from string to number
saitunc Jan 17, 2026
ebed33e
refactor: simplify ClientBlock construction and fix type in Block
saitunc Jan 17, 2026
11f7b85
refactor: update UntypedStateTranisition and UntypedOption
saitunc Jan 17, 2026
4a77e29
refactor: refactor away inheritance of PendingTransaction
saitunc Jan 17, 2026
231d654
refactor: make original types non-provable and remove unnecessary code
saitunc Jan 17, 2026
b9267b8
refactor: replace PendingTransactionJSONType with PendingTransaction
saitunc Jan 18, 2026
1ee230b
refactor: move FieldString to common/utils
saitunc Jan 18, 2026
170d86b
refactor: use toRuntimeTransaction for signature verification
saitunc Jan 18, 2026
7dab7e5
refactor: replace TransactionExecutionResultJson with TransactionExec…
saitunc Jan 18, 2026
a5602a2
fix: update missing PendingTransaction replacement
saitunc Jan 18, 2026
0d8db76
refactor: update toProvable in UntypedStateTransition
saitunc Jan 18, 2026
20081d7
refactor: replace UntypedStateTransitionJson with UntypedStateTransition
saitunc Jan 18, 2026
8a09ced
refactor: replace StateTransitionBatchJson with StateTransitionBatch
saitunc Jan 18, 2026
8053677
refactor(fix): fix use of PendingTransaction attributes
saitunc Jan 18, 2026
f8bb8e2
refactor: remove STBatchFromJson and fix UntypedStateTransition code
saitunc Jan 18, 2026
4ed3853
refactor: update RuntimeProofParameters and TaskStateRecord
saitunc Jan 19, 2026
a959f99
refactor(fix): fix missing changes on refactored non-provable code
saitunc Jan 19, 2026
0c38966
refactor: add helper methods to UntypedOption and UntypedStateTransition
saitunc Jan 19, 2026
019591f
refactor: flatten PendingTransaction like UnsignedTransaction
saitunc Jan 19, 2026
9fd7a92
refactor: update code using PendingTransaction
saitunc Jan 19, 2026
cbecb5a
refactor: make decode to take string array as input
saitunc Jan 19, 2026
44e9ea6
refactor: remove unnecessary lines and fix mappings
saitunc Jan 19, 2026
4f776a7
style: run lint fix
saitunc Jan 19, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions packages/api/src/graphql/modules/BlockResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,17 @@ import { BatchTransactionModel } from "./model/BatchTransactionModel";
export class BlockModel {
public static fromServiceLayerModel(block: Block) {
return new BlockModel(
Number(block.networkState.during.block.height.toBigInt()),
Number(block.networkState.during.block.height),
block.transactions.map((tx) =>
BatchTransactionModel.fromServiceLayerModel({
tx: tx.tx,
status: tx.status.toBoolean(),
status: tx.status,
statusMessage: tx.statusMessage,
})
),
block.transactionsHash.toString(),
block.hash.toString(),
block.previousBlockHash?.toString()
block.transactionsHash,
block.hash,
block.previousBlockHash
);
}

Expand Down
6 changes: 3 additions & 3 deletions packages/api/src/graphql/modules/MempoolResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ export class TransactionObject {
isMessage,
} = pt.toJSON();
return new TransactionObject(
pt.hash().toString(),
pt.hash,
methodId,
sender,
nonce,
Expand Down Expand Up @@ -128,7 +128,7 @@ export class MempoolResolver extends GraphqlModule {
const decoded = PendingTransaction.fromJSON(tx);
await this.mempool.add(decoded);

return decoded.hash().toString();
return decoded.hash;
}

// TODO Add retrieval of pending messages somewhere as well
Expand Down Expand Up @@ -162,6 +162,6 @@ export class MempoolResolver extends GraphqlModule {
})
public async transactions() {
const txs = await this.transactionStorage.getPendingUserTransactions();
return txs.map((x) => x.hash().toString());
return txs.map((x) => x.hash);
}
}
4 changes: 2 additions & 2 deletions packages/api/src/graphql/modules/QueryGraphqlModule.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {
} from "@proto-kit/module";
import {
MandatoryProtocolModulesRecord,
NetworkState,
ProvableNetworkState,
Protocol,
ProtocolModulesRecord,
State,
Expand Down Expand Up @@ -385,7 +385,7 @@ export class QueryGraphqlModule<
this.networkStateTransportModule
);
const networkType = this.flexiblePureToGraphql(
NetworkState,
ProvableNetworkState,
"Network",
this.jsonToGraphQl.bind(this)
);
Expand Down
2 changes: 1 addition & 1 deletion packages/api/src/metrics/SequencerInstrumentation.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export class SequencerInstrumentation extends InstrumentationBase<{}> {
super("protokit", "canary", {});
if (trigger !== undefined) {
trigger.events.on("block-produced", (block) => {
this.blockProduced(parseInt(block.height.toString(), 10));
this.blockProduced(block.height);
});
}
}
Expand Down
14 changes: 14 additions & 0 deletions packages/common/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -295,3 +295,17 @@ export function assertDefined<T>(
throw new Error(msg ?? "Value is undefined");
}
}

/**
* Type for serialized {@link Field}.
*/
export type FieldString = string;
/**
*
* @param value Value to be converted to {@link Field}.
* @returns
*/
// eslint-disable-next-line @typescript-eslint/no-redeclare
export const FieldString = (
value: number | string | bigint | Field
): FieldString => String(value);
6 changes: 2 additions & 4 deletions packages/indexer/src/IndexerNotifier.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,7 @@ export class IndexerNotifier extends SequencerModule<Record<never, never>> {
this.indexSettlementTask.inputSerializer();

this.sequencer.events.on("block-metadata-produced", async (block) => {
log.debug(
"Notifiying the indexer about block",
block.block.height.toBigInt()
);
log.debug("Notifiying the indexer about block", block.block.height);
const payload = await inputSerializer.toJSON(block);
const sequencerId = this.sequencerIdProvider.getSequencerId();

Expand All @@ -69,6 +66,7 @@ export class IndexerNotifier extends SequencerModule<Record<never, never>> {
const txQueue = await this.taskQueue.getQueue(
this.indexPendingTxTask.name
);
// This part seems weird
const payload = await txInputSerializer.toJSON(tx);
const sequencerId = this.sequencerIdProvider.getSequencerId();

Expand Down
7 changes: 3 additions & 4 deletions packages/indexer/src/tasks/IndexBlockTask.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,12 +37,11 @@ export class IndexBlockTask
await this.blockStorage.pushBlock(input.block);
await this.blockStorage.pushResult(input.result);
} catch (error) {
log.error("Failed to index block", input.block.height.toBigInt(), error);
return undefined;
log.error("Failed to index block", input.block.height, error);
return;
}

log.info(`Block ${input.block.height.toBigInt()} indexed sucessfully`);
return "";
log.info(`Block ${input.block.height} indexed sucessfully`);
}

public inputSerializer(): TaskSerializer<IndexBlockTaskParameters> {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { log } from "@proto-kit/common";
import { jest } from "@jest/globals";

import { Indexer } from "../src/Indexer";
import { GeneratedResolverFactoryGraphqlModule } from "../src/api/GeneratedResolverFactoryGraphqlModule";
import { GeneratedResolverFactoryGraphqlModule } from "../src";

log.setLevel("info");

Expand Down
4 changes: 1 addition & 3 deletions packages/indexer/test/IndexBlockTask.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ describe("IndexBlockTask", () => {
const storage = indexer.resolve("BlockStorage");
const latestBlock = await storage.getLatestBlock();

expect(latestBlock?.block.hash.toBigInt()).toBe(
block.block.hash.toBigInt()
);
expect(latestBlock?.block.hash).toBe(block.block.hash);
});
});
7 changes: 4 additions & 3 deletions packages/indexer/test/IndexerNotifier.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import {
} from "@proto-kit/sdk";
import {
LocalTaskQueue,
PendingTransaction,
Sequencer,
TaskPayload,
VanillaTaskWorkerModules,
Expand Down Expand Up @@ -130,7 +131,7 @@ async function sendTransactions(
{ nonce: i }
);

console.log("tx nonce", tx.transaction?.nonce.toBigInt());
console.log("tx nonce", (tx.transaction as PendingTransaction).nonce);

await tx.sign();
await tx.send();
Expand All @@ -141,7 +142,7 @@ async function sendTransactions(
const txs = await mempool.getTxs();
console.log(
"txs",
txs.map((tx) => tx.nonce.toBigInt())
txs.map((tx) => tx.nonce)
);

return await appChain.produceBlock();
Expand Down Expand Up @@ -183,7 +184,7 @@ describe.skip("IndexerNotifier", () => {
.resolve(IndexBlockTaskParametersSerializer)
.fromJSON(addTaskSpy.mock.lastCall?.[0].payload!);

expect(block.height.toBigInt()).toBe(0n);
expect(block.height).toBe(0);
expect(block.transactions.length).toBe(2);
});
});
18 changes: 9 additions & 9 deletions packages/library/src/hooks/RuntimeFeeAnalyzerService.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import { container, inject } from "tsyringe";
import {
RuntimeMethodExecutionContext,
RuntimeTransaction,
NetworkState,
ProvableNetworkState,
} from "@proto-kit/protocol";
import { Field, Poseidon, Struct } from "o1js";

Expand Down Expand Up @@ -77,7 +77,7 @@ export class RuntimeFeeAnalyzerService extends ConfigurableModule<RuntimeFeeAnal

context.setup({
transaction: RuntimeTransaction.dummyTransaction(),
networkState: NetworkState.empty(),
networkState: ProvableNetworkState.empty(),
});

container.resolve(RuntimeMethodExecutionContext).clear();
Expand Down Expand Up @@ -110,8 +110,8 @@ export class RuntimeFeeAnalyzerService extends ConfigurableModule<RuntimeFeeAnal
{
...values,

[methodId.toString()]: {
methodId,
[methodId]: {
methodId: BigInt(methodId),

baseFee:
this.config.methods[combinedMethodName]?.baseFee ??
Expand All @@ -129,7 +129,7 @@ export class RuntimeFeeAnalyzerService extends ConfigurableModule<RuntimeFeeAnal
{
...indexes,
// eslint-disable-next-line no-plusplus
[methodId.toString()]: BigInt(methodCounter++),
[methodId]: BigInt(methodCounter++),
},
];
},
Expand Down Expand Up @@ -166,8 +166,8 @@ export class RuntimeFeeAnalyzerService extends ConfigurableModule<RuntimeFeeAnal
return this.persistedFeeTree;
}

public getFeeConfig(methodId: bigint) {
const feeConfig = this.getFeeTree().values[methodId.toString()];
public getFeeConfig(methodId: string) {
const feeConfig = this.getFeeTree().values[methodId];

return new MethodFeeConfigData({
methodId: Field(feeConfig.methodId),
Expand All @@ -177,9 +177,9 @@ export class RuntimeFeeAnalyzerService extends ConfigurableModule<RuntimeFeeAnal
});
}

public getWitness(methodId: bigint) {
public getWitness(methodId: string) {
const feeTree = this.getFeeTree();
return feeTree.tree.getWitness(feeTree.indexes[methodId.toString()]);
return feeTree.tree.getWitness(feeTree.indexes[methodId]);
}

public getRoot(): bigint {
Expand Down
6 changes: 3 additions & 3 deletions packages/library/src/hooks/TransactionFeeHook.ts
Original file line number Diff line number Diff line change
Expand Up @@ -131,14 +131,14 @@ export class TransactionFeeHook extends ProvableTransactionHook<TransactionFeeHo
): Promise<void> {
const feeConfig = Provable.witness(MethodFeeConfigData, () =>
this.feeAnalyzer.getFeeConfig(
executionData.transaction.methodId.toBigInt()
executionData.transaction.methodId.toString()
)
);
const witness = Provable.witness(
RuntimeFeeAnalyzerService.getWitnessType(),
() =>
this.feeAnalyzer.getWitness(
executionData.transaction.methodId.toBigInt()
executionData.transaction.methodId.toString()
)
);

Expand Down Expand Up @@ -167,7 +167,7 @@ export class TransactionFeeHook extends ProvableTransactionHook<TransactionFeeHo
args: BeforeTransactionHookArguments
): Promise<boolean> {
const feeConfig = this.feeAnalyzer.getFeeConfig(
args.transaction.methodId.toBigInt()
args.transaction.methodId.toString()
);

const fee = this.getFee(feeConfig);
Expand Down
4 changes: 2 additions & 2 deletions packages/library/test/math/State.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import {
StateServiceProvider,
RuntimeMethodExecutionContext,
RuntimeTransaction,
NetworkState,
ProvableNetworkState,
} from "@proto-kit/protocol";
import { UInt64, Field } from "o1js";
import { InMemoryStateService } from "@proto-kit/module";
Expand All @@ -24,7 +24,7 @@ describe("interop uint <-> state", () => {
const context = container.resolve(RuntimeMethodExecutionContext);
context.setup({
transaction: RuntimeTransaction.dummyTransaction(),
networkState: NetworkState.empty(),
networkState: ProvableNetworkState.empty(),
});

const uint = await state.get();
Expand Down
12 changes: 4 additions & 8 deletions packages/module/src/method/MethodParameterEncoder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ export class MethodParameterEncoder {

public constructor(private readonly types: ArgTypeArray) {}

public decode(fields: Field[], auxiliary: string[]): Promise<ArgArray> {
public decode(fields: string[], auxiliary: string[]): Promise<ArgArray> {
if (fields.length < this.fieldSize()) {
throw errors.fieldLengthNotMatching(this.fieldSize(), fields.length);
}
Expand All @@ -155,12 +155,8 @@ export class MethodParameterEncoder {
const inputFieldSize = MethodParameterEncoder.fieldSize(
type.publicInputType
)!;
const input = structFields
.slice(0, inputFieldSize)
.map((x) => x.toString());
const output = structFields
.slice(inputFieldSize)
.map((x) => x.toString());
const input = structFields.slice(0, inputFieldSize);
const output = structFields.slice(inputFieldSize);

// fromJSON has incompatible signature for Proof and DynamicProof
if (isProofType(type)) {
Expand All @@ -180,7 +176,7 @@ export class MethodParameterEncoder {
}

return (type as FlexibleProvable<unknown>).fromFields(
structFields,
structFields.map(Field),
[]
) as any;
})
Expand Down
10 changes: 5 additions & 5 deletions packages/module/src/runtime/MethodIdResolver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ export class MethodIdResolver {
this.runtime.assertIsValidModuleName(moduleName);

runtime.resolve(moduleName).runtimeMethodNames.forEach((methodName) => {
dict[this.getMethodId(moduleName, methodName).toString()] = {
dict[this.getMethodId(moduleName, methodName)] = {
moduleName,
methodName,
};
Expand Down Expand Up @@ -83,8 +83,8 @@ export class MethodIdResolver {
}, {});
}

public getMethodNameFromId(methodId: bigint): [string, string] | undefined {
const methodPath = this.dictionary[methodId.toString()];
public getMethodNameFromId(methodId: string): [string, string] | undefined {
const methodPath = this.dictionary[methodId];

if (methodPath === undefined) {
return undefined;
Expand All @@ -97,12 +97,12 @@ export class MethodIdResolver {
return [moduleName, methodName];
}

public getMethodId(moduleName: string, methodName: string): bigint {
public getMethodId(moduleName: string, methodName: string): string {
this.runtime.assertIsValidModuleName(moduleName);

return Poseidon.hash([
stringToField(moduleName),
stringToField(methodName),
]).toBigInt();
]).toString();
}
}
6 changes: 3 additions & 3 deletions packages/module/src/runtime/Runtime.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {
SimpleAsyncStateService,
RuntimeMethodExecutionContext,
RuntimeTransaction,
NetworkState,
ProvableNetworkState,
} from "@proto-kit/protocol";

import {
Expand Down Expand Up @@ -337,7 +337,7 @@ export class Runtime<Modules extends RuntimeModulesRecord>
* Encoding: "stringToField(module.name) << 128 + stringToField(method-name)"
*/
public getMethodById(
methodId: bigint
methodId: string
): ((...args: unknown[]) => Promise<unknown>) | undefined {
const methodDescriptor =
this.methodIdResolver.getMethodNameFromId(methodId);
Expand Down Expand Up @@ -388,7 +388,7 @@ export class Runtime<Modules extends RuntimeModulesRecord>
const context = container.resolve(RuntimeMethodExecutionContext);
context.setup({
transaction: RuntimeTransaction.dummyTransaction(),
networkState: NetworkState.empty(),
networkState: ProvableNetworkState.empty(),
});
return await this.zkProgrammable.compile(registry);
}
Expand Down
Loading
Loading