Skip to content

Commit

Permalink
Merge pull request #1919 from subspace/tx-range
Browse files Browse the repository at this point in the history
Change the initial tx_range and disable dynamic adjustment of the tx_range
  • Loading branch information
NingLin-P authored Sep 2, 2023
2 parents c83467b + 063982a commit a53ff8d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 7 deletions.
8 changes: 4 additions & 4 deletions crates/pallet-domains/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -702,7 +702,6 @@ mod pallet {
// The stale receipt should not be further processed, but we still track them for purposes
// of measuring the bundle production rate.
ReceiptType::Stale => {
Self::note_domain_bundle(domain_id);
return Ok(());
}
ReceiptType::Rejected(rejected_receipt_type) => {
Expand Down Expand Up @@ -781,8 +780,6 @@ mod pallet {

SuccessfulBundles::<T>::append(domain_id, bundle_hash);

Self::note_domain_bundle(domain_id);

Self::deposit_event(Event::BundleStored {
domain_id,
bundle_hash,
Expand Down Expand Up @@ -1095,7 +1092,6 @@ mod pallet {

fn on_finalize(_: T::BlockNumber) {
let _ = LastEpochStakingDistribution::<T>::clear(u32::MAX, None);
Self::update_domain_tx_range();
}
}

Expand Down Expand Up @@ -1388,6 +1384,8 @@ impl<T: Config> Pallet<T> {

/// Called when a bundle is added to update the bundle state for tx range
/// calculation.
#[allow(dead_code)]
// TODO: use once we support tx-range dynamic adjustment properly
fn note_domain_bundle(domain_id: DomainId) {
DomainTxRangeState::<T>::mutate(domain_id, |maybe_state| match maybe_state {
Some(state) => {
Expand All @@ -1405,6 +1403,8 @@ impl<T: Config> Pallet<T> {

/// Called when the block is finalized to update the tx range for all the
/// domains with bundles in the block.
#[allow(dead_code)]
// TODO: use once we support tx-range dynamic adjustment properly
fn update_domain_tx_range() {
for domain_id in DomainTxRangeState::<T>::iter_keys() {
if let Some(domain_config) =
Expand Down
2 changes: 1 addition & 1 deletion crates/pallet-domains/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ impl frame_system::Config for Test {

parameter_types! {
pub const MaximumReceiptDrift: BlockNumber = 128;
pub const InitialDomainTxRange: u64 = 10;
pub const InitialDomainTxRange: u64 = 3;
pub const DomainTxRangeAdjustmentInterval: u64 = 100;
pub const DomainRuntimeUpgradeDelay: BlockNumber = 100;
pub const MaxBundlesPerBlock: u32 = 10;
Expand Down
2 changes: 1 addition & 1 deletion crates/subspace-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,7 @@ const ERA_DURATION_IN_BLOCKS: BlockNumber = 2016;
const EQUIVOCATION_REPORT_LONGEVITY: BlockNumber = 256;

/// Initial tx range = U256::MAX / INITIAL_DOMAIN_TX_RANGE.
const INITIAL_DOMAIN_TX_RANGE: u64 = 10;
const INITIAL_DOMAIN_TX_RANGE: u64 = 3;

/// Tx range is adjusted every DOMAIN_TX_RANGE_ADJUSTMENT_INTERVAL blocks.
const TX_RANGE_ADJUSTMENT_INTERVAL_BLOCKS: u64 = 100;
Expand Down
2 changes: 1 addition & 1 deletion test/subspace-test-runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -615,7 +615,7 @@ impl pallet_offences_subspace::Config for Runtime {

parameter_types! {
pub const MaximumReceiptDrift: BlockNumber = 2;
pub const InitialDomainTxRange: u64 = 10;
pub const InitialDomainTxRange: u64 = 3;
pub const DomainTxRangeAdjustmentInterval: u64 = 100;
pub const DomainRuntimeUpgradeDelay: BlockNumber = 10;
pub const MinOperatorStake: Balance = 100 * SSC;
Expand Down

0 comments on commit a53ff8d

Please sign in to comment.