Clean up error logging
This commit is contained in:
parent
ecd34978d3
commit
99a29191b1
@ -50,12 +50,12 @@ func (sdb *builder) BuildStateDiff(oldStateRoot, newStateRoot common.Hash, block
|
|||||||
// Generate tries for old and new states
|
// Generate tries for old and new states
|
||||||
oldTrie, err := trie.New(oldStateRoot, sdb.trieDB)
|
oldTrie, err := trie.New(oldStateRoot, sdb.trieDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error creating oldTrie", err)
|
log.Error("Error creating trie for oldStateRoot", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
newTrie, err := trie.New(newStateRoot, sdb.trieDB)
|
newTrie, err := trie.New(newStateRoot, sdb.trieDB)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error creating newTrie", err)
|
log.Error("Error creating trie for newStateRoot", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -64,7 +64,7 @@ func (sdb *builder) BuildStateDiff(oldStateRoot, newStateRoot common.Hash, block
|
|||||||
newIt := newTrie.NodeIterator([]byte{})
|
newIt := newTrie.NodeIterator([]byte{})
|
||||||
creations, err := sdb.collectDiffNodes(oldIt, newIt)
|
creations, err := sdb.collectDiffNodes(oldIt, newIt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error collecting creation diff nodes", err)
|
log.Error("Error collecting creation diff nodes", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -73,7 +73,7 @@ func (sdb *builder) BuildStateDiff(oldStateRoot, newStateRoot common.Hash, block
|
|||||||
newIt = newTrie.NodeIterator(make([]byte, 0))
|
newIt = newTrie.NodeIterator(make([]byte, 0))
|
||||||
deletions, err := sdb.collectDiffNodes(newIt, oldIt)
|
deletions, err := sdb.collectDiffNodes(newIt, oldIt)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error collecting deletion diff nodes", err)
|
log.Error("Error collecting deletion diff nodes", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -85,17 +85,17 @@ func (sdb *builder) BuildStateDiff(oldStateRoot, newStateRoot common.Hash, block
|
|||||||
// Build and return the statediff
|
// Build and return the statediff
|
||||||
updatedAccounts, err := sdb.buildDiffIncremental(creations, deletions, updatedKeys)
|
updatedAccounts, err := sdb.buildDiffIncremental(creations, deletions, updatedKeys)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error building diff incremental for updated", err)
|
log.Error("Error building diff for updated accounts", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
createdAccounts, err := sdb.buildDiffEventual(creations, true)
|
createdAccounts, err := sdb.buildDiffEventual(creations, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error building diff incremental for created", err)
|
log.Error("Error building diff for created accounts", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
deletedAccounts, err := sdb.buildDiffEventual(deletions, false)
|
deletedAccounts, err := sdb.buildDiffEventual(deletions, false)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Debug("error building diff incremental for deleted", err)
|
log.Error("Error building diff for deleted accounts", "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -260,9 +260,7 @@ func (sdb *builder) buildStorageDiffsIncremental(oldSR common.Hash, newSR common
|
|||||||
}
|
}
|
||||||
|
|
||||||
func (sdb *builder) addressByPath(path []byte) (*common.Address, error) {
|
func (sdb *builder) addressByPath(path []byte) (*common.Address, error) {
|
||||||
// db := core.PreimageTable(sdb.chainDb)
|
|
||||||
log.Debug("Looking up address from path", "path", hexutil.Encode(append([]byte("secure-key-"), path...)))
|
log.Debug("Looking up address from path", "path", hexutil.Encode(append([]byte("secure-key-"), path...)))
|
||||||
// if addrBytes,err := db.Get(path); err != nil {
|
|
||||||
if addrBytes, err := sdb.chainDB.Get(append([]byte("secure-key-"), hexToKeybytes(path)...)); err != nil {
|
if addrBytes, err := sdb.chainDB.Get(append([]byte("secure-key-"), hexToKeybytes(path)...)); err != nil {
|
||||||
log.Error("Error looking up address via path", "path", hexutil.Encode(append([]byte("secure-key-"), path...)), "error", err)
|
log.Error("Error looking up address via path", "path", hexutil.Encode(append([]byte("secure-key-"), path...)), "error", err)
|
||||||
return nil, err
|
return nil, err
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
"github.com/ethereum/go-ethereum/common"
|
"github.com/ethereum/go-ethereum/common"
|
||||||
"github.com/ethereum/go-ethereum/core/types"
|
"github.com/ethereum/go-ethereum/core/types"
|
||||||
"github.com/ethereum/go-ethereum/event"
|
"github.com/ethereum/go-ethereum/event"
|
||||||
|
"github.com/ethereum/go-ethereum/log"
|
||||||
)
|
)
|
||||||
|
|
||||||
type BlockChain interface {
|
type BlockChain interface {
|
||||||
@ -51,19 +52,30 @@ func (StateDiffService) APIs() []rpc.API {
|
|||||||
func (sds *StateDiffService) Loop(events chan core.ChainEvent) {
|
func (sds *StateDiffService) Loop(events chan core.ChainEvent) {
|
||||||
for elem := range events {
|
for elem := range events {
|
||||||
currentBlock := elem.Block
|
currentBlock := elem.Block
|
||||||
|
|
||||||
parentHash := currentBlock.ParentHash()
|
parentHash := currentBlock.ParentHash()
|
||||||
parentBlock := sds.BlockChain.GetBlockByHash(parentHash)
|
parentBlock := sds.BlockChain.GetBlockByHash(parentHash)
|
||||||
|
|
||||||
sds.Extractor.ExtractStateDiff(*parentBlock, *currentBlock)
|
stateDiffLocation, err := sds.Extractor.ExtractStateDiff(*parentBlock, *currentBlock)
|
||||||
|
if err != nil {
|
||||||
|
log.Error("Error extracting statediff", "block number", currentBlock.Number(), "error", err)
|
||||||
|
} else {
|
||||||
|
log.Info("Statediff extracted", "block number", currentBlock.Number(), "location", stateDiffLocation)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var eventsChannel chan core.ChainEvent
|
||||||
func (sds *StateDiffService) Start(server *p2p.Server) error {
|
func (sds *StateDiffService) Start(server *p2p.Server) error {
|
||||||
events := make(chan core.ChainEvent, 10)
|
log.Info("Starting statediff service")
|
||||||
sds.BlockChain.SubscribeChainEvent(events)
|
eventsChannel := make(chan core.ChainEvent, 10)
|
||||||
go sds.Loop(events)
|
sds.BlockChain.SubscribeChainEvent(eventsChannel)
|
||||||
|
go sds.Loop(eventsChannel)
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func (StateDiffService) Stop() error { return nil }
|
func (StateDiffService) Stop() error {
|
||||||
|
log.Info("Stopping statediff service")
|
||||||
|
close(eventsChannel)
|
||||||
|
|
||||||
|
return nil
|
||||||
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user