Skip to content

Commit 51519f6

Browse files
authored
Merge branch 'ethereum:master' into gethintegration
2 parents 59f0b61 + 88a7ef2 commit 51519f6

File tree

9 files changed

+97
-147
lines changed

9 files changed

+97
-147
lines changed

accounts/abi/abigen/testdata/v2/structs-abi.go.txt

Lines changed: 0 additions & 116 deletions
This file was deleted.

core/blockchain.go

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2543,14 +2543,22 @@ func (bc *BlockChain) reportBlock(block *types.Block, res *ProcessResult, err er
25432543
// logForkReadiness will write a log when a future fork is scheduled, but not
25442544
// active. This is useful so operators know their client is ready for the fork.
25452545
func (bc *BlockChain) logForkReadiness(block *types.Block) {
2546-
c := bc.Config()
2547-
current, last := c.LatestFork(block.Time()), c.LatestFork(math.MaxUint64)
2548-
t := c.Timestamp(last)
2549-
if t == nil {
2546+
config := bc.Config()
2547+
current, last := config.LatestFork(block.Time()), config.LatestFork(math.MaxUint64)
2548+
2549+
// Short circuit if the timestamp of the last fork is undefined,
2550+
// or if the network has already passed the last configured fork.
2551+
t := config.Timestamp(last)
2552+
if t == nil || current >= last {
25502553
return
25512554
}
25522555
at := time.Unix(int64(*t), 0)
2553-
if current < last && time.Now().After(bc.lastForkReadyAlert.Add(forkReadyInterval)) {
2556+
2557+
// Only log if:
2558+
// - Current time is before the fork activation time
2559+
// - Enough time has passed since last alert
2560+
now := time.Now()
2561+
if now.Before(at) && now.After(bc.lastForkReadyAlert.Add(forkReadyInterval)) {
25542562
log.Info("Ready for fork activation", "fork", last, "date", at.Format(time.RFC822),
25552563
"remaining", time.Until(at).Round(time.Second), "timestamp", at.Unix())
25562564
bc.lastForkReadyAlert = time.Now()

core/state/statedb.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -298,7 +298,7 @@ func (s *StateDB) SubRefund(gas uint64) {
298298
}
299299

300300
// Exist reports whether the given account address exists in the state.
301-
// Notably this also returns true for self-destructed accounts.
301+
// Notably this also returns true for self-destructed accounts within the current transaction.
302302
func (s *StateDB) Exist(addr common.Address) bool {
303303
return s.getStateObject(addr) != nil
304304
}

core/vm/interface.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,7 @@ type StateDB interface {
6969
SelfDestruct6780(common.Address) (uint256.Int, bool)
7070

7171
// Exist reports whether the given account exists in state.
72-
// Notably this should also return true for self-destructed accounts.
72+
// Notably this also returns true for self-destructed accounts within the current transaction.
7373
Exist(common.Address) bool
7474
// Empty returns whether the given account is empty. Empty
7575
// is defined according to EIP161 (balance = nonce = code = 0).

crypto/kzg4844/kzg4844_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ import (
2121
"testing"
2222

2323
"github.com/consensys/gnark-crypto/ecc/bls12-381/fr"
24-
gokzg4844 "github.com/crate-crypto/go-kzg-4844"
24+
gokzg4844 "github.com/crate-crypto/go-eth-kzg"
2525
)
2626

2727
func randFieldElement() [32]byte {

eth/state_accessor.go

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -217,7 +217,13 @@ func (eth *Ethereum) stateAtBlock(ctx context.Context, block *types.Block, reexe
217217
return eth.pathState(block)
218218
}
219219

220-
// stateAtTransaction returns the execution environment of a certain transaction.
220+
// stateAtTransaction returns the execution environment of a certain
221+
// transaction.
222+
//
223+
// Note: when a block is empty and the state for tx index 0 is requested, this
224+
// function will return the state of block after the pre-block operations have
225+
// been completed (e.g. updating system contracts), but before post-block
226+
// operations are completed (e.g. processing withdrawals).
221227
func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block, txIndex int, reexec uint64) (*types.Transaction, vm.BlockContext, *state.StateDB, tracers.StateReleaseFunc, error) {
222228
// Short circuit if it's genesis block.
223229
if block.NumberU64() == 0 {
@@ -245,7 +251,7 @@ func (eth *Ethereum) stateAtTransaction(ctx context.Context, block *types.Block,
245251
core.ProcessParentBlockHash(block.ParentHash(), evm)
246252
}
247253
if txIndex == 0 && len(block.Transactions()) == 0 {
248-
return nil, vm.BlockContext{}, statedb, release, nil
254+
return nil, context, statedb, release, nil
249255
}
250256
// Recompute transactions up to the target index.
251257
signer := types.MakeSigner(eth.blockchain.Config(), block.Number(), block.Time())

ethdb/pebble/pebble.go

Lines changed: 73 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"bytes"
2222
"fmt"
2323
"runtime"
24+
"strings"
2425
"sync"
2526
"sync/atomic"
2627
"time"
@@ -55,24 +56,35 @@ const (
5556
// Apart from basic data storage functionality it also supports batch writes and
5657
// iterating over the keyspace in binary-alphabetical order.
5758
type Database struct {
58-
fn string // filename for reporting
59-
db *pebble.DB // Underlying pebble storage engine
60-
61-
compTimeMeter *metrics.Meter // Meter for measuring the total time spent in database compaction
62-
compReadMeter *metrics.Meter // Meter for measuring the data read during compaction
63-
compWriteMeter *metrics.Meter // Meter for measuring the data written during compaction
64-
writeDelayNMeter *metrics.Meter // Meter for measuring the write delay number due to database compaction
65-
writeDelayMeter *metrics.Meter // Meter for measuring the write delay duration due to database compaction
66-
diskSizeGauge *metrics.Gauge // Gauge for tracking the size of all the levels in the database
67-
diskReadMeter *metrics.Meter // Meter for measuring the effective amount of data read
68-
diskWriteMeter *metrics.Meter // Meter for measuring the effective amount of data written
69-
memCompGauge *metrics.Gauge // Gauge for tracking the number of memory compaction
70-
level0CompGauge *metrics.Gauge // Gauge for tracking the number of table compaction in level0
71-
nonlevel0CompGauge *metrics.Gauge // Gauge for tracking the number of table compaction in non0 level
72-
seekCompGauge *metrics.Gauge // Gauge for tracking the number of table compaction caused by read opt
73-
manualMemAllocGauge *metrics.Gauge // Gauge for tracking amount of non-managed memory currently allocated
74-
75-
levelsGauge []*metrics.Gauge // Gauge for tracking the number of tables in levels
59+
fn string // filename for reporting
60+
db *pebble.DB // Underlying pebble storage engine
61+
namespace string // Namespace for metrics
62+
63+
compTimeMeter *metrics.Meter // Meter for measuring the total time spent in database compaction
64+
compReadMeter *metrics.Meter // Meter for measuring the data read during compaction
65+
compWriteMeter *metrics.Meter // Meter for measuring the data written during compaction
66+
writeDelayNMeter *metrics.Meter // Meter for measuring the write delay number due to database compaction
67+
writeDelayMeter *metrics.Meter // Meter for measuring the write delay duration due to database compaction
68+
diskSizeGauge *metrics.Gauge // Gauge for tracking the size of all the levels in the database
69+
diskReadMeter *metrics.Meter // Meter for measuring the effective amount of data read
70+
diskWriteMeter *metrics.Meter // Meter for measuring the effective amount of data written
71+
memCompGauge *metrics.Gauge // Gauge for tracking the number of memory compaction
72+
level0CompGauge *metrics.Gauge // Gauge for tracking the number of table compaction in level0
73+
nonlevel0CompGauge *metrics.Gauge // Gauge for tracking the number of table compaction in non0 level
74+
seekCompGauge *metrics.Gauge // Gauge for tracking the number of table compaction caused by read opt
75+
manualMemAllocGauge *metrics.Gauge // Gauge for tracking amount of non-managed memory currently allocated
76+
liveMemTablesGauge *metrics.Gauge // Gauge for tracking the number of live memory tables
77+
zombieMemTablesGauge *metrics.Gauge // Gauge for tracking the number of zombie memory tables
78+
blockCacheHitGauge *metrics.Gauge // Gauge for tracking the number of total hit in the block cache
79+
blockCacheMissGauge *metrics.Gauge // Gauge for tracking the number of total miss in the block cache
80+
tableCacheHitGauge *metrics.Gauge // Gauge for tracking the number of total hit in the table cache
81+
tableCacheMissGauge *metrics.Gauge // Gauge for tracking the number of total miss in the table cache
82+
filterHitGauge *metrics.Gauge // Gauge for tracking the number of total hit in bloom filter
83+
filterMissGauge *metrics.Gauge // Gauge for tracking the number of total miss in bloom filter
84+
estimatedCompDebtGauge *metrics.Gauge // Gauge for tracking the number of bytes that need to be compacted
85+
liveCompGauge *metrics.Gauge // Gauge for tracking the number of in-progress compactions
86+
liveCompSizeGauge *metrics.Gauge // Gauge for tracking the size of in-progress compactions
87+
levelsGauge []*metrics.Gauge // Gauge for tracking the number of tables in levels
7688

7789
quitLock sync.RWMutex // Mutex protecting the quit channel and the closed flag
7890
quitChan chan chan error // Quit channel to stop the metrics collection before closing the database
@@ -88,6 +100,7 @@ type Database struct {
88100

89101
writeStalled atomic.Bool // Flag whether the write is stalled
90102
writeDelayStartTime time.Time // The start time of the latest write stall
103+
writeDelayReason string // The reason of the latest write stall
91104
writeDelayCount atomic.Int64 // Total number of write stall counts
92105
writeDelayTime atomic.Int64 // Total time spent in write stalls
93106

@@ -120,11 +133,30 @@ func (d *Database) onWriteStallBegin(b pebble.WriteStallBeginInfo) {
120133
d.writeDelayStartTime = time.Now()
121134
d.writeDelayCount.Add(1)
122135
d.writeStalled.Store(true)
136+
137+
// Take just the first word of the reason. These are two potential
138+
// reasons for the write stall:
139+
// - memtable count limit reached
140+
// - L0 file count limit exceeded
141+
reason := b.Reason
142+
if i := strings.IndexByte(reason, ' '); i != -1 {
143+
reason = reason[:i]
144+
}
145+
if reason == "L0" || reason == "memtable" {
146+
d.writeDelayReason = reason
147+
metrics.GetOrRegisterGauge(d.namespace+"stall/count/"+reason, nil).Inc(1)
148+
}
123149
}
124150

125151
func (d *Database) onWriteStallEnd() {
126152
d.writeDelayTime.Add(int64(time.Since(d.writeDelayStartTime)))
127153
d.writeStalled.Store(false)
154+
155+
if d.writeDelayReason != "" {
156+
metrics.GetOrRegisterResettingTimer(d.namespace+"stall/time/"+d.writeDelayReason, nil).UpdateSince(d.writeDelayStartTime)
157+
d.writeDelayReason = ""
158+
}
159+
d.writeDelayStartTime = time.Time{}
128160
}
129161

130162
// panicLogger is just a noop logger to disable Pebble's internal logger.
@@ -270,6 +302,17 @@ func New(file string, cache int, handles int, namespace string, readonly bool) (
270302
db.nonlevel0CompGauge = metrics.GetOrRegisterGauge(namespace+"compact/nonlevel0", nil)
271303
db.seekCompGauge = metrics.GetOrRegisterGauge(namespace+"compact/seek", nil)
272304
db.manualMemAllocGauge = metrics.GetOrRegisterGauge(namespace+"memory/manualalloc", nil)
305+
db.liveMemTablesGauge = metrics.GetOrRegisterGauge(namespace+"table/live", nil)
306+
db.zombieMemTablesGauge = metrics.GetOrRegisterGauge(namespace+"table/zombie", nil)
307+
db.blockCacheHitGauge = metrics.GetOrRegisterGauge(namespace+"cache/block/hit", nil)
308+
db.blockCacheMissGauge = metrics.GetOrRegisterGauge(namespace+"cache/block/miss", nil)
309+
db.tableCacheHitGauge = metrics.GetOrRegisterGauge(namespace+"cache/table/hit", nil)
310+
db.tableCacheMissGauge = metrics.GetOrRegisterGauge(namespace+"cache/table/miss", nil)
311+
db.filterHitGauge = metrics.GetOrRegisterGauge(namespace+"filter/hit", nil)
312+
db.filterMissGauge = metrics.GetOrRegisterGauge(namespace+"filter/miss", nil)
313+
db.estimatedCompDebtGauge = metrics.GetOrRegisterGauge(namespace+"compact/estimateDebt", nil)
314+
db.liveCompGauge = metrics.GetOrRegisterGauge(namespace+"compact/live/count", nil)
315+
db.liveCompSizeGauge = metrics.GetOrRegisterGauge(namespace+"compact/live/size", nil)
273316

274317
// Start up the metrics gathering and return
275318
go db.meter(metricsGatheringInterval, namespace)
@@ -517,6 +560,18 @@ func (d *Database) meter(refresh time.Duration, namespace string) {
517560
d.nonlevel0CompGauge.Update(nonLevel0CompCount)
518561
d.level0CompGauge.Update(level0CompCount)
519562
d.seekCompGauge.Update(stats.Compact.ReadCount)
563+
d.liveCompGauge.Update(stats.Compact.NumInProgress)
564+
d.liveCompSizeGauge.Update(stats.Compact.InProgressBytes)
565+
566+
d.liveMemTablesGauge.Update(stats.MemTable.Count)
567+
d.zombieMemTablesGauge.Update(stats.MemTable.ZombieCount)
568+
d.estimatedCompDebtGauge.Update(int64(stats.Compact.EstimatedDebt))
569+
d.tableCacheHitGauge.Update(stats.TableCache.Hits)
570+
d.tableCacheMissGauge.Update(stats.TableCache.Misses)
571+
d.blockCacheHitGauge.Update(stats.BlockCache.Hits)
572+
d.blockCacheMissGauge.Update(stats.BlockCache.Misses)
573+
d.filterHitGauge.Update(stats.Filter.Hits)
574+
d.filterMissGauge.Update(stats.Filter.Misses)
520575

521576
for i, level := range stats.Levels {
522577
// Append metrics for additional layers

go.mod

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@ require (
1616
github.com/consensys/gnark-crypto v0.16.0
1717
github.com/crate-crypto/go-eth-kzg v1.3.0
1818
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a
19-
github.com/crate-crypto/go-kzg-4844 v1.1.0
2019
github.com/davecgh/go-spew v1.1.1
2120
github.com/deckarep/golang-set/v2 v2.6.0
2221
github.com/decred/dcrd/dcrec/secp256k1/v4 v4.0.1

go.sum

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,8 +84,6 @@ github.com/crate-crypto/go-eth-kzg v1.3.0 h1:05GrhASN9kDAidaFJOda6A4BEvgvuXbazXg
8484
github.com/crate-crypto/go-eth-kzg v1.3.0/go.mod h1:J9/u5sWfznSObptgfa92Jq8rTswn6ahQWEuiLHOjCUI=
8585
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a h1:W8mUrRp6NOVl3J+MYp5kPMoUZPp7aOYHtaua31lwRHg=
8686
github.com/crate-crypto/go-ipa v0.0.0-20240724233137-53bbb0ceb27a/go.mod h1:sTwzHBvIzm2RfVCGNEBZgRyjwK40bVoun3ZnGOCafNM=
87-
github.com/crate-crypto/go-kzg-4844 v1.1.0 h1:EN/u9k2TF6OWSHrCCDBBU6GLNMq88OspHHlMnHfoyU4=
88-
github.com/crate-crypto/go-kzg-4844 v1.1.0/go.mod h1:JolLjpSff1tCCJKaJx4psrlEdlXuJEC996PL3tTAFks=
8987
github.com/creack/pty v1.1.9/go.mod h1:oKZEueFk5CKHvIhNR5MUki03XCEU+Q6VDXinZuGJ33E=
9088
github.com/cyberdelia/templates v0.0.0-20141128023046-ca7fffd4298c/go.mod h1:GyV+0YP4qX0UQ7r2MoYZ+AvYDp12OF5yg4q8rGnyNh4=
9189
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=

0 commit comments

Comments
 (0)