Skip to content

Commit

Permalink
feat: support get withdrawal proof on pathdb
Browse files Browse the repository at this point in the history
  • Loading branch information
joeylichang committed Apr 10, 2024
1 parent d6fbbc7 commit f9eba05
Show file tree
Hide file tree
Showing 17 changed files with 1,095 additions and 60 deletions.
2 changes: 2 additions & 0 deletions cmd/geth/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,8 @@ var (
utils.TxLookupLimitFlag,
utils.TransactionHistoryFlag,
utils.StateHistoryFlag,
utils.ProposeBlockIntervalFlag,
utils.PathDBNodeBufferTypeFlag,
utils.LightServeFlag,
utils.LightIngressFlag,
utils.LightEgressFlag,
Expand Down
21 changes: 15 additions & 6 deletions cmd/utils/flags.go
Original file line number Diff line number Diff line change
Expand Up @@ -300,10 +300,16 @@ var (
Usage: "Scheme to use for storing ethereum state ('hash' or 'path')",
Category: flags.StateCategory,
}
PathDBSyncFlag = &cli.BoolFlag{
Name: "pathdb.sync",
Usage: "sync flush nodes cache to disk in path schema",
Value: false,
PathDBNodeBufferTypeFlag = &cli.StringFlag{
Name: "pathdb.nodebuffer",
Usage: "Type of trienodebuffer to cache trie nodes in disklayer('list', 'sync', or 'async')",
Value: "async",
Category: flags.StateCategory,
}
ProposeBlockIntervalFlag = &cli.Uint64Flag{
Name: "pathdb.proposeblock",
Usage: "keep the same with op-proposer propose block interval",
Value: pathdb.DefaultProposeBlockInterval,
Category: flags.StateCategory,
}
StateHistoryFlag = &cli.Uint64Flag{
Expand Down Expand Up @@ -1862,8 +1868,11 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
log.Warn("The flag --txlookuplimit is deprecated and will be removed, please use --history.transactions")
cfg.TransactionHistory = ctx.Uint64(TxLookupLimitFlag.Name)
}
if ctx.IsSet(PathDBSyncFlag.Name) {
cfg.PathSyncFlush = true
if ctx.IsSet(PathDBNodeBufferTypeFlag.Name) {
cfg.PathNodeBuffer = pathdb.GetNodeBufferType(ctx.String(PathDBNodeBufferTypeFlag.Name))
}
if ctx.IsSet(ProposeBlockIntervalFlag.Name) {
cfg.ProposeBlockInterval = ctx.Uint64(ProposeBlockIntervalFlag.Name)
}
if ctx.String(GCModeFlag.Name) == "archive" && cfg.TransactionHistory != 0 {
cfg.TransactionHistory = 0
Expand Down
35 changes: 18 additions & 17 deletions core/blockchain.go
Original file line number Diff line number Diff line change
Expand Up @@ -137,19 +137,19 @@ const (
// CacheConfig contains the configuration values for the trie database
// and state snapshot these are resident in a blockchain.
type CacheConfig struct {
TrieCleanLimit int // Memory allowance (MB) to use for caching trie nodes in memory
TrieCleanNoPrefetch bool // Whether to disable heuristic state prefetching for followup blocks
TrieDirtyLimit int // Memory limit (MB) at which to start flushing dirty trie nodes to disk
TrieDirtyDisabled bool // Whether to disable trie write caching and GC altogether (archive node)
TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk
SnapshotLimit int // Memory allowance (MB) to use for caching snapshot entries in memory
Preimages bool // Whether to store preimage of trie key to the disk
StateHistory uint64 // Number of blocks from head whose state histories are reserved.
StateScheme string // Scheme used to store ethereum states and merkle tree nodes on top
PathSyncFlush bool // Whether sync flush the trienodebuffer of pathdb to disk.

SnapshotNoBuild bool // Whether the background generation is allowed
SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it
TrieCleanLimit int // Memory allowance (MB) to use for caching trie nodes in memory
TrieCleanNoPrefetch bool // Whether to disable heuristic state prefetching for followup blocks
TrieDirtyLimit int // Memory limit (MB) at which to start flushing dirty trie nodes to disk
TrieDirtyDisabled bool // Whether to disable trie write caching and GC altogether (archive node)
TrieTimeLimit time.Duration // Time limit after which to flush the current in-memory trie to disk
SnapshotLimit int // Memory allowance (MB) to use for caching snapshot entries in memory
Preimages bool // Whether to store preimage of trie key to the disk
StateHistory uint64 // Number of blocks from head whose state histories are reserved.
StateScheme string // Scheme used to store ethereum states and merkle tree nodes on top
PathNodeBuffer pathdb.NodeBufferType // Type of trienodebuffer to cache trie nodes in disklayer
ProposeBlockInterval uint64 // Propose block to L1 block interval.
SnapshotNoBuild bool // Whether the background generation is allowed
SnapshotWait bool // Wait for snapshot construction on startup. TODO(karalabe): This is a dirty hack for testing, nuke it

TrieCommitInterval uint64 // Define a block height interval, commit trie every TrieCommitInterval block height.
}
Expand All @@ -164,10 +164,11 @@ func (c *CacheConfig) triedbConfig() *trie.Config {
}
if c.StateScheme == rawdb.PathScheme {
config.PathDB = &pathdb.Config{
SyncFlush: c.PathSyncFlush,
StateHistory: c.StateHistory,
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
DirtyCacheSize: c.TrieDirtyLimit * 1024 * 1024,
TrieNodeBufferType: c.PathNodeBuffer,
StateHistory: c.StateHistory,
CleanCacheSize: c.TrieCleanLimit * 1024 * 1024,
DirtyCacheSize: c.TrieDirtyLimit * 1024 * 1024,
ProposeBlockInterval: c.ProposeBlockInterval,
}
}
return config
Expand Down
23 changes: 12 additions & 11 deletions eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -196,17 +196,18 @@ func New(stack *node.Node, config *ethconfig.Config) (*Ethereum, error) {
EnablePreimageRecording: config.EnablePreimageRecording,
}
cacheConfig = &core.CacheConfig{
TrieCleanLimit: config.TrieCleanCache,
TrieCleanNoPrefetch: config.NoPrefetch,
TrieDirtyLimit: config.TrieDirtyCache,
TrieDirtyDisabled: config.NoPruning,
TrieTimeLimit: config.TrieTimeout,
SnapshotLimit: config.SnapshotCache,
Preimages: config.Preimages,
StateHistory: config.StateHistory,
StateScheme: scheme,
TrieCommitInterval: config.TrieCommitInterval,
PathSyncFlush: config.PathSyncFlush,
TrieCleanLimit: config.TrieCleanCache,
TrieCleanNoPrefetch: config.NoPrefetch,
TrieDirtyLimit: config.TrieDirtyCache,
TrieDirtyDisabled: config.NoPruning,
TrieTimeLimit: config.TrieTimeout,
SnapshotLimit: config.SnapshotCache,
Preimages: config.Preimages,
StateHistory: config.StateHistory,
StateScheme: scheme,
TrieCommitInterval: config.TrieCommitInterval,
PathNodeBuffer: config.PathNodeBuffer,
ProposeBlockInterval: config.ProposeBlockInterval,
}
)
// Override the chain config with provided settings.
Expand Down
6 changes: 4 additions & 2 deletions eth/ethconfig/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ import (
"github.com/ethereum/go-ethereum/ethdb"
"github.com/ethereum/go-ethereum/miner"
"github.com/ethereum/go-ethereum/params"
"github.com/ethereum/go-ethereum/trie/triedb/pathdb"
)

// FullNodeGPO contains default gasprice oracle settings for full node.
Expand Down Expand Up @@ -109,8 +110,9 @@ type Config struct {
// State scheme represents the scheme used to store ethereum states and trie
// nodes on top. It can be 'hash', 'path', or none which means use the scheme
// consistent with persistent state.
StateScheme string `toml:",omitempty"`
PathSyncFlush bool `toml:",omitempty"` // State scheme used to store ethereum state and merkle trie nodes on top
StateScheme string `toml:",omitempty"`
PathNodeBuffer pathdb.NodeBufferType `toml:",omitempty"` // Type of trienodebuffer to cache trie nodes in disklayer
ProposeBlockInterval uint64 `toml:",omitempty"` // Keep the same with op-proposer propose block interval

// RequiredBlocks is a set of block number -> hash mappings which must be in the
// canonical chain of all remote peers. Setting the option makes geth verify the
Expand Down
17 changes: 12 additions & 5 deletions eth/ethconfig/gen_config.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion go.mod
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
module github.com/ethereum/go-ethereum

go 1.20
go 1.21

//toolchain go1.22.0

require (
github.com/Azure/azure-sdk-for-go/sdk/storage/azblob v1.2.0
Expand Down
Loading

0 comments on commit f9eba05

Please sign in to comment.