ir

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

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

View Source
var PADDING_STRATEGIES = map[string]PaddingStrategy{
	"none":              NaryRowPadding(0),
	"single-row":        NaryRowPadding(1),
	"double-row":        NaryRowPadding(2),
	"triple-row":        NaryRowPadding(3),
	"next-power-of-two": NextPowerOfTwoPadding,
}

PADDING_STRATEGIES maps the name of each strategy (as accepted on the command line) to its value.

Functions

func AlignTrace

func AlignTrace[F any, M register.Map](schema []M, trace []lt.Module[F], expanding bool,
) ([]lt.Module[F], []error)

AlignTrace performs "trace alignment" on a given trace file. That is, it ensures: firstly, the order in which modules occur in the trace file matches (i.e. aligns with) those in the given schema; secondly, it ensures that the columns within each module match (i.e. align with) those of the corresponding schema module. If any columns or modules are missing, then one or more errors will be reported.

NOTE: alignment is impacted by whether or not the trace is being expanded or not. Specifically, expanding traces don't need to include data for computed columns, since these will be added during expansion.

func BuildModule

func BuildModule[F field.Element[F], C schema.Constraint[F], T term.Expr[F, T], M BuildableModule[F, C, M]](
	m ModuleBuilder[F, C, T]) M

BuildModule builds a module from a given ModuleBuilder instance.

func BuildSchema

func BuildSchema[M BuildableModule[F, C, M], F field.Element[F], C schema.Constraint[F], T term.Expr[F, T]](
	p SchemaBuilder[F, C, T]) []M

BuildSchema builds all modules defined within a give SchemaBuilder instance.

func NextPowerOfTwoPadding added in v1.2.21

func NextPowerOfTwoPadding(height, multiplier uint) uint

NextPowerOfTwoPadding rounds the logical height to the next power of 2. For example, a height of 3 would become 4, etc. An empty module is expanded to a height of one; a module whose height is already a (non-zero) power of two is left unchanged.

func PaddingFor

func PaddingFor[F field.Element[F], T term.Evaluable[F]](term T, mod schema.ModuleView) big.Int

PaddingFor determines the appropriate padding value for the given term. This is done by evaluating the term against a artificially constructed trace from the given module, where each column has its declared padding value.

Types

type BuildableModule

type BuildableModule[F any, C schema.Constraint[F], M any] interface {
	Init(name module.Name, padding, public, synthetic, native, static bool, keys uint) M
	// Add one or more assignments to this buildable module
	AddAssignments(assignments ...schema.Assignment[F])
	// Add one or more constraints to this buildable module
	AddConstraints(constraints ...C)
	// Add one or more registers to this buildable module.
	AddRegisters(registers ...register.Register)
	// Set contents for static module
	SetStaticContents(contents [][]F)
}

BuildableModule embodies the notion of a module which can be initialised from the various required components. This provides a useful way for constructing modules once all the various pieces of information have been finalised.

type ModuleBuilder

type ModuleBuilder[F field.Element[F], C schema.Constraint[F], T term.Expr[F, T]] interface {
	fmt.Stringer
	schema.ModuleView
	// AddAssignment adds a new assignment to this module.  Assignments are
	// responsible for computing the values of computed columns.
	AddAssignment(assignment schema.Assignment[F])
	// AddConstraint adds a new constraint to this module.
	AddConstraint(constraint C)
	// AllowPadding determines whether the given module allows an initial
	// padding row, or not.
	AllowPadding() bool
	// Assignments returns those assignments added to this module.
	Assignments() []schema.Assignment[F]
	// Constraints returns those constraints added to this module.
	Constraints() []C
	// Keys returns the number n of key columns in this module.  Key columns are
	// always the first n columns in a module.  Such columns have the property
	// that they can be used in conjunction with Find.
	Keys() uint
	// Id returns the module index of this module.
	Id() uint
	// IsExtern determines whether or not this is an external module or not.
	IsExtern() bool
	// NewRegister declares a new register within the module being built.  This will
	// panic if a register of the same name already exists.
	NewRegister(reg register.Register) register.Id
	// NewRegisters declares zero or more new registers within the module being
	// built.  This will panic if a register of the same name already exists.
	NewRegisters(registers ...register.Register) []register.Id
	// ZeroRegister returns an ID for the "zero register".  That is, a register
	// which is always zero.  If no such register exists already, one is
	// created.
	ConstRegister(constant uint8) register.Id
	// SetStaticContents sets the contents of this static reference table.  It
	// panics if invoked on a non-static module.
	SetStaticContents(contents [][]F)
	// StaticContents returns the static contents for a static reference table.  It
	// panics if invoked on a non-static module.
	StaticContents() (contents [][]F)
}

ModuleBuilder provides a mechanism to ease the construction of modules for use in schemas. For example, it maintains a mapping from register names to their relevant indices. It also provides a mechanism for constructing a register access based on the register name, etc.

NOTE: overall, this interface has got somewhat out-of-hand and it would be useful to try and simplify it where possible.

func NewExternModuleBuilder

func NewExternModuleBuilder[F field.Element[F], C schema.Constraint[F], T term.Expr[F, T]](mid schema.ModuleId,
	module register.ConstMap) ModuleBuilder[F, C, T]

NewExternModuleBuilder constructs a new builder suitable for external modules. These are just used for linking purposes.

func NewModuleBuilder

func NewModuleBuilder[F field.Element[F], C schema.Constraint[F], T term.Expr[F, T]](name module.Name,
	mid schema.ModuleId, padding, public, synthetic, static, native bool, keys uint) ModuleBuilder[F, C, T]

NewModuleBuilder constructs a new builder for a module with the given name.

type PaddingStrategy added in v1.2.21

type PaddingStrategy func(height, multiplier uint) uint

PaddingStrategy captures the notion of an algorithm that determines how much front padding is added to each module when expanding a trace (see TraceBuilder.WithPadding).

func GetPaddingStrategy added in v1.2.21

func GetPaddingStrategy(name string) (PaddingStrategy, bool)

GetPaddingStrategy resolves a strategy name (e.g. as supplied on the command line) to its value, returning false if the name is not recognised.

func NaryRowPadding added in v1.2.21

func NaryRowPadding(n uint) PaddingStrategy

NaryRowPadding rounds up the height of a module by a given number of complete rows.

type SchemaBuilder

type SchemaBuilder[F field.Element[F], C schema.Constraint[F], T term.Expr[F, T]] struct {
	// contains filtered or unexported fields
}

SchemaBuilder is a mechanism for constructing mixed schemas which attempts to simplify the problem of mapping source-level names to e.g. module-specific register indexes.

func NewSchemaBuilder

func NewSchemaBuilder[F field.Element[F], C schema.Constraint[F], T term.Expr[F, T], E register.ConstMap](externs ...E,
) SchemaBuilder[F, C, T]

NewSchemaBuilder constructs a new schema builder with a given number of externally defined modules. Such modules are allocated module indices first.

func (*SchemaBuilder[F, C, T]) Externs

func (p *SchemaBuilder[F, C, T]) Externs() []register.ConstMap

Externs provides direct access to the external modules.

func (*SchemaBuilder[F, C, T]) HasModule

func (p *SchemaBuilder[F, C, T]) HasModule(name module.Name) (uint, bool)

HasModule checks whether a moduleregister of the given name exists already and,if so, returns its index.

func (*SchemaBuilder[F, C, T]) Module

func (p *SchemaBuilder[F, C, T]) Module(mid uint) ModuleBuilder[F, C, T]

Module returns the builder for the given module based on its index.

func (*SchemaBuilder[F, C, T]) ModuleOf

func (p *SchemaBuilder[F, C, T]) ModuleOf(name module.Name) ModuleBuilder[F, C, T]

ModuleOf returns the builder for the given module based on its name.

func (*SchemaBuilder[F, C, T]) NewModule

func (p *SchemaBuilder[F, C, T]) NewModule(name module.Name, padding, public, synthetic, static, native bool,
	keys uint) uint

NewModule constructs a new, empty module and returns its unique module identifier.

type TraceBuilder

type TraceBuilder[F field.Element[F]] struct {
	// contains filtered or unexported fields
}

TraceBuilder provides a mechanical means of constructing a trace from a given schema and set of input columns. The goal is to encapsulate all of the logic around building a trace.

func NewTraceBuilder

func NewTraceBuilder[F field.Element[F]]() TraceBuilder[F]

NewTraceBuilder constructs a default trace builder. The idea is that this could then be customized as needed following the builder pattern.

func (TraceBuilder[F]) BatchSize

func (tb TraceBuilder[F]) BatchSize() uint

BatchSize returns the configured batch size for this builder.

func (TraceBuilder[F]) Build

func (tb TraceBuilder[F]) Build(schema sc.AnySchema[F], tf lt.TraceFile) (trace.Trace[F], []error)

Build attempts to construct a trace for a given schema, producing errors if there are inconsistencies (e.g. missing columns, duplicate columns, etc).

func (TraceBuilder[F]) Expand added in v1.2.21

func (tb TraceBuilder[F]) Expand(schema sc.AnySchema[F], modules []lt.Module[F]) (trace.Trace[F], []error)

Expand applies trace expansion directly on a given trace.

func (TraceBuilder[F]) Expanding

func (tb TraceBuilder[F]) Expanding() bool

Expanding indicates whether or not this builder will expand the trace.

func (TraceBuilder[F]) Mapping

func (tb TraceBuilder[F]) Mapping() module.LimbsMap

Mapping returns the mapping from registers to limbs used with this builder.

func (TraceBuilder[F]) Parallelism

func (tb TraceBuilder[F]) Parallelism() bool

Parallelism checks whether parallelism is enabled for this builder.

func (TraceBuilder[F]) WithBatchSize

func (tb TraceBuilder[F]) WithBatchSize(batchSize uint) TraceBuilder[F]

WithBatchSize sets the maximum number of batches to run in parallel during trace expansion.

func (TraceBuilder[F]) WithDefensivePadding

func (tb TraceBuilder[F]) WithDefensivePadding(flag bool) TraceBuilder[F]

WithDefensivePadding updates a given builder configuration to apply defensive padding (or not).

func (TraceBuilder[F]) WithExpansion

func (tb TraceBuilder[F]) WithExpansion(flag bool) TraceBuilder[F]

WithExpansion updates a given builder configuration to perform trace expansion (or not).

func (TraceBuilder[F]) WithExpansionChecks

func (tb TraceBuilder[F]) WithExpansionChecks(flag bool) TraceBuilder[F]

WithExpansionChecks enables runtime safety checks on the expanded trace.

func (TraceBuilder[F]) WithPadding

func (tb TraceBuilder[F]) WithPadding(strategy PaddingStrategy) TraceBuilder[F]

WithPadding updates a given builder configuration to control padding.

func (TraceBuilder[F]) WithParallelism

func (tb TraceBuilder[F]) WithParallelism(flag bool) TraceBuilder[F]

WithParallelism updates a given builder configuration to allow trace expansion to be performed concurrently (or not).

func (TraceBuilder[F]) WithRegisterMapping

func (tb TraceBuilder[F]) WithRegisterMapping(mapping module.LimbsMap) TraceBuilder[F]

WithRegisterMapping updates a given builder configuration to split the trace according to a given mapping of registers.

func (TraceBuilder[F]) WithValidation

func (tb TraceBuilder[F]) WithValidation(flag bool) TraceBuilder[F]

WithValidation updates a given builder configuration to perform trace validation (or not).

Directories

Path Synopsis
air

Jump to

Keyboard shortcuts

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