mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-31 17:13:57 +00:00
Merge branch 'ethereum:master' into portal
This commit is contained in:
commit
bc7987bd91
8 changed files with 40 additions and 42 deletions
|
|
@ -272,8 +272,17 @@ func runCmd(ctx *cli.Context) error {
|
|||
output, leftOverGas, stats, err := timedExec(bench, execFunc)
|
||||
|
||||
if ctx.Bool(DumpFlag.Name) {
|
||||
statedb.Commit(genesisConfig.Number, true)
|
||||
fmt.Println(string(statedb.Dump(nil)))
|
||||
root, err := statedb.Commit(genesisConfig.Number, true)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to commit changes %v\n", err)
|
||||
return err
|
||||
}
|
||||
dumpdb, err := state.New(root, sdb, nil)
|
||||
if err != nil {
|
||||
fmt.Printf("Failed to open statedb %v\n", err)
|
||||
return err
|
||||
}
|
||||
fmt.Println(string(dumpdb.Dump(nil)))
|
||||
}
|
||||
|
||||
if ctx.Bool(DebugFlag.Name) {
|
||||
|
|
|
|||
|
|
@ -115,9 +115,7 @@ func (c *BasicLRU[K, V]) Peek(key K) (value V, ok bool) {
|
|||
// Purge empties the cache.
|
||||
func (c *BasicLRU[K, V]) Purge() {
|
||||
c.list.init()
|
||||
for k := range c.items {
|
||||
delete(c.items, k)
|
||||
}
|
||||
clear(c.items)
|
||||
}
|
||||
|
||||
// Remove drops an item from the cache. Returns true if the key was present in cache.
|
||||
|
|
|
|||
|
|
@ -17,6 +17,8 @@
|
|||
package state
|
||||
|
||||
import (
|
||||
"maps"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
)
|
||||
|
||||
|
|
@ -57,16 +59,10 @@ func newAccessList() *accessList {
|
|||
// Copy creates an independent copy of an accessList.
|
||||
func (a *accessList) Copy() *accessList {
|
||||
cp := newAccessList()
|
||||
for k, v := range a.addresses {
|
||||
cp.addresses[k] = v
|
||||
}
|
||||
cp.addresses = maps.Clone(a.addresses)
|
||||
cp.slots = make([]map[common.Hash]struct{}, len(a.slots))
|
||||
for i, slotMap := range a.slots {
|
||||
newSlotmap := make(map[common.Hash]struct{}, len(slotMap))
|
||||
for k := range slotMap {
|
||||
newSlotmap[k] = struct{}{}
|
||||
}
|
||||
cp.slots[i] = newSlotmap
|
||||
cp.slots[i] = maps.Clone(slotMap)
|
||||
}
|
||||
return cp
|
||||
}
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import (
|
|||
"bytes"
|
||||
"fmt"
|
||||
"io"
|
||||
"maps"
|
||||
"time"
|
||||
|
||||
"github.com/ethereum/go-ethereum/common"
|
||||
|
|
@ -47,11 +48,7 @@ func (s Storage) String() (str string) {
|
|||
}
|
||||
|
||||
func (s Storage) Copy() Storage {
|
||||
cpy := make(Storage, len(s))
|
||||
for key, value := range s {
|
||||
cpy[key] = value
|
||||
}
|
||||
return cpy
|
||||
return maps.Clone(s)
|
||||
}
|
||||
|
||||
// stateObject represents an Ethereum account which is being modified.
|
||||
|
|
|
|||
|
|
@ -19,6 +19,7 @@ package state
|
|||
|
||||
import (
|
||||
"fmt"
|
||||
"maps"
|
||||
"math/big"
|
||||
"slices"
|
||||
"sort"
|
||||
|
|
@ -750,9 +751,8 @@ func (s *StateDB) Copy() *StateDB {
|
|||
state.stateObjectsDirty[addr] = struct{}{}
|
||||
}
|
||||
// Deep copy the destruction markers.
|
||||
for addr, value := range s.stateObjectsDestruct {
|
||||
state.stateObjectsDestruct[addr] = value
|
||||
}
|
||||
state.stateObjectsDestruct = maps.Clone(s.stateObjectsDestruct)
|
||||
|
||||
// Deep copy the state changes made in the scope of block
|
||||
// along with their original values.
|
||||
state.accounts = copySet(s.accounts)
|
||||
|
|
@ -770,9 +770,7 @@ func (s *StateDB) Copy() *StateDB {
|
|||
state.logs[hash] = cpy
|
||||
}
|
||||
// Deep copy the preimages occurred in the scope of block
|
||||
for hash, preimage := range s.preimages {
|
||||
state.preimages[hash] = preimage
|
||||
}
|
||||
state.preimages = maps.Clone(s.preimages)
|
||||
// Do we need to copy the access list and transient storage?
|
||||
// In practice: No. At the start of a transaction, these two lists are empty.
|
||||
// In practice, we only ever copy state _between_ transactions/blocks, never
|
||||
|
|
|
|||
|
|
@ -20,6 +20,7 @@ import (
|
|||
"errors"
|
||||
"math/big"
|
||||
"math/rand"
|
||||
"slices"
|
||||
"testing"
|
||||
"time"
|
||||
|
||||
|
|
@ -1823,12 +1824,12 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
|
|||
continue
|
||||
}
|
||||
for _, hash := range hashes {
|
||||
if !containsHash(request.hashes, hash) {
|
||||
if !slices.Contains(request.hashes, hash) {
|
||||
t.Errorf("step %d, peer %s: hash %x missing from requests", i, peer, hash)
|
||||
}
|
||||
}
|
||||
for _, hash := range request.hashes {
|
||||
if !containsHash(hashes, hash) {
|
||||
if !slices.Contains(hashes, hash) {
|
||||
t.Errorf("step %d, peer %s: hash %x extra in requests", i, peer, hash)
|
||||
}
|
||||
}
|
||||
|
|
@ -1850,7 +1851,7 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
|
|||
for hash := range fetcher.fetching {
|
||||
var found bool
|
||||
for _, req := range fetcher.requests {
|
||||
if containsHash(req.hashes, hash) {
|
||||
if slices.Contains(req.hashes, hash) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
|
@ -1891,12 +1892,12 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
|
|||
continue
|
||||
}
|
||||
for _, hash := range hashes {
|
||||
if !containsHash(request.hashes, hash) {
|
||||
if !slices.Contains(request.hashes, hash) {
|
||||
t.Errorf("step %d, peer %s: hash %x missing from requests", i, peer, hash)
|
||||
}
|
||||
}
|
||||
for _, hash := range request.hashes {
|
||||
if !containsHash(hashes, hash) {
|
||||
if !slices.Contains(hashes, hash) {
|
||||
t.Errorf("step %d, peer %s: hash %x extra in requests", i, peer, hash)
|
||||
}
|
||||
}
|
||||
|
|
@ -1909,7 +1910,7 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
|
|||
for _, ann := range announces {
|
||||
var found bool
|
||||
for _, hs := range step.fetching {
|
||||
if containsHash(hs, ann.hash) {
|
||||
if slices.Contains(hs, ann.hash) {
|
||||
found = true
|
||||
break
|
||||
}
|
||||
|
|
@ -1925,7 +1926,7 @@ func testTransactionFetcher(t *testing.T, tt txFetcherTest) {
|
|||
}
|
||||
}
|
||||
for hash := range fetcher.announced {
|
||||
if !containsHash(queued, hash) {
|
||||
if !slices.Contains(queued, hash) {
|
||||
t.Errorf("step %d: hash %x extra in announced", i, hash)
|
||||
}
|
||||
}
|
||||
|
|
@ -1984,16 +1985,6 @@ func containsHashInAnnounces(slice []announce, hash common.Hash) bool {
|
|||
return false
|
||||
}
|
||||
|
||||
// containsHash returns whether a hash is contained within a hash slice.
|
||||
func containsHash(slice []common.Hash, hash common.Hash) bool {
|
||||
for _, have := range slice {
|
||||
if have == hash {
|
||||
return true
|
||||
}
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Tests that a transaction is forgotten after the timeout.
|
||||
func TestTransactionForgotten(t *testing.T) {
|
||||
fetcher := NewTxFetcher(
|
||||
|
|
|
|||
|
|
@ -37,7 +37,9 @@ const (
|
|||
)
|
||||
|
||||
var (
|
||||
activePeerGauge metrics.Gauge = metrics.NilGauge{}
|
||||
activePeerGauge metrics.Gauge = metrics.NilGauge{}
|
||||
activeInboundPeerGauge metrics.Gauge = metrics.NilGauge{}
|
||||
activeOutboundPeerGauge metrics.Gauge = metrics.NilGauge{}
|
||||
|
||||
ingressTrafficMeter = metrics.NewRegisteredMeter("p2p/ingress", nil)
|
||||
egressTrafficMeter = metrics.NewRegisteredMeter("p2p/egress", nil)
|
||||
|
|
@ -65,6 +67,8 @@ func init() {
|
|||
}
|
||||
|
||||
activePeerGauge = metrics.NewRegisteredGauge("p2p/peers", nil)
|
||||
activeInboundPeerGauge = metrics.NewRegisteredGauge("p2p/peers/inbound", nil)
|
||||
activeOutboundPeerGauge = metrics.NewRegisteredGauge("p2p/peers/outbound", nil)
|
||||
serveMeter = metrics.NewRegisteredMeter("p2p/serves", nil)
|
||||
serveSuccessMeter = metrics.NewRegisteredMeter("p2p/serves/success", nil)
|
||||
dialMeter = metrics.NewRegisteredMeter("p2p/dials", nil)
|
||||
|
|
|
|||
|
|
@ -771,8 +771,10 @@ running:
|
|||
if p.Inbound() {
|
||||
inboundCount++
|
||||
serveSuccessMeter.Mark(1)
|
||||
activeInboundPeerGauge.Inc(1)
|
||||
} else {
|
||||
dialSuccessMeter.Mark(1)
|
||||
activeOutboundPeerGauge.Inc(1)
|
||||
}
|
||||
activePeerGauge.Inc(1)
|
||||
}
|
||||
|
|
@ -786,6 +788,9 @@ running:
|
|||
srv.dialsched.peerRemoved(pd.rw)
|
||||
if pd.Inbound() {
|
||||
inboundCount--
|
||||
activeInboundPeerGauge.Dec(1)
|
||||
} else {
|
||||
activeOutboundPeerGauge.Dec(1)
|
||||
}
|
||||
activePeerGauge.Dec(1)
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in a new issue