Skip to content

State-provisioning must flush parentchain import queue and set last imported parentchain header #1366

@clangenb

Description

@clangenb

I have yet to conclude my analysis, but I think I found the cause of the failing integration tests in #1337.

As noted in #1337 (comment), w2 imports some missing parentchain blocks before importing the sidechain block. However, the imported blocks are [0...=n], where n is the layer_one_head denoted in the to be imported sidechain block.

This means, we import blocks that are already included in the provisioned sidechain state, and re-apply them. My current guess is that by chance this did not lead to state transitions pre polkadot-0.9.42 such that we did not note that bug before.

Logs observed on #1337 with the following log-levels:

'itp_stf_state_handler=debug,'
'its_consensus_common=debug,'
'its_consensus_aura=trace,'
'itc_parentchain_block_importer=debug,'
[Attempting to import sidechain block (number: 36, hash: 0xaf8bb6dbed80fd8cef2471b0e8d263c567b1285be4591097137c9a2944d98501, parentchain hash: 0x56fc141a2895a1cc2c738193cc13714dfe8ee5913b03ed889cdc0134df72b3ef)
[2023-06-15T14:32:14Z [DEBUG its_consensus_aura::block_importer] Peeking parentchain header
[2023-06-15T14:32:14Z [DEBUG its_consensus_aura::block_importer] sidechain block parentchain head: 0x56fc…b3ef
[2023-06-15T14:32:14Z [DEBUG its_consensus_aura::block_importer] last imported head: 0xc0f2…4314, number: 0, parenthash: 0x0000…0000
[2023-06-15T14:32:14Z [WARN  its_consensus_common::peer_block_sync] Got ancestry mismatch error upon block import. Attempting to fetch missing blocks from peer
[2023-06-15T14:32:14Z [INFO  its_consensus_common::peer_block_sync] Initiating fetch blocks from peer, last imported block hash: 0xb529cac5cec61d2e5281457c5ebd2edc350f03d1bd0914016a89e9454474f4db, until block hash: 0xaf8bb6dbed80fd8cef2471b0e8d263c567b1285be4591097137c9a2944d98501
[2023-06-15T14:32:14Z [INFO  its_consensus_common::peer_block_sync] Fetched 20 blocks from peer to import
[2023-06-15T14:32:14Z [DEBUG its_consensus_common::block_import] Attempting to import sidechain block (number: 16, hash: 0x95f38e6d6f1ff7d3a237562721828df06bced3e3ec8d14ad3db6ab2824814059, parentchain hash: 0x598897bfe33c9fdf5d9d3e9386121f7ec6476b7b6f3374b51469a1c3485a6c86)
[2023-06-15T14:32:14Z [DEBUG its_consensus_aura::block_importer] Peeking parentchain header
[2023-06-15T14:32:14Z [DEBUG its_consensus_aura::block_importer] sidechain block parentchain head: 0x5988…6c86
[2023-06-15T14:32:14Z [DEBUG its_consensus_aura::block_importer] last imported head: 0xc0f2…4314, number: 0, parenthash: 0x0000…0000
[2023-06-15T14:32:14Z [DEBUG itc_parentchain_block_importer::block_importer]Import blocks to light-client!
[2023-06-15T14:32:14Z [DEBUG itp_stf_state_handler::state_handler] Writing state
[2023-06-15T14:32:14Z [INFO  itc_parentchain_block_importer::block_importer] Successfully imported parentchain block (number: 1, hash: 0xfa79…7982)
[2023-06-15T14:32:14Z [DEBUG itp_stf_state_handler::state_handler] Writing state
[2023-06-15T14:32:14Z [INFO  itc_parentchain_block_importer::block_importer] Successfully imported parentchain block (number: 2, hash: 0xbe75…c85e)
[2023-06-15T14:32:14Z [DEBUG itp_stf_state_handler::state_handler] Writing state
[2023-06-15T14:32:14Z [INFO  itc_parentchain_block_importer::block_importer] Successfully imported parentchain block (number: 3, hash: 0x5776…8966)
[2023-06-15T14:32:14Z [DEBUG itp_stf_state_handler::state_handler] Writing state
[2023-06-15T14:32:14Z [INFO  itc_parentchain_block_importer::block_importer] Successfully imported parentchain block (number: 4, hash: 0x5988…6c86)
[2023-06-15T14:32:14Z [INFO  its_consensus_common::block_import] Applying state diff for block 16 of size 219 bytes
[2023-06-15T14:32:14Z [ERROR its_consensus_common::peer_block_sync] Failed to import sidechain block that was fetched from peer: Other(InvalidAprioriHash)
[2023-06-15T14:32:14Z enclave_runtime::error] Returning error Consensus(Other(InvalidAprioriHash)) as sgx unexpected.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions