Skip to content

Commit

Permalink
Merge pull request #5194 from onflow/petera/access-script-compare-log…
Browse files Browse the repository at this point in the history
…ging

[Access] Log script exec mismatches as error
  • Loading branch information
peterargue authored Jan 4, 2024
2 parents eeff3f3 + d1998b1 commit ffddae1
Showing 1 changed file with 9 additions and 5 deletions.
14 changes: 9 additions & 5 deletions engine/access/rpc/backend/script_comparer.go
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ func (c *scriptResultComparison) compare(execResult, localResult *scriptResult)
if isOutOfRangeError(localResult.err) {
c.metrics.ScriptExecutionNotIndexed()
c.logComparison(execResult, localResult,
"script execution results do not match EN because data is not indexed yet")
"script execution results do not match EN because data is not indexed yet", false)
return false
}

Expand All @@ -66,7 +66,7 @@ func (c *scriptResultComparison) compare(execResult, localResult *scriptResult)

c.metrics.ScriptExecutionErrorMismatch()
c.logComparison(execResult, localResult,
"cadence errors from local execution do not match and EN")
"cadence errors from local execution do not match EN", true)
return false
}

Expand All @@ -77,12 +77,12 @@ func (c *scriptResultComparison) compare(execResult, localResult *scriptResult)

c.metrics.ScriptExecutionResultMismatch()
c.logComparison(execResult, localResult,
"script execution results from local execution do not match EN")
"script execution results from local execution do not match EN", true)
return false
}

// logScriptExecutionComparison logs the script execution comparison between local execution and execution node
func (c *scriptResultComparison) logComparison(execResult, localResult *scriptResult, msg string) {
func (c *scriptResultComparison) logComparison(execResult, localResult *scriptResult, msg string, useError bool) {
args := make([]string, len(c.request.arguments))
for i, arg := range c.request.arguments {
args[i] = string(arg)
Expand All @@ -109,7 +109,11 @@ func (c *scriptResultComparison) logComparison(execResult, localResult *scriptRe
lgCtx = lgCtx.Dur("local_duration_ms", localResult.duration)

lg := lgCtx.Logger()
lg.Debug().Msg(msg)
if useError {
lg.Error().Msg(msg)
} else {
lg.Debug().Msg(msg)
}
}

func isOutOfRangeError(err error) bool {
Expand Down

0 comments on commit ffddae1

Please sign in to comment.