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
- Variables
- func FromBytesV1(data []byte) (WordHeap, []Module[word.BigEndian], error)
- func FromBytesV2(data []byte) (WordHeap, []Module[word.BigEndian], error)
- func FromBytesV3(data []byte) (WordHeap, []Module[word.BigEndian], error)
- func IsTraceFile(data []byte) bool
- func NumberOfColumns[F any](modules []Module[F]) uint
- func ToBytes(heap WordHeap, rawModules []Module[word.BigEndian]) ([]byte, error)
- func ToBytesBuffer(modules []Module[word.BigEndian]) (*bytes.Buffer, error)
- func ToBytesLegacy(modules []Module[word.BigEndian]) ([]byte, error)
- func WriteBytes(modules []Module[word.BigEndian], buf io.Writer) error
- type ArrayBuilder
- type Column
- type Header
- type Module
- type TraceFile
- func (p *TraceFile) Builder() array.Builder[word.BigEndian]
- func (p *TraceFile) Clone() TraceFile
- func (p *TraceFile) Column(ref tr.ColumnRef) tr.Column[word.BigEndian]
- func (p *TraceFile) HasModule(name tr.ModuleName) (uint, bool)
- func (p *TraceFile) Header() Header
- func (p *TraceFile) Heap() WordHeap
- func (p *TraceFile) MarshalBinary() ([]byte, error)
- func (p *TraceFile) Module(mid tr.ModuleId) tr.Module[word.BigEndian]
- func (p *TraceFile) Modules() iter.Iterator[tr.Module[word.BigEndian]]
- func (p *TraceFile) RawModules() []Module[word.BigEndian]
- func (p *TraceFile) UnmarshalBinary(data []byte) error
- func (p *TraceFile) Width() uint
- type WordArrayBuilder
- type WordHeap
Constants ¶
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.
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.
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.
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 ¶
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 ¶
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 ¶
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 ¶
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 ¶
IsTraceFile checks whether the given data file begins with the expected "zktracer" identifier.
func NumberOfColumns ¶
NumberOfColumns determines the total number of columns in a given array of modules.
func ToBytes ¶
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 ¶
ToBytesBuffer writes a given trace file into a byte buffer.
func ToBytesLegacy ¶
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.
Types ¶
type ArrayBuilder ¶
type ArrayBuilder = array.DynamicBuilder[word.BigEndian, *pool.SharedHeap[word.BigEndian]]
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.
type Header ¶
Header provides a structured header for the binary file format. In particular, it supports versioning and embedded (binary) metadata.
func (*Header) GetMetaData ¶
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 ¶
IsCompatible determines whether a given binary file is compatible with this version of go-corset.
func (*Header) MarshalBinary ¶
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 ¶
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.
type Module ¶
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]) Name ¶
func (p *Module[F]) Name() trace.ModuleName
Name 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 ¶
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 ¶
NewTraceFile constructs a new trace file with the default header for the current default version.
func NewTraceFileV1 ¶
NewTraceFileV1 constructs a new legacy trace file with the default header for the current default version.
func (*TraceFile) HasModule ¶
func (p *TraceFile) HasModule(name tr.ModuleName) (uint, bool)
HasModule implementation for trace interface.
func (*TraceFile) MarshalBinary ¶
MarshalBinary converts the TraceFile into a sequence of bytes.
func (*TraceFile) RawModules ¶
RawModules provides direct access to the underlying modules
func (*TraceFile) UnmarshalBinary ¶
UnmarshalBinary initialises this TraceFile from a given set of data bytes. This should match exactly the encoding above.
type WordArrayBuilder ¶
type WordArrayBuilder = array.DynamicBuilder[word.BigEndian, *WordHeap]
WordArrayBuilder provides a convenient aliasO