lt

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: 16 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

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

View Source
const LTV1_MAJOR_VERSION uint16 = 1

LTV1_MAJOR_VERSION givesn the major version of the (currently supported) legacy binary file format. No matter what version, we should always have the ZKBINARY identifier first, followed by a GOB encoding of the header. What follows after that, however, is determined by the major version.

View Source
const LTV2_MAJOR_VERSION uint16 = 2

LTV2_MAJOR_VERSION gives the major version of the binary file format. No matter what version, we should always have the ZKBINARY identifier first, followed by a GOB encoding of the header. What follows after that, however, is determined by the major version.

View Source
const LTV3_MAJOR_VERSION uint16 = 3

LTV3_MAJOR_VERSION gives the major version of the binary file format. No matter what version, we should always have the ZKBINARY identifier first, followed by a GOB encoding of the header. What follows after that, however, is determined by the major version.

View Source
const LTV3_MINOR_VERSION uint16 = 0

LTV3_MINOR_VERSION gives the minor version of the binary file format. The expected interpretation is that older versions are compatible with newer ones, but not vice-versa.

Variables

View Source
var ZKTRACER [8]byte = [8]byte{'z', 'k', 't', 'r', 'a', 'c', 'e', 'r'}

ZKTRACER is used as the file identifier for binary file types. This just helps us identify actual binary files from corrupted files.

Functions

func FromBytesV1

func FromBytesV1(data []byte) (WordHeap, []Module[word.BigEndian], error)

FromBytesV1 parses a byte array representing a given (legacy) LT trace file into an columns, or produces an error if the original file was malformed in some way. The input represents the original legacy format of trace files (i.e. without any additional header information prepended, etc).

func FromBytesV2

func FromBytesV2(data []byte) (WordHeap, []Module[word.BigEndian], error)

FromBytesV2 parses a byte array representing a given LTv2 trace file into a set of columns, or produces an error if the original file was malformed in some way.

func FromBytesV3

func FromBytesV3(data []byte) (WordHeap, []Module[word.BigEndian], error)

FromBytesV3 parses a byte array representing a given LTv3 trace file into a set of columns, or produces an error if the original file was malformed in some way.

func IsTraceFile

func IsTraceFile(data []byte) bool

IsTraceFile checks whether the given data file begins with the expected "zktracer" identifier.

func NumberOfColumns

func NumberOfColumns[F any](modules []Module[F]) uint

NumberOfColumns determines the total number of columns in a given array of modules.

func ToBytes

func ToBytes(heap WordHeap, rawModules []Module[word.BigEndian]) ([]byte, error)

ToBytes writes a given trace file as an array of bytes. See FromBytes for more information on the layout of data in this format.

func ToBytesBuffer

func ToBytesBuffer(modules []Module[word.BigEndian]) (*bytes.Buffer, error)

ToBytesBuffer writes a given trace file into a byte buffer.

func ToBytesLegacy

func ToBytesLegacy(modules []Module[word.BigEndian]) ([]byte, error)

ToBytesLegacy writes a given trace file as an array of (legacy) bytes. The output represents the legacy format if the bytes are used "as is" without any additional header information being preprended.

func WriteBytes

func WriteBytes(modules []Module[word.BigEndian], buf io.Writer) error

WriteBytes a given trace file to an io.Writer.

Types

type ArrayBuilder

ArrayBuilder provides a usefuil alias

type Column

type Column[F any] struct {
	// contains filtered or unexported fields
}

Column captures the raw data for a given column.

func NewColumn

func NewColumn[F any](name string, data array.MutArray[F]) Column[F]

NewColumn constructs a new column

func (*Column[F]) Data

func (p *Column[F]) Data() array.Array[F]

Data implementation for trace.Column interface

func (*Column[F]) Get

func (p *Column[F]) Get(row int) F

Get implementation for trace.Column interface

func (*Column[F]) MutData

func (p *Column[F]) MutData() array.MutArray[F]

MutData provides access to real data

func (*Column[F]) Name

func (p *Column[F]) Name() string

Name implementation for trace.Column interface

func (*Column[F]) Padding

func (p *Column[F]) Padding() F

Padding implementation for trace.Column interface

type Header struct {
	Identifier   [8]byte
	MajorVersion uint16
	MinorVersion uint16
	MetaData     []byte
}

Header provides a structured header for the binary file format. In particular, it supports versioning and embedded (binary) metadata.

func (*Header) GetMetaData

func (p *Header) GetMetaData() (typed.Map, error)

GetMetaData attempts to parse the metadata bytes as JSON which is then unmarshalled into a map. This can fail if the embedded metadata bytes are not, in fact, JSON. Observe that, if there are no metadata bytes, then nil will be returned.

func (*Header) IsCompatible

func (p *Header) IsCompatible() bool

IsCompatible determines whether a given binary file is compatible with this version of go-corset.

func (*Header) MarshalBinary

func (p *Header) MarshalBinary() ([]byte, error)

MarshalBinary converts the LT file header into a sequence of bytes. Observe that we don't use GobEncoding here to avoid being tied to that encoding scheme.

func (*Header) SetMetaData

func (p *Header) SetMetaData(metadata typed.Map) error

SetMetaData attempts to set the metadata bytes for this header, using a JSON encoding of the given map. If this fails, an error is returned and the metadata bytes are unaffected.

func (*Header) UnmarshalBinary

func (p *Header) UnmarshalBinary(buffer *bytes.Buffer) error

UnmarshalBinary initialises this LT file header from a given set of data bytes. This should match exactly the encoding above.

type Module

type Module[F any] struct {
	Columns []Column[F]
	// contains filtered or unexported fields
}

Module groups together columns from the same module.

func NewModule

func NewModule[F any](name trace.ModuleName, columns []Column[F]) Module[F]

NewModule constructs a new trace module with a given name and column set.

func (*Module[F]) Column

func (p *Module[F]) Column(id uint) trace.Column[F]

Column implementation for trace.Module interface

func (*Module[F]) ColumnOf

func (p *Module[F]) ColumnOf(name string) trace.Column[F]

ColumnOf implementation for trace.Module interface

func (*Module[T]) FindLast

func (p *Module[T]) FindLast(...T) uint

FindLast implementation for the trace.Module interface.

func (*Module[F]) Height

func (p *Module[F]) Height() uint

Height returns the height of this module in the trace.

func (*Module[T]) Keys

func (p *Module[T]) Keys() uint

Keys implementation for the trace.Module interface.

func (*Module[F]) Name

func (p *Module[F]) Name() trace.ModuleName

Name implementation for trace.Module interface

func (*Module[F]) Width

func (p *Module[F]) Width() uint

Width implementation for trace.Module interface

type TraceFile

type TraceFile struct {
	// contains filtered or unexported fields
}

TraceFile is a programatic represresentation of an underlying trace file.

func FromRawTrace

func FromRawTrace[F field.Element[F]](metadata []byte, trace trace.Trace[F]) TraceFile

FromRawTrace constructs a TraceFile from an instance of trace.Trace[F]. This is always safe since the trace instance contains values of some field which will always git within a word.BigEndian.

func NewTraceFile

func NewTraceFile(metadata []byte, pool WordHeap, modules []Module[word.BigEndian]) TraceFile

NewTraceFile constructs a new trace file with the default header for the current default version.

func NewTraceFileV1

func NewTraceFileV1(metadata []byte, pool WordHeap, modules []Module[word.BigEndian]) TraceFile

NewTraceFileV1 constructs a new legacy trace file with the default header for the current default version.

func (*TraceFile) Builder

func (p *TraceFile) Builder() array.Builder[word.BigEndian]

Builder implementation for trace.Trace interface.

func (*TraceFile) Clone

func (p *TraceFile) Clone() TraceFile

Clone a trace file producing an unaliased copy

func (*TraceFile) Column

func (p *TraceFile) Column(ref tr.ColumnRef) tr.Column[word.BigEndian]

Column implementation for trace.Trace interface.

func (*TraceFile) HasModule

func (p *TraceFile) HasModule(name tr.ModuleName) (uint, bool)

HasModule implementation for trace interface.

func (*TraceFile) Header

func (p *TraceFile) Header() Header

Header returns the trace file header

func (*TraceFile) Heap

func (p *TraceFile) Heap() WordHeap

Heap returns the trace file heap

func (*TraceFile) MarshalBinary

func (p *TraceFile) MarshalBinary() ([]byte, error)

MarshalBinary converts the TraceFile into a sequence of bytes.

func (*TraceFile) Module

func (p *TraceFile) Module(mid tr.ModuleId) tr.Module[word.BigEndian]

Module implementation for trace.Trace interface

func (*TraceFile) Modules

func (p *TraceFile) Modules() iter.Iterator[tr.Module[word.BigEndian]]

Modules implementation for trace.Trace interface

func (*TraceFile) RawModules

func (p *TraceFile) RawModules() []Module[word.BigEndian]

RawModules provides direct access to the underlying modules

func (*TraceFile) UnmarshalBinary

func (p *TraceFile) UnmarshalBinary(data []byte) error

UnmarshalBinary initialises this TraceFile from a given set of data bytes. This should match exactly the encoding above.

func (*TraceFile) Width

func (p *TraceFile) Width() uint

Width implementation for trace.Trace interface

type WordArrayBuilder

type WordArrayBuilder = array.DynamicBuilder[word.BigEndian, *WordHeap]

WordArrayBuilder provides a convenient aliasO

type WordHeap

type WordHeap = pool.LocalHeap[word.BigEndian]

WordHeap provides a usefuil alias

Jump to

Keyboard shortcuts

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