mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2024-12-22 19:50:36 +00:00
c3e1cfdac8
* Pruning for: exec, log_index, tx_lookup, history stages * Pruning for: exec, log_index, tx_lookup, history stages * Pruning for: exec, log_index, tx_lookup, history stages * Pruning for: exec, log_index, tx_lookup, history stages * add tvm flag * save * db migration for storage mode add flag --prune= remove flag --storage-mode= add flag --experiments=tevm,... rename integration set_storage_mode to set_prune * fix * forward move of stages must skip everything before PruneTo * keep in db progress of prune method * keep in db progress of prune method * simplify logs * simplify logs * simplify logs * fix test * simplify logs * simplify logs * simplify logs * simplify logs * remove callTraceSet as dupsort use etl transform for txlookup prune remove some logs * cleanup tests a bit * print_stages and eth_sync to show prune progress * fix print_stages * add readme about --prune.to flag * more docs * add --prune.history.older and other flags support * fix migration on empty db * better toString * better toString
77 lines
2.0 KiB
Go
77 lines
2.0 KiB
Go
package migrations
|
|
|
|
import (
|
|
"github.com/ledgerwatch/erigon/common/dbutils"
|
|
"github.com/ledgerwatch/erigon/common/etl"
|
|
"github.com/ledgerwatch/erigon/common/math"
|
|
"github.com/ledgerwatch/erigon/ethdb"
|
|
"github.com/ledgerwatch/erigon/ethdb/prune"
|
|
"github.com/ledgerwatch/erigon/params"
|
|
)
|
|
|
|
var storageMode = Migration{
|
|
Name: "storage_mode",
|
|
Up: func(db ethdb.Database, tmpdir string, progress []byte, CommitProgress etl.LoadCommitHandler) (err error) {
|
|
var ( // old db keys
|
|
//StorageModeHistory - does node save history.
|
|
StorageModeHistory = []byte("smHistory")
|
|
//StorageModeReceipts - does node save receipts.
|
|
StorageModeReceipts = []byte("smReceipts")
|
|
//StorageModeTxIndex - does node save transactions index.
|
|
StorageModeTxIndex = []byte("smTxIndex")
|
|
//StorageModeCallTraces - does not build index of call traces
|
|
StorageModeCallTraces = []byte("smCallTraces")
|
|
)
|
|
pm := prune.Mode{Initialised: true}
|
|
castToPruneDistance := func(v []byte) prune.Distance {
|
|
if len(v) == 1 && v[0] == 2 {
|
|
return params.FullImmutabilityThreshold // means, prune enabled
|
|
}
|
|
return math.MaxUint64 // means, prune disabled
|
|
}
|
|
{
|
|
v, err := db.GetOne(dbutils.DatabaseInfoBucket, StorageModeHistory)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pm.History = castToPruneDistance(v)
|
|
|
|
}
|
|
{
|
|
v, err := db.GetOne(dbutils.DatabaseInfoBucket, StorageModeReceipts)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pm.Receipts = castToPruneDistance(v)
|
|
}
|
|
{
|
|
v, err := db.GetOne(dbutils.DatabaseInfoBucket, StorageModeTxIndex)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pm.TxIndex = castToPruneDistance(v)
|
|
}
|
|
{
|
|
v, err := db.GetOne(dbutils.DatabaseInfoBucket, StorageModeCallTraces)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pm.CallTraces = castToPruneDistance(v)
|
|
}
|
|
{
|
|
v, err := db.GetOne(dbutils.DatabaseInfoBucket, dbutils.StorageModeTEVM)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
pm.Experiments.TEVM = len(v) == 1 && v[0] == 1
|
|
}
|
|
|
|
err = prune.SetIfNotExist(db, pm)
|
|
if err != nil {
|
|
return err
|
|
}
|
|
|
|
return CommitProgress(db, nil, true)
|
|
},
|
|
}
|