Skip to content

Commit ccb76c0

Browse files
authored
eth/tracers: use slices.Contains (#29461)
1 parent 74995bf commit ccb76c0

File tree

2 files changed

+4
-13
lines changed

2 files changed

+4
-13
lines changed

eth/tracers/js/goja.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"math/big"
24+
"slices"
2425

2526
"github.com/dop251/goja"
2627
"github.com/ethereum/go-ethereum/core/tracing"
@@ -529,13 +530,7 @@ func (t *jsTracer) setBuiltinFunctions() {
529530
vm.Interrupt(err)
530531
return false
531532
}
532-
addr := common.BytesToAddress(a)
533-
for _, p := range t.activePrecompiles {
534-
if p == addr {
535-
return true
536-
}
537-
}
538-
return false
533+
return slices.Contains(t.activePrecompiles, common.BytesToAddress(a))
539534
})
540535
vm.Set("slice", func(slice goja.Value, start, end int64) goja.Value {
541536
b, err := t.fromBuf(vm, slice, false)

eth/tracers/native/call_flat.go

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"math/big"
24+
"slices"
2425
"strings"
2526

2627
"github.com/ethereum/go-ethereum/common"
@@ -228,12 +229,7 @@ func (t *flatCallTracer) Stop(err error) {
228229

229230
// isPrecompiled returns whether the addr is a precompile.
230231
func (t *flatCallTracer) isPrecompiled(addr common.Address) bool {
231-
for _, p := range t.activePrecompiles {
232-
if p == addr {
233-
return true
234-
}
235-
}
236-
return false
232+
return slices.Contains(t.activePrecompiles, addr)
237233
}
238234

239235
func flatFromNested(input *callFrame, traceAddress []int, convertErrs bool, ctx *tracers.Context) (output []flatCallFrame, err error) {

0 commit comments

Comments
 (0)