StorageSorter
StorageSorter PI
Input
pub struct StorageDeduplicatorInputData<F: SmallField> {
pub shard_id_to_process: UInt8<F>,
pub unsorted_log_queue_state: QueueState<F, QUEUE_STATE_WIDTH>,
pub intermediate_sorted_queue_state: QueueState<F, QUEUE_STATE_WIDTH>,
}Output
pub struct StorageDeduplicatorOutputData<F: SmallField> {
pub final_sorted_queue_state: QueueState<F, QUEUE_STATE_WIDTH>,
}FSM Input and FSM Output
Main circuit logic
The main logic of this circuit is sorting and deduplicating storage requests from unsorted_log_queue_state. The result storage requests are pushed to final_sorted_queue_state.
First part
We start, as usually, with allocating input fields from PI.
In this part, we should decide what unsorted_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 queue for the output, or continue working with the existing one.
Now we need to generate challenges for permutation argument.
And decide whether we generate new accumulators for permutation argument or use existing ones.
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.
Then we accumulate encodings for permutation argument. You can read more about it here.
Now we enforce sorting.
Maybe we should push the old query if the new key is different. So we push if at least one of these conditions holds:
there was a read at depth 0;
the sell is changes;
write that was declined, but not by a rollback.
After that, we update some inner variables.
Now we continue working with current query. We check that the read field is correct.
After that, we do some other variable updates.
After the main cycle, we do one more iteration if we took the last query from the queue during the last cycle.
Final part
If the queues are empty, we check the permutation argument accumulators equality.
Now we update PI output parts and compute a commitment. Then we allocate it as public variables.
Last updated