Skip to content

Commit

Permalink
update some merge tag v1.101411.2 issues
Browse files Browse the repository at this point in the history
  • Loading branch information
Eduard-Voiculescu committed Nov 25, 2024
1 parent c834ace commit 687f186
Show file tree
Hide file tree
Showing 18 changed files with 540 additions and 1,059 deletions.
3 changes: 0 additions & 3 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -1923,9 +1923,6 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
// TODO(fjl): force-enable this in --dev mode
cfg.EnablePreimageRecording = ctx.Bool(VMEnableDebugFlag.Name)
}
if ctx.IsSet(CollectWitnessFlag.Name) {
cfg.EnableWitnessCollection = ctx.Bool(CollectWitnessFlag.Name)
}

if ctx.IsSet(RPCGlobalGasCapFlag.Name) {
cfg.RPCGasCap = ctx.Uint64(RPCGlobalGasCapFlag.Name)
Expand Down
24 changes: 0 additions & 24 deletions core/block_validator.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,10 +20,8 @@ import (
"errors"
"fmt"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/consensus"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/stateless"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie"
Expand Down Expand Up @@ -160,28 +158,6 @@ func (v *BlockValidator) ValidateState(block *types.Block, statedb *state.StateD
return nil
}

// ValidateWitness cross validates a block execution with stateless remote clients.
//
// Normally we'd distribute the block witness to remote cross validators, wait
// for them to respond and then merge the results. For now, however, it's only
// Geth, so do an internal stateless run.
func (v *BlockValidator) ValidateWitness(witness *stateless.Witness, receiptRoot common.Hash, stateRoot common.Hash) error {
// Run the cross client stateless execution
// TODO(karalabe): Self-stateless for now, swap with other clients
crossReceiptRoot, crossStateRoot, err := ExecuteStateless(v.config, witness)
if err != nil {
return fmt.Errorf("stateless execution failed: %v", err)
}
// Stateless cross execution suceeeded, validate the withheld computed fields
if crossReceiptRoot != receiptRoot {
return fmt.Errorf("cross validator receipt root mismatch (cross: %x local: %x)", crossReceiptRoot, receiptRoot)
}
if crossStateRoot != stateRoot {
return fmt.Errorf("cross validator state root mismatch (cross: %x local: %x)", crossStateRoot, stateRoot)
}
return nil
}

// CalcGasLimit computes the gas limit of the next block after parent. It aims
// to keep the baseline gas close to the provided target, and increase it towards
// the target if the baseline gas is lower.
Expand Down
33 changes: 0 additions & 33 deletions core/genesis.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,39 +221,6 @@ func getGenesisState(db ethdb.Database, blockhash common.Hash) (alloc types.Gene
return nil, nil
}

func getGenesisState(db ethdb.Database, blockhash common.Hash) (alloc types.GenesisAlloc, err error) {
blob := rawdb.ReadGenesisStateSpec(db, blockhash)
if len(blob) != 0 {
if err := alloc.UnmarshalJSON(blob); err != nil {
return nil, err
}

return alloc, nil
}

// Genesis allocation is missing and there are several possibilities:
// the node is legacy which doesn't persist the genesis allocation or
// the persisted allocation is just lost.
// - supported networks(mainnet, testnets), recover with defined allocations
// - private network, can't recover
var genesis *Genesis
switch blockhash {
case params.MainnetGenesisHash:
genesis = DefaultGenesisBlock()
case params.GoerliGenesisHash:
genesis = DefaultGoerliGenesisBlock()
case params.SepoliaGenesisHash:
genesis = DefaultSepoliaGenesisBlock()
case params.HoleskyGenesisHash:
genesis = DefaultHoleskyGenesisBlock()
}
if genesis != nil {
return genesis.Alloc, nil
}

return nil, nil
}

// field type overrides for gencodec
type genesisSpecMarshaling struct {
Nonce math.HexOrDecimal64
Expand Down
3 changes: 0 additions & 3 deletions core/state/database.go
Original file line number Diff line number Diff line change
Expand Up @@ -64,9 +64,6 @@ type Database interface {
// PointCache returns the cache holding points used in verkle tree key computation
PointCache() *utils.PointCache

// PointCache returns the cache holding points used in verkle tree key computation
PointCache() *utils.PointCache

// TrieDB returns the underlying trie database for managing trie nodes.
TrieDB() *triedb.Database

Expand Down
50 changes: 0 additions & 50 deletions core/state/journal.go
Original file line number Diff line number Diff line change
Expand Up @@ -332,14 +332,6 @@ func (ch selfDestructChange) copy() journalEntry {
}
}

func (ch selfDestructChange) copy() journalEntry {
return selfDestructChange{
account: ch.account,
prev: ch.prev,
prevbalance: new(uint256.Int).Set(ch.prevbalance),
}
}

var ripemd = common.HexToAddress("0000000000000000000000000000000000000003")

func (ch touchChange) revert(s *StateDB) {
Expand All @@ -355,12 +347,6 @@ func (ch touchChange) copy() journalEntry {
}
}

func (ch touchChange) copy() journalEntry {
return touchChange{
account: ch.account,
}
}

func (ch balanceChange) revert(s *StateDB) {
s.getStateObject(ch.account).setBalance(ch.prev)
}
Expand All @@ -376,13 +362,6 @@ func (ch balanceChange) copy() journalEntry {
}
}

func (ch balanceChange) copy() journalEntry {
return balanceChange{
account: ch.account,
prev: new(uint256.Int).Set(ch.prev),
}
}

func (ch nonceChange) revert(s *StateDB) {
s.getStateObject(ch.account).setNonce(ch.prev)
}
Expand All @@ -398,13 +377,6 @@ func (ch nonceChange) copy() journalEntry {
}
}

func (ch nonceChange) copy() journalEntry {
return nonceChange{
account: ch.account,
prev: ch.prev,
}
}

func (ch codeChange) revert(s *StateDB) {
s.getStateObject(ch.account).setCode(types.EmptyCodeHash, nil)
}
Expand All @@ -417,14 +389,6 @@ func (ch codeChange) copy() journalEntry {
return codeChange{account: ch.account}
}

func (ch codeChange) copy() journalEntry {
return codeChange{
account: ch.account,
prevhash: common.CopyBytes(ch.prevhash),
prevcode: common.CopyBytes(ch.prevcode),
}
}

func (ch storageChange) revert(s *StateDB) {
s.getStateObject(ch.account).setState(ch.key, ch.prevvalue, ch.origvalue)
}
Expand All @@ -441,14 +405,6 @@ func (ch storageChange) copy() journalEntry {
}
}

func (ch storageChange) copy() journalEntry {
return storageChange{
account: ch.account,
key: ch.key,
prevvalue: ch.prevvalue,
}
}

func (ch transientStorageChange) revert(s *StateDB) {
s.setTransientState(ch.account, ch.key, ch.prevalue)
}
Expand Down Expand Up @@ -499,12 +455,6 @@ func (ch addLogChange) copy() journalEntry {
}
}

func (ch addPreimageChange) copy() journalEntry {
return addPreimageChange{
hash: ch.hash,
}
}

func (ch accessListAddAccountChange) revert(s *StateDB) {
/*
One important invariant here, is that whenever a (addr, slot) is added, if the
Expand Down
3 changes: 2 additions & 1 deletion core/state/state_object.go
Original file line number Diff line number Diff line change
Expand Up @@ -554,9 +554,10 @@ func (s *stateObject) CodeSize() int {
}

func (s *stateObject) SetCode(codeHash common.Hash, code []byte) {
prevCode := s.Code()
s.db.journal.setCode(s.address)
if s.db.logger != nil && s.db.logger.OnCodeChange != nil {
s.db.logger.OnCodeChange(s.address, common.BytesToHash(s.CodeHash()), prevcode, codeHash, code)
s.db.logger.OnCodeChange(s.address, common.BytesToHash(s.CodeHash()), prevCode, codeHash, code)
}
s.setCode(codeHash, code)
}
Expand Down
27 changes: 0 additions & 27 deletions core/state/statedb.go
Original file line number Diff line number Diff line change
Expand Up @@ -41,35 +41,11 @@ import (
"github.com/ethereum/go-ethereum/trie/triestate"
"github.com/ethereum/go-ethereum/trie/utils"
"github.com/holiman/uint256"
"golang.org/x/sync/errgroup"
)

// TriesInMemory represents the number of layers that are kept in RAM.
const TriesInMemory = 128

type revision struct {
id int
journalIndex int
type mutationType int

const (
update mutationType = iota
deletion
)

type mutation struct {
typ mutationType
applied bool
}

func (m *mutation) copy() *mutation {
return &mutation{typ: m.typ, applied: m.applied}
}

func (m *mutation) isDelete() bool {
return m.typ == deletion
}

type mutationType int

const (
Expand Down Expand Up @@ -175,9 +151,6 @@ type StateDB struct {
SnapshotCommits time.Duration
TrieDBCommits time.Duration

// State witness if cross validation is needed
witness *stateless.Witness

AccountLoaded int // Number of accounts retrieved from the database during the state transition
AccountUpdated int // Number of accounts updated during the state transition
AccountDeleted int // Number of accounts deleted during the state transition
Expand Down
2 changes: 0 additions & 2 deletions core/state/statedb_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -918,8 +918,6 @@ func TestCommitCopy(t *testing.T) {
if val := copied.GetState(addr, skey1); val != sval1 {
t.Fatalf("unexpected storage slot: have %x", val)
}
if !errors.Is(copied.Error(), trie.ErrCommitted) {
t.Fatalf("unexpected state error, %v", copied.Error())
if val := copied.GetCommittedState(addr, skey1); val != sval1 {
t.Fatalf("unexpected storage slot: have %x", val)
}
Expand Down
74 changes: 0 additions & 74 deletions core/stateless/gen_encoding_json.go

This file was deleted.

36 changes: 0 additions & 36 deletions core/stateless/witness.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,13 @@
package stateless

import (
"bytes"
"errors"
"fmt"
"maps"
"slices"
"sync"

"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/rlp"
)

// HeaderReader is an interface to pull in headers in place of block hashes for
Expand Down Expand Up @@ -116,39 +113,6 @@ func (w *Witness) Copy() *Witness {
return cpy
}

// String prints a human-readable summary containing the total size of the
// witness and the sizes of the underlying components
func (w *Witness) String() string {
blob, _ := rlp.EncodeToBytes(w)
bytesTotal := len(blob)

blob, _ = rlp.EncodeToBytes(w.Block)
bytesBlock := len(blob)

bytesHeaders := 0
for _, header := range w.Headers {
blob, _ = rlp.EncodeToBytes(header)
bytesHeaders += len(blob)
}
bytesCodes := 0
for code := range w.Codes {
bytesCodes += len(code)
}
bytesState := 0
for node := range w.State {
bytesState += len(node)
}
buf := new(bytes.Buffer)

fmt.Fprintf(buf, "Witness #%d: %v\n", w.Block.Number(), common.StorageSize(bytesTotal))
fmt.Fprintf(buf, " block (%4d txs): %10v\n", len(w.Block.Transactions()), common.StorageSize(bytesBlock))
fmt.Fprintf(buf, "%4d headers: %10v\n", len(w.Headers), common.StorageSize(bytesHeaders))
fmt.Fprintf(buf, "%4d trie nodes: %10v\n", len(w.State), common.StorageSize(bytesState))
fmt.Fprintf(buf, "%4d codes: %10v\n", len(w.Codes), common.StorageSize(bytesCodes))

return buf.String()
}

// Root returns the pre-state root from the first header.
//
// Note, this method will panic in case of a bad witness (but RLP decoding will
Expand Down
Loading

0 comments on commit 687f186

Please sign in to comment.