From 407acf925020e14a7ba1ea0c1867ddf4d7a667ad Mon Sep 17 00:00:00 2001 From: TAdev0 Date: Thu, 4 Jul 2024 19:33:50 +0200 Subject: [PATCH] rename collectMemory to BuildMemory --- cmd/cli/main.go | 28 ++++++++++++++-------------- pkg/runners/zero/zero.go | 2 ++ 2 files changed, 16 insertions(+), 14 deletions(-) diff --git a/cmd/cli/main.go b/cmd/cli/main.go index 42078b04..9b65956a 100644 --- a/cmd/cli/main.go +++ b/cmd/cli/main.go @@ -13,7 +13,7 @@ import ( func main() { var proofmode bool - var collectMemory bool + var buildMemory bool var collectTrace bool var maxsteps uint64 var entrypointOffset uint64 @@ -37,18 +37,6 @@ func main() { Required: false, Destination: &proofmode, }, - &cli.BoolFlag{ - Name: "collect_trace", - Usage: "builds the relocated trace after execution", - Required: false, - Destination: &collectTrace, - }, - &cli.BoolFlag{ - Name: "collect_memory", - Usage: "builds the relocated memory after execution", - Required: false, - Destination: &collectMemory, - }, &cli.Uint64Flag{ Name: "maxsteps", Usage: "limits the execution steps to 'maxsteps'", @@ -63,12 +51,24 @@ func main() { Value: 0, Destination: &entrypointOffset, }, + &cli.BoolFlag{ + Name: "collect_trace", + Usage: "collects the trace and builds the relocated trace after execution", + Required: false, + Destination: &collectTrace, + }, &cli.StringFlag{ Name: "tracefile", Usage: "location to store the relocated trace", Required: false, Destination: &traceLocation, }, + &cli.BoolFlag{ + Name: "build_memory", + Usage: "builds the relocated memory after execution", + Required: false, + Destination: &buildMemory, + }, &cli.StringFlag{ Name: "memoryfile", Usage: "location to store the relocated memory", @@ -153,7 +153,7 @@ func main() { } } - if proofmode || collectMemory { + if proofmode || buildMemory { memory, err := runner.BuildMemory() if err != nil { return fmt.Errorf("cannot build memory: %w", err) diff --git a/pkg/runners/zero/zero.go b/pkg/runners/zero/zero.go index c9b7d108..f279f3eb 100644 --- a/pkg/runners/zero/zero.go +++ b/pkg/runners/zero/zero.go @@ -364,11 +364,13 @@ func (runner *ZeroRunner) FinalizeSegments() error { return nil } +// BuildMemory relocates the memory and returns it func (runner *ZeroRunner) BuildMemory() ([]byte, error) { relocatedMemory := runner.vm.RelocateMemory() return vm.EncodeMemory(relocatedMemory), nil } +// BuildMemory relocates the trace and returns it func (runner *ZeroRunner) BuildTrace() ([]byte, error) { relocatedTrace := runner.vm.RelocateTrace() return vm.EncodeTrace(relocatedTrace), nil