gogen

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

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Build

func Build(src string) (string, func(), error)

Build compiles generated gogen source — as produced by vm.GenerateGo with the default ("main") package — into an executable, returning the path to the compiled binary together with a cleanup function that removes the temporary build directory. The returned path is suitable for passing to Run.

It mirrors the differential-test build harness: a throwaway module directory holding the generated main.go, compiled with the local Go toolchain.

func MarshalInputs

func MarshalInputs(in map[string][]byte) ([]byte, error)

MarshalInputs renders input memories as the JSON the generated harness reads: one "0x…" hex string per memory. Benchmarks pre-marshal once so the timed loop measures the executor, not the marshalling.

func Run

func Run(prog string, in map[string][]byte, stderr io.Writer) (map[string][]byte, bool, error)

Run executes a built gogen program on the given input memories, returning the output memories, whether the program reported an execution error (a rejected trace — the reference machine's error path), and any harness-level error (everything else).

Inputs and outputs are raw memory bytes keyed by memory name, exactly as vm.BootAndExecute consumes/produces them: the generated harness shares the JSON-hex encoding `zkc exec` accepts.

The generated binary's debug/printf output and any fail message are written to stderr; callers pass the sink they want those statements forwarded to (os.Stderr for `exec --gogen`, io.Discard for differential tests, which compare outputs rather than messages).

func RunRaw

func RunRaw(prog string, inJSON []byte, stderr io.Writer) (map[string][]byte, bool, error)

RunRaw is Run with the inputs already marshalled to JSON (see MarshalInputs).

The protocol matches the generated main harness: a JSON object of hex strings on stdin, the same on stdout, exit code 1 for an execution error.

The generated binary writes its debug/printf output and any fail message to stderr (output memories travel on stdout as JSON, so the two never interfere). That stream is forwarded to the caller-supplied stderr sink — so `exec --gogen` surfaces those statements as the interpreter paths do — while also being captured to enrich any harness-level error.

Types

This section is empty.

Jump to

Keyboard shortcuts

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