You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
So as I assumed on_initialize() function should has been executed ONCE and BEFORE on_finalize() function.
I have been spamming substrate node with the abci_transaction extrinsic.
But I have got the following log:
2020-10-23 11:03:48.118 http.worker10 INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.123 http.worker10 INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.129 http.worker10 WARN txpool (offchain call) Error submitting a transaction to the pool: Pool(AlreadyImported(Any))
2020-10-23 11:03:48.130 http.worker10 ERROR node_template_runtime Failed to broadcast deliver_tx transaction, error: ()
2020-10-23 11:03:48.243 http.worker20 INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.247 http.worker20 INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.255 http.worker20 WARN txpool (offchain call) Error submitting a transaction to the pool: Pool(AlreadyImported(Any))
2020-10-23 11:03:48.255 http.worker20 ERROR node_template_runtime Failed to broadcast deliver_tx transaction, error: ()
2020-10-23 11:03:48.278 tokio-runtime-worker INFO sc_basic_authorship::basic_authorship 🙌 Starting consensus session on top of parent 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4
2020-10-23 11:03:48.282 tokio-blocking-driver INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.290 tokio-blocking-driver INFO pallet_cosmos_abci on_finalize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.297 tokio-blocking-driver INFO sc_basic_authorship::basic_authorship 🎁 Prepared block for proposing at 5 [hash: 0x5f08415120dcd51327713a1d03d1ab00fc96c762e0947536f5c5d34ee4345e54; parent_hash: 0x43e9…5aa4; extrinsics (2): [0x973e…f7ee, 0x35eb…5bb6]]
2020-10-23 11:03:48.399 http.worker00 INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.407 http.worker00 INFO pallet_cosmos_abci on_initialize(), block_number: 5, block_hash: 0x0000000000000000000000000000000000000000000000000000000000000000, parent_hash: 0x43e9ee424ed88ce8c2a0232bbd39b4a78bc0db5e0f95b301b621347313585aa4, extrinsics_root: 0x0000000000000000000000000000000000000000000000000000000000000000
2020-10-23 11:03:48.417 http.worker00 WARN txpool (offchain call) Error submitting a transaction to the pool: Pool(AlreadyImported(Any))
So you can see that:
on_initialize() function has executed more than ONCE.
on_initialize() function for the block 5 has been executed AFTER on_finalize() function. It seems like bug.
during the processing on_initialize() and on_finalize() functions I can not get the block hash of the current block, and extrinsics root hash, returns "0x0000000000000000000000000000000000000000000000000000000000000000".
Here is what I have learned about the questions you asked:
on_initialize is called any time that a runtime function is called from the client, so it is normal to see multiple calls to on_initialize.
There is no guarantee that on_finalize will execute after on_initialize.
on_initialize and on_finalize are called before the block hash and extrinsic root are calculated so it is expected that you would not be able to access them in either function; these values are calculated immediately after calling on_finalize.
Can you please close this Issue if you don't have any follow-up questions?
I have developed on substrate and I have faced withed some interesting behaviour.
I have the following code of my module:
So as I assumed on_initialize() function should has been executed ONCE and BEFORE on_finalize() function.
I have been spamming substrate node with the abci_transaction extrinsic.
But I have got the following log:
So you can see that:
Maybe someone can comment something on it ?
Here is the full log from the Substrate:
The text was updated successfully, but these errors were encountered: