mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-25 13:07:17 +00:00
Erigon22 - small fixes to reconstitution (#5076)
* Fix db issues * Fix * another fix * Another fix Co-authored-by: Alexey Sharp <alexeysharp@Alexeys-iMac.local>
This commit is contained in:
parent
8083aaa013
commit
2e50dc9543
@ -992,9 +992,12 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
return err
|
||||
}
|
||||
plainContractCollector.Close()
|
||||
if err = rwTx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
sentryControlServer, err := sentry.NewMultiClient(
|
||||
db,
|
||||
chainDb,
|
||||
"",
|
||||
chainConfig,
|
||||
common.Hash{},
|
||||
@ -1013,32 +1016,20 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
cfg.DeprecatedTxPool.Disable = true
|
||||
cfg.Dirs = datadir2.New(datadir)
|
||||
cfg.Snapshot = allSnapshots.Cfg()
|
||||
stagedSync, err := stages2.NewStagedSync(context.Background(), logger, db, p2p.Config{}, &cfg, sentryControlServer, &stagedsync.Notifications{}, nil, allSnapshots, nil, false /* exec22 */, nil)
|
||||
stagedSync, err := stages2.NewStagedSync(context.Background(), logger, chainDb, p2p.Config{}, &cfg, sentryControlServer, &stagedsync.Notifications{}, nil, allSnapshots, nil, false /* exec22 */, nil)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
defer func() {
|
||||
if rwTx != nil {
|
||||
rwTx.Rollback()
|
||||
}
|
||||
}()
|
||||
execStage, err := stagedSync.StageState(stages.Execution, rwTx, db)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = execStage.Update(rwTx, blockNum-1); err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
if err = rwTx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
if rwTx, err = chainDb.BeginRw(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
execStage, err := stagedSync.StageState(stages.Execution, rwTx, chainDb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = execStage.Update(rwTx, block); err != nil {
|
||||
return err
|
||||
}
|
||||
log.Info("Reconstitution complete", "duration", time.Since(startTime))
|
||||
log.Info("Computing hashed state")
|
||||
tmpDir := filepath.Join(datadir, "tmp")
|
||||
@ -1051,17 +1042,31 @@ func Recon(genesis *core.Genesis, logger log.Logger) error {
|
||||
if err = rwTx.ClearBucket(kv.ContractCode); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = stagedsync.PromoteHashedStateCleanly("recon", rwTx, stagedsync.StageHashStateCfg(db, tmpDir), ctx); err != nil {
|
||||
if err = stagedsync.PromoteHashedStateCleanly("recon", rwTx, stagedsync.StageHashStateCfg(chainDb, tmpDir), ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
hashStage, err := stagedSync.StageState(stages.HashState, rwTx, chainDb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = hashStage.Update(rwTx, block); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rwTx.Commit(); err != nil {
|
||||
return err
|
||||
}
|
||||
if rwTx, err = db.BeginRw(ctx); err != nil {
|
||||
if rwTx, err = chainDb.BeginRw(ctx); err != nil {
|
||||
return err
|
||||
}
|
||||
var rootHash common.Hash
|
||||
if rootHash, err = stagedsync.RegenerateIntermediateHashes("recon", rwTx, stagedsync.StageTrieCfg(db, false /* checkRoot */, false /* saveHashesToDB */, false /* badBlockHalt */, tmpDir, blockReader, nil /* HeaderDownload */), common.Hash{}, make(chan struct{}, 1)); err != nil {
|
||||
if rootHash, err = stagedsync.RegenerateIntermediateHashes("recon", rwTx, stagedsync.StageTrieCfg(chainDb, false /* checkRoot */, true /* saveHashesToDB */, false /* badBlockHalt */, tmpDir, blockReader, nil /* HeaderDownload */), common.Hash{}, make(chan struct{}, 1)); err != nil {
|
||||
return err
|
||||
}
|
||||
trieStage, err := stagedSync.StageState(stages.IntermediateHashes, rwTx, chainDb)
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
if err = trieStage.Update(rwTx, block); err != nil {
|
||||
return err
|
||||
}
|
||||
if err = rwTx.Commit(); err != nil {
|
||||
|
Loading…
Reference in New Issue
Block a user