mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 03:30:37 +00:00
tmpdb: move to tmpdir (#8003)
This commit is contained in:
parent
e377cea51d
commit
c464d84334
@ -74,10 +74,10 @@ func IncrementVerkleTree(cfg optionsCfg, logger log.Logger) error {
|
||||
}
|
||||
verkleWriter := verkletrie.NewVerkleTreeWriter(vTx, cfg.tmpdir, logger)
|
||||
defer verkleWriter.Close()
|
||||
if err := verkletrie.IncrementAccount(vTx, tx, uint64(cfg.workersCount), verkleWriter, from, to); err != nil {
|
||||
if err := verkletrie.IncrementAccount(vTx, tx, uint64(cfg.workersCount), verkleWriter, from, to, cfg.tmpdir); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err := verkletrie.IncrementStorage(vTx, tx, uint64(cfg.workersCount), verkleWriter, from, to); err != nil {
|
||||
if _, err := verkletrie.IncrementStorage(vTx, tx, uint64(cfg.workersCount), verkleWriter, from, to, cfg.tmpdir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := stages.SaveStageProgress(vTx, stages.VerkleTrie, to); err != nil {
|
||||
|
@ -16,7 +16,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/core/types/accounts"
|
||||
)
|
||||
|
||||
func IncrementAccount(vTx kv.RwTx, tx kv.Tx, workers uint64, verkleWriter *VerkleTreeWriter, from, to uint64) error {
|
||||
func IncrementAccount(vTx kv.RwTx, tx kv.Tx, workers uint64, verkleWriter *VerkleTreeWriter, from, to uint64, tmpdir string) error {
|
||||
logInterval := time.NewTicker(30 * time.Second)
|
||||
logPrefix := "IncrementVerkleAccount"
|
||||
|
||||
@ -59,7 +59,7 @@ func IncrementAccount(vTx kv.RwTx, tx kv.Tx, workers uint64, verkleWriter *Verkl
|
||||
}
|
||||
}
|
||||
}()
|
||||
marker := NewVerkleMarker()
|
||||
marker := NewVerkleMarker(tmpdir)
|
||||
defer marker.Rollback()
|
||||
|
||||
for k, v, err := accountCursor.Seek(hexutility.EncodeTs(from)); k != nil; k, v, err = accountCursor.Next() {
|
||||
|
@ -17,7 +17,7 @@ import (
|
||||
"github.com/ledgerwatch/erigon/core/rawdb"
|
||||
)
|
||||
|
||||
func IncrementStorage(vTx kv.RwTx, tx kv.Tx, workers uint64, verkleWriter *VerkleTreeWriter, from, to uint64) (libcommon.Hash, error) {
|
||||
func IncrementStorage(vTx kv.RwTx, tx kv.Tx, workers uint64, verkleWriter *VerkleTreeWriter, from, to uint64, tmpdir string) (libcommon.Hash, error) {
|
||||
logInterval := time.NewTicker(30 * time.Second)
|
||||
logPrefix := "IncrementVerkleStorage"
|
||||
|
||||
@ -50,7 +50,7 @@ func IncrementStorage(vTx kv.RwTx, tx kv.Tx, workers uint64, verkleWriter *Verkl
|
||||
}
|
||||
}
|
||||
}()
|
||||
marker := NewVerkleMarker()
|
||||
marker := NewVerkleMarker(tmpdir)
|
||||
defer marker.Rollback()
|
||||
|
||||
for k, v, err := storageCursor.Seek(hexutility.EncodeTs(from)); k != nil; k, v, err = storageCursor.Next() {
|
||||
|
@ -13,8 +13,8 @@ type VerkleMarker struct {
|
||||
}
|
||||
|
||||
//nolint:gocritic
|
||||
func NewVerkleMarker() *VerkleMarker {
|
||||
markedSlotsDb, err := mdbx.NewTemporaryMdbx()
|
||||
func NewVerkleMarker(tempdir string) *VerkleMarker {
|
||||
markedSlotsDb, err := mdbx.NewTemporaryMdbx(tempdir)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
|
@ -32,11 +32,11 @@ func SpawnVerkleTrie(s *StageState, u Unwinder, tx kv.RwTx, cfg TrieCfg, ctx con
|
||||
return libcommon.Hash{}, err
|
||||
}
|
||||
verkleWriter := verkletrie.NewVerkleTreeWriter(tx, cfg.tmpDir, logger)
|
||||
if err := verkletrie.IncrementAccount(tx, tx, 10, verkleWriter, from, to); err != nil {
|
||||
if err := verkletrie.IncrementAccount(tx, tx, 10, verkleWriter, from, to, cfg.tmpDir); err != nil {
|
||||
return libcommon.Hash{}, err
|
||||
}
|
||||
var newRoot libcommon.Hash
|
||||
if newRoot, err = verkletrie.IncrementStorage(tx, tx, 10, verkleWriter, from, to); err != nil {
|
||||
if newRoot, err = verkletrie.IncrementStorage(tx, tx, 10, verkleWriter, from, to, cfg.tmpDir); err != nil {
|
||||
return libcommon.Hash{}, err
|
||||
}
|
||||
if cfg.checkRoot {
|
||||
@ -72,10 +72,10 @@ func UnwindVerkleTrie(u *UnwindState, s *StageState, tx kv.RwTx, cfg TrieCfg, ct
|
||||
return err
|
||||
}
|
||||
verkleWriter := verkletrie.NewVerkleTreeWriter(tx, cfg.tmpDir, logger)
|
||||
if err := verkletrie.IncrementAccount(tx, tx, 10, verkleWriter, from, to); err != nil {
|
||||
if err := verkletrie.IncrementAccount(tx, tx, 10, verkleWriter, from, to, cfg.tmpDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if _, err = verkletrie.IncrementStorage(tx, tx, 10, verkleWriter, from, to); err != nil {
|
||||
if _, err = verkletrie.IncrementStorage(tx, tx, 10, verkleWriter, from, to, cfg.tmpDir); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Update(tx, from); err != nil {
|
||||
|
2
go.mod
2
go.mod
@ -3,7 +3,7 @@ module github.com/ledgerwatch/erigon
|
||||
go 1.19
|
||||
|
||||
require (
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230811055104-e22b2e3ec100
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230811190401-0b81275ff736
|
||||
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230810173239-feb52fae58d9
|
||||
github.com/ledgerwatch/log/v3 v3.8.0
|
||||
github.com/ledgerwatch/secp256k1 v1.0.0
|
||||
|
4
go.sum
4
go.sum
@ -497,8 +497,8 @@ github.com/kr/text v0.2.0/go.mod h1:eLer722TekiGuMkidMxC/pM04lWEeraHUUmBw8l2grE=
|
||||
github.com/kylelemons/godebug v0.0.0-20170224010052-a616ab194758 h1:0D5M2HQSGD3PYPwICLl+/9oulQauOuETfgFvhBDffs0=
|
||||
github.com/leanovate/gopter v0.2.9 h1:fQjYxZaynp97ozCzfOyOuAGOU4aU/z37zf/tOujFk7c=
|
||||
github.com/leanovate/gopter v0.2.9/go.mod h1:U2L/78B+KVFIx2VmW6onHJQzXtFb+p5y3y2Sh+Jxxv8=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230811055104-e22b2e3ec100 h1:DRQDvUPhWfTHCinPxJHKHvoRoUPIEstVHkdf2TfPmyQ=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230811055104-e22b2e3ec100/go.mod h1:vMETmlckriMRtrg81+YGcmA4/V3XFmjScMqjCojPr3g=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230811190401-0b81275ff736 h1:7nReXKhGOpFxazZi6qE4vEh8C2geBZbPOp8WDOBzINI=
|
||||
github.com/ledgerwatch/erigon-lib v0.0.0-20230811190401-0b81275ff736/go.mod h1:vMETmlckriMRtrg81+YGcmA4/V3XFmjScMqjCojPr3g=
|
||||
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230810173239-feb52fae58d9 h1:fG8PozTh9rKBRtWwZsoCA8kJ0M/B6SiG4Vo1sF29Inw=
|
||||
github.com/ledgerwatch/erigon-snapshot v1.2.1-0.20230810173239-feb52fae58d9/go.mod h1:3AuPxZc85jkehh/HA9h8gabv5MSi3kb/ddtzBsTVJFo=
|
||||
github.com/ledgerwatch/log/v3 v3.8.0 h1:gCpp7uGtIerEz1jKVPeDnbIopFPud9ZnCpBLlLBGqPU=
|
||||
|
@ -38,7 +38,7 @@ func (e *EngineBlockDownloader) download(hashToDownload libcommon.Hash, download
|
||||
}
|
||||
defer tx.Rollback()
|
||||
|
||||
tmpDb, err := mdbx.NewTemporaryMdbx()
|
||||
tmpDb, err := mdbx.NewTemporaryMdbx(e.tmpdir)
|
||||
if err != nil {
|
||||
e.logger.Warn("[EngineBlockDownloader] Could create temporary mdbx", "err", err)
|
||||
e.status.Store(headerdownload.Idle)
|
||||
|
Loading…
Reference in New Issue
Block a user