SortDecommitments
SortDecommitments PI
Input
pub struct CodeDecommitmentsDeduplicatorInputData<F: SmallField> {
pub initial_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
pub sorted_queue_initial_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
}Output
pub struct CodeDecommittmentsDeduplicatorOutputData<F: SmallField> {
pub final_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
}FSM Input and FSM Output
pub struct CodeDecommittmentsDeduplicatorFSMInputOutput<F: SmallField> {
pub initial_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
pub sorted_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
pub final_queue_state: QueueState<F, FULL_SPONGE_QUEUE_STATE_WIDTH>,
pub lhs_accumulator: [Num<F>; DEFAULT_NUM_PERMUTATION_ARGUMENT_REPETITIONS],
pub rhs_accumulator: [Num<F>; DEFAULT_NUM_PERMUTATION_ARGUMENT_REPETITIONS],
pub previous_packed_key: [UInt32<F>; PACKED_KEY_LENGTH],
pub first_encountered_timestamp: UInt32<F>,
pub previous_record: DecommitQuery<F>,
}Main circuit logic
This circuit handles the sorting and deduplication of code cancellation requests. Before starting, during the pre-start phase, the first decommitter queue is generated. To decommitter a code, the input will receive the hash root of the code, the length of the code, the code hash of the opcode, the number of opcodes and the code of the page. Next, it sorts the queue and, in the process, identifies and removes identical requests, serving as a filtering mechanism in case the same contract is called several times.
The detailed explanation of sorting and deduplicating can be found here.
First part
The circuit begins with allocating input part of the PI.
In this part, we should decide what initial_queue_state to use (the one from Input or the other one from FSM Input). We do the same for sorted queue.
Also, we decide to create a new result queue or use one from the previous circuit.
Now we need to generate challenges for permutation argument.
And decide whether we generate new accumulators for permutation argument or use existing ones.
Also, we make other parts of FSM state based on start_flag.
Main part
Here we implement the main logic of the circuit. We run a cycle where on each iteration we try to pop a new element.
We compute contribution to permutation argument accumulators.
After, we enforce that elements from sorted queue are actually sorted.
Also, we need to deduplicate some decommit requests if there are the same ones.
Now we update inner variables.
In the end, if the queues are empty, and we have taken the last element, we push it immediately.
Final part
We check that permutation accumulators are equal, if the queues are already empty.
Now we update PI output parts and compute a commitment. Then we allocate it as public variables.
Last updated