From c82e6cdbe422a4e6cd3288efa6675e0d5b133c7e Mon Sep 17 00:00:00 2001 From: Parth Desai Date: Tue, 27 Feb 2024 11:12:03 +0400 Subject: [PATCH 1/3] refactor DomainBundleProposer to store slot probability --- Cargo.lock | 3 +++ crates/subspace-malicious-operator/Cargo.toml | 1 + .../src/malicious_bundle_producer.rs | 13 +++++++------ .../src/malicious_domain_instance_starter.rs | 3 ++- domains/client/domain-operator/Cargo.toml | 1 + .../src/domain_bundle_producer.rs | 5 ++++- .../src/domain_bundle_proposer.rs | 17 +++++++++++++---- .../client/domain-operator/src/domain_worker.rs | 4 +++- domains/client/domain-operator/src/operator.rs | 8 +++++--- domains/client/domain-operator/src/tests.rs | 6 ++++-- domains/service/Cargo.toml | 1 + domains/service/src/domain.rs | 4 +++- 12 files changed, 47 insertions(+), 19 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 8a6e4325e3..87e5ecbddf 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2566,6 +2566,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-slots", + "sp-consensus-subspace", "sp-core", "sp-domain-digests", "sp-domains", @@ -2704,6 +2705,7 @@ dependencies = [ "sp-blockchain", "sp-consensus", "sp-consensus-slots", + "sp-consensus-subspace", "sp-core", "sp-domains", "sp-domains-fraud-proof", @@ -11762,6 +11764,7 @@ dependencies = [ "sp-api", "sp-block-builder", "sp-blockchain", + "sp-consensus", "sp-consensus-slots", "sp-consensus-subspace", "sp-core", diff --git a/crates/subspace-malicious-operator/Cargo.toml b/crates/subspace-malicious-operator/Cargo.toml index dbbaea8b77..d5c5ab5f40 100644 --- a/crates/subspace-malicious-operator/Cargo.toml +++ b/crates/subspace-malicious-operator/Cargo.toml @@ -55,6 +55,7 @@ serde_json = "1.0.111" sp-api = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-block-builder = { git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8", default-features = false, version = "4.0.0-dev" } +sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-consensus-subspace = { version = "0.1.0", path = "../sp-consensus-subspace" } sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } diff --git a/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs b/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs index 8722012be5..478ce357c1 100644 --- a/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs +++ b/crates/subspace-malicious-operator/src/malicious_bundle_producer.rs @@ -16,7 +16,7 @@ use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::Info; use sp_consensus_slots::Slot; -use sp_consensus_subspace::FarmerPublicKey; +use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_core::crypto::UncheckedFrom; use sp_core::Get; use sp_domains::core_api::DomainCoreApi; @@ -105,7 +105,8 @@ where CClient: HeaderBackend + ProvideRuntimeApi + 'static, CClient::Api: DomainsApi::Header> + BundleProducerElectionApi - + AccountNonceApi, + + AccountNonceApi + + SubspaceApi, TransactionPool: sc_transaction_pool_api::TransactionPool< Block = DomainBlock, Hash = ::Hash, @@ -118,7 +119,7 @@ where consensus_keystore: KeystorePtr, consensus_offchain_tx_pool_factory: OffchainTransactionPoolFactory, domain_transaction_pool: Arc, - ) -> Self { + ) -> Result { let operator_keystore = KeystoreContainer::new(&KeystoreConfig::InMemory) .expect("create in-memory keystore container must succeed") .keystore(); @@ -128,7 +129,7 @@ where domain_client.clone(), consensus_client.clone(), domain_transaction_pool, - ); + )?; let (bundle_sender, _bundle_receiver) = tracing_unbounded("domain_bundle_stream", 100); let bundle_producer = DomainBundleProducer::new( @@ -150,7 +151,7 @@ where .sudo_account_id(consensus_client.info().best_hash) .expect("Failed to get sudo account"); - Self { + Ok(Self { domain_id, consensus_client, consensus_keystore, @@ -160,7 +161,7 @@ where malicious_operator_status: MaliciousOperatorStatus::NoStatus, sudo_acccount, consensus_offchain_tx_pool_factory, - } + }) } async fn handle_new_slot( diff --git a/crates/subspace-malicious-operator/src/malicious_domain_instance_starter.rs b/crates/subspace-malicious-operator/src/malicious_domain_instance_starter.rs index af1bc237d3..5a7d870096 100644 --- a/crates/subspace-malicious-operator/src/malicious_domain_instance_starter.rs +++ b/crates/subspace-malicious-operator/src/malicious_domain_instance_starter.rs @@ -173,7 +173,8 @@ where consensus_keystore, consensus_offchain_tx_pool_factory, domain_node.transaction_pool.clone(), - ); + ) + .map_err(Box::new)?; domain_node .task_manager diff --git a/domains/client/domain-operator/Cargo.toml b/domains/client/domain-operator/Cargo.toml index 0666ef70a3..b1d7293ab1 100644 --- a/domains/client/domain-operator/Cargo.toml +++ b/domains/client/domain-operator/Cargo.toml @@ -22,6 +22,7 @@ sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polk sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } +sp-consensus-subspace = { path = "../../../crates/sp-consensus-subspace" } sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-domains = { version = "0.1.0", path = "../../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../../../crates/sp-domains-fraud-proof" } diff --git a/domains/client/domain-operator/src/domain_bundle_producer.rs b/domains/client/domain-operator/src/domain_bundle_producer.rs index 5014b64ec9..699864ed37 100644 --- a/domains/client/domain-operator/src/domain_bundle_producer.rs +++ b/domains/client/domain-operator/src/domain_bundle_producer.rs @@ -7,6 +7,7 @@ use sc_client_api::{AuxStore, BlockBackend}; use sp_api::ProvideRuntimeApi; use sp_block_builder::BlockBuilder; use sp_blockchain::HeaderBackend; +use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_domains::core_api::DomainCoreApi; use sp_domains::{ Bundle, BundleProducerElectionApi, DomainId, DomainsApi, OperatorId, OperatorPublicKey, @@ -73,7 +74,9 @@ where Client: HeaderBackend + BlockBackend + AuxStore + ProvideRuntimeApi, Client::Api: BlockBuilder + DomainCoreApi + TaggedTransactionQueue, CClient: HeaderBackend + ProvideRuntimeApi, - CClient::Api: DomainsApi + BundleProducerElectionApi, + CClient::Api: DomainsApi + + BundleProducerElectionApi + + SubspaceApi, TransactionPool: sc_transaction_pool_api::TransactionPool::Hash>, { diff --git a/domains/client/domain-operator/src/domain_bundle_proposer.rs b/domains/client/domain-operator/src/domain_bundle_proposer.rs index 927e23b0f4..c2998a0134 100644 --- a/domains/client/domain-operator/src/domain_bundle_proposer.rs +++ b/domains/client/domain-operator/src/domain_bundle_proposer.rs @@ -6,6 +6,7 @@ use sc_transaction_pool_api::InPoolTransaction; use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder; use sp_blockchain::HeaderBackend; +use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_domains::core_api::DomainCoreApi; use sp_domains::{ BundleHeader, DomainId, DomainsApi, ExecutionReceipt, HeaderHashingFor, ProofOfElection, @@ -64,6 +65,7 @@ pub struct DomainBundleProposer, transaction_pool: Arc, previous_bundled_tx: PreviousBundledTx, + consensus_slot_probability: (u64, u64), _phantom_data: PhantomData<(Block, CBlock)>, } @@ -77,6 +79,7 @@ impl Clone consensus_client: self.consensus_client.clone(), transaction_pool: self.transaction_pool.clone(), previous_bundled_tx: PreviousBundledTx::new(), + consensus_slot_probability: self.consensus_slot_probability, _phantom_data: self._phantom_data, } } @@ -96,7 +99,7 @@ where Client: HeaderBackend + BlockBackend + AuxStore + ProvideRuntimeApi, Client::Api: BlockBuilder + DomainCoreApi + TaggedTransactionQueue, CClient: HeaderBackend + ProvideRuntimeApi, - CClient::Api: DomainsApi, + CClient::Api: DomainsApi + SubspaceApi, TransactionPool: sc_transaction_pool_api::TransactionPool::Hash>, { @@ -105,15 +108,21 @@ where client: Arc, consensus_client: Arc, transaction_pool: Arc, - ) -> Self { - Self { + ) -> sp_blockchain::Result { + let chain_constants = consensus_client + .runtime_api() + .chain_constants(consensus_client.info().best_hash) + .map_err(|api_error| sp_blockchain::Error::Application(api_error.into()))?; + + Ok(Self { domain_id, client, consensus_client, transaction_pool, previous_bundled_tx: PreviousBundledTx::new(), + consensus_slot_probability: chain_constants.slot_probability(), _phantom_data: PhantomData, - } + }) } pub(crate) async fn propose_bundle_at( diff --git a/domains/client/domain-operator/src/domain_worker.rs b/domains/client/domain-operator/src/domain_worker.rs index 154483a4e1..1a9583f1f9 100644 --- a/domains/client/domain-operator/src/domain_worker.rs +++ b/domains/client/domain-operator/src/domain_worker.rs @@ -27,6 +27,7 @@ use sc_transaction_pool_api::OffchainTransactionPoolFactory; use sp_api::{ApiExt, ProvideRuntimeApi}; use sp_block_builder::BlockBuilder; use sp_blockchain::{HeaderBackend, HeaderMetadata}; +use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_core::traits::{CodeExecutor, SpawnEssentialNamed}; use sp_core::H256; use sp_domains::core_api::DomainCoreApi; @@ -92,7 +93,8 @@ pub(super) async fn start_worker< CClient::Api: DomainsApi + MessengerApi> + BundleProducerElectionApi - + FraudProofApi, + + FraudProofApi + + SubspaceApi, TransactionPool: sc_transaction_pool_api::TransactionPool::Hash> + 'static, Backend: sc_client_api::Backend + 'static, diff --git a/domains/client/domain-operator/src/operator.rs b/domains/client/domain-operator/src/operator.rs index 9e8abfb5ff..e2a43e90ec 100644 --- a/domains/client/domain-operator/src/operator.rs +++ b/domains/client/domain-operator/src/operator.rs @@ -12,6 +12,7 @@ use sc_client_api::{ use sc_utils::mpsc::tracing_unbounded; use sp_api::ProvideRuntimeApi; use sp_blockchain::{HeaderBackend, HeaderMetadata}; +use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_core::traits::{CodeExecutor, SpawnEssentialNamed}; use sp_core::H256; use sp_domains::core_api::DomainCoreApi; @@ -92,7 +93,8 @@ where CClient::Api: DomainsApi + MessengerApi> + BundleProducerElectionApi - + FraudProofApi, + + FraudProofApi + + SubspaceApi, Backend: sc_client_api::Backend + Send + Sync + 'static, TransactionPool: sc_transaction_pool_api::TransactionPool::Hash> + 'static, @@ -114,7 +116,7 @@ where NSNS, ASS, >, - ) -> Result + ) -> Result where IBNS: Stream, mpsc::Sender<()>)> + Send + 'static, CIBNS: Stream> + Send + 'static, @@ -126,7 +128,7 @@ where params.client.clone(), params.consensus_client.clone(), params.transaction_pool.clone(), - ); + )?; let bundle_producer = DomainBundleProducer::new( params.domain_id, diff --git a/domains/client/domain-operator/src/tests.rs b/domains/client/domain-operator/src/tests.rs index a7371fc009..246dd1dd9f 100644 --- a/domains/client/domain-operator/src/tests.rs +++ b/domains/client/domain-operator/src/tests.rs @@ -2954,7 +2954,8 @@ async fn stale_and_in_future_bundle_should_be_rejected() { alice.client.clone(), ferdie.client.clone(), alice.operator.transaction_pool.clone(), - ); + ) + .unwrap(); let (bundle_sender, _bundle_receiver) = sc_utils::mpsc::tracing_unbounded("domain_bundle_stream", 100); DomainBundleProducer::new( @@ -3871,7 +3872,8 @@ async fn test_bad_receipt_chain() { alice.client.clone(), ferdie.client.clone(), alice.operator.transaction_pool.clone(), - ); + ) + .unwrap(); let (bundle_sender, _bundle_receiver) = sc_utils::mpsc::tracing_unbounded("domain_bundle_stream", 100); DomainBundleProducer::new( diff --git a/domains/service/Cargo.toml b/domains/service/Cargo.toml index d5c8ac7e3f..86184fc39e 100644 --- a/domains/service/Cargo.toml +++ b/domains/service/Cargo.toml @@ -51,6 +51,7 @@ sp-block-builder = { version = "4.0.0-dev", git = "https://github.com/subspace/p sp-blockchain = { version = "4.0.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-consensus = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-consensus-slots = { version = "0.10.0-dev", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } +sp-consensus-subspace = { version = "0.1.0", path = "../../crates/sp-consensus-subspace" } sp-core = { version = "21.0.0", git = "https://github.com/subspace/polkadot-sdk", rev = "d6b500960579d73c43fc4ef550b703acfa61c4c8" } sp-domains = { version = "0.1.0", path = "../../crates/sp-domains" } sp-domains-fraud-proof = { version = "0.1.0", path = "../../crates/sp-domains-fraud-proof" } diff --git a/domains/service/src/domain.rs b/domains/service/src/domain.rs index 6039a3a9c8..df047feacf 100644 --- a/domains/service/src/domain.rs +++ b/domains/service/src/domain.rs @@ -30,6 +30,7 @@ use sp_block_builder::BlockBuilder; use sp_blockchain::{HeaderBackend, HeaderMetadata}; use sp_consensus::SyncOracle; use sp_consensus_slots::Slot; +use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_core::traits::SpawnEssentialNamed; use sp_core::{Decode, Encode, H256}; use sp_domains::core_api::DomainCoreApi; @@ -275,7 +276,8 @@ where + MessengerApi> + BundleProducerElectionApi + FraudProofApi - + MmrApi>, + + MmrApi> + + SubspaceApi, IBNS: Stream, mpsc::Sender<()>)> + Send + 'static, CIBNS: Stream> + Send + 'static, NSNS: Stream + Send + 'static, From 82cdd90bb911adfb857b8c14e607c407cb683d22 Mon Sep 17 00:00:00 2001 From: Parth Desai Date: Tue, 27 Feb 2024 13:58:52 +0400 Subject: [PATCH 2/3] require BundleProducerElectionApi for fetching bundle slot probability --- .../client/domain-operator/src/domain_bundle_proposer.rs | 7 +++++-- domains/service/src/domain.rs | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/domains/client/domain-operator/src/domain_bundle_proposer.rs b/domains/client/domain-operator/src/domain_bundle_proposer.rs index c2998a0134..74cabd8067 100644 --- a/domains/client/domain-operator/src/domain_bundle_proposer.rs +++ b/domains/client/domain-operator/src/domain_bundle_proposer.rs @@ -9,7 +9,8 @@ use sp_blockchain::HeaderBackend; use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_domains::core_api::DomainCoreApi; use sp_domains::{ - BundleHeader, DomainId, DomainsApi, ExecutionReceipt, HeaderHashingFor, ProofOfElection, + BundleHeader, BundleProducerElectionApi, DomainId, DomainsApi, ExecutionReceipt, + HeaderHashingFor, ProofOfElection, }; use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor, One, Zero}; use sp_runtime::Percent; @@ -99,7 +100,9 @@ where Client: HeaderBackend + BlockBackend + AuxStore + ProvideRuntimeApi, Client::Api: BlockBuilder + DomainCoreApi + TaggedTransactionQueue, CClient: HeaderBackend + ProvideRuntimeApi, - CClient::Api: DomainsApi + SubspaceApi, + CClient::Api: DomainsApi + + SubspaceApi + + BundleProducerElectionApi, TransactionPool: sc_transaction_pool_api::TransactionPool::Hash>, { diff --git a/domains/service/src/domain.rs b/domains/service/src/domain.rs index df047feacf..41be8b967d 100644 --- a/domains/service/src/domain.rs +++ b/domains/service/src/domain.rs @@ -74,7 +74,9 @@ where + Send + Sync + 'static, - CClient::Api: DomainsApi + MessengerApi>, + CClient::Api: DomainsApi + + MessengerApi> + + BundleProducerElectionApi, RuntimeApi: ConstructRuntimeApi> + Send + Sync + 'static, RuntimeApi::RuntimeApi: ApiExt + Metadata From 9cbefd78917d51c2fddffcfae8cd88ccfe70f5a9 Mon Sep 17 00:00:00 2001 From: Parth Desai Date: Tue, 27 Feb 2024 15:05:04 +0400 Subject: [PATCH 3/3] calculate domain max bundle weight --- .../src/domain_bundle_proposer.rs | 78 +++++++++++++++---- 1 file changed, 62 insertions(+), 16 deletions(-) diff --git a/domains/client/domain-operator/src/domain_bundle_proposer.rs b/domains/client/domain-operator/src/domain_bundle_proposer.rs index 74cabd8067..a162eeb7fd 100644 --- a/domains/client/domain-operator/src/domain_bundle_proposer.rs +++ b/domains/client/domain-operator/src/domain_bundle_proposer.rs @@ -9,10 +9,12 @@ use sp_blockchain::HeaderBackend; use sp_consensus_subspace::{FarmerPublicKey, SubspaceApi}; use sp_domains::core_api::DomainCoreApi; use sp_domains::{ - BundleHeader, BundleProducerElectionApi, DomainId, DomainsApi, ExecutionReceipt, - HeaderHashingFor, ProofOfElection, + BundleHeader, BundleProducerElectionApi, DomainBlockLimit, DomainId, DomainsApi, + ExecutionReceipt, HeaderHashingFor, ProofOfElection, +}; +use sp_runtime::traits::{ + Block as BlockT, Hash as HashT, Header as HeaderT, IntegerSquareRoot, NumberFor, One, Zero, }; -use sp_runtime::traits::{Block as BlockT, Hash as HashT, Header as HeaderT, NumberFor, One, Zero}; use sp_runtime::Percent; use sp_transaction_pool::runtime_api::TaggedTransactionQueue; use sp_weights::Weight; @@ -60,6 +62,26 @@ impl PreviousBundledTx { } } +pub fn calculate_max_bundle_weight_and_size( + domain_block_limit: DomainBlockLimit, + consensus_slot_probability: (u64, u64), + bundle_slot_probability: (u64, u64), +) -> (Weight, u32) { + // (n1 / d1) / (n2 / d2) is equal to (n1 * d2) / (d1 * n2) + // This represents: bundle_slot_probability/SLOT_PROBABILITY + let expected_bundles_per_block = (bundle_slot_probability.0 * consensus_slot_probability.1) + / (bundle_slot_probability.1 * consensus_slot_probability.0); + + // This represents: Ceil[2*Sqrt[bundle_slot_probability/SLOT_PROBABILITY]]) + let std_of_expected_bundles_per_block = (2 * expected_bundles_per_block.integer_sqrt()) + 1; + + // max_bundle_weight = TargetDomainBlockWeight/(bundle_slot_probability/SLOT_PROBABILITY+ Ceil[2*Sqrt[ bundle_slot_probability/SLOT_PROBABILITY]]) + let max_bundle_weight = domain_block_limit.max_block_weight + / (expected_bundles_per_block + std_of_expected_bundles_per_block); + + (max_bundle_weight, domain_block_limit.max_block_size) +} + pub struct DomainBundleProposer { domain_id: DomainId, client: Arc, @@ -128,6 +150,38 @@ where }) } + fn max_bundle_weight_and_size(&self) -> sp_blockchain::Result<(Weight, u32)> { + let domain_block_limit = self + .consensus_client + .runtime_api() + .domain_block_limit(self.consensus_client.info().best_hash, self.domain_id)? + .ok_or_else(|| { + sp_blockchain::Error::Application( + format!("Domain block limit for {:?} not found", self.domain_id).into(), + ) + })?; + let consensus_slot_probability = self.consensus_slot_probability; + let bundle_slot_probability = self + .consensus_client + .runtime_api() + .bundle_producer_election_params( + self.consensus_client.info().best_hash, + self.domain_id, + )? + .ok_or_else(|| { + sp_blockchain::Error::Application( + format!("Domain configuration for {:?} not found", self.domain_id).into(), + ) + })? + .bundle_slot_probability; + + Ok(calculate_max_bundle_weight_and_size( + domain_block_limit, + consensus_slot_probability, + bundle_slot_probability, + )) + } + pub(crate) async fn propose_bundle_at( &mut self, proof_of_election: ProofOfElection, @@ -158,15 +212,7 @@ where .maybe_clear(self.consensus_client.info().best_hash); let bundle_vrf_hash = U256::from_be_bytes(proof_of_election.vrf_hash()); - let domain_block_limit = self - .consensus_client - .runtime_api() - .domain_block_limit(self.consensus_client.info().best_hash, self.domain_id)? - .ok_or_else(|| { - sp_blockchain::Error::Application( - format!("Domain block limit for {:?} not found", self.domain_id).into(), - ) - })?; + let (max_bundle_weight, max_bundle_size) = self.max_bundle_weight_and_size()?; let mut extrinsics = Vec::new(); let mut estimated_bundle_weight = Weight::default(); let mut bundle_size = 0u32; @@ -211,11 +257,11 @@ where })?; let next_estimated_bundle_weight = estimated_bundle_weight.saturating_add(tx_weight); - if next_estimated_bundle_weight.any_gt(domain_block_limit.max_block_weight) { + if next_estimated_bundle_weight.any_gt(max_bundle_weight) { if skipped < MAX_SKIPPED_TRANSACTIONS && Percent::from_rational( estimated_bundle_weight.ref_time(), - domain_block_limit.max_block_weight.ref_time(), + max_bundle_weight.ref_time(), ) < BUNDLE_UTILIZATION_THRESHOLD { skipped += 1; @@ -225,9 +271,9 @@ where } let next_bundle_size = bundle_size + pending_tx_data.encoded_size() as u32; - if next_bundle_size > domain_block_limit.max_block_size { + if next_bundle_size > max_bundle_size { if skipped < MAX_SKIPPED_TRANSACTIONS - && Percent::from_rational(bundle_size, domain_block_limit.max_block_size) + && Percent::from_rational(bundle_size, max_bundle_size) < BUNDLE_UTILIZATION_THRESHOLD { skipped += 1;