I've reproduced my tests with latest changes to constants + estimations:
- cost of Polkadot -> Kusama message: 2.40 DOT
- cost of Kusama -> Polkadot message: 0.40 KSM
Details for Polkadot -> Kusama message:
- cost of XCM execution at Polkadot BH: 0.48 DOT
- cost of message delivery transaction at Kusama BH: 0.3 DOT (converted from 0.06 KSM)
- cost of delivery confirmation transaction at Polkadot BH: 1.62 DOT
Details for Kusama -> Polkadot message:
- cost of XCM execution at Kusama BH: 0.02 KSM
- cost of message delivery transaction at Polkadot BH: 0.34 KSM (converted from 1.7 DOT)
- cost of delivery confirmation transaction at Kusama AH: 0.05 DOT
Every cost from above has 33% reserve. So actual test result is X * 3 / 4
.
Details of XCM execution estimations: https://github.com/paritytech/polkadot-sdk/blob/ce1c9a44a79841ee03878be9710ac49401c71aa6/cumulus/parachains/runtimes/bridge-hubs/test-utils/src/test_cases/mod.rs#L570-L673. TLDR: it is an execution cost (WeightToFee(XcmWeight(<program>))
) of a regular program that is executed at BH when reserve_asset_transfer
is called at AH.
Details of message delivery transaction estimation:
- delivered message (XCM) is assumed to be 1K. The storage proof overhead is minimal;
- proved parachain head (BH header) is minimal. The storage proof overhead is minimal;
- proved relay chain header + justification is assumed to be the max refundable amount that we are paying to relayer in GRANDPA pallet. So it is a
AVERAGE_HEADER_SIZE
+ justification size that is computed assuming twoAVERAGE_HEADER_SIZE
-byte headers in the ancestry proof + signatures of838
validators.
Details of delivery confirmation transaction:
- delivery proof and storage proof overhead is assumed to be minimal;
- proved parachain head (BH header) is minimal. The storage proof overhead is minimal;
- proved relay chain header + justification is assumed to be the max refundable amount that we are paying to relayer in GRANDPA pallet. So it is a
AVERAGE_HEADER_SIZE
+ justification size that is computed assuming twoAVERAGE_HEADER_SIZE
-byte headers in the ancestry proof + signatures of838
validators.
AVERAGE_HEADER_SIZE
is set to 1_024
, even though normally it is 327
. 838
is the MAX_AUTHORITIES_COUNT * 2/3+1
, where MAX_AUTHORITIES_COUNT
is set to 1_256
. Actual (atm) authorities count at Polkadot is ~300. Actual (atm) authorities count at Kusama is 1000.
First things that catches the eye:
- Polkadot BH transactions are much more expensive than Kusama AH. E.g. delivery is 0.3 DOT for Polkadot->Kusama messages and 1.7 DOT for Kusama->Polkadot messages;
- the biggest fee share comes from the GRANDPA justification size (i.e. not from the execution weight). If, say, we set justification size to zero, then e.g. cost of Kusama -> Polkadot message delivery transaction drops from 1.27 DOTs to 0.13 DOTs. And within justification, signatures are occupying 99% - they're ~100Kb alone;
- maybe we have too many reserves in our constants. E.g.
MAX_AUTHORITIES_COUNT
is set to1_256
, when actually at Polkadot there are300
authorities. Then after using this constant to compute cost of delivery transaction, we add another33%
.
updated write-up:
paritytech/parity-bridges-common#2871