diff --git a/core/blockchain.go b/core/blockchain.go index cead459551..69ac93c63c 100644 --- a/core/blockchain.go +++ b/core/blockchain.go @@ -2220,6 +2220,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { } // Both sides of the reorg are at the same number, reduce both until the common // ancestor is found + log.Info("neo reorg start") for { // If the common ancestor was found, bail out if oldBlock.Hash() == newBlock.Hash() { @@ -2228,10 +2229,12 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { } // Remove an old block as well as stash away a new block oldChain = append(oldChain, oldBlock) + log.Info("neo reorg oldBlock info ", "hash", oldBlock.Hash(), "number", oldBlock.Number()) for _, tx := range oldBlock.Transactions() { deletedTxs = append(deletedTxs, tx.Hash()) } newChain = append(newChain, newBlock) + log.Info("neo reorg newBlock info ", "hash", newBlock.Hash(), "number", newBlock.Number()) // Step back with both chains oldBlock = bc.GetBlock(oldBlock.ParentHash(), oldBlock.NumberU64()-1) @@ -2243,6 +2246,7 @@ func (bc *BlockChain) reorg(oldHead *types.Header, newHead *types.Block) error { return fmt.Errorf("invalid new chain") } } + log.Info("neo reorg end") // Ensure the user sees large reorgs if len(oldChain) > 0 && len(newChain) > 0 { @@ -2378,6 +2382,7 @@ func (bc *BlockChain) SetCanonical(head *types.Block) (common.Hash, error) { // Run the reorg if necessary and set the given block as new head. start := time.Now() if head.ParentHash() != bc.CurrentBlock().Hash() { + log.Info("neo reorg start ", "parentHash", head.ParentHash(), "currentHash", bc.CurrentBlock().Hash()) if err := bc.reorg(bc.CurrentBlock(), head); err != nil { return common.Hash{}, err } diff --git a/core/blockchain_reader.go b/core/blockchain_reader.go index 21a9c6676b..5c97b9ee46 100644 --- a/core/blockchain_reader.go +++ b/core/blockchain_reader.go @@ -17,6 +17,7 @@ package core import ( + "github.com/ethereum/go-ethereum/log" "math/big" "github.com/ethereum/go-ethereum/common" @@ -182,6 +183,7 @@ func (bc *BlockChain) GetBlockByHash(hash common.Hash) *types.Block { // GetBlockByNumber retrieves a block from the database by number, caching it // (associated with its hash) if found. func (bc *BlockChain) GetBlockByNumber(number uint64) *types.Block { + log.Info("neo get block by number test") hash := rawdb.ReadCanonicalHash(bc.db, number) if hash == (common.Hash{}) { return nil diff --git a/eth/catalyst/api.go b/eth/catalyst/api.go index 8d5d301518..059aa746d3 100644 --- a/eth/catalyst/api.go +++ b/eth/catalyst/api.go @@ -209,10 +209,11 @@ func (api *ConsensusAPI) verifyPayloadAttributes(attr *engine.PayloadAttributes) } func (api *ConsensusAPI) forkchoiceUpdated(update engine.ForkchoiceStateV1, payloadAttributes *engine.PayloadAttributes) (engine.ForkChoiceResponse, error) { + log.Info("neo reorg verify") api.forkchoiceLock.Lock() defer api.forkchoiceLock.Unlock() - log.Trace("Engine API request received", "method", "ForkchoiceUpdated", "head", update.HeadBlockHash, "finalized", update.FinalizedBlockHash, "safe", update.SafeBlockHash) + log.Info("Engine API request received", "method", "ForkchoiceUpdated", "head", update.HeadBlockHash, "finalized", update.FinalizedBlockHash, "safe", update.SafeBlockHash) if update.HeadBlockHash == (common.Hash{}) { log.Warn("Forkchoice requested update to zero hash") return engine.STATUS_INVALID, nil // TODO(karalabe): Why does someone send us this?