Skip to content

Commit

Permalink
allow SUBSTREAMS_TRACE_READS and SUBSTREAMS_TRACE_WRITES to be set to…
Browse files Browse the repository at this point in the history
… false
  • Loading branch information
sduchesneau committed Dec 2, 2024
1 parent ae3c7bd commit b5884d8
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions wasm/call.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package wasm
import (
"fmt"
"math/big"
"os"
"time"

"github.com/dustin/go-humanize"
Expand All @@ -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
Expand Down Expand Up @@ -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 {
Expand All @@ -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)
Expand Down

0 comments on commit b5884d8

Please sign in to comment.