mirror of
https://github.com/luxfi/evm.git
synced 2026-09-24 00:27:44 +00:00
config: drop ancient-read-only, which said nothing ancient-shared did not
The two settings each required the other, so neither could be given alone and the pair named one arrangement twice. Reading a store another node writes already means not writing to it. Nothing branched on ancient-read-only. Co-authored-by: Hanzo Dev <[email protected]>
This commit is contained in:
@@ -5,6 +5,7 @@ package config
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"errors"
|
||||
"fmt"
|
||||
"time"
|
||||
|
||||
@@ -76,6 +77,11 @@ const (
|
||||
estimatedBlockAcceptPeriod = 2 * time.Second
|
||||
defaultHistoricalProofQueryWindow = uint64(24 * time.Hour / estimatedBlockAcceptPeriod)
|
||||
defaultStateHistory = uint64(32)
|
||||
|
||||
// defaultFreezeThreshold is how many recent blocks stay in the chain
|
||||
// database when an ancient store is configured and nobody said otherwise.
|
||||
// It matches luxd's --cchain-freeze-threshold default.
|
||||
defaultFreezeThreshold = uint64(90_000)
|
||||
)
|
||||
|
||||
type PBool bool
|
||||
@@ -283,6 +289,15 @@ type Config struct {
|
||||
DatabasePath string `json:"database-path"`
|
||||
DatabaseReadOnly bool `json:"database-read-only"`
|
||||
|
||||
// Ancient store. Set AncientDir and blocks older than FreezeThreshold move
|
||||
// out of the chain database into an append-only store on that path. A node
|
||||
// that sets AncientShared reads a store another node writes instead of
|
||||
// keeping its own, which is how many nodes on one machine come to hold one
|
||||
// copy of history between them. Set by luxd's --cchain-ancient flags.
|
||||
AncientDir string `json:"ancient-dir"`
|
||||
AncientShared bool `json:"ancient-shared"`
|
||||
FreezeThreshold uint64 `json:"freeze-threshold"`
|
||||
|
||||
// Database Scheme
|
||||
StateScheme string `json:"state-scheme"`
|
||||
|
||||
@@ -368,6 +383,7 @@ func (c *Config) SetDefaults(txPoolConfig TxPoolConfig) {
|
||||
c.AllowUnprotectedTxHashes = defaultAllowUnprotectedTxHashes
|
||||
c.AcceptedCacheSize = defaultAcceptedCacheSize
|
||||
c.DatabaseType = defaultDBType
|
||||
c.FreezeThreshold = defaultFreezeThreshold
|
||||
c.ValidatorsAPIEnabled = defaultValidatorAPIEnabled
|
||||
c.AdminAPIEnabled = defaultAdminAPIEnabled
|
||||
c.HistoricalProofQueryWindow = defaultHistoricalProofQueryWindow
|
||||
@@ -420,6 +436,26 @@ func (c *Config) Validate() error {
|
||||
if c.PushGossipPercentStake < 0 || c.PushGossipPercentStake > 1 {
|
||||
return fmt.Errorf("push-gossip-percent-stake is %f but must be in the range [0, 1]", c.PushGossipPercentStake)
|
||||
}
|
||||
if err := c.validateAncient(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
// validateAncient holds the ancient store to combinations that describe a real
|
||||
// arrangement of nodes on a machine.
|
||||
func (c *Config) validateAncient() error {
|
||||
if c.AncientDir == "" {
|
||||
if c.AncientShared {
|
||||
return errors.New("ancient-shared needs ancient-dir")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
// Sharing means reading a store another node writes. Writing to it from two
|
||||
// nodes at once would interleave two chains into one append-only file.
|
||||
if c.FreezeThreshold == 0 {
|
||||
return errors.New("freeze-threshold must be at least 1: the block being built needs its parent in the chain database")
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
|
||||
@@ -243,6 +243,18 @@ Configuration is provided as a JSON object. All fields are optional unless other
|
||||
| `inspect-database` | bool | Inspect database on startup | `false` |
|
||||
| `state-scheme` | string | EXPERIMENTAL: specifies the database scheme to store state data; can be one of `hash` or `firewood` | `hash` |
|
||||
|
||||
## Ancient Store
|
||||
|
||||
Blocks the chain will never rewrite can live in an append-only store on their own
|
||||
path instead of in the chain database. One node writes the store and any number
|
||||
read it at the same time, so a machine running several nodes holds one copy of
|
||||
history rather than one copy per node. luxd's `--cchain-ancient` flags set these.
|
||||
|
||||
| Option | Type | Description | Default |
|
||||
|--------|------|-------------|---------|
|
||||
| `ancient-dir` | string | Path to the ancient store. Empty leaves all history in the chain database | - |
|
||||
| `freeze-threshold` | uint64 | Recent blocks kept in the chain database before they move to the store; at least 1 | `90000` |
|
||||
|
||||
## Transaction Indexing
|
||||
|
||||
| Option | Type | Description | Default |
|
||||
|
||||
Reference in New Issue
Block a user