mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-08 20:11:21 +00:00
Downloader flag
This commit is contained in:
parent
fae6fe0775
commit
14b45ea50b
@ -109,6 +109,7 @@ var (
|
||||
utils.CacheTrieFlag,
|
||||
utils.CacheGCFlag,
|
||||
utils.TrieCacheGenFlag,
|
||||
utils.DownloaderFlag,
|
||||
utils.NoHistory,
|
||||
utils.ArchiveSyncInterval,
|
||||
utils.ListenPortFlag,
|
||||
|
@ -87,6 +87,7 @@ var AppHelpFlagGroups = []flagGroup{
|
||||
utils.IdentityFlag,
|
||||
utils.LightKDFFlag,
|
||||
utils.WhitelistFlag,
|
||||
utils.DownloaderFlag,
|
||||
utils.NoHistory,
|
||||
utils.ArchiveSyncInterval,
|
||||
},
|
||||
|
@ -297,6 +297,10 @@ var (
|
||||
Name: "ulc.onlyannounce",
|
||||
Usage: "Ultra light server sends announcements only",
|
||||
}
|
||||
DownloaderFlag = cli.BoolFlag{
|
||||
Name: "downloader",
|
||||
Usage: "Run in downloader mode - only fetch blocks but not process them",
|
||||
}
|
||||
// Dashboard settings
|
||||
DashboardEnabledFlag = cli.BoolFlag{
|
||||
Name: "dashboard",
|
||||
@ -1468,6 +1472,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *eth.Config) {
|
||||
cfg.BlocksToPrune = ctx.GlobalUint64(GCModeBlockToPruneFlag.Name)
|
||||
cfg.PruningTimeout = ctx.GlobalDuration(GCModeTickTimeout.Name)
|
||||
|
||||
cfg.DownloadOnly = ctx.GlobalBoolT(DownloaderFlag.Name)
|
||||
cfg.NoHistory = ctx.GlobalBoolT(NoHistory.Name)
|
||||
cfg.ArchiveSyncInterval = ctx.GlobalInt(ArchiveSyncInterval.Name)
|
||||
|
||||
|
@ -124,6 +124,7 @@ type CacheConfig struct {
|
||||
BlocksToPrune uint64
|
||||
PruneTimeout time.Duration
|
||||
ArchiveSyncInterval uint64
|
||||
DownloadOnly bool
|
||||
NoHistory bool
|
||||
}
|
||||
|
||||
@ -205,6 +206,7 @@ func NewBlockChain(db ethdb.Database, cacheConfig *CacheConfig, chainConfig *par
|
||||
TrieCleanLimit: 256,
|
||||
TrieDirtyLimit: 256,
|
||||
TrieTimeLimit: 5 * time.Minute,
|
||||
DownloadOnly: false,
|
||||
NoHistory: false,
|
||||
}
|
||||
}
|
||||
@ -1243,7 +1245,7 @@ func (bc *BlockChain) WriteBlockWithState(block *types.Block, receipts []*types.
|
||||
|
||||
// writeBlockWithState writes the block and all associated state to the database,
|
||||
// but is expects the chain mutex to be held.
|
||||
func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.Receipt, state *state.IntraBlockState, tds *state.TrieDbState) (status WriteStatus, err error) {
|
||||
func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.Receipt, stateDb *state.IntraBlockState, tds *state.TrieDbState) (status WriteStatus, err error) {
|
||||
bc.wg.Add(1)
|
||||
defer bc.wg.Done()
|
||||
|
||||
@ -1264,13 +1266,17 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||
}
|
||||
rawdb.WriteBlock(bc.db, block)
|
||||
|
||||
if tds != nil {
|
||||
tds.SetBlockNr(block.NumberU64())
|
||||
}
|
||||
|
||||
ctx := bc.WithContext(context.Background(), block.Number())
|
||||
if err := state.CommitBlock(ctx, tds.DbStateWriter()); err != nil {
|
||||
if stateDb != nil {
|
||||
if err := stateDb.CommitBlock(ctx, tds.DbStateWriter()); err != nil {
|
||||
return NonStatTy, err
|
||||
}
|
||||
if bc.enableReceipts {
|
||||
}
|
||||
if bc.enableReceipts && !bc.cacheConfig.DownloadOnly {
|
||||
rawdb.WriteReceipts(bc.db, block.Hash(), block.NumberU64(), receipts)
|
||||
}
|
||||
|
||||
@ -1300,8 +1306,12 @@ func (bc *BlockChain) writeBlockWithState(block *types.Block, receipts []*types.
|
||||
}
|
||||
}
|
||||
// Write the positional metadata for transaction/receipt lookups and preimages
|
||||
if !bc.cacheConfig.DownloadOnly {
|
||||
rawdb.WriteTxLookupEntries(bc.db, block)
|
||||
rawdb.WritePreimages(bc.db, state.Preimages())
|
||||
}
|
||||
if stateDb != nil {
|
||||
rawdb.WritePreimages(bc.db, stateDb.Preimages())
|
||||
}
|
||||
|
||||
status = CanonStatTy
|
||||
//} else {
|
||||
@ -1547,17 +1557,19 @@ func (bc *BlockChain) insertChain(ctx context.Context, chain types.Blocks, verif
|
||||
}
|
||||
readBlockNr := parentNumber
|
||||
var root common.Hash
|
||||
if bc.trieDbState == nil {
|
||||
if bc.trieDbState == nil && !bc.cacheConfig.DownloadOnly {
|
||||
if _, err = bc.GetTrieDbState(); err != nil {
|
||||
return k, events, coalescedLogs, err
|
||||
}
|
||||
}
|
||||
if !bc.cacheConfig.DownloadOnly {
|
||||
root = bc.trieDbState.LastRoot()
|
||||
}
|
||||
var parentRoot common.Hash
|
||||
if parent != nil {
|
||||
parentRoot = parent.Root()
|
||||
}
|
||||
if parent != nil && root != parentRoot {
|
||||
if parent != nil && root != parentRoot && !bc.cacheConfig.DownloadOnly {
|
||||
log.Info("Rewinding from", "block", bc.CurrentBlock().NumberU64(), "to block", readBlockNr)
|
||||
if _, err = bc.db.Commit(); err != nil {
|
||||
log.Error("Could not commit chainDb before rewinding", "error", err)
|
||||
@ -1591,10 +1603,15 @@ func (bc *BlockChain) insertChain(ctx context.Context, chain types.Blocks, verif
|
||||
return 0, events, coalescedLogs, err
|
||||
}
|
||||
}
|
||||
stateDB := state.New(bc.trieDbState)
|
||||
var stateDB *state.IntraBlockState
|
||||
var receipts types.Receipts
|
||||
var logs []*types.Log
|
||||
var usedGas uint64
|
||||
if !bc.cacheConfig.DownloadOnly {
|
||||
stateDB = state.New(bc.trieDbState)
|
||||
// Process block using the parent state as reference point.
|
||||
//t0 := time.Now()
|
||||
receipts, logs, usedGas, err := bc.processor.Process(block, stateDB, bc.trieDbState, bc.vmConfig)
|
||||
receipts, logs, usedGas, err = bc.processor.Process(block, stateDB, bc.trieDbState, bc.vmConfig)
|
||||
//t1 := time.Now()
|
||||
if err != nil {
|
||||
bc.db.Rollback()
|
||||
@ -1624,6 +1641,7 @@ func (bc *BlockChain) insertChain(ctx context.Context, chain types.Blocks, verif
|
||||
bc.reportBlock(block, receipts, err)
|
||||
return k, events, coalescedLogs, err
|
||||
}
|
||||
}
|
||||
proctime := time.Since(start)
|
||||
|
||||
// Update the metrics touched during block validation
|
||||
@ -1693,7 +1711,9 @@ func (bc *BlockChain) insertChain(ctx context.Context, chain types.Blocks, verif
|
||||
bc.trieDbState = nil
|
||||
return 0, events, coalescedLogs, err
|
||||
}
|
||||
if bc.trieDbState != nil {
|
||||
bc.trieDbState.PruneTries(false)
|
||||
}
|
||||
log.Info("Database", "size", bc.db.Size(), "written", written)
|
||||
}
|
||||
}
|
||||
|
@ -186,6 +186,7 @@ func New(ctx *node.ServiceContext, config *Config) (*Ethereum, error) {
|
||||
TrieDirtyLimit: config.TrieDirtyCache,
|
||||
TrieCleanNoPrefetch: config.NoPrefetch,
|
||||
TrieTimeLimit: config.TrieTimeout,
|
||||
DownloadOnly: config.DownloadOnly,
|
||||
NoHistory: config.NoHistory,
|
||||
ArchiveSyncInterval: uint64(config.ArchiveSyncInterval),
|
||||
}
|
||||
|
@ -99,6 +99,9 @@ type Config struct {
|
||||
NoPrefetch bool // Whether to disable prefetching and only load state on demand
|
||||
|
||||
NoHistory bool
|
||||
// DownloadOnly is set when the node does not need to process the blocks, but simply
|
||||
// download them
|
||||
DownloadOnly bool
|
||||
ArchiveSyncInterval int
|
||||
BlocksBeforePruning uint64
|
||||
BlocksToPrune uint64
|
||||
|
Loading…
Reference in New Issue
Block a user