Skip to content

Commit

Permalink
eth/tracers: use slices.Contains (ethereum#29461)
Browse files Browse the repository at this point in the history
  • Loading branch information
AaronChen0 authored and jorgemmsilva committed Jun 17, 2024
1 parent e7503d6 commit 85fac00
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 13 deletions.
9 changes: 2 additions & 7 deletions eth/tracers/js/goja.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"math/big"
"slices"

"github.com/dop251/goja"
"github.com/ethereum/go-ethereum/core/tracing"
Expand Down Expand Up @@ -529,13 +530,7 @@ func (t *jsTracer) setBuiltinFunctions() {
vm.Interrupt(err)
return false
}
addr := common.BytesToAddress(a)
for _, p := range t.activePrecompiles {
if p == addr {
return true
}
}
return false
return slices.Contains(t.activePrecompiles, common.BytesToAddress(a))
})
vm.Set("slice", func(slice goja.Value, start, end int64) goja.Value {
b, err := t.fromBuf(vm, slice, false)
Expand Down
8 changes: 2 additions & 6 deletions eth/tracers/native/call_flat.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ import (
"errors"
"fmt"
"math/big"
"slices"
"strings"

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

// isPrecompiled returns whether the addr is a precompile.
func (t *flatCallTracer) isPrecompiled(addr common.Address) bool {
for _, p := range t.activePrecompiles {
if p == addr {
return true
}
}
return false
return slices.Contains(t.activePrecompiles, addr)
}

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

0 comments on commit 85fac00

Please sign in to comment.