Skip to content
This repository has been archived by the owner on Oct 18, 2023. It is now read-only.

Commit

Permalink
better prune error message (erigontech#2475)
Browse files Browse the repository at this point in the history
  • Loading branch information
AskAlexSharov authored Jul 31, 2021
1 parent a2b97d5 commit 3ed0f5c
Show file tree
Hide file tree
Showing 4 changed files with 40 additions and 29 deletions.
9 changes: 7 additions & 2 deletions cmd/erigon/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,13 @@ func runErigon(cliCtx *cli.Context) {
chaindb.Close()
}

err := node.New(nodeCfg, ethCfg, logger).Serve()
ethNode, err := node.New(nodeCfg, ethCfg, logger)
if err != nil {
log.Error("error while serving a Erigon node", "err", err)
log.Error("Erigon startup", "err", err)
return
}
err = ethNode.Serve()
if err != nil {
log.Error("error while serving an Erigon node", "err", err)
}
}
2 changes: 1 addition & 1 deletion eth/backend.go
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ func New(stack *node.Node, config *ethconfig.Config, logger log.Logger) (*Ethere
if config.Prune.Initialised {
// If storage mode is not explicitly specified, we take whatever is in the database
if !reflect.DeepEqual(pm, config.Prune) {
return errors.New("prune is " + config.Prune.String() + " original prune is " + pm.String())
return errors.New("not allowed change of --prune flag, last time you used: " + pm.String())
}
} else {
config.Prune = pm
Expand Down
41 changes: 24 additions & 17 deletions ethdb/prune/storage_mode.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,33 +152,40 @@ func (m Mode) String() string {
if !m.Initialised {
return "default"
}
modeString := ""
long := ""
short := "--prune="
if m.History.Enabled() {
modeString += fmt.Sprintf("history=%d,", m.History)
} else {
modeString += "history=no,"
if m.History == params.FullImmutabilityThreshold {
short += "h"
} else {
long += fmt.Sprintf(" --prune.h.older=%d", m.History)
}
}
if m.Receipts.Enabled() {
modeString += fmt.Sprintf("receipt=%d,", m.Receipts)
} else {
modeString += "receipt=no,"
if m.Receipts == params.FullImmutabilityThreshold {
short += "r"
} else {
long += fmt.Sprintf(" --prune.r.older=%d", m.Receipts)
}
}
if m.TxIndex.Enabled() {
modeString += fmt.Sprintf("txindex=%d,", m.TxIndex)
} else {
modeString += "txindex=no,"
if m.TxIndex == params.FullImmutabilityThreshold {
short += "t"
} else {
long += fmt.Sprintf(" --prune.t.older=%d", m.TxIndex)
}
}
if m.CallTraces.Enabled() {
modeString += fmt.Sprintf("calltrace=%d,", m.CallTraces)
} else {
modeString += "calltrace=no,"
if m.CallTraces == params.FullImmutabilityThreshold {
short += "c"
} else {
long += fmt.Sprintf(" --prune.c.older=%d", m.CallTraces)
}
}
if m.Experiments.TEVM {
modeString += "experiments.tevm=enabled"
} else {
modeString += "experiments.tevm=disabled"
long += " --experiments.tevm=enabled"
}
return modeString
return short + long
}

func Override(db kv.RwTx, sm Mode) error {
Expand Down
17 changes: 8 additions & 9 deletions turbo/node/node.go
Original file line number Diff line number Diff line change
Expand Up @@ -92,20 +92,19 @@ func New(
nodeConfig *node.Config,
ethConfig *ethconfig.Config,
logger log.Logger,
) *ErigonNode {
) (*ErigonNode, error) {
//prepareBuckets(optionalParams.CustomBuckets)
node := makeConfigNode(nodeConfig)
ethereum := RegisterEthService(node, ethConfig, logger)
return &ErigonNode{stack: node, backend: ethereum}
ethereum, err := RegisterEthService(node, ethConfig, logger)
if err != nil {
return nil, err
}
return &ErigonNode{stack: node, backend: ethereum}, nil
}

// RegisterEthService adds an Ethereum client to the stack.
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config, logger log.Logger) *eth.Ethereum {
backend, err := eth.New(stack, cfg, logger)
if err != nil {
panic(err)
}
return backend
func RegisterEthService(stack *node.Node, cfg *ethconfig.Config, logger log.Logger) (*eth.Ethereum, error) {
return eth.New(stack, cfg, logger)
}

func NewNodeConfig() *node.Config {
Expand Down

0 comments on commit 3ed0f5c

Please sign in to comment.