mirror of
https://github.com/pezkuwichain/pezkuwi-subxt.git
synced 2026-05-31 07:31:02 +00:00
Add set_current_relay_chain_state method for benchmarks (#2731)
This commit is contained in:
@@ -1568,6 +1568,13 @@ pub trait RelaychainStateProvider {
|
|||||||
///
|
///
|
||||||
/// **NOTE**: This is not guaranteed to return monotonically increasing relay parents.
|
/// **NOTE**: This is not guaranteed to return monotonically increasing relay parents.
|
||||||
fn current_relay_chain_state() -> RelayChainState;
|
fn current_relay_chain_state() -> RelayChainState;
|
||||||
|
|
||||||
|
/// Utility function only to be used in benchmarking scenarios, to be implemented optionally,
|
||||||
|
/// else a noop.
|
||||||
|
///
|
||||||
|
/// It allows for setting a custom RelayChainState.
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
fn set_current_relay_chain_state(_state: RelayChainState) {}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements [`BlockNumberProvider`] that returns relay chain block number fetched from validation
|
/// Implements [`BlockNumberProvider`] that returns relay chain block number fetched from validation
|
||||||
@@ -1611,6 +1618,21 @@ impl<T: Config> RelaychainStateProvider for RelaychainDataProvider<T> {
|
|||||||
})
|
})
|
||||||
.unwrap_or_default()
|
.unwrap_or_default()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(feature = "runtime-benchmarks")]
|
||||||
|
fn set_current_relay_chain_state(state: RelayChainState) {
|
||||||
|
let mut validation_data = Pallet::<T>::validation_data().unwrap_or_else(||
|
||||||
|
// PersistedValidationData does not impl default in non-std
|
||||||
|
PersistedValidationData {
|
||||||
|
parent_head: vec![].into(),
|
||||||
|
relay_parent_number: Default::default(),
|
||||||
|
max_pov_size: Default::default(),
|
||||||
|
relay_parent_storage_root: Default::default(),
|
||||||
|
});
|
||||||
|
validation_data.relay_parent_number = state.number;
|
||||||
|
validation_data.relay_parent_storage_root = state.state_root;
|
||||||
|
ValidationData::<T>::put(validation_data)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// Implements [`BlockNumberProvider`] and [`RelaychainStateProvider`] that returns relevant relay
|
/// Implements [`BlockNumberProvider`] and [`RelaychainStateProvider`] that returns relevant relay
|
||||||
|
|||||||
Reference in New Issue
Block a user