rtrace

package
v1.2.23 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jul 22, 2026 License: Apache-2.0 Imports: 13 Imported by: 0

Documentation

Overview

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Copyright Consensys Software Inc.

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.

SPDX-License-Identifier: Apache-2.0

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MarshalBinary

func MarshalBinary[W util.BigInter](tr Trace[W]) ([]byte, error)

MarshalBinary encodes a row-major trace into a binary format. Lengths, counts and descriptor metadata are encoded as unsigned varints. Row data is encoded row-major, using unsigned LEB128 for each word value.

func ToTrace

func ToTrace[T word.Word[T]](tr Trace[T]) []lt.Module[T]

ToTrace converts a row-major rtrace.Trace into a column-major trace.Trace. Each limb becomes one column, named following the register splitting convention: a register backed by a single limb keeps its own name, whilst the limbs of a subdivided register are named "reg'0", "reg'1", etc. Observe that key columns are not reconstructed (every module reports zero keys), and all columns are padded with zero.

Types

type Array

type Array[T any] struct {
	// contains filtered or unexported fields
}

Array provides an implementation of Trace which stores rows as an array.

func FromTrace

func FromTrace[T any](tr ctrace.Trace[T]) *Array[T]

FromTrace converts a column-major trace.Trace into a row-major rtrace.Array. Each source column becomes one register, and each register is backed by one limb using the source column data bitwidth when available.

func NewArray

func NewArray[T any](modules []ArrayModule[T]) *Array[T]

NewArray constructs a row-major trace from a given set of modules.

func ParallelReduce

func ParallelReduce[T any](traces []Trace[T]) *Array[T]

ParallelReduce behaves exactly like Reduce, combining a sequence of aligned traces into a single trace, but reduces each module of the result concurrently using one goroutine per module.

func Reduce

func Reduce[T any](traces []Trace[T]) *Array[T]

Reduce combines a sequence of aligned traces into a single trace. Two traces are aligned when they have the same width and modules sharing a name also share the same module index and matching register (and hence limb) descriptors. For each module, the rows of every input trace are concatenated, in trace order, into the corresponding module of the result.

func (*Array[T]) HasModule

func (p *Array[T]) HasModule(name string) (uint, bool)

HasModule determines whether this trace has a module with the given name and, if so, what its module index is.

func (*Array[T]) Module

func (p *Array[T]) Module(module uint) Module[T]

Module returns a specific module in this trace.

func (*Array[T]) Modules

func (p *Array[T]) Modules() iter.Iterator[Module[T]]

Modules returns an iterator over the modules in this trace.

func (*Array[T]) RawModule

func (p *Array[T]) RawModule(module uint) *ArrayModule[T]

RawModule returns a specific module in this trace.

func (*Array[T]) String

func (p *Array[T]) String() string

func (*Array[T]) UnmarshalBinary

func (p *Array[T]) UnmarshalBinary(data []byte) error

UnmarshalBinary decodes a row-major trace encoded by MarshalBinary.

func (*Array[T]) Width

func (p *Array[T]) Width() uint

Width returns the number of modules in this trace.

type ArrayModule

type ArrayModule[T any] struct {
	// contains filtered or unexported fields
}

ArrayModule describes an individual module within a row-major trace.

func NewArrayModule

func NewArrayModule[T any](name string, descriptor []Register, rows ...[]T) ArrayModule[T]

NewArrayModule constructs a module with the given name, descriptor and rows. This assigns final module-wide limb identifiers and register identifiers to the descriptor.

func (ArrayModule[T]) Descriptor

func (p ArrayModule[T]) Descriptor() iter.Iterator[Register]

Descriptor returns the registers describing this module.

func (ArrayModule[T]) Height

func (p ArrayModule[T]) Height() uint

Height returns the height of this module, meaning the number of assigned rows.

func (ArrayModule[T]) LimbAt

func (p ArrayModule[T]) LimbAt(index uint) Limb

LimbAt returns the limb with the given index.

func (ArrayModule[T]) Limbs

func (p ArrayModule[T]) Limbs() iter.Iterator[Limb]

Limbs returns the limbs describing this module.

func (ArrayModule[T]) Name

func (p ArrayModule[T]) Name() string

Name returns the name of this module.

func (ArrayModule[T]) Row

func (p ArrayModule[T]) Row(id uint) Row[T]

Row returns a specific row within this trace module.

func (ArrayModule[T]) String

func (p ArrayModule[T]) String() string

func (ArrayModule[T]) Width

func (p ArrayModule[T]) Width() uint

Width returns the number of columns in this module.

type ArrayRow

type ArrayRow[T any] struct {
	// contains filtered or unexported fields
}

ArrayRow describes an individual row of data within a row-major trace module.

func NewArrayRow

func NewArrayRow[T any](data []T) ArrayRow[T]

NewArrayRow constructs a row from the given data.

func (ArrayRow[T]) Get

func (p ArrayRow[T]) Get(column uint) T

Get returns the value at a given column in this row.

func (ArrayRow[T]) String

func (p ArrayRow[T]) String() string

func (ArrayRow[T]) Width

func (p ArrayRow[T]) Width() uint

Width returns the number of columns in this row.

type Limb

type Limb interface {
	// Limb identifier.
	LimbId() uint
	// Register identifier.
	RegisterId() uint
	// Limb bitwidth.  If this is none, then the limb represents a field
	// element.
	Bitwidth() util.Option[uint]
}

Limb describes a subdivided register limb.

type Module

type Module[T any] interface {
	// Module name.
	Name() string
	// Descriptor returns the registers describing the columns of this module.
	Descriptor() iter.Iterator[Register]
	// Limbs returns the limbs describing the columns of this module.
	Limbs() iter.Iterator[Limb]
	// LimbAt returns the limb with the given index.
	LimbAt(uint) Limb
	// Access a given row in this module.
	Row(uint) Row[T]
	// Returns the number of columns in this module.
	Width() uint
	// Returns the height of this module.
	Height() uint
}

Module describes a module within the trace. Every module is composed of some number of rows, and has a specific width.

type Register

type Register interface {
	// Register name.
	Name() string
	// Register bitwidth.  If this is none, then this represents a "native
	// register" (i.e. one backed by field elements).
	Bitwidth() util.Option[uint]
	// Limbs returns the limbs backing this register.
	Limbs() iter.Iterator[Limb]
}

Register describes an individual register in a row-major trace module.

func NewRegister

func NewRegister(name string, limbs util.Option[[]uint]) Register

NewRegister constructs a register with the given name and limb bitwidths. If no limb bitwidths are provided, the register is treated as native and has one limb without a fixed bitwidth. Otherwise, the register bitwidth is the sum of the given limb bitwidths.

type Row

type Row[T any] interface {
	// Get the value in a given column of this row.
	Get(column uint) T
	// Returns the number of columns in this row.
	Width() uint
}

Row describes an individual row of data within a trace table.

type Trace

type Trace[T any] interface {
	// Determine whether this trace has a module with the given name and, if so,
	// what its module index is.
	HasModule(name string) (uint, bool)
	// Access a given module in this trace.
	Module(uint) Module[T]
	// Returns an iterator over the contained modules.
	Modules() iter.Iterator[Module[T]]
	// Returns the number of modules in this trace.
	Width() uint
}

Trace describes a set of named modules whose data is organised by row.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL