Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

eth/tracers: use slices.Contains #29461

Merged
merged 1 commit into from
Apr 6, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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