paritytech / substrate

Substrate: The platform for blockchain innovators
Apache License 2.0
8.39k stars 2.65k forks source link

Manual-seal finalization not working in Docker #10239

Open daniel-savu opened 3 years ago

daniel-savu commented 3 years ago

I've been experimenting with the sc-consensus-manual-seal pallet and since instant-seal doesn't finalize blocks, I wrote a wrapper around manual-seal. I used the run_instant_seal function (https://github.com/paritytech/substrate/blob/master/client/consensus/manual-seal/src/lib.rs#L201) to guide my implementation and I basically only changed these two fields: https://github.com/interlay/interbtc/pull/363/files#diff-9bbfbf9397681b04f9be425b4ddc02a359bccfc55ad97c9427c8ff93ff47e016R177-R178

The binary successfully creates and finalizes blocks automatically on each extrinsic when run outside Docker. When run as part of docker-compose, however, block creation works but finalization doesn't.

Outside Docker:

2021-11-11 17:45:22 💤 Idle (0 peers), best: #1 (0x3702…0af0), finalized #1 (0x3702…0af0), ⬇ 0 ⬆ 0    
2021-11-11 17:45:22 🙌 Starting consensus session on top of parent 0x3702a6c88dfbc930b9796cef5bcf803d570f060246f4f8fd953e29b449b50af0    
2021-11-11 17:45:23 🎁 Prepared block for proposing at 2 [hash: 0xdcc46347f8d3daf2410e93dab6cc8162b42baf12f142190c3c604ee09bb17e81; parent_hash: 0x3702…0af0; extrinsics (2): [0x3e63…9a4f, 0x2827…abb9]]    
2021-11-11 17:45:23 Possible safety violation: attempted to re-finalize last finalized block 0x3702a6c88dfbc930b9796cef5bcf803d570f060246f4f8fd953e29b449b50af0     
2021-11-11 17:45:23 ✨ Imported #2 (0xdcc4…7e81)    
2021-11-11 17:45:23 Instant Seal success: CreatedBlock { hash: 0xdcc46347f8d3daf2410e93dab6cc8162b42baf12f142190c3c604ee09bb17e81, aux: ImportedAux { header_only: false, clear_justification_requests: false, needs_justification: false, bad_justification: false, is_new_best: true } }    
2021-11-11 17:45:23 Off-chain worker started on block 2    
2021-11-11 17:45:27 💤 Idle (0 peers), best: #2 (0xdcc4…7e81), finalized #2 (0xdcc4…7e81), ⬇ 0 ⬆ 0 

Inside Docker:

2021-11-11 13:52:24 💤 Idle (0 peers), best: #0 (0x4775…32aa), finalized #0 (0x4775…32aa), ⬇ 0 ⬆ 0
2021-11-11 13:52:25 🎁 Prepared block for proposing at 1 [hash: 0x6b25ac78711269aa6961315242eefb624869e63b7d2ac63e8233eed33d9b19b3; parent_hash: 0x4775…32aa; extrinsics (5): [0x846b…4797, 0x1e86…11b1, 0xc87f…9574, 0x1aa1…bdde, 0xb2bd…3d7a]]
2021-11-11 13:52:25 Instant Seal success: CreatedBlock { hash: 0x6b25ac78711269aa6961315242eefb624869e63b7d2ac63e8233eed33d9b19b3, aux: ImportedAux { header_only: false, clear_justification_requests: false, needs_justification: false, bad_justification: false, is_new_best: true } }
2021-11-11 13:52:25 🙌 Starting consensus session on top of parent 0x6b25ac78711269aa6961315242eefb624869e63b7d2ac63e8233eed33d9b19b3    
2021-11-11 13:52:25 ✨ Imported #1 (0x6b25…19b3)    
2021-11-11 13:52:25 Off-chain worker started on block 1 
2021-11-11 13:52:25 Instant Seal encountered an error: Transaction pool is empty, set create_empty to true,if you want to create empty blocks
 2021-11-11 13:52:29 💤 Idle (0 peers), best: #1 (0xb8e2…478a), finalized #0 (0x4775…32aa), ⬇ 0 ⬆ 0
bkchr commented 3 years ago

2021-11-11 13:52:25 Instant Seal encountered an error: Transaction pool is empty, set create_empty to true,if you want to create empty blocks

It prints this error.

sander2 commented 3 years ago

It prints this error.

But we have create_empty set to true already. Also, if we're creating a new block only when a transaction arries, how can the transaction pool be empty at all? If the transaction fails with a dispatch error, would that count as an empty transaction pool?

bkchr commented 3 years ago

I don't know the logic for sure, but maybe there is a bug :D