Skip to content

Commit fd1f3a2

Browse files
committed
stash
1 parent b2c09b9 commit fd1f3a2

File tree

9 files changed

+17
-24
lines changed

9 files changed

+17
-24
lines changed

cmd/utils/flags.go

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -270,9 +270,9 @@ var (
270270
Usage: "Scheme to use for storing ethereum state ('hash' or 'path')",
271271
Category: flags.StateCategory,
272272
}
273-
StateHistoryFlag = &cli.Int64Flag{
273+
StateHistoryFlag = &cli.Uint64Flag{
274274
Name: "history.state",
275-
Usage: "Number of recent blocks to retain state history for, only relevant in state.scheme=path (default = 90,000 blocks, 0 = entire chain, -1 = disabled)",
275+
Usage: "Number of recent blocks to retain state history for, only relevant in state.scheme=path (default = 90,000 blocks, 0 = entire chain)",
276276
Value: ethconfig.Defaults.StateHistory,
277277
Category: flags.StateCategory,
278278
}
@@ -1639,7 +1639,7 @@ func SetEthConfig(ctx *cli.Context, stack *node.Node, cfg *ethconfig.Config) {
16391639
log.Info("Enabling recording of key preimages since archive mode is used")
16401640
}
16411641
if ctx.IsSet(StateHistoryFlag.Name) {
1642-
cfg.StateHistory = ctx.Int64(StateHistoryFlag.Name)
1642+
cfg.StateHistory = ctx.Uint64(StateHistoryFlag.Name)
16431643
}
16441644
if ctx.IsSet(StateSchemeFlag.Name) {
16451645
cfg.StateScheme = ctx.String(StateSchemeFlag.Name)
@@ -2199,8 +2199,7 @@ func MakeChain(ctx *cli.Context, stack *node.Node, readonly bool) (*core.BlockCh
21992199
SnapshotLimit: ethconfig.Defaults.SnapshotCache,
22002200
Preimages: ctx.Bool(CachePreimagesFlag.Name),
22012201
StateScheme: scheme,
2202-
StateHistory: ctx.Int64(StateHistoryFlag.Name),
2203-
2202+
StateHistory: ctx.Uint64(StateHistoryFlag.Name),
22042203
// Disable transaction indexing/unindexing.
22052204
TxLookupLimit: -1,
22062205

core/blockchain.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -174,8 +174,7 @@ type BlockChainConfig struct {
174174

175175
// Number of blocks from the chain head for which state histories are retained.
176176
// If set to 0, all state histories across the entire chain will be retained;
177-
// If set to -1, no state history will be retained;
178-
StateHistory int64
177+
StateHistory uint64
179178

180179
// State snapshot related options
181180
SnapshotLimit int // Memory allowance (MB) to use for caching snapshot entries in memory

eth/ethconfig/config.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ type Config struct {
103103
LogHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head where a log search index is maintained.
104104
LogNoHistory bool `toml:",omitempty"` // No log search index is maintained.
105105
LogExportCheckpoints string // export log index checkpoints to file
106-
StateHistory int64 `toml:",omitempty"` // The maximum number of blocks from head whose state histories are reserved.
106+
StateHistory uint64 `toml:",omitempty"` // The maximum number of blocks from head whose state histories are reserved.
107107

108108
// State scheme represents the scheme used to store ethereum states and trie
109109
// nodes on top. It can be 'hash', 'path', or none which means use the scheme

eth/ethconfig/gen_config.go

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

triedb/pathdb/config.go

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,8 +70,8 @@ var ReadOnly = &Config{
7070
// Config contains the settings for database.
7171
type Config struct {
7272
// Number of recent blocks to maintain state history for.
73-
// 0: full chain, -1: disabled.
74-
StateHistory int64
73+
// 0: full chain
74+
StateHistory uint64
7575

7676
// Number of recent blocks to maintain trienode history for.
7777
// 0: full chain, -1: disabled.
@@ -111,12 +111,10 @@ func (c *Config) fields() []interface{} {
111111
list = append(list, "statecache", common.StorageSize(c.StateCleanSize))
112112
list = append(list, "buffer", common.StorageSize(c.WriteBufferSize))
113113

114-
if c.StateHistory >= 0 {
115-
if c.StateHistory == 0 {
116-
list = append(list, "state-history", "entire chain")
117-
} else {
118-
list = append(list, "state-history", fmt.Sprintf("last %d blocks", c.StateHistory))
119-
}
114+
if c.StateHistory == 0 {
115+
list = append(list, "state-history", "entire chain")
116+
} else {
117+
list = append(list, "state-history", fmt.Sprintf("last %d blocks", c.StateHistory))
120118
}
121119
if c.TrienodeHistory >= 0 {
122120
if c.TrienodeHistory == 0 {

triedb/pathdb/database.go

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -201,9 +201,6 @@ func New(diskdb ethdb.Database, config *Config, isVerkle bool) *Database {
201201
// repairHistory truncates leftover state history objects, which may occur due
202202
// to an unclean shutdown or other unexpected reasons.
203203
func (db *Database) repairHistory() error {
204-
if db.config.StateHistory < 0 {
205-
return nil
206-
}
207204
// Open the freezer for state history. This mechanism ensures that
208205
// only one database instance can be opened at a time to prevent
209206
// accidental mutation.

triedb/pathdb/database_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ type tester struct {
136136
}
137137

138138
type testerConfig struct {
139-
stateHistory int64
139+
stateHistory uint64
140140
trienodeHistory int64
141141
isVerkle bool
142142
layers int

triedb/pathdb/disklayer.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -350,7 +350,7 @@ func (dl *diskLayer) commit(bottom *diffLayer, force bool) (*diskLayer, error) {
350350
if err != nil {
351351
return nil, err
352352
}
353-
limit := uint64(dl.db.config.StateHistory)
353+
limit := dl.db.config.StateHistory
354354
if limit != 0 && bottom.stateID()-tail > limit {
355355
overflow = true
356356
oldest = bottom.stateID() - limit + 1 // track the id of history **after truncation**

triedb/pathdb/history_reader_test.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ func TestHistoryReader(t *testing.T) {
119119
testHistoryReader(t, 10) // with latest 10 histories reserved
120120
}
121121

122-
func testHistoryReader(t *testing.T, historyLimit int64) {
122+
func testHistoryReader(t *testing.T, historyLimit uint64) {
123123
maxDiffLayers = 4
124124
defer func() {
125125
maxDiffLayers = 128

0 commit comments

Comments
 (0)