mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-08-20 10:52:25 +00:00
Merge branch 'ethereum:master' into pgeth
This commit is contained in:
commit
2b7eccf7d0
38 changed files with 165 additions and 174 deletions
|
|
@ -195,7 +195,7 @@ func TextHash(data []byte) []byte {
|
||||||
//
|
//
|
||||||
// This gives context to the signed message and prevents signing of transactions.
|
// This gives context to the signed message and prevents signing of transactions.
|
||||||
func TextAndHash(data []byte) ([]byte, string) {
|
func TextAndHash(data []byte) ([]byte, string) {
|
||||||
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), string(data))
|
msg := fmt.Sprintf("\x19Ethereum Signed Message:\n%d%s", len(data), data)
|
||||||
hasher := sha3.NewLegacyKeccak256()
|
hasher := sha3.NewLegacyKeccak256()
|
||||||
hasher.Write([]byte(msg))
|
hasher.Write([]byte(msg))
|
||||||
return hasher.Sum(nil), msg
|
return hasher.Sum(nil), msg
|
||||||
|
|
|
||||||
|
|
@ -257,7 +257,7 @@ func (s *serverWithLimits) init() {
|
||||||
}
|
}
|
||||||
|
|
||||||
// subscribe subscribes to events which include parent (serverWithTimeout) events
|
// subscribe subscribes to events which include parent (serverWithTimeout) events
|
||||||
// plus EvCanRequstAgain.
|
// plus EvCanRequestAgain.
|
||||||
func (s *serverWithLimits) subscribe(eventCallback func(event Event)) {
|
func (s *serverWithLimits) subscribe(eventCallback func(event Event)) {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
@ -415,7 +415,7 @@ func (s *serverWithLimits) delay(delay time.Duration) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// fail reports that a response from the server was found invalid by the processing
|
// fail reports that a response from the server was found invalid by the processing
|
||||||
// Module, disabling new requests for a dynamically adjused time period.
|
// Module, disabling new requests for a dynamically adjusted time period.
|
||||||
func (s *serverWithLimits) fail(desc string) {
|
func (s *serverWithLimits) fail(desc string) {
|
||||||
s.lock.Lock()
|
s.lock.Lock()
|
||||||
defer s.lock.Unlock()
|
defer s.lock.Unlock()
|
||||||
|
|
|
||||||
|
|
@ -242,7 +242,7 @@ func readInput(ctx *cli.Context) (*bbInput, error) {
|
||||||
if headerStr == stdinSelector || ommersStr == stdinSelector || txsStr == stdinSelector || cliqueStr == stdinSelector {
|
if headerStr == stdinSelector || ommersStr == stdinSelector || txsStr == stdinSelector || cliqueStr == stdinSelector {
|
||||||
decoder := json.NewDecoder(os.Stdin)
|
decoder := json.NewDecoder(os.Stdin)
|
||||||
if err := decoder.Decode(inputData); err != nil {
|
if err := decoder.Decode(inputData); err != nil {
|
||||||
return nil, NewError(ErrorJson, fmt.Errorf("failed unmarshaling stdin: %v", err))
|
return nil, NewError(ErrorJson, fmt.Errorf("failed unmarshalling stdin: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if cliqueStr != stdinSelector && cliqueStr != "" {
|
if cliqueStr != stdinSelector && cliqueStr != "" {
|
||||||
|
|
|
||||||
|
|
@ -86,7 +86,7 @@ func Transaction(ctx *cli.Context) error {
|
||||||
if txStr == stdinSelector {
|
if txStr == stdinSelector {
|
||||||
decoder := json.NewDecoder(os.Stdin)
|
decoder := json.NewDecoder(os.Stdin)
|
||||||
if err := decoder.Decode(inputData); err != nil {
|
if err := decoder.Decode(inputData); err != nil {
|
||||||
return NewError(ErrorJson, fmt.Errorf("failed unmarshaling stdin: %v", err))
|
return NewError(ErrorJson, fmt.Errorf("failed unmarshalling stdin: %v", err))
|
||||||
}
|
}
|
||||||
// Decode the body of already signed transactions
|
// Decode the body of already signed transactions
|
||||||
body = common.FromHex(inputData.TxRlp)
|
body = common.FromHex(inputData.TxRlp)
|
||||||
|
|
|
||||||
|
|
@ -135,7 +135,7 @@ func Transition(ctx *cli.Context) error {
|
||||||
if allocStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector {
|
if allocStr == stdinSelector || envStr == stdinSelector || txStr == stdinSelector {
|
||||||
decoder := json.NewDecoder(os.Stdin)
|
decoder := json.NewDecoder(os.Stdin)
|
||||||
if err := decoder.Decode(inputData); err != nil {
|
if err := decoder.Decode(inputData); err != nil {
|
||||||
return NewError(ErrorJson, fmt.Errorf("failed unmarshaling stdin: %v", err))
|
return NewError(ErrorJson, fmt.Errorf("failed unmarshalling stdin: %v", err))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if allocStr != stdinSelector {
|
if allocStr != stdinSelector {
|
||||||
|
|
|
||||||
|
|
@ -127,7 +127,7 @@ func loadTransactions(txStr string, inputData *input, env stEnv, chainConfig *pa
|
||||||
return newRlpTxIterator(body), nil
|
return newRlpTxIterator(body), nil
|
||||||
}
|
}
|
||||||
if err := json.Unmarshal(data, &txsWithKeys); err != nil {
|
if err := json.Unmarshal(data, &txsWithKeys); err != nil {
|
||||||
return nil, NewError(ErrorJson, fmt.Errorf("failed unmarshaling txs-file: %v", err))
|
return nil, NewError(ErrorJson, fmt.Errorf("failed unmarshalling txs-file: %v", err))
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if len(inputData.TxRlp) > 0 {
|
if len(inputData.TxRlp) > 0 {
|
||||||
|
|
|
||||||
|
|
@ -33,7 +33,7 @@ func readFile(path, desc string, dest interface{}) error {
|
||||||
defer inFile.Close()
|
defer inFile.Close()
|
||||||
decoder := json.NewDecoder(inFile)
|
decoder := json.NewDecoder(inFile)
|
||||||
if err := decoder.Decode(dest); err != nil {
|
if err := decoder.Decode(dest); err != nil {
|
||||||
return NewError(ErrorJson, fmt.Errorf("failed unmarshaling %s file: %v", desc, err))
|
return NewError(ErrorJson, fmt.Errorf("failed unmarshalling %s file: %v", desc, err))
|
||||||
}
|
}
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -267,7 +267,7 @@ func applyMetricConfig(ctx *cli.Context, cfg *gethConfig) {
|
||||||
cfg.Metrics.Enabled = ctx.Bool(utils.MetricsEnabledFlag.Name)
|
cfg.Metrics.Enabled = ctx.Bool(utils.MetricsEnabledFlag.Name)
|
||||||
}
|
}
|
||||||
if ctx.IsSet(utils.MetricsEnabledExpensiveFlag.Name) {
|
if ctx.IsSet(utils.MetricsEnabledExpensiveFlag.Name) {
|
||||||
cfg.Metrics.EnabledExpensive = ctx.Bool(utils.MetricsEnabledExpensiveFlag.Name)
|
log.Warn("Expensive metrics are collected by default, please remove this flag", "flag", utils.MetricsEnabledExpensiveFlag.Name)
|
||||||
}
|
}
|
||||||
if ctx.IsSet(utils.MetricsHTTPFlag.Name) {
|
if ctx.IsSet(utils.MetricsHTTPFlag.Name) {
|
||||||
cfg.Metrics.HTTP = ctx.String(utils.MetricsHTTPFlag.Name)
|
cfg.Metrics.HTTP = ctx.String(utils.MetricsHTTPFlag.Name)
|
||||||
|
|
|
||||||
|
|
@ -862,12 +862,6 @@ var (
|
||||||
Usage: "Enable metrics collection and reporting",
|
Usage: "Enable metrics collection and reporting",
|
||||||
Category: flags.MetricsCategory,
|
Category: flags.MetricsCategory,
|
||||||
}
|
}
|
||||||
MetricsEnabledExpensiveFlag = &cli.BoolFlag{
|
|
||||||
Name: "metrics.expensive",
|
|
||||||
Usage: "Enable expensive metrics collection and reporting",
|
|
||||||
Category: flags.MetricsCategory,
|
|
||||||
}
|
|
||||||
|
|
||||||
// MetricsHTTPFlag defines the endpoint for a stand-alone metrics HTTP endpoint.
|
// MetricsHTTPFlag defines the endpoint for a stand-alone metrics HTTP endpoint.
|
||||||
// Since the pprof service enables sensitive/vulnerable behavior, this allows a user
|
// Since the pprof service enables sensitive/vulnerable behavior, this allows a user
|
||||||
// to enable a public-OK metrics endpoint without having to worry about ALSO exposing
|
// to enable a public-OK metrics endpoint without having to worry about ALSO exposing
|
||||||
|
|
|
||||||
|
|
@ -93,35 +93,35 @@ var (
|
||||||
Name: "light.serve",
|
Name: "light.serve",
|
||||||
Usage: "Maximum percentage of time allowed for serving LES requests (deprecated)",
|
Usage: "Maximum percentage of time allowed for serving LES requests (deprecated)",
|
||||||
Value: ethconfig.Defaults.LightServ,
|
Value: ethconfig.Defaults.LightServ,
|
||||||
Category: flags.LightCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
LightIngressFlag = &cli.IntFlag{
|
LightIngressFlag = &cli.IntFlag{
|
||||||
Name: "light.ingress",
|
Name: "light.ingress",
|
||||||
Usage: "Incoming bandwidth limit for serving light clients (deprecated)",
|
Usage: "Incoming bandwidth limit for serving light clients (deprecated)",
|
||||||
Value: ethconfig.Defaults.LightIngress,
|
Value: ethconfig.Defaults.LightIngress,
|
||||||
Category: flags.LightCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
LightEgressFlag = &cli.IntFlag{
|
LightEgressFlag = &cli.IntFlag{
|
||||||
Name: "light.egress",
|
Name: "light.egress",
|
||||||
Usage: "Outgoing bandwidth limit for serving light clients (deprecated)",
|
Usage: "Outgoing bandwidth limit for serving light clients (deprecated)",
|
||||||
Value: ethconfig.Defaults.LightEgress,
|
Value: ethconfig.Defaults.LightEgress,
|
||||||
Category: flags.LightCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
LightMaxPeersFlag = &cli.IntFlag{
|
LightMaxPeersFlag = &cli.IntFlag{
|
||||||
Name: "light.maxpeers",
|
Name: "light.maxpeers",
|
||||||
Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated)",
|
Usage: "Maximum number of light clients to serve, or light servers to attach to (deprecated)",
|
||||||
Value: ethconfig.Defaults.LightPeers,
|
Value: ethconfig.Defaults.LightPeers,
|
||||||
Category: flags.LightCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
LightNoPruneFlag = &cli.BoolFlag{
|
LightNoPruneFlag = &cli.BoolFlag{
|
||||||
Name: "light.nopruning",
|
Name: "light.nopruning",
|
||||||
Usage: "Disable ancient light chain data pruning (deprecated)",
|
Usage: "Disable ancient light chain data pruning (deprecated)",
|
||||||
Category: flags.LightCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
LightNoSyncServeFlag = &cli.BoolFlag{
|
LightNoSyncServeFlag = &cli.BoolFlag{
|
||||||
Name: "light.nosyncserve",
|
Name: "light.nosyncserve",
|
||||||
Usage: "Enables serving light clients before syncing (deprecated)",
|
Usage: "Enables serving light clients before syncing (deprecated)",
|
||||||
Category: flags.LightCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
// Deprecated November 2023
|
// Deprecated November 2023
|
||||||
LogBacktraceAtFlag = &cli.StringFlag{
|
LogBacktraceAtFlag = &cli.StringFlag{
|
||||||
|
|
@ -138,19 +138,24 @@ var (
|
||||||
// Deprecated February 2024
|
// Deprecated February 2024
|
||||||
MinerNewPayloadTimeoutFlag = &cli.DurationFlag{
|
MinerNewPayloadTimeoutFlag = &cli.DurationFlag{
|
||||||
Name: "miner.newpayload-timeout",
|
Name: "miner.newpayload-timeout",
|
||||||
Usage: "Specify the maximum time allowance for creating a new payload",
|
Usage: "Specify the maximum time allowance for creating a new payload (deprecated)",
|
||||||
Value: ethconfig.Defaults.Miner.Recommit,
|
Value: ethconfig.Defaults.Miner.Recommit,
|
||||||
Category: flags.MinerCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
MinerEtherbaseFlag = &cli.StringFlag{
|
MinerEtherbaseFlag = &cli.StringFlag{
|
||||||
Name: "miner.etherbase",
|
Name: "miner.etherbase",
|
||||||
Usage: "0x prefixed public address for block mining rewards",
|
Usage: "0x prefixed public address for block mining rewards (deprecated)",
|
||||||
Category: flags.MinerCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
MiningEnabledFlag = &cli.BoolFlag{
|
MiningEnabledFlag = &cli.BoolFlag{
|
||||||
Name: "mine",
|
Name: "mine",
|
||||||
Usage: "Enable mining",
|
Usage: "Enable mining (deprecated)",
|
||||||
Category: flags.MinerCategory,
|
Category: flags.DeprecatedCategory,
|
||||||
|
}
|
||||||
|
MetricsEnabledExpensiveFlag = &cli.BoolFlag{
|
||||||
|
Name: "metrics.expensive",
|
||||||
|
Usage: "Enable expensive metrics collection and reporting (deprecated)",
|
||||||
|
Category: flags.DeprecatedCategory,
|
||||||
}
|
}
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -152,8 +152,7 @@ func (env *tester) Close(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
// Tests that the node lists the correct welcome message, notably that it contains
|
// Tests that the node lists the correct welcome message, notably that it contains
|
||||||
// the instance name, coinbase account, block number, data directory and supported
|
// the instance name, block number, data directory and supported console modules.
|
||||||
// console modules.
|
|
||||||
func TestWelcome(t *testing.T) {
|
func TestWelcome(t *testing.T) {
|
||||||
tester := newTester(t, nil)
|
tester := newTester(t, nil)
|
||||||
defer tester.Close(t)
|
defer tester.Close(t)
|
||||||
|
|
@ -171,7 +170,10 @@ func TestWelcome(t *testing.T) {
|
||||||
t.Fatalf("console output missing sync status: have\n%s\nwant also %s", output, want)
|
t.Fatalf("console output missing sync status: have\n%s\nwant also %s", output, want)
|
||||||
}
|
}
|
||||||
if want := fmt.Sprintf("datadir: %s", tester.workspace); !strings.Contains(output, want) {
|
if want := fmt.Sprintf("datadir: %s", tester.workspace); !strings.Contains(output, want) {
|
||||||
t.Fatalf("console output missing coinbase: have\n%s\nwant also %s", output, want)
|
t.Fatalf("console output missing datadir: have\n%s\nwant also %s", output, want)
|
||||||
|
}
|
||||||
|
if want := "modules: "; !strings.Contains(output, want) {
|
||||||
|
t.Fatalf("console output missing modules: have\n%s\nwant also %s", output, want)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -61,26 +61,26 @@ var (
|
||||||
|
|
||||||
chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
|
chainInfoGauge = metrics.NewRegisteredGaugeInfo("chain/info", nil)
|
||||||
|
|
||||||
accountReadTimer = metrics.NewRegisteredTimer("chain/account/reads", nil)
|
accountReadTimer = metrics.NewRegisteredResettingTimer("chain/account/reads", nil)
|
||||||
accountHashTimer = metrics.NewRegisteredTimer("chain/account/hashes", nil)
|
accountHashTimer = metrics.NewRegisteredResettingTimer("chain/account/hashes", nil)
|
||||||
accountUpdateTimer = metrics.NewRegisteredTimer("chain/account/updates", nil)
|
accountUpdateTimer = metrics.NewRegisteredResettingTimer("chain/account/updates", nil)
|
||||||
accountCommitTimer = metrics.NewRegisteredTimer("chain/account/commits", nil)
|
accountCommitTimer = metrics.NewRegisteredResettingTimer("chain/account/commits", nil)
|
||||||
|
|
||||||
storageReadTimer = metrics.NewRegisteredTimer("chain/storage/reads", nil)
|
storageReadTimer = metrics.NewRegisteredResettingTimer("chain/storage/reads", nil)
|
||||||
storageHashTimer = metrics.NewRegisteredTimer("chain/storage/hashes", nil)
|
storageHashTimer = metrics.NewRegisteredResettingTimer("chain/storage/hashes", nil)
|
||||||
storageUpdateTimer = metrics.NewRegisteredTimer("chain/storage/updates", nil)
|
storageUpdateTimer = metrics.NewRegisteredResettingTimer("chain/storage/updates", nil)
|
||||||
storageCommitTimer = metrics.NewRegisteredTimer("chain/storage/commits", nil)
|
storageCommitTimer = metrics.NewRegisteredResettingTimer("chain/storage/commits", nil)
|
||||||
|
|
||||||
snapshotAccountReadTimer = metrics.NewRegisteredTimer("chain/snapshot/account/reads", nil)
|
snapshotAccountReadTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/account/reads", nil)
|
||||||
snapshotStorageReadTimer = metrics.NewRegisteredTimer("chain/snapshot/storage/reads", nil)
|
snapshotStorageReadTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/storage/reads", nil)
|
||||||
snapshotCommitTimer = metrics.NewRegisteredTimer("chain/snapshot/commits", nil)
|
snapshotCommitTimer = metrics.NewRegisteredResettingTimer("chain/snapshot/commits", nil)
|
||||||
|
|
||||||
triedbCommitTimer = metrics.NewRegisteredTimer("chain/triedb/commits", nil)
|
triedbCommitTimer = metrics.NewRegisteredResettingTimer("chain/triedb/commits", nil)
|
||||||
|
|
||||||
blockInsertTimer = metrics.NewRegisteredTimer("chain/inserts", nil)
|
blockInsertTimer = metrics.NewRegisteredResettingTimer("chain/inserts", nil)
|
||||||
blockValidationTimer = metrics.NewRegisteredTimer("chain/validation", nil)
|
blockValidationTimer = metrics.NewRegisteredResettingTimer("chain/validation", nil)
|
||||||
blockExecutionTimer = metrics.NewRegisteredTimer("chain/execution", nil)
|
blockExecutionTimer = metrics.NewRegisteredResettingTimer("chain/execution", nil)
|
||||||
blockWriteTimer = metrics.NewRegisteredTimer("chain/write", nil)
|
blockWriteTimer = metrics.NewRegisteredResettingTimer("chain/write", nil)
|
||||||
|
|
||||||
blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil)
|
blockReorgMeter = metrics.NewRegisteredMeter("chain/reorg/executes", nil)
|
||||||
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
|
blockReorgAddMeter = metrics.NewRegisteredMeter("chain/reorg/add", nil)
|
||||||
|
|
|
||||||
|
|
@ -45,7 +45,7 @@ import (
|
||||||
|
|
||||||
var errGenesisNoConfig = errors.New("genesis has no chain configuration")
|
var errGenesisNoConfig = errors.New("genesis has no chain configuration")
|
||||||
|
|
||||||
// Deprecated: use types.GenesisAccount instead.
|
// Deprecated: use types.Account instead.
|
||||||
type GenesisAccount = types.Account
|
type GenesisAccount = types.Account
|
||||||
|
|
||||||
// Deprecated: use types.GenesisAlloc instead.
|
// Deprecated: use types.GenesisAlloc instead.
|
||||||
|
|
|
||||||
|
|
@ -25,7 +25,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
|
||||||
"github.com/ethereum/go-ethereum/rlp"
|
"github.com/ethereum/go-ethereum/rlp"
|
||||||
"github.com/ethereum/go-ethereum/trie/trienode"
|
"github.com/ethereum/go-ethereum/trie/trienode"
|
||||||
"github.com/holiman/uint256"
|
"github.com/holiman/uint256"
|
||||||
|
|
@ -197,9 +196,8 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
|
||||||
if s.db.snap != nil {
|
if s.db.snap != nil {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key.Bytes()))
|
enc, err = s.db.snap.Storage(s.addrHash, crypto.Keccak256Hash(key.Bytes()))
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
s.db.SnapshotStorageReads += time.Since(start)
|
s.db.SnapshotStorageReads += time.Since(start)
|
||||||
}
|
|
||||||
if len(enc) > 0 {
|
if len(enc) > 0 {
|
||||||
_, content, _, err := rlp.Split(enc)
|
_, content, _, err := rlp.Split(enc)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
|
|
@ -217,9 +215,8 @@ func (s *stateObject) GetCommittedState(key common.Hash) common.Hash {
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
}
|
}
|
||||||
val, err := tr.GetStorage(s.address, key.Bytes())
|
val, err := tr.GetStorage(s.address, key.Bytes())
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
s.db.StorageReads += time.Since(start)
|
s.db.StorageReads += time.Since(start)
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.db.setError(err)
|
s.db.setError(err)
|
||||||
return common.Hash{}
|
return common.Hash{}
|
||||||
|
|
@ -283,9 +280,8 @@ func (s *stateObject) updateTrie() (Trie, error) {
|
||||||
return s.trie, nil
|
return s.trie, nil
|
||||||
}
|
}
|
||||||
// Track the amount of time wasted on updating the storage trie
|
// Track the amount of time wasted on updating the storage trie
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
defer func(start time.Time) { s.db.StorageUpdates += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.db.StorageUpdates += time.Since(start) }(time.Now())
|
||||||
}
|
|
||||||
// The snapshot storage map for the object
|
// The snapshot storage map for the object
|
||||||
var (
|
var (
|
||||||
storage map[common.Hash][]byte
|
storage map[common.Hash][]byte
|
||||||
|
|
@ -370,9 +366,8 @@ func (s *stateObject) updateRoot() {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
// Track the amount of time wasted on hashing the storage trie
|
// Track the amount of time wasted on hashing the storage trie
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
defer func(start time.Time) { s.db.StorageHashes += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.db.StorageHashes += time.Since(start) }(time.Now())
|
||||||
}
|
|
||||||
s.data.Root = tr.Hash()
|
s.data.Root = tr.Hash()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -386,9 +381,8 @@ func (s *stateObject) commit() (*trienode.NodeSet, error) {
|
||||||
return nil, nil
|
return nil, nil
|
||||||
}
|
}
|
||||||
// Track the amount of time wasted on committing the storage trie
|
// Track the amount of time wasted on committing the storage trie
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
defer func(start time.Time) { s.db.StorageCommits += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.db.StorageCommits += time.Since(start) }(time.Now())
|
||||||
}
|
|
||||||
// The trie is currently in an open state and could potentially contain
|
// The trie is currently in an open state and could potentially contain
|
||||||
// cached mutations. Call commit to acquire a set of nodes that have been
|
// cached mutations. Call commit to acquire a set of nodes that have been
|
||||||
// modified, the set can be nil if nothing to commit.
|
// modified, the set can be nil if nothing to commit.
|
||||||
|
|
|
||||||
|
|
@ -28,7 +28,6 @@ import (
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/crypto"
|
"github.com/ethereum/go-ethereum/crypto"
|
||||||
"github.com/ethereum/go-ethereum/log"
|
"github.com/ethereum/go-ethereum/log"
|
||||||
"github.com/ethereum/go-ethereum/metrics"
|
|
||||||
"github.com/ethereum/go-ethereum/params"
|
"github.com/ethereum/go-ethereum/params"
|
||||||
"github.com/ethereum/go-ethereum/trie"
|
"github.com/ethereum/go-ethereum/trie"
|
||||||
"github.com/ethereum/go-ethereum/trie/trienode"
|
"github.com/ethereum/go-ethereum/trie/trienode"
|
||||||
|
|
@ -495,9 +494,8 @@ func (s *StateDB) GetTransientState(addr common.Address, key common.Hash) common
|
||||||
// updateStateObject writes the given object to the trie.
|
// updateStateObject writes the given object to the trie.
|
||||||
func (s *StateDB) updateStateObject(obj *stateObject) {
|
func (s *StateDB) updateStateObject(obj *stateObject) {
|
||||||
// Track the amount of time wasted on updating the account from the trie
|
// Track the amount of time wasted on updating the account from the trie
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now())
|
||||||
}
|
|
||||||
// Encode the account and update the account trie
|
// Encode the account and update the account trie
|
||||||
addr := obj.Address()
|
addr := obj.Address()
|
||||||
if err := s.trie.UpdateAccount(addr, &obj.data); err != nil {
|
if err := s.trie.UpdateAccount(addr, &obj.data); err != nil {
|
||||||
|
|
@ -527,9 +525,8 @@ func (s *StateDB) updateStateObject(obj *stateObject) {
|
||||||
// deleteStateObject removes the given object from the state trie.
|
// deleteStateObject removes the given object from the state trie.
|
||||||
func (s *StateDB) deleteStateObject(obj *stateObject) {
|
func (s *StateDB) deleteStateObject(obj *stateObject) {
|
||||||
// Track the amount of time wasted on deleting the account from the trie
|
// Track the amount of time wasted on deleting the account from the trie
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.AccountUpdates += time.Since(start) }(time.Now())
|
||||||
}
|
|
||||||
// Delete the account from the trie
|
// Delete the account from the trie
|
||||||
addr := obj.Address()
|
addr := obj.Address()
|
||||||
if err := s.trie.DeleteAccount(addr); err != nil {
|
if err := s.trie.DeleteAccount(addr); err != nil {
|
||||||
|
|
@ -561,9 +558,8 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
|
||||||
if s.snap != nil {
|
if s.snap != nil {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
acc, err := s.snap.Account(crypto.HashData(s.hasher, addr.Bytes()))
|
acc, err := s.snap.Account(crypto.HashData(s.hasher, addr.Bytes()))
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
s.SnapshotAccountReads += time.Since(start)
|
s.SnapshotAccountReads += time.Since(start)
|
||||||
}
|
|
||||||
if err == nil {
|
if err == nil {
|
||||||
if acc == nil {
|
if acc == nil {
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -587,9 +583,8 @@ func (s *StateDB) getDeletedStateObject(addr common.Address) *stateObject {
|
||||||
start := time.Now()
|
start := time.Now()
|
||||||
var err error
|
var err error
|
||||||
data, err = s.trie.GetAccount(addr)
|
data, err = s.trie.GetAccount(addr)
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
s.AccountReads += time.Since(start)
|
s.AccountReads += time.Since(start)
|
||||||
}
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
s.setError(fmt.Errorf("getDeleteStateObject (%x) error: %w", addr.Bytes(), err))
|
s.setError(fmt.Errorf("getDeleteStateObject (%x) error: %w", addr.Bytes(), err))
|
||||||
return nil
|
return nil
|
||||||
|
|
@ -917,9 +912,8 @@ func (s *StateDB) IntermediateRoot(deleteEmptyObjects bool) common.Hash {
|
||||||
s.stateObjectsPending = make(map[common.Address]struct{})
|
s.stateObjectsPending = make(map[common.Address]struct{})
|
||||||
}
|
}
|
||||||
// Track the amount of time wasted on hashing the account trie
|
// Track the amount of time wasted on hashing the account trie
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
defer func(start time.Time) { s.AccountHashes += time.Since(start) }(time.Now())
|
defer func(start time.Time) { s.AccountHashes += time.Since(start) }(time.Now())
|
||||||
}
|
|
||||||
return s.trie.Hash()
|
return s.trie.Hash()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1042,7 +1036,7 @@ func (s *StateDB) deleteStorage(addr common.Address, addrHash common.Hash, root
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, nil, err
|
return nil, nil, err
|
||||||
}
|
}
|
||||||
if metrics.EnabledExpensive {
|
// Report the metrics
|
||||||
n := int64(len(slots))
|
n := int64(len(slots))
|
||||||
|
|
||||||
slotDeletionMaxCount.UpdateIfGt(int64(len(slots)))
|
slotDeletionMaxCount.UpdateIfGt(int64(len(slots)))
|
||||||
|
|
@ -1051,7 +1045,7 @@ func (s *StateDB) deleteStorage(addr common.Address, addrHash common.Hash, root
|
||||||
slotDeletionTimer.UpdateSince(start)
|
slotDeletionTimer.UpdateSince(start)
|
||||||
slotDeletionCount.Mark(n)
|
slotDeletionCount.Mark(n)
|
||||||
slotDeletionSize.Mark(int64(size))
|
slotDeletionSize.Mark(int64(size))
|
||||||
}
|
|
||||||
return slots, nodes, nil
|
return slots, nodes, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -1190,10 +1184,8 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Write the account trie changes, measuring the amount of wasted time
|
// Write the account trie changes, measuring the amount of wasted time
|
||||||
var start time.Time
|
start := time.Now()
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
start = time.Now()
|
|
||||||
}
|
|
||||||
root, set, err := s.trie.Commit(true)
|
root, set, err := s.trie.Commit(true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
|
|
@ -1205,7 +1197,7 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
||||||
}
|
}
|
||||||
accountTrieNodesUpdated, accountTrieNodesDeleted = set.Size()
|
accountTrieNodesUpdated, accountTrieNodesDeleted = set.Size()
|
||||||
}
|
}
|
||||||
if metrics.EnabledExpensive {
|
// Report the commit metrics
|
||||||
s.AccountCommits += time.Since(start)
|
s.AccountCommits += time.Since(start)
|
||||||
|
|
||||||
accountUpdatedMeter.Mark(int64(s.AccountUpdated))
|
accountUpdatedMeter.Mark(int64(s.AccountUpdated))
|
||||||
|
|
@ -1218,10 +1210,10 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
||||||
storageTriesDeletedMeter.Mark(int64(storageTrieNodesDeleted))
|
storageTriesDeletedMeter.Mark(int64(storageTrieNodesDeleted))
|
||||||
s.AccountUpdated, s.AccountDeleted = 0, 0
|
s.AccountUpdated, s.AccountDeleted = 0, 0
|
||||||
s.StorageUpdated, s.StorageDeleted = 0, 0
|
s.StorageUpdated, s.StorageDeleted = 0, 0
|
||||||
}
|
|
||||||
// If snapshotting is enabled, update the snapshot tree with this new version
|
// If snapshotting is enabled, update the snapshot tree with this new version
|
||||||
if s.snap != nil {
|
if s.snap != nil {
|
||||||
start := time.Now()
|
start = time.Now()
|
||||||
// Only update if there's a state transition (skip empty Clique blocks)
|
// Only update if there's a state transition (skip empty Clique blocks)
|
||||||
if parent := s.snap.Root(); parent != root {
|
if parent := s.snap.Root(); parent != root {
|
||||||
if err := s.snaps.Update(root, parent, s.convertAccountSet(s.stateObjectsDestruct), s.accounts, s.storages); err != nil {
|
if err := s.snaps.Update(root, parent, s.convertAccountSet(s.stateObjectsDestruct), s.accounts, s.storages); err != nil {
|
||||||
|
|
@ -1235,9 +1227,7 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
||||||
log.Warn("Failed to cap snapshot tree", "root", root, "layers", 128, "err", err)
|
log.Warn("Failed to cap snapshot tree", "root", root, "layers", 128, "err", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
s.SnapshotCommits += time.Since(start)
|
s.SnapshotCommits += time.Since(start)
|
||||||
}
|
|
||||||
s.snap = nil
|
s.snap = nil
|
||||||
}
|
}
|
||||||
if root == (common.Hash{}) {
|
if root == (common.Hash{}) {
|
||||||
|
|
@ -1248,15 +1238,14 @@ func (s *StateDB) Commit(block uint64, deleteEmptyObjects bool) (common.Hash, er
|
||||||
origin = types.EmptyRootHash
|
origin = types.EmptyRootHash
|
||||||
}
|
}
|
||||||
if root != origin {
|
if root != origin {
|
||||||
start := time.Now()
|
start = time.Now()
|
||||||
set := triestate.New(s.accountsOrigin, s.storagesOrigin)
|
set := triestate.New(s.accountsOrigin, s.storagesOrigin)
|
||||||
if err := s.db.TrieDB().Update(root, origin, block, nodes, set); err != nil {
|
if err := s.db.TrieDB().Update(root, origin, block, nodes, set); err != nil {
|
||||||
return common.Hash{}, err
|
return common.Hash{}, err
|
||||||
}
|
}
|
||||||
s.originalRoot = root
|
s.originalRoot = root
|
||||||
if metrics.EnabledExpensive {
|
|
||||||
s.TrieDBCommits += time.Since(start)
|
s.TrieDBCommits += time.Since(start)
|
||||||
}
|
|
||||||
if s.onCommit != nil {
|
if s.onCommit != nil {
|
||||||
s.onCommit(set)
|
s.onCommit(set)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -1131,8 +1131,12 @@ func (p *BlobPool) validateTx(tx *types.Transaction) error {
|
||||||
next = p.state.GetNonce(from)
|
next = p.state.GetNonce(from)
|
||||||
)
|
)
|
||||||
if uint64(len(p.index[from])) > tx.Nonce()-next {
|
if uint64(len(p.index[from])) > tx.Nonce()-next {
|
||||||
// Account can support the replacement, but the price bump must also be met
|
|
||||||
prev := p.index[from][int(tx.Nonce()-next)]
|
prev := p.index[from][int(tx.Nonce()-next)]
|
||||||
|
// Ensure the transaction is different than the one tracked locally
|
||||||
|
if prev.hash == tx.Hash() {
|
||||||
|
return txpool.ErrAlreadyKnown
|
||||||
|
}
|
||||||
|
// Account can support the replacement, but the price bump must also be met
|
||||||
switch {
|
switch {
|
||||||
case tx.GasFeeCapIntCmp(prev.execFeeCap.ToBig()) <= 0:
|
case tx.GasFeeCapIntCmp(prev.execFeeCap.ToBig()) <= 0:
|
||||||
return fmt.Errorf("%w: new tx gas fee cap %v <= %v queued", txpool.ErrReplaceUnderpriced, tx.GasFeeCap(), prev.execFeeCap)
|
return fmt.Errorf("%w: new tx gas fee cap %v <= %v queued", txpool.ErrReplaceUnderpriced, tx.GasFeeCap(), prev.execFeeCap)
|
||||||
|
|
|
||||||
|
|
@ -984,9 +984,14 @@ func TestAdd(t *testing.T) {
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
adds: []addtx{
|
adds: []addtx{
|
||||||
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
|
{ // New account, 1 tx pending: reject duplicate nonce 0
|
||||||
from: "alice",
|
from: "alice",
|
||||||
tx: makeUnsignedTx(0, 1, 1, 1),
|
tx: makeUnsignedTx(0, 1, 1, 1),
|
||||||
|
err: txpool.ErrAlreadyKnown,
|
||||||
|
},
|
||||||
|
{ // New account, 1 tx pending: reject replacement nonce 0 (ignore price for now)
|
||||||
|
from: "alice",
|
||||||
|
tx: makeUnsignedTx(0, 1, 1, 2),
|
||||||
err: txpool.ErrReplaceUnderpriced,
|
err: txpool.ErrReplaceUnderpriced,
|
||||||
},
|
},
|
||||||
{ // New account, 1 tx pending: accept nonce 1
|
{ // New account, 1 tx pending: accept nonce 1
|
||||||
|
|
@ -1009,10 +1014,10 @@ func TestAdd(t *testing.T) {
|
||||||
tx: makeUnsignedTx(3, 1, 1, 1),
|
tx: makeUnsignedTx(3, 1, 1, 1),
|
||||||
err: nil,
|
err: nil,
|
||||||
},
|
},
|
||||||
{ // Old account, 1 tx in chain, 1 tx pending: reject replacement nonce 1 (ignore price for now)
|
{ // Old account, 1 tx in chain, 1 tx pending: reject duplicate nonce 1
|
||||||
from: "bob",
|
from: "bob",
|
||||||
tx: makeUnsignedTx(1, 1, 1, 1),
|
tx: makeUnsignedTx(1, 1, 1, 1),
|
||||||
err: txpool.ErrReplaceUnderpriced,
|
err: txpool.ErrAlreadyKnown,
|
||||||
},
|
},
|
||||||
{ // Old account, 1 tx in chain, 1 tx pending: accept nonce 2 (ignore price for now)
|
{ // Old account, 1 tx in chain, 1 tx pending: accept nonce 2 (ignore price for now)
|
||||||
from: "bob",
|
from: "bob",
|
||||||
|
|
|
||||||
|
|
@ -52,7 +52,7 @@ type accountMarshaling struct {
|
||||||
}
|
}
|
||||||
|
|
||||||
// storageJSON represents a 256 bit byte array, but allows less than 256 bits when
|
// storageJSON represents a 256 bit byte array, but allows less than 256 bits when
|
||||||
// unmarshaling from hex.
|
// unmarshalling from hex.
|
||||||
type storageJSON common.Hash
|
type storageJSON common.Hash
|
||||||
|
|
||||||
func (h *storageJSON) UnmarshalText(text []byte) error {
|
func (h *storageJSON) UnmarshalText(text []byte) error {
|
||||||
|
|
|
||||||
|
|
@ -343,7 +343,7 @@ func TestReceiptJSON(t *testing.T) {
|
||||||
r := Receipt{}
|
r := Receipt{}
|
||||||
err = r.UnmarshalJSON(b)
|
err = r.UnmarshalJSON(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("error unmarshaling receipt from json:", err)
|
t.Fatal("error unmarshalling receipt from json:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -360,7 +360,7 @@ func TestEffectiveGasPriceNotRequired(t *testing.T) {
|
||||||
r2 := Receipt{}
|
r2 := Receipt{}
|
||||||
err = r2.UnmarshalJSON(b)
|
err = r2.UnmarshalJSON(b)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatal("error unmarshaling receipt from json:", err)
|
t.Fatal("error unmarshalling receipt from json:", err)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -85,7 +85,7 @@ type Claim [32]byte
|
||||||
var useCKZG atomic.Bool
|
var useCKZG atomic.Bool
|
||||||
|
|
||||||
// UseCKZG can be called to switch the default Go implementation of KZG to the C
|
// UseCKZG can be called to switch the default Go implementation of KZG to the C
|
||||||
// library if fo some reason the user wishes to do so (e.g. consensus bug in one
|
// library if for some reason the user wishes to do so (e.g. consensus bug in one
|
||||||
// or the other).
|
// or the other).
|
||||||
func UseCKZG(use bool) error {
|
func UseCKZG(use bool) error {
|
||||||
if use && !ckzgAvailable {
|
if use && !ckzgAvailable {
|
||||||
|
|
|
||||||
|
|
@ -357,7 +357,7 @@ SECP256K1_API int secp256k1_ecdsa_signature_serialize_compact(
|
||||||
/** Verify an ECDSA signature.
|
/** Verify an ECDSA signature.
|
||||||
*
|
*
|
||||||
* Returns: 1: correct signature
|
* Returns: 1: correct signature
|
||||||
* 0: incorrect or unparseable signature
|
* 0: incorrect or unparsable signature
|
||||||
* Args: ctx: a secp256k1 context object, initialized for verification.
|
* Args: ctx: a secp256k1 context object, initialized for verification.
|
||||||
* In: sig: the signature being verified (cannot be NULL)
|
* In: sig: the signature being verified (cannot be NULL)
|
||||||
* msg32: the 32-byte message hash being verified (cannot be NULL)
|
* msg32: the 32-byte message hash being verified (cannot be NULL)
|
||||||
|
|
|
||||||
|
|
@ -17,7 +17,7 @@
|
||||||
# - A constraint describing the requirements of the law, called "require"
|
# - A constraint describing the requirements of the law, called "require"
|
||||||
# * Implementations are transliterated into functions that operate as well on
|
# * Implementations are transliterated into functions that operate as well on
|
||||||
# algebraic input points, and are called once per combination of branches
|
# algebraic input points, and are called once per combination of branches
|
||||||
# exectured. Each execution returns:
|
# executed. Each execution returns:
|
||||||
# - A constraint describing the assumptions this implementation requires
|
# - A constraint describing the assumptions this implementation requires
|
||||||
# (such as Z1=1), called "assumeFormula"
|
# (such as Z1=1), called "assumeFormula"
|
||||||
# - A constraint describing the assumptions this specific branch requires,
|
# - A constraint describing the assumptions this specific branch requires,
|
||||||
|
|
|
||||||
|
|
@ -497,7 +497,7 @@ func (h *handler) BroadcastTransactions(txs types.Transactions) {
|
||||||
}
|
}
|
||||||
// Send the transaction (if it's small enough) directly to a subset of
|
// Send the transaction (if it's small enough) directly to a subset of
|
||||||
// the peers that have not received it yet, ensuring that the flow of
|
// the peers that have not received it yet, ensuring that the flow of
|
||||||
// transactions is groupped by account to (try and) avoid nonce gaps.
|
// transactions is grouped by account to (try and) avoid nonce gaps.
|
||||||
//
|
//
|
||||||
// To do this, we hash the local enode IW with together with a peer's
|
// To do this, we hash the local enode IW with together with a peer's
|
||||||
// enode ID together with the transaction sender and broadcast if
|
// enode ID together with the transaction sender and broadcast if
|
||||||
|
|
|
||||||
|
|
@ -1502,7 +1502,7 @@ func getCodeByHash(hash common.Hash) []byte {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeAccountTrieNoStorage spits out a trie, along with the leafs
|
// makeAccountTrieNoStorage spits out a trie, along with the leaves
|
||||||
func makeAccountTrieNoStorage(n int, scheme string) (string, *trie.Trie, []*kv) {
|
func makeAccountTrieNoStorage(n int, scheme string) (string, *trie.Trie, []*kv) {
|
||||||
var (
|
var (
|
||||||
db = triedb.NewDatabase(rawdb.NewMemoryDatabase(), newDbConfig(scheme))
|
db = triedb.NewDatabase(rawdb.NewMemoryDatabase(), newDbConfig(scheme))
|
||||||
|
|
@ -1650,7 +1650,7 @@ func makeAccountTrieWithStorageWithUniqueStorage(scheme string, accounts, slots
|
||||||
return db.Scheme(), accTrie, entries, storageTries, storageEntries
|
return db.Scheme(), accTrie, entries, storageTries, storageEntries
|
||||||
}
|
}
|
||||||
|
|
||||||
// makeAccountTrieWithStorage spits out a trie, along with the leafs
|
// makeAccountTrieWithStorage spits out a trie, along with the leaves
|
||||||
func makeAccountTrieWithStorage(scheme string, accounts, slots int, code, boundary bool, uneven bool) (*trie.Trie, []*kv, map[common.Hash]*trie.Trie, map[common.Hash][]*kv) {
|
func makeAccountTrieWithStorage(scheme string, accounts, slots int, code, boundary bool, uneven bool) (*trie.Trie, []*kv, map[common.Hash]*trie.Trie, map[common.Hash][]*kv) {
|
||||||
var (
|
var (
|
||||||
db = triedb.NewDatabase(rawdb.NewMemoryDatabase(), newDbConfig(scheme))
|
db = triedb.NewDatabase(rawdb.NewMemoryDatabase(), newDbConfig(scheme))
|
||||||
|
|
|
||||||
|
|
@ -245,6 +245,12 @@ func toCallArg(msg ethereum.CallMsg) interface{} {
|
||||||
if msg.AccessList != nil {
|
if msg.AccessList != nil {
|
||||||
arg["accessList"] = msg.AccessList
|
arg["accessList"] = msg.AccessList
|
||||||
}
|
}
|
||||||
|
if msg.BlobGasFeeCap != nil {
|
||||||
|
arg["maxFeePerBlobGas"] = (*hexutil.Big)(msg.BlobGasFeeCap)
|
||||||
|
}
|
||||||
|
if msg.BlobHashes != nil {
|
||||||
|
arg["blobVersionedHashes"] = msg.BlobHashes
|
||||||
|
}
|
||||||
return arg
|
return arg
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -146,7 +146,7 @@ func TestGethClient(t *testing.T) {
|
||||||
func(t *testing.T) { testCallContractWithBlockOverrides(t, client) },
|
func(t *testing.T) { testCallContractWithBlockOverrides(t, client) },
|
||||||
},
|
},
|
||||||
// The testaccesslist is a bit time-sensitive: the newTestBackend imports
|
// The testaccesslist is a bit time-sensitive: the newTestBackend imports
|
||||||
// one block. The `testAcessList` fails if the miner has not yet created a
|
// one block. The `testAccessList` fails if the miner has not yet created a
|
||||||
// new pending-block after the import event.
|
// new pending-block after the import event.
|
||||||
// Hence: this test should be last, execute the tests serially.
|
// Hence: this test should be last, execute the tests serially.
|
||||||
{
|
{
|
||||||
|
|
|
||||||
|
|
@ -21,7 +21,6 @@ import "github.com/urfave/cli/v2"
|
||||||
const (
|
const (
|
||||||
EthCategory = "ETHEREUM"
|
EthCategory = "ETHEREUM"
|
||||||
BeaconCategory = "BEACON CHAIN"
|
BeaconCategory = "BEACON CHAIN"
|
||||||
LightCategory = "LIGHT CLIENT"
|
|
||||||
DevCategory = "DEVELOPER CHAIN"
|
DevCategory = "DEVELOPER CHAIN"
|
||||||
StateCategory = "STATE HISTORY MANAGEMENT"
|
StateCategory = "STATE HISTORY MANAGEMENT"
|
||||||
TxPoolCategory = "TRANSACTION POOL (EVM)"
|
TxPoolCategory = "TRANSACTION POOL (EVM)"
|
||||||
|
|
|
||||||
|
|
@ -98,6 +98,10 @@ func LoggerWithHandler(t *testing.T, handler slog.Handler) log.Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *logger) Handler() slog.Handler {
|
||||||
|
return l.l.Handler()
|
||||||
|
}
|
||||||
|
|
||||||
func (l *logger) Write(level slog.Level, msg string, ctx ...interface{}) {}
|
func (l *logger) Write(level slog.Level, msg string, ctx ...interface{}) {}
|
||||||
|
|
||||||
func (l *logger) Enabled(ctx context.Context, level slog.Level) bool {
|
func (l *logger) Enabled(ctx context.Context, level slog.Level) bool {
|
||||||
|
|
|
||||||
|
|
@ -137,6 +137,9 @@ type Logger interface {
|
||||||
|
|
||||||
// Enabled reports whether l emits log records at the given context and level.
|
// Enabled reports whether l emits log records at the given context and level.
|
||||||
Enabled(ctx context.Context, level slog.Level) bool
|
Enabled(ctx context.Context, level slog.Level) bool
|
||||||
|
|
||||||
|
// Handler returns the underlying handler of the inner logger.
|
||||||
|
Handler() slog.Handler
|
||||||
}
|
}
|
||||||
|
|
||||||
type logger struct {
|
type logger struct {
|
||||||
|
|
@ -150,6 +153,10 @@ func NewLogger(h slog.Handler) Logger {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (l *logger) Handler() slog.Handler {
|
||||||
|
return l.inner.Handler()
|
||||||
|
}
|
||||||
|
|
||||||
// write logs a message at the specified level:
|
// write logs a message at the specified level:
|
||||||
func (l *logger) Write(level slog.Level, msg string, attrs ...any) {
|
func (l *logger) Write(level slog.Level, msg string, attrs ...any) {
|
||||||
if !l.inner.Enabled(context.Background(), level) {
|
if !l.inner.Enabled(context.Background(), level) {
|
||||||
|
|
|
||||||
|
|
@ -19,7 +19,7 @@ package metrics
|
||||||
// Config contains the configuration for the metric collection.
|
// Config contains the configuration for the metric collection.
|
||||||
type Config struct {
|
type Config struct {
|
||||||
Enabled bool `toml:",omitempty"`
|
Enabled bool `toml:",omitempty"`
|
||||||
EnabledExpensive bool `toml:",omitempty"`
|
EnabledExpensive bool `toml:"-"`
|
||||||
HTTP string `toml:",omitempty"`
|
HTTP string `toml:",omitempty"`
|
||||||
Port int `toml:",omitempty"`
|
Port int `toml:",omitempty"`
|
||||||
EnableInfluxDB bool `toml:",omitempty"`
|
EnableInfluxDB bool `toml:",omitempty"`
|
||||||
|
|
|
||||||
|
|
@ -98,20 +98,23 @@ func readMeter(namespace, name string, i interface{}) (string, map[string]interf
|
||||||
}
|
}
|
||||||
return measurement, fields
|
return measurement, fields
|
||||||
case metrics.ResettingTimer:
|
case metrics.ResettingTimer:
|
||||||
t := metric.Snapshot()
|
ms := metric.Snapshot()
|
||||||
if t.Count() == 0 {
|
if ms.Count() == 0 {
|
||||||
break
|
break
|
||||||
}
|
}
|
||||||
ps := t.Percentiles([]float64{0.50, 0.95, 0.99})
|
ps := ms.Percentiles([]float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999})
|
||||||
measurement := fmt.Sprintf("%s%s.span", namespace, name)
|
measurement := fmt.Sprintf("%s%s.timer", namespace, name)
|
||||||
fields := map[string]interface{}{
|
fields := map[string]interface{}{
|
||||||
"count": t.Count(),
|
"count": ms.Count(),
|
||||||
"max": t.Max(),
|
"max": ms.Max(),
|
||||||
"mean": t.Mean(),
|
"mean": ms.Mean(),
|
||||||
"min": t.Min(),
|
"min": ms.Min(),
|
||||||
"p50": int(ps[0]),
|
"p50": ps[0],
|
||||||
"p95": int(ps[1]),
|
"p75": ps[1],
|
||||||
"p99": int(ps[2]),
|
"p95": ps[2],
|
||||||
|
"p99": ps[3],
|
||||||
|
"p999": ps[4],
|
||||||
|
"p9999": ps[5],
|
||||||
}
|
}
|
||||||
return measurement, fields
|
return measurement, fields
|
||||||
}
|
}
|
||||||
|
|
|
||||||
2
metrics/influxdb/testdata/influxdbv1.want
vendored
2
metrics/influxdb/testdata/influxdbv1.want
vendored
|
|
@ -7,5 +7,5 @@ goth.test/gauge_float64.gauge value=34567.89 978307200000000000
|
||||||
goth.test/gauge_info.gauge value="{\"arch\":\"amd64\",\"commit\":\"7caa2d8163ae3132c1c2d6978c76610caee2d949\",\"os\":\"linux\",\"protocol_versions\":\"64 65 66\",\"version\":\"1.10.18-unstable\"}" 978307200000000000
|
goth.test/gauge_info.gauge value="{\"arch\":\"amd64\",\"commit\":\"7caa2d8163ae3132c1c2d6978c76610caee2d949\",\"os\":\"linux\",\"protocol_versions\":\"64 65 66\",\"version\":\"1.10.18-unstable\"}" 978307200000000000
|
||||||
goth.test/histogram.histogram count=3i,max=3i,mean=2,min=1i,p25=1,p50=2,p75=3,p95=3,p99=3,p999=3,p9999=3,stddev=0.816496580927726,variance=0.6666666666666666 978307200000000000
|
goth.test/histogram.histogram count=3i,max=3i,mean=2,min=1i,p25=1,p50=2,p75=3,p95=3,p99=3,p999=3,p9999=3,stddev=0.816496580927726,variance=0.6666666666666666 978307200000000000
|
||||||
goth.test/meter.meter count=0i,m1=0,m15=0,m5=0,mean=0 978307200000000000
|
goth.test/meter.meter count=0i,m1=0,m15=0,m5=0,mean=0 978307200000000000
|
||||||
goth.test/resetting_timer.span count=6i,max=120000000i,mean=30000000,min=10000000i,p50=12500000i,p95=120000000i,p99=120000000i 978307200000000000
|
goth.test/resetting_timer.timer count=6i,max=120000000i,mean=30000000,min=10000000i,p50=12500000,p75=40500000,p95=120000000,p99=120000000,p999=120000000,p9999=120000000 978307200000000000
|
||||||
goth.test/timer.timer count=6i,m1=0,m15=0,m5=0,max=120000000i,mean=38333333.333333336,meanrate=0,min=20000000i,p50=22500000,p75=48000000,p95=120000000,p99=120000000,p999=120000000,p9999=120000000,stddev=36545253.529775314,variance=1335555555555555.2 978307200000000000
|
goth.test/timer.timer count=6i,m1=0,m15=0,m5=0,max=120000000i,mean=38333333.333333336,meanrate=0,min=20000000i,p50=22500000,p75=48000000,p95=120000000,p99=120000000,p999=120000000,p9999=120000000,stddev=36545253.529775314,variance=1335555555555555.2 978307200000000000
|
||||||
|
|
|
||||||
2
metrics/influxdb/testdata/influxdbv2.want
vendored
2
metrics/influxdb/testdata/influxdbv2.want
vendored
|
|
@ -7,5 +7,5 @@ goth.test/gauge_float64.gauge value=34567.89 978307200000000000
|
||||||
goth.test/gauge_info.gauge value="{\"arch\":\"amd64\",\"commit\":\"7caa2d8163ae3132c1c2d6978c76610caee2d949\",\"os\":\"linux\",\"protocol_versions\":\"64 65 66\",\"version\":\"1.10.18-unstable\"}" 978307200000000000
|
goth.test/gauge_info.gauge value="{\"arch\":\"amd64\",\"commit\":\"7caa2d8163ae3132c1c2d6978c76610caee2d949\",\"os\":\"linux\",\"protocol_versions\":\"64 65 66\",\"version\":\"1.10.18-unstable\"}" 978307200000000000
|
||||||
goth.test/histogram.histogram count=3i,max=3i,mean=2,min=1i,p25=1,p50=2,p75=3,p95=3,p99=3,p999=3,p9999=3,stddev=0.816496580927726,variance=0.6666666666666666 978307200000000000
|
goth.test/histogram.histogram count=3i,max=3i,mean=2,min=1i,p25=1,p50=2,p75=3,p95=3,p99=3,p999=3,p9999=3,stddev=0.816496580927726,variance=0.6666666666666666 978307200000000000
|
||||||
goth.test/meter.meter count=0i,m1=0,m15=0,m5=0,mean=0 978307200000000000
|
goth.test/meter.meter count=0i,m1=0,m15=0,m5=0,mean=0 978307200000000000
|
||||||
goth.test/resetting_timer.span count=6i,max=120000000i,mean=30000000,min=10000000i,p50=12500000i,p95=120000000i,p99=120000000i 978307200000000000
|
goth.test/resetting_timer.timer count=6i,max=120000000i,mean=30000000,min=10000000i,p50=12500000,p75=40500000,p95=120000000,p99=120000000,p999=120000000,p9999=120000000 978307200000000000
|
||||||
goth.test/timer.timer count=6i,m1=0,m15=0,m5=0,max=120000000i,mean=38333333.333333336,meanrate=0,min=20000000i,p50=22500000,p75=48000000,p95=120000000,p99=120000000,p999=120000000,p9999=120000000,stddev=36545253.529775314,variance=1335555555555555.2 978307200000000000
|
goth.test/timer.timer count=6i,m1=0,m15=0,m5=0,max=120000000i,mean=38333333.333333336,meanrate=0,min=20000000i,p50=22500000,p75=48000000,p95=120000000,p99=120000000,p999=120000000,p9999=120000000,stddev=36545253.529775314,variance=1335555555555555.2 978307200000000000
|
||||||
|
|
|
||||||
|
|
@ -24,23 +24,12 @@ import (
|
||||||
// for less cluttered pprof profiles.
|
// for less cluttered pprof profiles.
|
||||||
var Enabled = false
|
var Enabled = false
|
||||||
|
|
||||||
// EnabledExpensive is a soft-flag meant for external packages to check if costly
|
|
||||||
// metrics gathering is allowed or not. The goal is to separate standard metrics
|
|
||||||
// for health monitoring and debug metrics that might impact runtime performance.
|
|
||||||
var EnabledExpensive = false
|
|
||||||
|
|
||||||
// enablerFlags is the CLI flag names to use to enable metrics collections.
|
// enablerFlags is the CLI flag names to use to enable metrics collections.
|
||||||
var enablerFlags = []string{"metrics"}
|
var enablerFlags = []string{"metrics"}
|
||||||
|
|
||||||
// enablerEnvVars is the env var names to use to enable metrics collections.
|
// enablerEnvVars is the env var names to use to enable metrics collections.
|
||||||
var enablerEnvVars = []string{"GETH_METRICS"}
|
var enablerEnvVars = []string{"GETH_METRICS"}
|
||||||
|
|
||||||
// expensiveEnablerFlags is the CLI flag names to use to enable metrics collections.
|
|
||||||
var expensiveEnablerFlags = []string{"metrics.expensive"}
|
|
||||||
|
|
||||||
// expensiveEnablerEnvVars is the env var names to use to enable metrics collections.
|
|
||||||
var expensiveEnablerEnvVars = []string{"GETH_METRICS_EXPENSIVE"}
|
|
||||||
|
|
||||||
// Init enables or disables the metrics system. Since we need this to run before
|
// Init enables or disables the metrics system. Since we need this to run before
|
||||||
// any other code gets to create meters and timers, we'll actually do an ugly hack
|
// any other code gets to create meters and timers, we'll actually do an ugly hack
|
||||||
// and peek into the command line args for the metrics flag.
|
// and peek into the command line args for the metrics flag.
|
||||||
|
|
@ -53,14 +42,6 @@ func init() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, enabler := range expensiveEnablerEnvVars {
|
|
||||||
if val, found := syscall.Getenv(enabler); found && !EnabledExpensive {
|
|
||||||
if enable, _ := strconv.ParseBool(val); enable { // ignore error, flag parser will choke on it later
|
|
||||||
log.Info("Enabling expensive metrics collection")
|
|
||||||
EnabledExpensive = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
for _, arg := range os.Args {
|
for _, arg := range os.Args {
|
||||||
flag := strings.TrimLeft(arg, "-")
|
flag := strings.TrimLeft(arg, "-")
|
||||||
|
|
||||||
|
|
@ -70,12 +51,6 @@ func init() {
|
||||||
Enabled = true
|
Enabled = true
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
for _, enabler := range expensiveEnablerFlags {
|
|
||||||
if !EnabledExpensive && flag == enabler {
|
|
||||||
log.Info("Enabling expensive metrics collection")
|
|
||||||
EnabledExpensive = true
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -125,12 +125,13 @@ func (c *collector) addResettingTimer(name string, m metrics.ResettingTimerSnaps
|
||||||
if m.Count() <= 0 {
|
if m.Count() <= 0 {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
ps := m.Percentiles([]float64{0.50, 0.95, 0.99})
|
pv := []float64{0.5, 0.75, 0.95, 0.99, 0.999, 0.9999}
|
||||||
|
ps := m.Percentiles(pv)
|
||||||
c.writeSummaryCounter(name, m.Count())
|
c.writeSummaryCounter(name, m.Count())
|
||||||
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
|
c.buff.WriteString(fmt.Sprintf(typeSummaryTpl, mutateKey(name)))
|
||||||
c.writeSummaryPercentile(name, "0.50", ps[0])
|
for i := range pv {
|
||||||
c.writeSummaryPercentile(name, "0.95", ps[1])
|
c.writeSummaryPercentile(name, strconv.FormatFloat(pv[i], 'f', -1, 64), ps[i])
|
||||||
c.writeSummaryPercentile(name, "0.99", ps[2])
|
}
|
||||||
c.buff.WriteRune('\n')
|
c.buff.WriteRune('\n')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
5
metrics/prometheus/testdata/prometheus.want
vendored
5
metrics/prometheus/testdata/prometheus.want
vendored
|
|
@ -53,9 +53,12 @@ test_meter 0
|
||||||
test_resetting_timer_count 6
|
test_resetting_timer_count 6
|
||||||
|
|
||||||
# TYPE test_resetting_timer summary
|
# TYPE test_resetting_timer summary
|
||||||
test_resetting_timer {quantile="0.50"} 1.25e+07
|
test_resetting_timer {quantile="0.5"} 1.25e+07
|
||||||
|
test_resetting_timer {quantile="0.75"} 4.05e+07
|
||||||
test_resetting_timer {quantile="0.95"} 1.2e+08
|
test_resetting_timer {quantile="0.95"} 1.2e+08
|
||||||
test_resetting_timer {quantile="0.99"} 1.2e+08
|
test_resetting_timer {quantile="0.99"} 1.2e+08
|
||||||
|
test_resetting_timer {quantile="0.999"} 1.2e+08
|
||||||
|
test_resetting_timer {quantile="0.9999"} 1.2e+08
|
||||||
|
|
||||||
# TYPE test_timer_count counter
|
# TYPE test_timer_count counter
|
||||||
test_timer_count 6
|
test_timer_count 6
|
||||||
|
|
|
||||||
|
|
@ -78,7 +78,7 @@ func TestTCPPipeBidirections(t *testing.T) {
|
||||||
}
|
}
|
||||||
|
|
||||||
if !bytes.Equal(expected, out) {
|
if !bytes.Equal(expected, out) {
|
||||||
t.Fatalf("expected %#v, got %#v", out, expected)
|
t.Fatalf("expected %#v, got %#v", expected, out)
|
||||||
} else {
|
} else {
|
||||||
msg := []byte(fmt.Sprintf("pong %02d", i))
|
msg := []byte(fmt.Sprintf("pong %02d", i))
|
||||||
if _, err := c2.Write(msg); err != nil {
|
if _, err := c2.Write(msg); err != nil {
|
||||||
|
|
@ -94,7 +94,7 @@ func TestTCPPipeBidirections(t *testing.T) {
|
||||||
t.Fatal(err)
|
t.Fatal(err)
|
||||||
}
|
}
|
||||||
if !bytes.Equal(expected, out) {
|
if !bytes.Equal(expected, out) {
|
||||||
t.Fatalf("expected %#v, got %#v", out, expected)
|
t.Fatalf("expected %#v, got %#v", expected, out)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -70,7 +70,7 @@ type BatchElem struct {
|
||||||
// discarded.
|
// discarded.
|
||||||
Result interface{}
|
Result interface{}
|
||||||
// Error is set if the server returns an error for this request, or if
|
// Error is set if the server returns an error for this request, or if
|
||||||
// unmarshaling into Result fails. It is not set for I/O errors.
|
// unmarshalling into Result fails. It is not set for I/O errors.
|
||||||
Error error
|
Error error
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue