BOXFoundation / boxd

Blockchain for BOX Payout
MIT License
40 stars 10 forks source link

panic when reorganize #230

Closed Jerick26 closed 5 years ago

Jerick26 commented 5 years ago

Expected Behavior

run normally

Current Behavior

panic when reorganize

Possible Solution

have not one yet

Steps to Reproduce

  1. set relay_size: 32 in .box-1.yaml
  2. ./integraion_tests -scope=continue on local machine
  3. run about 20 minutes

Context (Environment)

branch: develop commit: 8b9b8921d79e3067ee6c25944a4766e7fafb791d

Detailed Description

Possible Implementation

WARN[1357] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[1357] The block is timeout. Now: 1544708852 BlockTimeStamp: 1544708850 Timeout: 2  source="chain/validate.go:28" tag=chain
WARN[1357] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[1357] The block is timeout. Now: 1544708852 BlockTimeStamp: 1544708850 Timeout: 2  source="chain/validate.go:28" tag=chain
WARN[1357] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[1357] The block is timeout. Now: 1544708852 BlockTimeStamp: 1544708850 Timeout: 2  source="chain/validate.go:28" tag=chain
WARN[1357] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
panic: runtime error: index out of range

goroutine 426 [running]:
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).LoadBlockInfoByTxHash(0xc0002250e0, 0xcf3cc867c92499de, 0x99bdb88dd1a747aa, 0x2a49297d031a3b6b, 0xbb85952648e46c0, 0x3f9db4ef92ef3981, 0xbe7e94ff5ad9aea4, 0x18dad2cd9bc5468d, 0x47ec11c5df26cd6)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:985 +0x46b
github.com/BOXFoundation/boxd/core/chain.(*UtxoSet).RevertTx(0xc01068f950, 0xc01a1222a0, 0xc0002250e0, 0xc000fe2000, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/utxoset.go:195 +0x2d1
github.com/BOXFoundation/boxd/core/chain.(*UtxoSet).RevertBlock(0xc01068f950, 0xc013cd8c80, 0xc0002250e0, 0xc000196510, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/utxoset.go:220 +0x71
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).revertBlock(0xc0002250e0, 0xc013cd8c80, 0x4cc69e0, 0xc015c81cc0, 0x1, 0x1)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:544 +0x9c
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).reorganize(0xc0002250e0, 0xc011c70be0, 0x4cc69e0, 0xc015c81cc0, 0x1, 0x1)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:631 +0xc9
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).tryAcceptBlock(0xc0002250e0, 0xc011c70be0, 0x0, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:370 +0x5e9
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).processOrphans(0xc0002250e0, 0xc015596640, 0x0, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:407 +0xff
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).ProcessBlock(0xc0002250e0, 0xc015596640, 0x110000, 0x0, 0x0, 0x0, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:280 +0x943
github.com/BOXFoundation/boxd/blocksync.(*SyncManager).onLightSyncResponse(0xc0001321e0, 0x4cc00a0, 0xc0115400c0, 0xc011540120, 0x2)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/blocksync/sync_server.go:361 +0xf8
github.com/BOXFoundation/boxd/blocksync.(*SyncManager).handleSyncMessage(0xc0001321e0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/blocksync/sync_server.go:66 +0x5e5
created by github.com/BOXFoundation/boxd/blocksync.(*SyncManager).Run
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/blocksync/sync_server.go:30 +0x17e
WARN[2912] Failed to handle eternalBlockMsg. Err: Illegal message from remote peer  source="dpos/bft_service.go:71" tag=dpos
WARN[2912] Failed to handle eternalBlockMsg. Err: Illegal message from remote peer  source="dpos/bft_service.go:71" tag=dpos
WARN[2912] Failed to handle eternalBlockMsg. Err: Illegal message from remote peer  source="dpos/bft_service.go:71" tag=dpos
WARN[2912] The block is timeout. Now: 1544710407 BlockTimeStamp: 1544710400 Timeout: 7  source="chain/validate.go:28" tag=chain
WARN[2912] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[2912] The block is timeout. Now: 1544710407 BlockTimeStamp: 1544710403 Timeout: 4  source="chain/validate.go:28" tag=chain
WARN[2912] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[2912] The block is timeout. Now: 1544710407 BlockTimeStamp: 1544710404 Timeout: 3  source="chain/validate.go:28" tag=chain
WARN[2912] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[2912] The block is timeout. Now: 1544710407 BlockTimeStamp: 1544710391 Timeout: 16  source="chain/validate.go:28" tag=chain
WARN[2912] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[2912] The block is timeout. Now: 1544710407 BlockTimeStamp: 1544710391 Timeout: 16  source="chain/validate.go:28" tag=chain
WARN[2912] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
WARN[2912] The block is timeout. Now: 1544710407 BlockTimeStamp: 1544710391 Timeout: 16  source="chain/validate.go:28" tag=chain
WARN[2912] Failed to processBlockMsg. Err: The block is timeout  source="chain/blockchain.go:188" tag=chain
ERRO[2912] Error reading tx hash, expect: 8d655a5786a9fba39712fe4066b48cb115359dfdc728c761a8e6c13e17e023c4 got: ddd51e03e22508a324a5fed15ae373b8493e94ab0562980100821ba01cfa287f  source="chain/blockchain.go:993" tag=chain
PANI[2912] Trying to unspend non-existing spent output {8d655a5786a9fba39712fe4066b48cb115359dfdc728c761a8e6c13e17e023c4 0}  source="chain/utxoset.go:197" tag=chain
panic: (*logrus.Entry) (0x4a7e780,0xc0179c1da0)

goroutine 396 [running]:
github.com/sirupsen/logrus.Entry.log(0xc0000e8820, 0xc012b2d140, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...)
    /Users/jerrypeen/go/pkg/mod/github.com/sirupsen/logrus@v1.1.1/entry.go:138 +0x29c
github.com/sirupsen/logrus.(*Entry).Panic(0xc0179c1d40, 0xc0009cf7b8, 0x1, 0x1)
    /Users/jerrypeen/go/pkg/mod/github.com/sirupsen/logrus@v1.1.1/entry.go:206 +0xb8
github.com/sirupsen/logrus.(*Entry).Panicf(0xc0179c1d40, 0x4abbfda, 0x2e, 0xc013a8c480, 0x1, 0x1)
    /Users/jerrypeen/go/pkg/mod/github.com/sirupsen/logrus@v1.1.1/entry.go:254 +0xed
github.com/BOXFoundation/boxd/log/logrus.(*logrusLogger).Panicf(0xc0004a5ea0, 0x4abbfda, 0x2e, 0xc013a8c480, 0x1, 0x1)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/log/logrus/logrus.go:126 +0x6b
github.com/BOXFoundation/boxd/core/chain.(*UtxoSet).RevertTx(0xc0009cf9f0, 0xc0165faf60, 0xc0004ae480, 0xc01b512000, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/utxoset.go:197 +0x4e1
github.com/BOXFoundation/boxd/core/chain.(*UtxoSet).RevertBlock(0xc0009cf9f0, 0xc01262a8c0, 0xc0004ae480, 0xc00022ac90, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/utxoset.go:220 +0x71
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).revertBlock(0xc0004ae480, 0xc01262a8c0, 0x4cc69e0, 0xc0159d5600, 0x1, 0x1)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:544 +0x9c
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).reorganize(0xc0004ae480, 0xc01a836b40, 0x4cc69e0, 0xc0159d5600, 0x1, 0x1)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:631 +0xc9
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).tryAcceptBlock(0xc0004ae480, 0xc01a836b40, 0x0, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:370 +0x5e9
github.com/BOXFoundation/boxd/core/chain.(*BlockChain).ProcessBlock(0xc0004ae480, 0xc01a836b40, 0x140000, 0x0, 0x0, 0x0, 0x0)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/core/chain/blockchain.go:275 +0x800
github.com/BOXFoundation/boxd/blocksync.(*SyncManager).onLightSyncResponse(0xc000692000, 0x4cc00a0, 0xc0183b31a0, 0xc0183b31e0, 0x2)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/blocksync/sync_server.go:361 +0xf8
github.com/BOXFoundation/boxd/blocksync.(*SyncManager).handleSyncMessage(0xc000692000)
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/blocksync/sync_server.go:66 +0x5e5
created by github.com/BOXFoundation/boxd/blocksync.(*SyncManager).Run
    /Users/jerrypeen/go/src/github.com/BOXFoundation/boxd/blocksync/sync_server.go:30 +0x17e