XinFinOrg / XDPoSChain

Customer centric, Hybrid & Interoperable XinFin Network
https://www.xinfin.org
GNU Lesser General Public License v3.0
51 stars 63 forks source link

bug: panic when sync call func getSignersFromContract #271

Closed gzliudan closed 1 year ago

gzliudan commented 1 year ago

The issue #268 reported a problem about sync, there is a panic bug in error messages. The reproduction steps are as follows:

cd ${HOME}
git clone https://github.com/XinFinOrg/XDPoSChain.git
cd XDPoSChain
wget https://raw.githubusercontent.com/XinFinOrg/XinFin-Node/master/mainnet/genesis.json
make all
./build/bin/XDC --datadir ${HOME}/.xinfin init genesis.json
./build/bin/XDC --datadir ${HOME}/.xinfin --networkid 50 --etherbase 0x000000000000000000000000000000000000dead

The panic messages are as follows:

INFO [05-25|06:07:54] It's time to update new set of masternodes for the next epoch... 
INFO [05-25|06:07:54] Ordered list of masternode candidates 
INFO [05-25|06:07:54]                                          address=xdcFaa7A3c5b5a7f8c9A69f73347F9F28E2B9669d72 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdcc67c2DEc79da735d6587d8DB3c23271d557196ab stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc664c4a7B15d91B07c468162f535909114C038b91 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdcC7d49d0a2CF198DeEBd6ce581aF465944ec8b2bB stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc25c65b4b379ac37CF78357c4915f73677022eaFF stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdcA0caeC455E7585d845BBF72420397774e52f3B74 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdced2cE9d056DB8DeF2B4d877c9a80b6f988ae202E stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc9a3787688fD210EC8F8D0224c6c50B8178d75Bc0 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc72fb467Ef6dA285b6B0D8f7A25AbD6049385d5fD stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdcA4F06BD6E4b217F1FfF9327BDE83da1d41193bE4 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdcDb2E141595d8Edf6B1CE40b10d57Ca5b83855ec5 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc595b8170eAF2e53e47cc20db47aD063a1e6e2C0f stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc7923B7f78dFfacBb3e1b886e2410630975384C7F stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdccfCCDeA1006a5CfA7d9484B5b293B46964c265c0 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc7aA125338BE075260e77c6a66A56c90A5DeC4C58 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc4398241671b3Dd484FE3213A4fB7511f30e7D7C0 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdca65010026b83368Ca05DF6E8B467985D6de3eAC5 stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc0eaa5c2F0929C95ED0280e8840A2416C4EF16E9d stake=10000000000000000000000000
INFO [05-25|06:07:54]                                          address=xdc065551F0dcAC6f00CAe11192D462db709bE3758c stake=10000000000000000000000000
INFO [05-25|06:07:54] Updating new set of masternodes 
INFO [05-25|06:07:54] New set of masternodes has been updated to snapshot number=516150 hash=25a20f…bc50cd new masternodes="[xdcFaa7A3c5b5a7f8c9A69f73347F9F28E2B9669d72 xdcc67c2DEc79da735d6587d8DB3c23271d557196ab xdc664c4a7B15d91B07c468162f535909114C038b91 xdcC7d49d0a2CF198DeEBd6ce581aF465944ec8b2bB xdc25c65b4b379ac37CF78357c4915f73677022eaFF xdcA0caeC455E7585d845BBF72420397774e52f3B74 xdced2cE9d056DB8DeF2B4d877c9a80b6f988ae202E xdc9a3787688fD210EC8F8D0224c6c50B8178d75Bc0 xdc72fb467Ef6dA285b6B0D8f7A25AbD6049385d5fD xdcA4F06BD6E4b217F1FfF9327BDE83da1d41193bE4 xdcDb2E141595d8Edf6B1CE40b10d57Ca5b83855ec5 xdc595b8170eAF2e53e47cc20db47aD063a1e6e2C0f xdc7923B7f78dFfacBb3e1b886e2410630975384C7F xdccfCCDeA1006a5CfA7d9484B5b293B46964c265c0 xdc7aA125338BE075260e77c6a66A56c90A5DeC4C58 xdc4398241671b3Dd484FE3213A4fB7511f30e7D7C0 xdca65010026b83368Ca05DF6E8B467985D6de3eAC5 xdc0eaa5c2F0929C95ED0280e8840A2416C4EF16E9d]"
INFO [05-25|06:07:54] Masternodes are ready for the next epoch 
INFO [05-25|06:07:54] Imported new chain segment               blocks=450 txs=537 mgas=42.642 elapsed=769.906ms mgasps=55.386  number=516150 hash=25a20f…bc50cd cache=1.03mB
INFO [05-25|06:07:54] Persisted trie from memory database      nodes=1476 size=465.02kB time=14.668533ms gcnodes=691 gcsize=246.44kB gctime=1.514012ms livenodes=2463 livesize=407.65kB
INFO [05-25|06:07:55] Persisted trie from memory database      nodes=1692 size=522.37kB time=12.382711ms gcnodes=770 gcsize=273.66kB gctime=1.975318ms livenodes=2187 livesize=323.26kB
INFO [05-25|06:07:55] Persisted trie from memory database      nodes=1487 size=462.49kB time=13.157319ms gcnodes=699 gcsize=249.23kB gctime=1.568515ms livenodes=2436 livesize=399.22kB
INFO [05-25|06:07:55] Imported new chain segment               blocks=449 txs=573 mgas=43.961 elapsed=746.348ms mgasps=58.902  number=516599 hash=a8731d…27b91a cache=1.40mB
ERROR[05-25|06:07:55] Masternodes lists are different in checkpoint header and snapshot number=516600 masternodes_from_checkpoint_header="[[6 85 81 240 220 172 111 0 202 225 17 146 212 98 219 112 155 227 117 140] [14 170 92 47 9 41 201 94 208 40 14 136 64 162 65 108 78 241 110 157] [37 198 91 75 55 154 195 124 247 131 87 196 145 95 115 103 112 34 234 255] [67 152 36 22 113 179 221 72 79 227 33 58 79 183 81 31 48 231 215 192] [89 91 129 112 234 242 229 62 71 204 32 219 71 173 6 58 30 110 44 15] [102 76 74 123 21 217 27 7 196 104 22 47 83 89 9 17 76 3 139 145] [114 251 70 126 246 218 40 91 107 13 143 122 37 171 214 4 147 133 213 253] [121 35 183 247 141 255 172 187 62 27 136 110 36 16 99 9 117 56 76 127] [122 161 37 51 139 224 117 38 14 119 198 166 106 86 201 10 93 236 76 88] [154 55 135 104 143 210 16 236 143 141 2 36 198 197 11 129 120 215 91 192] [160 202 236 69 94 117 133 216 69 187 247 36 32 57 119 116 229 47 59 116] [164 240 107 214 228 178 23 241 255 249 50 123 222 131 218 29 65 25 59 228] [199 212 157 10 44 241 152 222 235 214 206 88 26 244 101 148 78 200 178 187] [219 46 20 21 149 216 237 246 177 206 64 177 13 87 202 91 131 133 94 197] [166 80 16 2 107 131 54 140 160 93 246 232 180 103 152 93 109 227 234 197] [207 204 222 161 0 106 92 250 125 148 132 181 178 147 180 105 100 194 101 192] [237 44 233 208 86 219 141 239 43 77 135 124 154 128 182 249 136 174 32 46]]" masternodes_in_snapshot="[[14 170 92 47 9 41 201 94 208 40 14 136 64 162 65 108 78 241 110 157] [37 198 91 75 55 154 195 124 247 131 87 196 145 95 115 103 112 34 234 255] [67 152 36 22 113 179 221 72 79 227 33 58 79 183 81 31 48 231 215 192] [89 91 129 112 234 242 229 62 71 204 32 219 71 173 6 58 30 110 44 15] [102 76 74 123 21 217 27 7 196 104 22 47 83 89 9 17 76 3 139 145] [114 251 70 126 246 218 40 91 107 13 143 122 37 171 214 4 147 133 213 253] [121 35 183 247 141 255 172 187 62 27 136 110 36 16 99 9 117 56 76 127] [122 161 37 51 139 224 117 38 14 119 198 166 106 86 201 10 93 236 76 88] [154 55 135 104 143 210 16 236 143 141 2 36 198 197 11 129 120 215 91 192] [160 202 236 69 94 117 133 216 69 187 247 36 32 57 119 116 229 47 59 116] [164 240 107 214 228 178 23 241 255 249 50 123 222 131 218 29 65 25 59 228] [199 212 157 10 44 241 152 222 235 214 206 88 26 244 101 148 78 200 178 187] [219 46 20 21 149 216 237 246 177 206 64 177 13 87 202 91 131 133 94 197] [166 80 16 2 107 131 54 140 160 93 246 232 180 103 152 93 109 227 234 197] [198 124 45 236 121 218 115 93 101 135 216 219 60 35 39 29 85 113 150 171] [207 204 222 161 0 106 92 250 125 148 132 181 178 147 180 105 100 194 101 192] [237 44 233 208 86 219 141 239 43 77 135 124 154 128 182 249 136 174 32 46]]" penList=[]
panic: runtime error: invalid memory address or nil pointer dereference
[signal SIGSEGV: segmentation violation code=0x1 addr=0x20 pc=0x7822e4]

goroutine 4538456 [running]:
github.com/XinFinOrg/XDPoSChain/core/state.(*StateDB).getStateObject(0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...})
    /home/liudan/XDPoSChain/core/state/statedb.go:388 +0x64
github.com/XinFinOrg/XDPoSChain/core/state.(*StateDB).GetState(0x0, {0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, 0x0, ...}, ...)
    /home/liudan/XDPoSChain/core/state/statedb.go:256 +0x50
github.com/XinFinOrg/XDPoSChain/core/state.GetCandidates(0xf7a1ca23f336eb19?)
    /home/liudan/XDPoSChain/core/state/statedb_utils.go:95 +0x12c
github.com/XinFinOrg/XDPoSChain/eth/hooks.AttachConsensusV1Hooks.func5({0x25, 0xa2, 0xf, 0xa7, 0x58, 0x4f, 0x55, 0x59, 0xb5, 0xf0, ...})
    /home/liudan/XDPoSChain/eth/hooks/engine_v1_hooks.go:231 +0x16d
github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/engines/engine_v1.(*XDPoS_v1).getSignersFromContract(0xc0001f9110, {0x14c1378, 0xc0002f8000}, 0xc03b968500?)
    /home/liudan/XDPoSChain/consensus/XDPoS/engines/engine_v1/engine.go:1003 +0x158
github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/engines/engine_v1.(*XDPoS_v1).verifyCascadingFields(0xc0001f9110, {0x14c1378, 0xc0002f8000}, 0xc03b968500, {0xc02297f2f0?, 0x0, 0x1}, 0x1c?)
    /home/liudan/XDPoSChain/consensus/XDPoS/engines/engine_v1/engine.go:263 +0x345
github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/engines/engine_v1.(*XDPoS_v1).verifyHeader(0xc0001f9110, {0x14c1378, 0xc0002f8000}, 0xc03b968500, {0xc02297f2f0, 0x0, 0x1}, 0x40?)
    /home/liudan/XDPoSChain/consensus/XDPoS/engines/engine_v1/engine.go:216 +0x605
github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/engines/engine_v1.(*XDPoS_v1).verifyHeaderWithCache(0xc0001f9110, {0x14c1378, 0xc0002f8000}, 0x6d7bc7?, {0xc02297f2f0, 0x0, 0x1}, 0x65?)
    /home/liudan/XDPoSChain/consensus/XDPoS/engines/engine_v1/engine.go:143 +0x12b
github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/engines/engine_v1.(*XDPoS_v1).VerifyHeaders.func1()
    /home/liudan/XDPoSChain/consensus/XDPoS/engines/engine_v1/engine.go:126 +0x114
created by github.com/XinFinOrg/XDPoSChain/consensus/XDPoS/engines/engine_v1.(*XDPoS_v1).VerifyHeaders
    /home/liudan/XDPoSChain/consensus/XDPoS/engines/engine_v1/engine.go:124 +0x16a
raghu0891 commented 1 year ago

@gzliudan We are getting the panice issue in one of our node.

image
git-ljm commented 1 year ago

me too.

gzliudan commented 1 year ago

@git-ljm Please refer to https://github.com/XinFinOrg/XDPoSChain/issues/268#issuecomment-1577045170

gzliudan commented 1 year ago

Closed by #271 or #282.