mirror of
https://gitlab.com/pulsechaincom/erigon-pulse.git
synced 2025-01-03 09:37:38 +00:00
Don't read cwd in blockchain validator, remove debug code (#992)
* print cwd * don't read cwd, remove debug code * oops, overdelete * clean
This commit is contained in:
parent
d73b036cff
commit
d30df505c8
@ -20,16 +20,12 @@ import (
|
||||
"context"
|
||||
"errors"
|
||||
"fmt"
|
||||
"io/ioutil"
|
||||
"os"
|
||||
"strconv"
|
||||
"strings"
|
||||
|
||||
"github.com/ledgerwatch/turbo-geth/common"
|
||||
"github.com/ledgerwatch/turbo-geth/consensus"
|
||||
"github.com/ledgerwatch/turbo-geth/core/state"
|
||||
"github.com/ledgerwatch/turbo-geth/core/types"
|
||||
"github.com/ledgerwatch/turbo-geth/log"
|
||||
"github.com/ledgerwatch/turbo-geth/params"
|
||||
)
|
||||
|
||||
@ -41,7 +37,6 @@ type BlockValidator struct {
|
||||
config *params.ChainConfig // Chain configuration options
|
||||
bc *BlockChain // Canonical block chain
|
||||
engine consensus.Engine // Consensus engine used for validating
|
||||
dblks map[uint64]bool // Block numbers to run diagnostics on
|
||||
}
|
||||
|
||||
// NewBlockValidator returns a new block validator which is safe for re-use
|
||||
@ -50,34 +45,6 @@ func NewBlockValidator(config *params.ChainConfig, blockchain *BlockChain, engin
|
||||
config: config,
|
||||
engine: engine,
|
||||
bc: blockchain,
|
||||
dblks: make(map[uint64]bool),
|
||||
}
|
||||
files, err := ioutil.ReadDir("./")
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
for _, f := range files {
|
||||
if !f.IsDir() && strings.HasPrefix(f.Name(), "root_") && strings.HasSuffix(f.Name(), ".txt") {
|
||||
blockNumber, err := strconv.ParseUint(f.Name()[len("root_"):len(f.Name())-len(".txt")], 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
if _, ok := validator.dblks[blockNumber]; !ok {
|
||||
validator.dblks[blockNumber] = true
|
||||
}
|
||||
}
|
||||
if !f.IsDir() && strings.HasPrefix(f.Name(), "right_") && strings.HasSuffix(f.Name(), ".txt") {
|
||||
blockNumber, err := strconv.ParseUint(f.Name()[len("right_"):len(f.Name())-len(".txt")], 10, 64)
|
||||
if err != nil {
|
||||
panic(err)
|
||||
}
|
||||
validator.dblks[blockNumber] = false
|
||||
}
|
||||
}
|
||||
for blockNumber, ok := range validator.dblks {
|
||||
if ok {
|
||||
log.Info("Block validator will watch", "block", blockNumber)
|
||||
}
|
||||
}
|
||||
return validator
|
||||
}
|
||||
@ -158,25 +125,10 @@ func (v *BlockValidator) ValidateGasAndRoot(block *types.Block, root common.Hash
|
||||
// Validate the state root against the received state root and throw
|
||||
// an error if they don't match.
|
||||
if block.Header().Root != root {
|
||||
filename := fmt.Sprintf("root_%d.txt", block.NumberU64())
|
||||
log.Warn("Generating deep snapshot of the wrong tries...", "file", filename)
|
||||
f, err := os.Create(filename)
|
||||
if err == nil {
|
||||
defer f.Close()
|
||||
tds.PrintTrie(f)
|
||||
}
|
||||
if errorBuf.Len() > 0 {
|
||||
errorBuf.WriteString("; ")
|
||||
}
|
||||
fmt.Fprintf(&errorBuf, "[pre-processed] invalid merkle root (remote: %x local: %x)", block.Header().Root, root)
|
||||
} else if has, ok := v.dblks[block.NumberU64()]; ok && has {
|
||||
filename := fmt.Sprintf("right_%d.txt", block.NumberU64())
|
||||
log.Warn("Generating deep snapshot of right tries...", "file", filename)
|
||||
f, err := os.Create(filename)
|
||||
if err == nil {
|
||||
defer f.Close()
|
||||
tds.PrintTrie(f)
|
||||
}
|
||||
}
|
||||
|
||||
if errorBuf.Len() > 0 {
|
||||
|
Loading…
Reference in New Issue
Block a user