From b5884d8ab0d4dfa0dbcf6afdf0fb7651ce5fac33 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?St=C3=A9phane=20Duchesneau?= Date: Sun, 1 Dec 2024 19:06:26 -0500 Subject: [PATCH] allow SUBSTREAMS_TRACE_READS and SUBSTREAMS_TRACE_WRITES to be set to false --- wasm/call.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/wasm/call.go b/wasm/call.go index 2b249f35..77462aa8 100644 --- a/wasm/call.go +++ b/wasm/call.go @@ -3,6 +3,7 @@ package wasm import ( "fmt" "math/big" + "os" "time" "github.com/dustin/go-humanize" @@ -13,6 +14,9 @@ import ( "github.com/streamingfast/substreams/storage/store" ) +var TraceReads = os.Getenv("SUBSTREAMS_TRACE_READS") != "false" +var TraceWrites = os.Getenv("SUBSTREAMS_TRACE_WRITES") != "false" + type Call struct { Clock *pbsubstreams.Clock // Used by WASM extensions ModuleName string @@ -334,6 +338,9 @@ func (c *Call) validateWithTwoValueTypes(stateFunc string, updatePolicy pbsubstr } func (c *Call) traceStateWrites(stateFunc, key string) { + if !TraceWrites { + return + } store := c.outputStore var line string if store == nil { @@ -345,6 +352,9 @@ func (c *Call) traceStateWrites(stateFunc, key string) { } func (c *Call) traceStateReads(stateFunc string, storeIndex int, found bool, key string) { + if !TraceReads { + return + } store := c.inputStores[storeIndex] line := fmt.Sprintf("%s::%s key: %q, found: %v, store details: %s", store.Name(), stateFunc, key, found, store.String()) c.ExecutionStack = append(c.ExecutionStack, line)