AntelopeIO / spring

C++ implementation of the Antelope protocol with Savanna consensus
Other
10 stars 5 forks source link

Limit unlinkable block exception #1045

Open heifner opened 3 days ago

heifner commented 3 days ago

An unlinkable_block_exception is thrown when a block is received that doesn't link to a block in the fork database.

We currently check if a block received on the network is <= LIB: https://github.com/AntelopeIO/spring/blob/90d255a84fceaa109368422155ad49db92b677a5/plugins/net_plugin/net_plugin.cpp#L3032-L3032 And discard it.

However, a block can make it pass this check and LIB move before it is put into the fork database. For example:

info  2024-11-18T08:01:13.469 nodeos    controller.cpp:3637           log_applied          ] Received block e9ba42711da87ce4... #405343386 @ 2024-11-18T08:01:13.000 signed by eosnationftw [trxs: 13, lib: 405343384, net: 973424, cpu: 73604 us, elapsed: 335023 us, applying time: 393147 us, latency: 469 ms]
warn  2024-11-18T08:01:13.469 nodeos    controller.cpp:4330           push_block           ] 3030001 unlinkable_block_exception: Unlinkable block
forkdb unlinkable block 18290c99dc9e02e11131f1067bfe07c7156e27d190cf4d70f73b4736df17f847 previous 18290c98f3ec193187f74ad8afe9a57c714c0bc2389eedc643c659d82b55283e
    {"id":"18290c99dc9e02e11131f1067bfe07c7156e27d190cf4d70f73b4736df17f847","p":"18290c98f3ec193187f74ad8afe9a57c714c0bc2389eedc643c659d82b55283e"}
    nodeos  fork_database.cpp:266 add_impl
info  2024-11-18T08:01:13.469 nodeos    producer_plugin.cpp:938       operator()           ] Exception on block 405343385: 3030001 unlinkable_block_exception: Unlinkable block
forkdb unlinkable block 18290c99dc9e02e11131f1067bfe07c7156e27d190cf4d70f73b4736df17f847 previous 18290c98f3ec193187f74ad8afe9a57c714c0bc2389eedc643c659d82b55283e
    {"id":"18290c99dc9e02e11131f1067bfe07c7156e27d190cf4d70f73b4736df17f847","p":"18290c98f3ec193187f74ad8afe9a57c714c0bc2389eedc643c659d82b55283e"}
    nodeos  fork_database.cpp:266 add_impl
rethrow
    {}
    nodeos  controller.cpp:4330 push_block
info  2024-11-18T08:01:13.469 nodeos    net_plugin.cpp:3871           process_signed_block ] unlinkable_block_exception connection - 4: #405343385 dc9e02e11131f106...: Unlinkable block (3030001)
forkdb unlinkable block 18290c99dc9e02e11131f1067bfe07c7156e27d190cf4d70f73b4736df17f847 previous 18290c98f3ec193187f74ad8afe9a57c714c0bc2389eedc643c659d82b55283e
rethrow

LIB is 405343384. Block 405343385 is trying to link to a block 405343384 that doesn't exist because it has been forked out.

The exception above is reported in push_block. In main this method no longer adds to the fork database. I think this situation is greatly reduced by the block processing optimizations already in main. See #619, #688, #802.

Likely not worth doing anything in release/1.0.