Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fixed GrandpaConsensusLogReader::find_scheduled_change #4208

Merged
merged 1 commit into from
Apr 19, 2024

Conversation

svyatonik
Copy link
Contributor

@svyatonik svyatonik commented Apr 19, 2024

The issue is here:

		// find the first consensus digest with the right ID which converts to
		// the right kind of consensus log.
		digest
			.convert_first(|log| log.consensus_try_to(&GRANDPA_ENGINE_ID))
			.and_then(|log| match log {
				ConsensusLog::ScheduledChange(change) => Some(change),
				_ => None,
			})

Correct code should be like that (see https://github.com/paritytech/parity-bridges-common/blob/ff8840b1ad043c5ae90a527e46c0dbd217e1b436/primitives/header-chain/src/lib.rs#L84-L93):

	let id = OpaqueDigestItemId::Consensus(&GRANDPA_ENGINE_ID);

	let filter_log = |log: ConsensusLog<H::Number>| match log {
		ConsensusLog::ScheduledChange(change) => Some(change),
		_ => None,
	};

	// find the first consensus digest with the right ID which converts to
	// the right kind of consensus log.
	header.digest().convert_first(|l| l.try_to(id).and_then(filter_log))

As you see, the incorrect code gets first GRANDPA digest item and tries to parse it as ScheduledChange.
The correct code tries to find first GRANDPA digest item which is ScheduledChange.

The issue is that on Kusama there are mandatory headers with digest: [Consensus(GRANDPA_ENGINE_ID, ConsensusLog::OnDisabled(_)), Consensus(GRANDPA_ENGINE_ID, ConsensusLog::ScheduledChange(_))]. So the incorrect code finds first item (OnDisabled) and ignores the actual ScheduledChange. IIUC this OnDisabled happens when validator is slashed (so staking involved), so we haven't seen it on Rialto/Millau/Rococo/Westend.

What happens:

  1. relayer: scans Kusama headers for those with ScheduledChange, but they are not detected => it skips such headers and proceeds to next mandatiry. Next mandatory is signed by different authority set => it fails to optimize justification (because it removes invalid signatures and all signatures are invalid here)
  2. what I've tried: I've fixed the relayer code and submitted such header to pallet_bridge_grandpa. I thought it should have solved our issue, but...
  3. the on-chain code: has received that header and applied incorrect code => so it has not found the authorities set change => the set has stayed the same. So now it does not accept next mandatory header, because it is signed by the different authorities set.

The only possible fix is to upgrade bridge hub runtime. We can't do set_storage to fix teh authorities set, because SafeCallFilter supports limited number of storage entries that can be modified this way.

@svyatonik svyatonik added R0-silent Changes should not be mentioned in any release notes T15-bridges This PR/Issue is related to bridges. labels Apr 19, 2024
@svyatonik svyatonik requested a review from a team April 19, 2024 08:10
@svyatonik svyatonik enabled auto-merge April 19, 2024 08:13
@svyatonik svyatonik added this pull request to the merge queue Apr 19, 2024
Merged via the queue into master with commit 21308d8 Apr 19, 2024
143 of 146 checks passed
@svyatonik svyatonik deleted the sv-fix-search-for-scheduled-change branch April 19, 2024 08:58
@Polkadot-Forum
Copy link

This pull request has been mentioned on Polkadot Forum. There might be relevant details there:

https://forum.polkadot.network/t/polkadot-kusama-bridge/2971/45

fellowship-merge-bot bot pushed a commit to polkadot-fellows/runtimes that referenced this pull request Apr 19, 2024
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]>
bkchr added a commit to polkadot-fellows/runtimes that referenced this pull request Apr 19, 2024
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]>
@acatangiu
Copy link
Contributor

This needed a prdoc instead of "silent"

@svyatonik
Copy link
Contributor Author

This needed a prdoc instead of "silent"

I've added it for 4209, but it is in a release branch, so copied here: #4239

@svyatonik svyatonik removed the R0-silent Changes should not be mentioned in any release notes label Apr 22, 2024
@kianenigma
Copy link
Contributor

so we haven't seen it on Rialto/Millau/Rococo/Westend.

We can use the pallet-root-offences that have been built for more or less this purpose to make sure on all testnets we have regularly slash a random set of validators. Even if not with this pallet, I think, we can easily scarp together the code to do this.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T15-bridges This PR/Issue is related to bridges.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants