Skip to content

Commit

Permalink
Revert "Event based pprof" and update version (ethereum#742)
Browse files Browse the repository at this point in the history
* Revert "Event based pprof (ethereum#732)"

This reverts commit 22fa403.

* params: update version to 0.3.4-beta3

* packaging/templates: update bor version
  • Loading branch information
manav2401 committed Feb 15, 2023
1 parent 4916d75 commit 79718d7
Show file tree
Hide file tree
Showing 13 changed files with 14 additions and 257 deletions.
32 changes: 0 additions & 32 deletions common/context.go

This file was deleted.

107 changes: 0 additions & 107 deletions common/context_test.go

This file was deleted.

17 changes: 0 additions & 17 deletions common/set/slice.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,20 +9,3 @@ func New[T comparable](slice []T) map[T]struct{} {

return m
}

func ToSlice[T comparable](m map[T]struct{}) []T {
slice := make([]T, len(m))

var i int

for k := range m {
slice[i] = k
i++
}

return slice
}

func Deduplicate[T comparable](slice []T) []T {
return ToSlice(New(slice))
}
2 changes: 1 addition & 1 deletion eth/tracers/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -1052,7 +1052,7 @@ func (api *API) TraceCall(ctx context.Context, args ethapi.TransactionArgs, bloc
}
}
// Execute the trace
msg, err := args.ToMessage(ctx, api.backend.RPCGasCap(), block.BaseFee())
msg, err := args.ToMessage(api.backend.RPCGasCap(), block.BaseFee())
if err != nil {
return nil, err
}
Expand Down
91 changes: 2 additions & 89 deletions internal/ethapi/api.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,11 +21,7 @@ import (
"errors"
"fmt"
"math/big"
"os"
"path/filepath"
"runtime/pprof"
"strings"
"sync"
"time"

"github.com/davecgh/go-spew/spew"
Expand Down Expand Up @@ -1013,7 +1009,7 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
defer cancel()

// Get a new instance of the EVM.
msg, err := args.ToMessage(ctx, globalGasCap, header.BaseFee)
msg, err := args.ToMessage(globalGasCap, header.BaseFee)
if err != nil {
return nil, err
}
Expand All @@ -1036,83 +1032,15 @@ func DoCall(ctx context.Context, b Backend, args TransactionArgs, blockNrOrHash
}

// If the timer caused an abort, return an appropriate error message
timeoutMu.Lock()
if evm.Cancelled() {
timeoutErrors++

if timeoutErrors >= pprofThreshold {
timeoutNoErrors = 0

if !isRunning {
runProfile()
}

log.Warn("[eth_call] timeout",
"timeoutErrors", timeoutErrors,
"timeoutNoErrors", timeoutNoErrors,
"args", args,
"blockNrOrHash", blockNrOrHash,
"overrides", overrides,
"timeout", timeout,
"globalGasCap", globalGasCap)
}

timeoutMu.Unlock()

return nil, fmt.Errorf("execution aborted (timeout = %v)", timeout)
} else {
if timeoutErrors >= pprofStopThreshold {
timeoutErrors = 0
timeoutNoErrors = 0

if isRunning {
pprof.StopCPUProfile()
isRunning = false
}
}
}

if isRunning && time.Since(pprofTime) >= pprofDuration {
timeoutErrors = 0
timeoutNoErrors = 0

pprof.StopCPUProfile()

isRunning = false
}

timeoutMu.Unlock()

if err != nil {
return result, fmt.Errorf("err: %w (supplied gas %d)", err, msg.Gas())
}

return result, nil
}

func runProfile() {
pprofTime = time.Now()

name := fmt.Sprintf("profile_eth_call-count-%d-time-%s.prof",
number, pprofTime.Format("2006-01-02-15-04-05"))

name = filepath.Join(os.TempDir(), name)

f, err := os.Create(name)
if err != nil {
log.Error("[eth_call] can't create profile file", "name", name, "err", err)
return
}

if err = pprof.StartCPUProfile(f); err != nil {
log.Error("[eth_call] can't start profiling", "name", name, "err", err)
return
}

isRunning = true
number++
}

func newRevertError(result *core.ExecutionResult) *revertError {
reason, errUnpack := abi.UnpackRevert(result.Revert())
err := errors.New("execution reverted")
Expand Down Expand Up @@ -1143,21 +1071,6 @@ func (e *revertError) ErrorData() interface{} {
return e.reason
}

var (
number int
timeoutErrors int // count for timeout errors
timeoutNoErrors int
timeoutMu sync.Mutex
isRunning bool
pprofTime time.Time
)

const (
pprofThreshold = 3
pprofStopThreshold = 3
pprofDuration = time.Minute
)

// Call executes the given transaction on the state for the given block number.
//
// Additionally, the caller can specify a batch of contract for fields overriding.
Expand Down Expand Up @@ -1664,7 +1577,7 @@ func AccessList(ctx context.Context, b Backend, blockNrOrHash rpc.BlockNumberOrH
statedb := db.Copy()
// Set the accesslist to the last al
args.AccessList = &accessList
msg, err := args.ToMessage(ctx, b.RPCGasCap(), header.BaseFee)
msg, err := args.ToMessage(b.RPCGasCap(), header.BaseFee)
if err != nil {
return nil, 0, nil, err
}
Expand Down
2 changes: 1 addition & 1 deletion internal/ethapi/transaction_args.go
Original file line number Diff line number Diff line change
Expand Up @@ -197,7 +197,7 @@ func (args *TransactionArgs) setDefaults(ctx context.Context, b Backend) error {
// ToMessage converts the transaction arguments to the Message type used by the
// core evm. This method is used in calls and traces that do not require a real
// live transaction.
func (args *TransactionArgs) ToMessage(_ context.Context, globalGasCap uint64, baseFee *big.Int) (types.Message, error) {
func (args *TransactionArgs) ToMessage(globalGasCap uint64, baseFee *big.Int) (types.Message, error) {
// Reject invalid combinations of pre- and post-1559 fee styles
if args.GasPrice != nil && (args.MaxFeePerGas != nil || args.MaxPriorityFeePerGas != nil) {
return types.Message{}, errors.New("both gasPrice and (maxFeePerGas or maxPriorityFeePerGas) specified")
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 0.3.5-beta
Version: 0.3.4-beta3
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor
Version: 0.3.5-beta
Version: 0.3.4-beta3
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.amd64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.3.5-beta
Version: 0.3.4-beta3
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.profile.arm64
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.3.5-beta
Version: 0.3.4-beta3
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>
Expand Down
2 changes: 1 addition & 1 deletion packaging/templates/package_scripts/control.validator
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.3.5-beta
Version: 0.3.4-beta3
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Source: bor-profile
Version: 0.3.5-beta
Version: 0.3.4-beta3
Section: develop
Priority: standard
Maintainer: Polygon <release-team@polygon.technology>
Expand Down
8 changes: 4 additions & 4 deletions params/version.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ import (
)

const (
VersionMajor = 0 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 5 // Patch version component of the current release
VersionMeta = "beta" // Version metadata to append to the version string
VersionMajor = 0 // Major version component of the current release
VersionMinor = 3 // Minor version component of the current release
VersionPatch = 4 // Patch version component of the current release
VersionMeta = "beta3" // Version metadata to append to the version string
)

// Version holds the textual version string.
Expand Down

0 comments on commit 79718d7

Please sign in to comment.