paritytech / polkadot-sdk

The Parity Polkadot Blockchain SDK
https://polkadot.com/
1.89k stars 697 forks source link

Revert to latest finalized doesn't work #5452

Open penumbra23 opened 2 months ago

penumbra23 commented 2 months ago

Is there an existing issue?

Experiencing problems? Have you tried our Stack Exchange first?

Description of bug

HI folks!

We have a running testnet babe/grandpa + some custom pallets. Our chain faced a finalization issue so I wanted to revert some blocks back to restore it.

Running chain-info gives me this:

{
  "best_hash": "0x0553bc04843513fb40fb15b6c010dcf173845a1d6e1bb095b93699332a8ab84e",
  "best_number": 1782944,
  "genesis_hash": "0x0614f7b74a2e47f7c8d8e2a5335be84bdde9402a43f5decdec03200a87c8b943",
  "finalized_hash": "0xde95600c420eff7415a9ff4f14afb8ea06981922f9705d31b5758db6f9c734d9",
  "finalized_number": 1771893
}

After that when I run revert for 10,000 blocks, it says:

Reverted 4097 blocks. Best: #1778852 (0x1f26…dece)

The chain-info after that is:

{
  "best_hash": "0x1f267544dc7e92d8bc34ac0b176d7cd3e32091fe27e6a3c538c3ff3ec29ddece",
  "best_number": 1778852,
  "genesis_hash": "0x0614f7b74a2e47f7c8d8e2a5335be84bdde9402a43f5decdec03200a87c8b943",
  "finalized_hash": "0xde95600c420eff7415a9ff4f14afb8ea06981922f9705d31b5758db6f9c734d9",
  "finalized_number": 1771893
}

I get why reverting finalized blocks doesn't work, there is an issue in the old repo already, but why isn't it reverting un-finalized blocks still?

Steps to reproduce

No response

bkchr commented 2 months ago

Is this a pruned node? Or an archive node?

penumbra23 commented 2 months ago

@bkchr It's a prunned node running as a validator, the prunning factor is 10.000 blocks.

bkchr commented 2 months ago

Okay. 4096 is the default force canonicalization window. I assume there is some bug around this.

bkchr commented 2 months ago

After looking a little bit more into it. The problem being the force canonicalization as I mentioned above. We prune the blocks and thus, we can not revert to them anymore.