Skip to content

Conversation

@saitunc
Copy link
Contributor

@saitunc saitunc commented Jan 12, 2026

Changes

In this PR, it is aimed to convert from provable types to non-provable types in out-of-circuit code.

Starting point changes in this refactoring was to implement or convert to JSON type of the followings:

  • Block
  • BlockWithResult

And since they are

  • TransactionExecutionResult
  • PendingTransaction
  • StateTransitionBatch
  • UntypedStateTransition
  • NetworkState

Especially last 3 is used all around the Sequencing and Tracing modules.

Commits

UntypedStateTransition & StateTransitionBatch

  • Implement UntypedStateTransitionJson 0199877 ( rename: 5934a13 )
  • Implement in block and tracing services 0199877
  • Change in tracing, block result services 5934a13

TransactionExecutionResult

  • Implemented Json interface, TransactionExecutionResultJson b017bb5
  • Implement conversion function between json type and provable type to use when needed 08f95bb
  • Changed in execution and tracing 564ba7a
  • Changed in Prisma storage 6905b36
  • Changed in various modules fb4c854

PendingTransaction

  • Changed in PrivateMempool d3c9336
  • Changed in various modules d5b6d7b
  • Changed in storage and mempool d8558f9
  • Changed in execution and tracing 564ba7a

NetworkState

  • Define NetworkStateJson by inferring it from Struct c29a51d
  • add RuntimeProofParametersJson type with NetworkStateJson and PendingTransactionJsonType a4ac392

Miscellanous

  • refactor CllientBlock with value types 1093afe

#### Test

  • Updated changes in test files 57ad69d

This PR closes #201

saitunc and others added 30 commits January 7, 2026 10:34
@saitunc saitunc marked this pull request as ready for review January 15, 2026 08:26
@saitunc saitunc requested a review from rpanic January 15, 2026 09:18
@saitunc
Copy link
Contributor Author

saitunc commented Jan 15, 2026

I've updated the commits - there might be missing parts in codebase, but most of the changes will be done in this manner.

I'd like to have your opinion on a decision:

The fields of Block and BlockWithResult are modified directly, whereas interfaces such as TransactionWithResult and StateTransitionBatch are neither removed nor changed. This can be discussed, but i am for keeping both provable and non provable types, since having them enables us the access provable types in an easier way at the boundaries of the provable code.

docs: remove mistakenyl pushed file
};
}

export function networkStateToFields(json: NetworkStateJson): Field[] {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This function shouldn't exist - or at least the implementation should be NetworkState.toFields(NetworkState.fromJSON())

return [Field(json.block.height), Field(json.previous.rootHash)];
}

export function hashNetworkState(json: NetworkStateJson): string {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same here, we already implement hash() in the provable version, so we should use this to not run into inconsistencies

hash: Field(blockData.hash),
height: Field(blockData.height),
hash: blockData.hash,
height: blockData.height.toString(),
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

height is number and can stay number imo - no need to convert into strings here

}

interface PendingTransactionJSONType {
export interface PendingTransactionJSONType {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So here, since PendingTransaction is never used inside circuits, we can just get rid of this type, and instead make PendingTransaction non-provable. That can get tricky with the signatures - we can keep UnsignedTransaction provable for now? Or create a new transaction creation API altogether

AppChainModule,
} from "@proto-kit/sequencer";
import { NetworkState } from "@proto-kit/protocol";
import { NetworkStateJson } from "@proto-kit/protocol";
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm a bit unsure, is the naming (NetworkState, NetworkStateJson) or (ProvableNetworkState, NetworkState) better?

),
startingStateBeforeHook: input.params.startingStateBeforeHook,

startingStateAfterHook: input.params.startingStateAfterHook,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Insert empty line


/**
* Serializer for RuntimeProofParametersJson.
* Since RuntimeProofParametersJson is already JSON-compatible, this is trivial.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Indeed this is trivial, hence why we have a JsonTaskSerializer that does this already - let's remove this one and replace usage with the JsonTaskSerializer


export type TaskStateRecord = Record<string, Field[]>;

export type TaskStateRecordJson = Record<string, string[]>;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

again - replace the existing struct


export type TaskStateRecordJson = Record<string, string[]>;

export function taskStateRecordToJson(
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should never live in a component like this - either implement a TaskSerializer or change the methods that create TaskStateRecords to do the serialization

tx.stateTransitions[1].stateTransitions
);
): RuntimeProofParametersJson {
const stBatch = STBatchFromJson(tx.stateTransitions[1]);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just seeing this - again, no standalone mapping functions, and then the naming case...

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Refactor non-provable codebase to use value-types instead of provable types

3 participants