Skip to content

Commit 881af02

Browse files
authored
increase MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX and MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX for RBH/WBH (#1765)
* increase MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX and MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX for RBH/WBH * moved MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX and MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX to cumulus bridge primitives * typo
1 parent 41d91e9 commit 881af02

File tree

2 files changed

+30
-10
lines changed
  • primitives

2 files changed

+30
-10
lines changed

primitives/chain-bridge-hub-cumulus/src/lib.rs

Lines changed: 30 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,7 @@ use bp_messages::*;
2020
pub use bp_polkadot_core::{
2121
AccountId, AccountInfoStorageMapKeyProvider, AccountPublic, Balance, BlockNumber, Hash, Hasher,
2222
Hashing, Header, Index, Nonce, Perbill, Signature, SignedBlock, SignedExtensions,
23-
UncheckedExtrinsic, MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX,
24-
MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX, TX_EXTRA_BYTES,
23+
UncheckedExtrinsic, TX_EXTRA_BYTES,
2524
};
2625
use frame_support::{
2726
dispatch::DispatchClass,
@@ -85,3 +84,32 @@ pub type AccountSigner = MultiSigner;
8584

8685
/// The address format for describing accounts.
8786
pub type Address = MultiAddress<AccountId, ()>;
87+
88+
// Note about selecting values of two following constants:
89+
//
90+
// Normal transactions have limit of 75% of 1/2 second weight for Cumulus parachains. Let's keep
91+
// some reserve for the rest of stuff there => let's select values that fit in 50% of maximal limit.
92+
//
93+
// Using current constants, the limit would be:
94+
//
95+
// `75% * WEIGHT_REF_TIME_PER_SECOND * 1 / 2 * 50% = 0.75 * 1_000_000_000_000 / 2 * 0.5 =
96+
// 187_500_000_000`
97+
//
98+
// According to (preliminary) weights of messages pallet, cost of additional message is zero and the
99+
// cost of additional relayer is `8_000_000 + db read + db write`. Let's say we want no more than
100+
// 4096 unconfirmed messages (no any scientific justification for that - it just looks large
101+
// enough). And then we can't have more than 4096 relayers. E.g. for 1024 relayers is (using
102+
// `RocksDbWeight`):
103+
//
104+
// `1024 * (8_000_000 + db read + db write) = 1024 * (8_000_000 + 25_000_000 + 100_000_000) =
105+
// 136_192_000_000`
106+
//
107+
// So 1024 looks like good approximation for the number of relayers. If something is wrong in those
108+
// assumptions, or something will change, it shall be caught by the
109+
// `ensure_able_to_receive_confirmation` test.
110+
111+
/// Maximal number of unrewarded relayer entries at inbound lane for Cumulus-based parachains.
112+
pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 1024;
113+
114+
/// Maximal number of unconfirmed messages at inbound lane for Cumulus-based parachains.
115+
pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 4096;

primitives/polkadot-core/src/lib.rs

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -118,14 +118,6 @@ parameter_types! {
118118
/// Maximal number of messages in single delivery transaction.
119119
pub const MAX_MESSAGES_IN_DELIVERY_TRANSACTION: MessageNonce = 128;
120120

121-
/// Maximal number of unrewarded relayer entries at inbound lane.
122-
pub const MAX_UNREWARDED_RELAYERS_IN_CONFIRMATION_TX: MessageNonce = 128;
123-
124-
// TODO [#438] should be selected keeping in mind:
125-
// finality delay on both chains + reward payout cost + messages throughput.
126-
/// Maximal number of unconfirmed messages at inbound lane.
127-
pub const MAX_UNCONFIRMED_MESSAGES_IN_CONFIRMATION_TX: MessageNonce = 8192;
128-
129121
/// Maximal number of bytes, included in the signed Polkadot-like transaction apart from the encoded
130122
/// call itself.
131123
///

0 commit comments

Comments
 (0)