Skip to content

Commit

Permalink
deploy: 2e6c250
Browse files Browse the repository at this point in the history
  • Loading branch information
grjte committed Sep 7, 2023
1 parent f042579 commit a7f7001
Show file tree
Hide file tree
Showing 9 changed files with 88 additions and 36 deletions.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added assets/design/decoder/decoder_dyn_operation.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
30 changes: 20 additions & 10 deletions design/decoder/constraints.html

Large diffs are not rendered by default.

16 changes: 16 additions & 0 deletions design/decoder/main.html
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,7 @@ <h2 id="program-execution"><a class="header" href="#program-execution">Program e
<tr><td><code>REPEAT</code></td><td>Initiates a new iteration of an executing loop.</td></tr>
<tr><td><code>SPAN</code></td><td>Initiates processing of a new <a href="../programs.html#span-block">Span block</a>.</td></tr>
<tr><td><code>RESPAN</code></td><td>Initiates processing of a new operation batch within a span block.</td></tr>
<tr><td><code>DYN</code></td><td>Initiates processing of a new <a href="../programs.html#dyn-block">Dyn block</a>.</td></tr>
<tr><td><code>CALL</code></td><td>Initiates processing of a new <a href="../programs.html#call-block">Call block</a>.</td></tr>
<tr><td><code>SYSCALL</code></td><td>Initiates processing ofa new <a href="../programs.html#syscall-block">Syscall block</a>.</td></tr>
<tr><td><code>END</code></td><td>Marks the end of a program block.</td></tr>
Expand Down Expand Up @@ -402,6 +403,17 @@ <h4 id="span-operation"><a class="header" href="#span-operation">SPAN operation<
<li>Decrements <code>group_count</code> register by <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">1</span></span></span></span>.</li>
<li>Sets the <code>op_index</code> register to <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>.</li>
</ol>
<h4 id="dyn-operation"><a class="header" href="#dyn-operation">DYN operation</a></h4>
<p>Before a <code>DYN</code> operation is executed by the VM, the prover populates <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">...</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">7</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> registers with <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> as shown in the diagram below.</p>
<p><img src="../../assets/design/decoder/decoder_dyn_operation.png" alt="decoder_dyn_operation" /></p>
<p>In the above diagram, <code>blk</code> is the ID of the <em>dyn</em> block which is about to be executed. <code>blk</code> is also the address of the hasher row in the auxiliary hasher table. <code>prnt</code> is the ID of the block's parent.</p>
<p>When the VM executes a <code>DYN</code> operation, it does the following:</p>
<ol>
<li>Adds a tuple <code>(blk, prnt, 0)</code> to the block stack table.</li>
<li>Gets the hash of the dynamic code block <code>dynamic_block_hash</code> from the top four elements of the stack.</li>
<li>Adds the tuple <code>(blk, dynamic_block_hash, 0, 0)</code> to the block hash table.</li>
<li>Initiates a 2-to-1 hash computation in the hash chiplet (as described <a href="#simple-2-to-1-hash">here</a>) using <code>blk</code> as row address in the auxiliary hashing table and <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">...</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">7</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> as input values.</li>
</ol>
<h4 id="end-operation"><a class="header" href="#end-operation">END operation</a></h4>
<p>Before an <code>END</code> operation is executed by the VM, the prover populates <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8889em;vertical-align:-0.1944em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">0</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord">...</span><span class="mpunct">,</span><span class="mspace" style="margin-right:0.1667em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">3</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> registers with the hash of the block which is about to end. The prover also sets values in <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">4</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> and <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.8444em;vertical-align:-0.15em;"></span><span class="mord"><span class="mord mathnormal">h</span><span class="msupsub"><span class="vlist-t vlist-t2"><span class="vlist-r"><span class="vlist" style="height:0.3011em;"><span style="top:-2.55em;margin-left:0em;margin-right:0.05em;"><span class="pstrut" style="height:2.7em;"></span><span class="sizing reset-size6 size3 mtight"><span class="mord mtight">5</span></span></span></span><span class="vlist-s"></span></span><span class="vlist-r"><span class="vlist" style="height:0.15em;"><span></span></span></span></span></span></span></span></span></span> registers as follows:</p>
<ul>
Expand Down Expand Up @@ -482,6 +494,10 @@ <h4 id="skipping-the-loop"><a class="header" href="#skipping-the-loop">Skipping
<p>If the top of the stack is <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>, the VM still executes the <code>LOOP</code> operation. But unlike in the case when we need to enter the loop, the VM sets <code>is_loop</code> flag to <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span> in the block stack table, and does not add any rows to the block hash table. The last point means that the only possible operation to be executed after the <code>LOOP</code> operation is the <code>END</code> operation. This is illustrated in the diagram below.</p>
<p><img src="../../assets/design/decoder/decoder_loop_skipping.png" alt="decoder_loop_skipping" /></p>
<p>Moreover, since we've set the <code>is_loop</code> flag to <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">0</span></span></span></span>, executing the <code>END</code> operation does not remove any items from the stack.</p>
<h3 id="dyn-block-decoding"><a class="header" href="#dyn-block-decoding">DYN block decoding</a></h3>
<p>When decoding a <em>dyn</em> bock, the VM first executes a <code>DYN</code> operation, then executes the child block dynamically specified by the top of the stack. Once the child of the <em>dyn</em> block has been executed, the VM executes an <code>END</code> operation. This is illustrated in the diagram below.</p>
<p><img src="../../assets/design/decoder/decoder_dyn_block_decoding.png" alt="decoder_dyn_block_decoding" /></p>
<p>As described previously, when the VM executes a <code>DYN</code> operation, the hash of the child is added to the block hash table. This hash is removed only when the <code>END</code> operation for the child block is executed. Thus, until the child block corresponding to the dynamically specified target is executed, the block hash table is not cleared.</p>
<h3 id="span-block-decoding"><a class="header" href="#span-block-decoding">SPAN block decoding</a></h3>
<p>As described <a href="../programs.html#span-block">here</a>, a <em>span</em> block can contain one or more operation batches, each batch containing up to <span class="katex"><span class="katex-html" aria-hidden="true"><span class="base"><span class="strut" style="height:0.6444em;"></span><span class="mord">8</span></span></span></span> operation groups. At the high level, decoding of a span block is done as follows:</p>
<ol>
Expand Down
Loading

0 comments on commit a7f7001

Please sign in to comment.