pub struct TraceTable<B> where
    B: StarkField, 
{ /* private fields */ }
Expand description

A concrete implementation of the Trace trait.

This implementation supports concurrent trace generation and should be sufficient for most use cases. There are two ways to create a trace table trace.

First, you can use the TraceTable::init() function which takes a set of vectors as a parameter, where each vector contains values for a given column of the trace. This approach allows you to build an execution trace as you see fit, as long as it meets a basic set of requirements. These requirements are:

  1. Lengths of all columns in the execution trace must be the same.
  2. The length of the columns must be some power of two.

The other approach is to use TraceTable::new() function, which takes trace width and length as parameters. This function will allocate memory for the trace, but will not fill it with data. To fill the execution trace, you can use the fill() method, which takes two closures as parameters:

  1. The first closure is responsible for initializing the first state of the computation (the first row of the execution trace).
  2. The second closure receives the previous state of the execution trace as input, and must update it to the next state of the computation.

You can also use TraceTable::with_meta() function to create a blank execution trace. This function work just like TraceTable::new() function, but also takes a metadata parameter which can be an arbitrary sequence of bytes up to 64KB in size.

Concurrent trace generation

For computations which consist of many small independent computations, we can generate the execution trace of the entire computation by building fragments of the trace in parallel, and then joining these fragments together.

For this purpose, TraceTable struct exposes fragments() method, which takes fragment length as a parameter, breaks the execution trace into equally sized fragments, and returns an iterator over these fragments. You can then use fragment’s fill() method to fill all fragments with data in parallel. The semantics of the fragment’s TraceTableFragment::fill() method are identical to the semantics of the TraceTable::fill() method.

Implementations

Creates a new execution trace of the specified width and length.

This allocates all the required memory for the trace, but does not initialize it. It is expected that the trace will be filled using one of the data mutator methods.

Panics

Panics if:

  • width is zero or greater than 255.
  • length is smaller than 8, greater than biggest multiplicative subgroup in the field B, or is not a power of two.

Creates a new execution trace of the specified width and length, and with the specified metadata.

This allocates all the required memory for the trace, but does not initialize it. It is expected that the trace will be filled using one of the data mutator methods.

Panics

Panics if:

  • width is zero or greater than 255.
  • length is smaller than 8, greater than the biggest multiplicative subgroup in the field B, or is not a power of two.
  • Length of meta is greater than 65535;

Creates a new execution trace from a list of provided trace columns.

Panics

Panics if:

  • The columns vector is empty or has over 255 columns.
  • Number of elements in any of the columns is smaller than 8, greater than the biggest multiplicative subgroup in the field B, or is not a power of two.
  • Number of elements is not identical for all columns.

Updates a value in a single cell of the execution trace.

Specifically, the value in the specified column and the specified step is set to the provide value.

Panics

Panics if either column or step are out of bounds for this execution trace.

Updates metadata for this execution trace to the specified vector of bytes.

Panics

Panics if the length of meta is greater than 65535;

Fill all rows in the execution trace.

The rows are filled by executing the provided closures as follows:

  • init closure is used to initialize the first row of the trace; it receives a mutable reference to the first state initialized to all zeros. The contents of the state are copied into the first row of the trace after the closure returns.
  • update closure is used to populate all subsequent rows of the trace; it receives two parameters:
    • index of the last updated row (starting with 0).
    • a mutable reference to the last updated state; the contents of the state are copied into the next row of the trace after the closure returns.

Updates a single row in the execution trace with provided data.

Breaks the execution trace into mutable fragments.

The number of rows in each fragment will be equal to fragment_length parameter. The returned fragments can be used to update data in the trace from multiple threads.

Panics

Panics if fragment_length is smaller than 2, greater than the length of the trace, or is not a power of two.

Returns the number of columns in this execution trace.

Returns the entire trace column at the specified index.

Returns value of the cell in the specified column at the specified row of this trace.

Reads a single row from this execution trace into the provided target.

Trait Implementations

Base field for this execution trace. Read more

Returns a description of how columns of this trace are arranged into trace segments.

Returns the number of rows in this trace.

Returns metadata associated with this trace.

Reads an evaluation frame from the main trace segment at the specified row.

Returns a reference to a Matrix describing the main segment of this trace.

Builds and returns the next auxiliary trace segment. If there are no more segments to build (i.e., the trace is complete), None is returned. Read more

Returns trace info for this trace.

Returns the number of columns in the main segment of this trace.

Returns the number of columns in all auxiliary trace segments.

Checks if this trace is valid against the specified AIR, and panics if not. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Should always be Self

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.