mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-19 03:10:48 +00:00
internal/ethapi: expose the eth_call gas consumption as a metric #32774
This commit is contained in:
parent
14c2408957
commit
13419fa39b
1 changed files with 4 additions and 0 deletions
|
|
@ -43,6 +43,7 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
"github.com/ethereum/go-ethereum/eth/tracers/logger"
|
||||||
"github.com/ethereum/go-ethereum/internal/ethapi/override"
|
"github.com/ethereum/go-ethereum/internal/ethapi/override"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
|
"github.com/ethereum/go-ethereum/metrics"
|
||||||
"github.com/ethereum/go-ethereum/p2p"
|
"github.com/ethereum/go-ethereum/p2p"
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
|
|
@ -56,6 +57,8 @@ const estimateGasErrorRatio = 0.015
|
||||||
var errBlobTxNotSupported = errors.New("signing blob transactions not supported")
|
var errBlobTxNotSupported = errors.New("signing blob transactions not supported")
|
||||||
var errSubClosed = errors.New("chain subscription closed")
|
var errSubClosed = errors.New("chain subscription closed")
|
||||||
|
|
||||||
|
var rpcGasUsedEthCall = metrics.NewRegisteredHistogram("rpc/gas_used/eth_call", nil, metrics.NewExpDecaySample(1028, 0.015))
|
||||||
|
|
||||||
// EthereumAPI provides an API to access Ethereum related information.
|
// EthereumAPI provides an API to access Ethereum related information.
|
||||||
type EthereumAPI struct {
|
type EthereumAPI struct {
|
||||||
b Backend
|
b Backend
|
||||||
|
|
@ -784,6 +787,7 @@ func (api *BlockChainAPI) Call(ctx context.Context, args TransactionArgs, blockN
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
rpcGasUsedEthCall.Update(int64(result.UsedGas))
|
||||||
if errors.Is(result.Err, vm.ErrExecutionReverted) {
|
if errors.Is(result.Err, vm.ErrExecutionReverted) {
|
||||||
return nil, newRevertError(result.Revert())
|
return nil, newRevertError(result.Revert())
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue