Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Unstuck Polkadot<>Kusama bridge (polkadot-fellows#277)
The `pallet_bridge_grandpa` at Polkadot Bridge Hub is now in inconsistent state, because of: paritytech/polkadot-sdk#4208. This PR does three thinds: 1) bumps `bp_header_chain` dependency to avoid having this issue in the future; 2) adds an upgrade to Polkadot BH, which will fix the `pallet_bridge_grandpa::CurrentAuthoritySet` storage value; 3) changes `SafeXcmFilter` to allow changing `pallet_bridge_grandpa::CurrentAuthoritySet` using `set_storage` call in the future. We'll need to do a patch release and upgrade Polkadot and Kusama BH. I've created this PR for master branch, but we can fork off from `1.2.0` tag and duplicate it there. Below some tests that are reproducible, so anyone can check it --- How to ensure that current Polkadot BH is broken: 1) download/clone https://github.com/AcalaNetwork/chopsticks/blob/master/configs/polkadot-bridge-hub.yml; 2) start chopsticks: `npx @acala-network/chopsticks@latest xcm -r polkadot -p configs/polkadot-bridge-hub.yml -p polkadot-bridge-hub`; 3) start `substrate-relay` (`cargo build -p substrate-relay` in `https://github.com/paritytech/parity-bridges-common/`): ```sh RUST_LOG=bridge=trace ./target/release/substrate-relay relay-headers kusama-to-bridge-hub-polkadot \ --source-uri wss://apps-kusama-rpc.polkadot.io:443 \ --source-version-mode Auto \ --target-uri ws://localhost:8000 \ --target-version-mode Auto \ --target-signer //Alice \ --target-transactions-mortality 16 \ --only-mandatory-headers ``` 4) wait and see that it fails: ```sh 2024-04-19 13:26:10 +00 INFO bridge Connecting to Kusama node at wss://apps-kusama-rpc.polkadot.io:443 2024-04-19 13:26:10 +00 INFO bridge Connecting to BridgeHubPolkadot node at ws://localhost:8000 2024-04-19 13:26:10 +00 INFO bridge Exposed substrate_relay_build_info metric: version=0.1.0 commit=bb7d2186d6-clean 2024-04-19 13:26:10 +00 INFO bridge Starting Kusama -> BridgeHubPolkadot finality proof relay 2024-04-19 13:26:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=0.000064708678110037, memory=29766975488 2024-04-19 13:26:10 +00 TRACE bridge-metrics Starting prometheus endpoint at: 127.0.0.1:9616 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:26:10 +00 WARN bridge Kusama finality proofs stream is being started / restarted [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:26:11 +00 INFO bridge Synced 22780167 of 22807058 headers [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:26:11 +00 TRACE bridge Considering range of headers (22780167; 22807058] 2024-04-19 13:26:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.3793294429779053, memory=47601156096 2024-04-19 13:26:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=1.91074800491333, memory=48406462464 2024-04-19 13:26:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.21091628074646, memory=48406462464 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:26:50 +00 TRACE bridge Header 22780416 has persistent finality proof 2024-04-19 13:26:50 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.7086338996887207, memory=59814969344 2024-04-19 13:27:00 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.6120808124542236, memory=59949187072 2024-04-19 13:27:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.3101067543029785, memory=65183678464 2024-04-19 13:27:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.5125627517700195, memory=65183678464 2024-04-19 13:27:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.8137168884277344, memory=65183678464 2024-04-19 13:27:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.511143207550049, memory=65183678464 2024-04-19 13:27:50 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.5087807178497314, memory=65183678464 2024-04-19 13:28:00 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.6122448444366455, memory=65183678464 2024-04-19 13:28:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=3.0101592540740967, memory=65183678464 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:28:12 +00 TRACE bridge Header 22780928 has persistent finality proof 2024-04-19 13:28:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=1.8107513189315796, memory=68807557120 2024-04-19 13:28:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.713397264480591, memory=68807557120 2024-04-19 13:28:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.4137279987335205, memory=68807557120 2024-04-19 13:28:50 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.9156715869903564, memory=68807557120 2024-04-19 13:29:00 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.1125431060791016, memory=68807557120 2024-04-19 13:29:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.113739252090454, memory=68807557120 2024-04-19 13:29:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.2080039978027344, memory=68807557120 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:29:30 +00 TRACE bridge Header 22781365 is mandatory [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:29:30 +00 DEBUG bridge Going to submit finality proof of Kusama header #22781365 to BridgeHubPolkadot [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:29:30 +00 ERROR bridge Finality sync loop iteration has failed with error: Target(Custom("Failed to optimize Kusama GRANDPA jutification for header HeaderId(22781365, 0x412ee6710afc4b2a835f31c7139bc0697845256d7e39ee77ace2a09c04b4e2d1): Error::TooLowCumulativeWeight")) ``` How to ensure that the fix works: 1) build upgraded Polkadot BH runtime: ```sh srtool build --root --package bridge-hub-polkadot-runtime --runtime-dir system-parachains/bridge-hubs/bridge-hub-polkadot/ ``` 2) download/clone https://github.com/AcalaNetwork/chopsticks/blob/master/configs/polkadot-bridge-hub.yml; 3) "patch" yml file ^^^ by adding: ``` wasm-override: /home/svyatonik/dev/runtimes/system-parachains/bridge-hubs/bridge-hub-polkadot/target/srtool/release/wbuild/bridge-hub-polkadot-runtime/bridge_hub_polkadot_runtime.compact.compressed.wasm ``` 4) start chopsticks: `npx @acala-network/chopsticks@latest xcm -r polkadot -p configs/polkadot-bridge-hub.yml -p polkadot-bridge-hub`; 5) the runtime is not yet upgraded - go to https://polkadot.js.org/apps/?rpc=ws%3A%2F%2Flocalhost%3A8000#/chainstate and check that `bridgeKusamaGrandpa.currentAuthoritySet.setId` is 8905; 6) upgrade BH runtime (and run migrations): ```sh wscat -c ws://127.0.0.1:8002 -x '{ "jsonrpc": "2.0", "id": 1, "method": "dev_newBlock", "params": [{"count": 1 }] }' wscat -c ws://127.0.0.1:8000 -x '{ "jsonrpc": "2.0", "id": 1, "method": "dev_newBlock", "params": [{"count": 1 }] }' ``` 7) go to https://polkadot.js.org/apps/?rpc=ws%3A%2F%2Flocalhost%3A8000#/chainstate and check that `bridgeKusamaGrandpa.currentAuthoritySet.setId` is changed to 8906; 8) start **fixed** `substrate-relay` (soon to be updated: `cargo build -p substrate-relay` in `https://github.com/paritytech/parity-bridges-common/`): ```sh RUST_LOG=bridge=trace ./target/release/substrate-relay relay-headers kusama-to-bridge-hub-polkadot \ --source-uri wss://apps-kusama-rpc.polkadot.io:443 \ --source-version-mode Auto \ --target-uri ws://localhost:8000 \ --target-version-mode Auto \ --target-signer //Alice \ --target-transactions-mortality 16 \ --only-mandatory-headers ``` 9) wait and see that it works: ```sh 024-04-19 13:36:09 +00 INFO bridge Connecting to Kusama node at wss://apps-kusama-rpc.polkadot.io:443 2024-04-19 13:36:10 +00 INFO bridge Connecting to BridgeHubPolkadot node at ws://localhost:8000 2024-04-19 13:36:10 +00 INFO bridge Exposed substrate_relay_build_info metric: version=0.1.0 commit=bb7d2186d6-clean 2024-04-19 13:36:10 +00 INFO bridge Starting Kusama -> BridgeHubPolkadot finality proof relay 2024-04-19 13:36:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=0, memory=29938941952 2024-04-19 13:36:10 +00 TRACE bridge-metrics Starting prometheus endpoint at: 127.0.0.1:9616 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:36:10 +00 WARN bridge Kusama finality proofs stream is being started / restarted [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:36:11 +00 INFO bridge Synced 22780167 of 22807159 headers [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:36:11 +00 TRACE bridge Considering range of headers (22780167; 22807159] 2024-04-19 13:36:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.193419933319092, memory=45940211712 2024-04-19 13:36:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.3150477409362793, memory=45940211712 2024-04-19 13:36:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.6142148971557617, memory=52919533568 2024-04-19 13:36:50 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.4085805416107178, memory=54932799488 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:36:51 +00 TRACE bridge Header 22780416 has persistent finality proof 2024-04-19 13:37:00 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.7103331089019775, memory=58690895872 2024-04-19 13:37:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.608804702758789, memory=58690895872 2024-04-19 13:37:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.9072680473327637, memory=58690895872 2024-04-19 13:37:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.810892343521118, memory=58690895872 2024-04-19 13:37:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.810363292694092, memory=62046339072 2024-04-19 13:37:50 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.91256046295166, memory=62046339072 2024-04-19 13:38:00 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.8086013793945313, memory=62046339072 2024-04-19 13:38:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.9083614349365234, memory=64864911360 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:38:18 +00 TRACE bridge Header 22780928 has persistent finality proof 2024-04-19 13:38:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=3.109522819519043, memory=68354572288 2024-04-19 13:38:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=3.2074172496795654, memory=68354572288 2024-04-19 13:38:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.90763258934021, memory=68354572288 2024-04-19 13:38:50 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.9101855754852295, memory=68354572288 2024-04-19 13:39:00 +00 TRACE bridge-metrics Refreshed process metrics: CPU=3.0146965980529785, memory=68354572288 2024-04-19 13:39:10 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.6119167804718018, memory=68354572288 2024-04-19 13:39:20 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.3114125728607178, memory=68354572288 2024-04-19 13:39:30 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.811950922012329, memory=68354572288 2024-04-19 13:39:40 +00 TRACE bridge-metrics Refreshed process metrics: CPU=2.3072102069854736, memory=68354572288 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:39:46 +00 TRACE bridge Header 22781365 is mandatory [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:39:46 +00 DEBUG bridge Going to submit finality proof of Kusama header #22781365 to BridgeHubPolkadot 2024-04-19 13:39:46 +00 TRACE bridge Sent transaction to BridgeHubPolkadot node: 0x0d7a80fec36ede67860f89028fb336009f82fef406ca31adaafcae54fa067e0d [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:39:48 +00 TRACE bridge BridgeHubPolkadot transaction 0x0d7a80fec36ede67860f89028fb336009f82fef406ca31adaafcae54fa067e0d has been included in block: (0xedf5af02e37da014a5b8e53325821f3618d80f1c75b62105aada4b6506919156, 0) [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:39:48 +00 TRACE bridge BridgeHubPolkadot transaction 0x0d7a80fec36ede67860f89028fb336009f82fef406ca31adaafcae54fa067e0d has been finalized at block: 0xedf5af02e37da014a5b8e53325821f3618d80f1c75b62105aada4b6506919156 [Kusama_to_BridgeHubPolkadot_Sync] 2024-04-19 13:39:49 +00 INFO bridge Synced 22781365 of 22807194 headers ``` 10) you can check Polkadot BH state and see that the new `bestFinalized` is `22781365`. --------- Co-authored-by: Adrian Catangiu <[email protected]> Co-authored-by: Bastian Köcher <[email protected]>
- Loading branch information