mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-06-11 08:21:05 +00:00
Unify maximum supported PoV size a bit. (#2691)
* Unify maximum supported PoV size a bit. * Use MAX_POV_SIZE also in `HostConfiguration`. * Fix types.
This commit is contained in:
@@ -36,6 +36,7 @@ use std::borrow::Cow;
|
||||
use std::time::Duration;
|
||||
|
||||
use futures::channel::mpsc;
|
||||
use polkadot_primitives::v1::MAX_COMPRESSED_POV_SIZE;
|
||||
use strum::EnumIter;
|
||||
|
||||
pub use sc_network::config as network;
|
||||
@@ -99,10 +100,7 @@ impl Protocol {
|
||||
Protocol::CollationFetching => RequestResponseConfig {
|
||||
name: p_name,
|
||||
max_request_size: 10_000,
|
||||
/// Collations are expected to be around 10Meg, probably much smaller with
|
||||
/// compression. So 30Meg should be well sufficient, we might be able to reduce
|
||||
/// this further, if needed.
|
||||
max_response_size: 30_000_000,
|
||||
max_response_size: MAX_COMPRESSED_POV_SIZE as u64,
|
||||
// Taken from initial implementation in collator protocol:
|
||||
request_timeout: DEFAULT_REQUEST_TIMEOUT_CONNECTED,
|
||||
inbound_queue: Some(tx),
|
||||
|
||||
@@ -25,7 +25,7 @@ use kusama_runtime as kusama;
|
||||
use pallet_im_online::sr25519::AuthorityId as ImOnlineId;
|
||||
use pallet_staking::Forcing;
|
||||
use polkadot::constants::currency::DOTS;
|
||||
use polkadot_primitives::v1::{AccountId, AccountPublic, ValidatorId, AssignmentId};
|
||||
use polkadot_primitives::v1::{AccountId, AccountPublic, AssignmentId, MAX_POV_SIZE, ValidatorId};
|
||||
use polkadot_runtime as polkadot;
|
||||
use rococo_runtime as rococo;
|
||||
use rococo_runtime::constants::currency::DOTS as ROC;
|
||||
@@ -877,7 +877,7 @@ fn rococo_staging_testnet_config_genesis(wasm_binary: &[u8]) -> rococo_runtime::
|
||||
validation_upgrade_delay: 300,
|
||||
acceptance_period: 1200,
|
||||
max_code_size: 5 * 1024 * 1024,
|
||||
max_pov_size: 50 * 1024 * 1024,
|
||||
max_pov_size: MAX_POV_SIZE,
|
||||
max_head_data_size: 32 * 1024,
|
||||
group_rotation_frequency: 20,
|
||||
chain_availability_period: 4,
|
||||
|
||||
@@ -458,6 +458,17 @@ impl PoV {
|
||||
#[derive(Clone, Encode, Decode, PartialEq, Eq)]
|
||||
pub struct CompressedPoV(Vec<u8>);
|
||||
|
||||
/// Maximum PoV size we support right now.
|
||||
pub const MAX_POV_SIZE: u32 = 50 * 1024 * 1024;
|
||||
|
||||
/// Very conservative (compression ratio of 1).
|
||||
///
|
||||
/// Experiments showed that we have a typical compression ratio of 3.4.
|
||||
/// https://github.com/ordian/bench-compression-algorithms/
|
||||
///
|
||||
/// So this could be reduced if deemed necessary.
|
||||
pub const MAX_COMPRESSED_POV_SIZE: u32 = MAX_POV_SIZE;
|
||||
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq, thiserror::Error)]
|
||||
#[cfg(feature = "std")]
|
||||
#[allow(missing_docs)]
|
||||
@@ -490,13 +501,12 @@ impl CompressedPoV {
|
||||
#[cfg(not(target_os = "unknown"))]
|
||||
pub fn decompress(&self) -> Result<PoV, CompressedPoVError> {
|
||||
use std::io::Read;
|
||||
const MAX_POV_BLOCK_SIZE: usize = 32 * 1024 * 1024;
|
||||
|
||||
struct InputDecoder<'a, T: std::io::BufRead>(&'a mut zstd::Decoder<T>, usize);
|
||||
impl<'a, T: std::io::BufRead> parity_scale_codec::Input for InputDecoder<'a, T> {
|
||||
fn read(&mut self, into: &mut [u8]) -> Result<(), parity_scale_codec::Error> {
|
||||
self.1 = self.1.saturating_add(into.len());
|
||||
if self.1 > MAX_POV_BLOCK_SIZE {
|
||||
if self.1 > MAX_POV_SIZE as usize {
|
||||
return Err("pov block too big".into())
|
||||
}
|
||||
self.0.read_exact(into).map_err(Into::into)
|
||||
|
||||
Reference in New Issue
Block a user