Skip to content
This repository has been archived by the owner on Feb 18, 2025. It is now read-only.

release: v2.9.0 #642

Merged
merged 49 commits into from
Feb 17, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
49 commits
Select commit Hold shift + click to select a range
94dcded
core,trie,eth,cmd: rework preimage store (#533)
huyngopt1994 Aug 19, 2024
147fcbc
trie, les, tests, core: implement trie tracer: Trie tracer is an aux…
huyngopt1994 Aug 30, 2024
cbcaa05
all: introduce trie owner notion (#24750) (#553)
Francesco4203 Sep 4, 2024
01a0024
core, trie: rework trie commiter (#560)
huyngopt1994 Sep 6, 2024
9dd4b7b
all: rework genesis api (#567)
Francesco4203 Sep 10, 2024
8e8b26e
core, eth: port snap sync changes (#564)
Francesco4203 Sep 11, 2024
615fcb1
core/rawdb: the ancient store implementing is now exported in package…
huyngopt1994 Sep 13, 2024
075fa9c
cmd,core,ethdb,node: change ancient chain segments from root ancient …
huyngopt1994 Sep 13, 2024
cb379f6
all: move genesis init to blockchain (#570)
Francesco4203 Sep 16, 2024
5e7d6c0
core/rawdb,state: make db inspector for extending multiple ancient st…
huyngopt1994 Sep 18, 2024
6218548
rawdb,ethdb,eth: implement freezer tail deletion and use atomic refer…
huyngopt1994 Sep 19, 2024
75ce76b
core,eth,tests,trie: abstract node scheme, and contruct database (#578)
huyngopt1994 Sep 25, 2024
1df9207
cmd, core, eth, trie: track deleted nodes (#576)
Francesco4203 Sep 25, 2024
1e5bac7
all: prep for path-based trie storage (#582)
Francesco4203 Sep 26, 2024
924e0f5
trie: implement NodeBlob api for trie iterator (#584)
Francesco4203 Sep 26, 2024
2b5d2c6
trie: refactor tracer (#581)
Francesco4203 Sep 26, 2024
8afe19c
eth/protocols/snap: fix batch writer when resuming an aborted sync (#…
huyngopt1994 Sep 27, 2024
2b2463a
trie: rework trie database (#585)
Francesco4203 Sep 30, 2024
a91ae4b
trie: add trie db wrapper; refactor trienode (#588)
Francesco4203 Oct 1, 2024
092ea8b
trie, core: track state changes in statedb (#589)
Francesco4203 Oct 3, 2024
74e20ed
all: remove trie cache journal (#595)
huyngopt1994 Oct 4, 2024
d26fbc1
core, trie: Expose block number to statedb (#593)
Francesco4203 Oct 4, 2024
4b202dc
all: final implementing path base (#591)
huyngopt1994 Oct 10, 2024
7d62321
trie: remove nodes method and add diskdb method for consistency with …
Francesco4203 Oct 11, 2024
03f2ff7
all: reworkNodeResolver for working with multiple state schemes with …
huyngopt1994 Oct 15, 2024
cbd0ef4
trie: fix issue insert wrong path in stack trie and remove the offset…
huyngopt1994 Oct 17, 2024
a4cca8f
all: enable pbss (#600)
Francesco4203 Oct 18, 2024
cf8e29b
cmd,eth,docker,rawdb,v1/consortirum: fix missing passing scheme when …
huyngopt1994 Oct 25, 2024
68b863a
core, eth/downloader: pbss fix release v1.13.1 (#614)
Francesco4203 Oct 25, 2024
d83ad2a
rlp, trie: faster trie node encoding (#24126) (#606)
minh-bq Oct 29, 2024
007a729
core, accounts, eth, trie: pbss fix release v1.13.2 (#615)
Francesco4203 Oct 29, 2024
0771738
trie/triedb/pathdb, core/rawdb: pbss fix release v1.13.5 (corner-case…
Francesco4203 Oct 29, 2024
bf23827
cmd/ronin/chaincmd: open ancient freezer when init genesis (#620)
Francesco4203 Oct 30, 2024
27e7a5c
docker/chainnode: remove duplicate param in entrypoint.sh
huyngopt1994 Oct 31, 2024
147b946
consensus: get Validators from genesis instead of triedb in v1 consor…
huyngopt1994 Nov 1, 2024
b43ad9b
cmd,rawdb: avoid extend Tail method in chainfreezer which make db ins…
huyngopt1994 Nov 7, 2024
87a7f63
trie: pbss fix release v1.13.5 continue (#621)
Francesco4203 Nov 8, 2024
64983cd
core, triedb/pathdb: pbss fix release v1.13.8 (continue) and v1.14.0 …
Francesco4203 Nov 8, 2024
195c33f
protocols/snap/sync_test: each peer have a different account trie (#628)
Francesco4203 Nov 9, 2024
56f0f68
core, cmd, trie: pbss fix release v1.13.6 and v1.13.8 (#618)
Francesco4203 Nov 11, 2024
c92761d
v2/consortium_test: fix for pbss: do not insert inserted blocks (#613)
Francesco4203 Nov 14, 2024
54e2f20
eth: only enable accepting transactions after checking (#686)
minh-bq Feb 10, 2025
bfe9543
ci: remove event trigger unittest
huyngopt1994 Feb 17, 2025
463c49c
trie: using common.Hash{} instead of EmptyRootHash for trie.NewEmpty
NganSM Dec 18, 2024
0b2a442
p2p: filter out when requesting ENR for node is failed
huyngopt1994 Dec 19, 2024
78d651a
core/state: return error when storage trie can't be opened (#26350)
rjl493456442 Dec 21, 2022
cd172b4
handler: add check more check state for switching from snap sync to f…
huyngopt1994 Jan 2, 2025
3bfe838
core/rawdb: improve freezerTable.Sync (#26245)
fjl Nov 24, 2022
bc45109
core/rawdb: fix cornercase shutdown behaviour in freezer (#26485)
holiman Jan 16, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
20 changes: 11 additions & 9 deletions accounts/abi/bind/backends/simulated.go
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ import (
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/rpc"
"github.com/ethereum/go-ethereum/trie"
)

// This nil assignment ensures at compile time that SimulatedBackend implements bind.ContractBackend.
Expand Down Expand Up @@ -77,8 +78,8 @@ type SimulatedBackend struct {
// A simulated backend always uses chainID 1337.
func NewSimulatedBackendWithDatabase(database ethdb.Database, alloc core.GenesisAlloc, gasLimit uint64) *SimulatedBackend {
genesis := core.Genesis{Config: params.AllEthashProtocolChanges, GasLimit: gasLimit, Alloc: alloc}
genesis.MustCommit(database)
blockchain, _ := core.NewBlockChain(database, nil, genesis.Config, ethash.NewFaker(), vm.Config{}, nil, nil)
genesis.MustCommit(database, trie.NewDatabase(database, trie.HashDefaults))
blockchain, _ := core.NewBlockChain(database, nil, &genesis, nil, ethash.NewFaker(), vm.Config{}, nil, nil)

backend := &SimulatedBackend{
database: database,
Expand Down Expand Up @@ -180,7 +181,6 @@ func (b *SimulatedBackend) CodeAt(ctx context.Context, contract common.Address,
if err != nil {
return nil, err
}

return stateDB.GetCode(contract), nil
}

Expand All @@ -193,7 +193,6 @@ func (b *SimulatedBackend) BalanceAt(ctx context.Context, contract common.Addres
if err != nil {
return nil, err
}

return stateDB.GetBalance(contract), nil
}

Expand All @@ -206,7 +205,6 @@ func (b *SimulatedBackend) NonceAt(ctx context.Context, contract common.Address,
if err != nil {
return 0, err
}

return stateDB.GetNonce(contract), nil
}

Expand All @@ -219,7 +217,6 @@ func (b *SimulatedBackend) StorageAt(ctx context.Context, contract common.Addres
if err != nil {
return nil, err
}

val := stateDB.GetState(contract, key)
return val[:], nil
}
Expand Down Expand Up @@ -666,7 +663,10 @@ func (b *SimulatedBackend) SendTransaction(ctx context.Context, tx *types.Transa
}
block.AddTxWithChain(b.blockchain, tx)
}, true)
stateDB, _ := b.blockchain.State()
stateDB, err := b.blockchain.State()
if err != nil {
return err
}

b.pendingBlock = blocks[0]
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)
Expand Down Expand Up @@ -781,11 +781,13 @@ func (b *SimulatedBackend) AdjustTime(adjustment time.Duration) error {
blocks, _ := core.GenerateChain(b.config, b.blockchain.CurrentBlock(), ethash.NewFaker(), b.database, 1, func(number int, block *core.BlockGen) {
block.OffsetTime(int64(adjustment.Seconds()))
}, true)
stateDB, _ := b.blockchain.State()
stateDB, err := b.blockchain.State()
if err != nil {
return err
}

b.pendingBlock = blocks[0]
b.pendingState, _ = state.New(b.pendingBlock.Root(), stateDB.Database(), nil)

return nil
}

Expand Down
2 changes: 1 addition & 1 deletion cmd/devp2p/internal/ethtest/chain.go
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ func loadChain(chainfile string, genesis string) (*Chain, error) {
if err != nil {
return nil, err
}
gblock := gen.ToBlock(nil)
gblock := gen.ToBlock()

blocks, err := blocksFromFile(chainfile, gblock)
if err != nil {
Expand Down
3 changes: 1 addition & 2 deletions cmd/devp2p/internal/ethtest/suite_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -91,8 +91,6 @@ func setupGeth(stack *node.Node) error {
Genesis: &chain.genesis,
NetworkId: chain.genesis.Config.ChainID.Uint64(), // 19763
DatabaseCache: 10,
TrieCleanCache: 10,
TrieCleanCacheJournal: "",
TrieCleanCacheRejournal: 60 * time.Minute,
TrieDirtyCache: 16,
TrieTimeout: 60 * time.Minute,
Expand All @@ -101,6 +99,7 @@ func setupGeth(stack *node.Node) error {
if err != nil {
return err
}
backend.SetSynced()

_, err = backend.BlockChain().InsertChain(chain.blocks[1:], nil)
return err
Expand Down
12 changes: 9 additions & 3 deletions cmd/evm/internal/t8ntool/execution.go
Original file line number Diff line number Diff line change
Expand Up @@ -242,7 +242,7 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
statedb.AddBalance(pre.Env.Coinbase, minerReward)
}
// Commit block
root, err := statedb.Commit(chainConfig.IsEIP158(vmContext.BlockNumber))
root, err := statedb.Commit(vmContext.BlockNumber.Uint64(), chainConfig.IsEIP158(vmContext.BlockNumber))
if err != nil {
fmt.Fprintf(os.Stderr, "Could not commit state: %v", err)
return nil, nil, NewError(ErrorEVM, fmt.Errorf("could not commit state: %v", err))
Expand All @@ -258,11 +258,17 @@ func (pre *Prestate) Apply(vmConfig vm.Config, chainConfig *params.ChainConfig,
Difficulty: (*math.HexOrDecimal256)(vmContext.Difficulty),
GasUsed: (math.HexOrDecimal64)(gasUsed),
}
// Re-create statedb instance with new root upon the updated database
// for accessing latest states.
statedb, err = state.New(root, statedb.Database(), nil)
if err != nil {
return nil, nil, NewError(ErrorEVM, fmt.Errorf("could not reopen state: %v", err))
}
return statedb, execRs, nil
}

func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB {
sdb := state.NewDatabase(db)
sdb := state.NewDatabaseWithConfig(db, &trie.Config{Preimages: true})
statedb, _ := state.New(common.Hash{}, sdb, nil)
for addr, a := range accounts {
statedb.SetCode(addr, a.Code)
Expand All @@ -273,7 +279,7 @@ func MakePreState(db ethdb.Database, accounts core.GenesisAlloc) *state.StateDB
}
}
// Commit and re-open to start with a clean state.
root, _ := statedb.Commit(false)
root, _ := statedb.Commit(0, false)
statedb, _ = state.New(root, sdb, nil)
return statedb
}
Expand Down
27 changes: 21 additions & 6 deletions cmd/evm/runner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,6 @@ import (
"bytes"
"encoding/json"
"fmt"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/ethereum/go-ethereum/internal/flags"
"io/ioutil"
"math/big"
"os"
Expand All @@ -30,12 +28,18 @@ import (
"testing"
"time"

"github.com/ethereum/go-ethereum/eth/tracers/logger"
"github.com/ethereum/go-ethereum/internal/flags"
"github.com/ethereum/go-ethereum/trie"
"github.com/ethereum/go-ethereum/trie/triedb/hashdb"

"github.com/ethereum/go-ethereum/cmd/evm/internal/compiler"
"github.com/ethereum/go-ethereum/cmd/utils"
"github.com/ethereum/go-ethereum/common"
"github.com/ethereum/go-ethereum/core"
"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/types"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/core/vm/runtime"
"github.com/ethereum/go-ethereum/log"
Expand Down Expand Up @@ -138,11 +142,22 @@ func runCmd(ctx *cli.Context) error {
gen := readGenesis(ctx.String(GenesisFlag.Name))
genesisConfig = gen
db := rawdb.NewMemoryDatabase()
genesis := gen.ToBlock(db)
statedb, _ = state.New(genesis.Root(), state.NewDatabase(db), nil)
triedb := trie.NewDatabase(db, &trie.Config{
HashDB: hashdb.Defaults,
})
defer triedb.Close()
genesis := gen.MustCommit(db, triedb)
sdb := state.NewDatabaseWithNodeDB(db, triedb)
statedb, _ = state.New(genesis.Root(), sdb, nil)
chainConfig = gen.Config
} else {
statedb, _ = state.New(common.Hash{}, state.NewDatabase(rawdb.NewMemoryDatabase()), nil)
db := rawdb.NewMemoryDatabase()
triedb := trie.NewDatabase(db, &trie.Config{
HashDB: hashdb.Defaults,
})
defer triedb.Close()
sdb := state.NewDatabaseWithNodeDB(db, triedb)
statedb, _ = state.New(types.EmptyRootHash, sdb, nil)
genesisConfig = new(core.Genesis)
}
if ctx.String(SenderFlag.Name) != "" {
Expand Down Expand Up @@ -269,7 +284,7 @@ func runCmd(ctx *cli.Context) error {
output, leftOverGas, stats, err := timedExec(bench, execFunc)

if ctx.Bool(DumpFlag.Name) {
statedb.Commit(true)
statedb.Commit(0, true)
statedb.IntermediateRoot(true)
fmt.Println(string(statedb.Dump(nil)))
}
Expand Down
30 changes: 17 additions & 13 deletions cmd/evm/staterunner.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,14 @@ import (
"encoding/json"
"errors"
"fmt"
"github.com/ethereum/go-ethereum/eth/tracers/logger"
"io/ioutil"
"os"

"github.com/ethereum/go-ethereum/eth/tracers/logger"

"github.com/ethereum/go-ethereum/core/rawdb"
"github.com/ethereum/go-ethereum/core/state"
"github.com/ethereum/go-ethereum/core/state/snapshot"
"github.com/ethereum/go-ethereum/core/vm"
"github.com/ethereum/go-ethereum/log"
"github.com/ethereum/go-ethereum/tests"
Expand Down Expand Up @@ -96,21 +99,22 @@ func stateTestCmd(ctx *cli.Context) error {
results := make([]StatetestResult, 0, len(tests))
for key, test := range tests {
for _, st := range test.Subtests() {
dump := ctx.Bool(DumpFlag.Name)
// Run the test and aggregate the result
result := &StatetestResult{Name: key, Fork: st.Fork, Pass: true}
_, s, err := test.Run(st, cfg, false)
// print state root for evmlab tracing
if ctx.Bool(MachineFlag.Name) && s != nil {
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", s.IntermediateRoot(false))
}
if err != nil {
// Test failed, mark as so and dump any state to aid debugging
result.Pass, result.Error = false, err.Error()
if ctx.Bool(DumpFlag.Name) && s != nil {
dump := s.RawDump(nil)
result.State = &dump
test.Run(st, cfg, false, rawdb.HashScheme, func(err error, snaps *snapshot.Tree, state *state.StateDB) {
if err != nil {
// Test failed, mark as so and dump any state to aid debugging
result.Pass, result.Error = false, err.Error()
if dump {
dump := state.RawDump(nil)
result.State = &dump
}
}
}
if ctx.Bool(MachineFlag.Name) && state != nil {
fmt.Fprintf(os.Stderr, "{\"stateRoot\": \"%x\"}\n", state.IntermediateRoot(false))
}
})

results = append(results, *result)

Expand Down
2 changes: 1 addition & 1 deletion cmd/faucet/faucet.go
Original file line number Diff line number Diff line change
Expand Up @@ -251,7 +251,7 @@ func newFaucet(genesis *core.Genesis, port int, enodes []*enode.Node, network ui
cfg.SyncMode = downloader.LightSync
cfg.NetworkId = network
cfg.Genesis = genesis
utils.SetDNSDiscoveryDefaults(&cfg, genesis.ToBlock(nil).Hash())
utils.SetDNSDiscoveryDefaults(&cfg, genesis.ToBlock().Hash())

lesBackend, err := les.New(stack, &cfg)
if err != nil {
Expand Down
21 changes: 17 additions & 4 deletions cmd/ronin/chaincmd.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,9 @@ var (
utils.DataDirFlag,
utils.DBEngineFlag,
utils.ForceOverrideChainConfigFlag,
utils.CachePreimagesFlag,
utils.StateSchemeFlag,
utils.AncientFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down Expand Up @@ -106,6 +109,9 @@ The dumpgenesis command dumps the genesis block configuration in JSON format to
utils.MetricsInfluxDBBucketFlag,
utils.MetricsInfluxDBOrganizationFlag,
utils.TxLookupLimitFlag,
utils.TransactionHistoryFlag,
utils.StateSchemeFlag,
utils.StateHistoryFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand All @@ -125,6 +131,7 @@ processing will proceed even if an individual RLP-file import failure occurs.`,
utils.DBEngineFlag,
utils.CacheFlag,
utils.SyncModeFlag,
utils.StateSchemeFlag,
},
Category: "BLOCKCHAIN COMMANDS",
Description: `
Expand Down Expand Up @@ -221,15 +228,18 @@ func initGenesis(ctx *cli.Context) error {
defer stack.Close()

for _, name := range []string{"chaindata", "lightchaindata"} {
chaindb, err := stack.OpenDatabase(name, 0, 0, "", false)
chaindb, err := stack.OpenDatabaseWithFreezer(name, 0, 0, ctx.String(utils.AncientFlag.Name), "", false)
if err != nil {
utils.Fatalf("Failed to open database: %v", err)
}
_, hash, err := core.SetupGenesisBlock(chaindb, genesis, overrideChainConfig)
// Create triedb firstly

triedb := utils.MakeTrieDatabase(ctx, chaindb, ctx.Bool(utils.CachePreimagesFlag.Name), false)
defer chaindb.Close()
_, hash, err := core.SetupGenesisBlock(chaindb, triedb, genesis, overrideChainConfig)
if err != nil {
utils.Fatalf("Failed to write genesis block: %v", err)
}
chaindb.Close()
log.Info("Successfully wrote genesis state", "database", name, "hash", hash)
}
return nil
Expand Down Expand Up @@ -467,7 +477,10 @@ func dump(ctx *cli.Context) error {
if err != nil {
return err
}
state, err := state.New(root, state.NewDatabase(db), nil)
triedb := utils.MakeTrieDatabase(ctx, db, true, false) // always enable preimage lookup
defer triedb.Close()
state, err := state.New(root, state.NewDatabaseWithNodeDB(db, triedb), nil)

if err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions cmd/ronin/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -287,6 +287,10 @@ func deprecated(field string) bool {
return true
case "ethconfig.Config.EWASMInterpreter":
return true
case "ethconfig.Config.TrieCleanCacheJournal":
return true
case "ethconfig.Config.TrieCleanCacheRejournal":
return true
default:
return false
}
Expand Down
Loading