From eec30131bf484cfd782bdcedb5d50335a7cf95e5 Mon Sep 17 00:00:00 2001 From: Svyatoslav Nikolsky Date: Tue, 18 Oct 2022 12:10:21 +0300 Subject: [PATCH] increase max header size of Rialto and Millau (512 -> 1024) (#1603) --- bridges/modules/grandpa/src/lib.rs | 27 ++++++++++++++++++---- bridges/primitives/chain-millau/src/lib.rs | 2 +- bridges/primitives/chain-rialto/src/lib.rs | 2 +- 3 files changed, 25 insertions(+), 6 deletions(-) diff --git a/bridges/modules/grandpa/src/lib.rs b/bridges/modules/grandpa/src/lib.rs index 37afbf2739ec7..b3801beb6f1f2 100644 --- a/bridges/modules/grandpa/src/lib.rs +++ b/bridges/modules/grandpa/src/lib.rs @@ -517,12 +517,31 @@ pub mod pallet { ) -> Result<(), Error> { let super::InitializationData { header, authority_list, set_id, operating_mode } = init_params; + let authority_set_length = authority_list.len(); let authority_set = StoredAuthoritySet::::try_new(authority_list, set_id) - .map_err(|_| Error::TooManyAuthoritiesInSet)?; - let header = StoredBridgedHeader::::try_from_inner(*header) - .map_err(|_| Error::::TooLargeHeader)?; - + .map_err(|_| { + log::error!( + target: LOG_TARGET, + "Failed to initialize bridge. Number of authorities in the set {} is larger than the configured value {}", + authority_set_length, + T::MaxBridgedAuthorities::get(), + ); + + Error::TooManyAuthoritiesInSet + })?; let initial_hash = header.hash(); + let header = StoredBridgedHeader::::try_from_inner(*header).map_err(|e| { + log::error!( + target: LOG_TARGET, + "Failed to initialize bridge. Size of header {:?} ({}) is larger that the configured value {}", + initial_hash, + e.value_size, + e.maximal_size, + ); + + Error::::TooLargeHeader + })?; + >::put(initial_hash); >::put(0); insert_header::(header, initial_hash); diff --git a/bridges/primitives/chain-millau/src/lib.rs b/bridges/primitives/chain-millau/src/lib.rs index 60fe21884487e..e63903aff7d57 100644 --- a/bridges/primitives/chain-millau/src/lib.rs +++ b/bridges/primitives/chain-millau/src/lib.rs @@ -113,7 +113,7 @@ pub const SESSION_LENGTH: BlockNumber = 5 * time_units::MINUTES; pub const MAX_AUTHORITIES_COUNT: u32 = 5; /// Maximal SCALE-encoded header size (in bytes) at Millau. -pub const MAX_HEADER_SIZE: u32 = 512; +pub const MAX_HEADER_SIZE: u32 = 1024; /// Re-export `time_units` to make usage easier. pub use time_units::*; diff --git a/bridges/primitives/chain-rialto/src/lib.rs b/bridges/primitives/chain-rialto/src/lib.rs index 257e94d0273c2..d87e82e78a2ff 100644 --- a/bridges/primitives/chain-rialto/src/lib.rs +++ b/bridges/primitives/chain-rialto/src/lib.rs @@ -104,7 +104,7 @@ pub const SESSION_LENGTH: BlockNumber = 4; pub const MAX_AUTHORITIES_COUNT: u32 = 5; /// Maximal SCALE-encoded header size (in bytes) at Rialto. -pub const MAX_HEADER_SIZE: u32 = 512; +pub const MAX_HEADER_SIZE: u32 = 1024; /// Maximal SCALE-encoded size of parachains headers that are stored at Rialto `Paras` pallet. pub const MAX_NESTED_PARACHAIN_HEAD_SIZE: u32 = MAX_HEADER_SIZE;