Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Prepare release 4.4.0 #1276

Merged
merged 3 commits into from
Nov 20, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion node/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "framenode"
version = "4.3.2"
version = "4.4.0"
authors = ["Parity Technologies <[email protected]>"]
build = "build.rs"
edition = "2021"
Expand Down
2 changes: 1 addition & 1 deletion node/chain_spec/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "framenode-chain-spec"
version = "4.3.2"
version = "4.4.0"
authors = ["Parity Technologies <[email protected]>"]
edition = "2021"

Expand Down
2 changes: 1 addition & 1 deletion pallets/kensetsu/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,7 @@ pub mod pallet {
pub type CdpId = u128;

/// The current storage version.
const STORAGE_VERSION: StorageVersion = StorageVersion::new(4);
const STORAGE_VERSION: StorageVersion = StorageVersion::new(5);

#[pallet::pallet]
#[pallet::generate_store(pub(super) trait Store)]
Expand Down
62 changes: 62 additions & 0 deletions pallets/kensetsu/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -608,3 +608,65 @@
}
}
}

/// Kensetsu version 5 replaces milliseconds to seconds in parameters
pub mod v4_to_v5 {
use crate::{CollateralInfos, Config, Pallet};
use core::marker::PhantomData;
use frame_support::dispatch::Weight;
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};
use sp_core::Get;
use sp_runtime::traits::Saturating;
use sp_runtime::FixedU128;

pub struct UpgradeToV5<T>(PhantomData<T>);

impl<T: Config + pallet_timestamp::Config> OnRuntimeUpgrade for UpgradeToV5<T> {
fn on_runtime_upgrade() -> Weight {
if Pallet::<T>::on_chain_storage_version() == 4 {
let mut count = 0;

CollateralInfos::<T>::translate_values::<crate::CollateralInfo<T::Moment>, _>(
|mut value| {
value.risk_parameters.stability_fee_rate = value
.risk_parameters
.stability_fee_rate
.saturating_mul(FixedU128::from_u32(1000u32));
value.last_fee_update_time =
value.last_fee_update_time / T::Moment::from(1000u32);
Fixed Show fixed Hide fixed
count += 1;
Some(value)
},
);

StorageVersion::new(5).put::<Pallet<T>>();
count += 1;

frame_support::log::info!("Migration to V5 applied");
T::DbWeight::get().reads_writes(count, count)
} else {
frame_support::log::info!("Migration to V5 already applied, skipping...");
T::DbWeight::get().reads(1)
}
}
}

#[cfg(test)]
mod tests {
use crate::migrations::v4_to_v5::UpgradeToV5;
use crate::mock::{new_test_ext, TestRuntime};
use crate::Pallet;
use frame_support::traits::{GetStorageVersion, OnRuntimeUpgrade, StorageVersion};

#[test]
fn test() {
new_test_ext().execute_with(|| {
StorageVersion::new(4).put::<Pallet<TestRuntime>>();

UpgradeToV5::<TestRuntime>::on_runtime_upgrade();

assert_eq!(Pallet::<TestRuntime>::on_chain_storage_version(), 5);
});
}
}
}
2 changes: 1 addition & 1 deletion runtime/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ license = "BSD-4-Clause"
homepage = "https://sora.org"
repository = "https://github.com/sora-xor/sora2-network"
name = "framenode-runtime"
version = "4.3.2"
version = "4.4.0"

[package.metadata.docs.rs]
targets = ["x86_64-unknown-linux-gnu"]
Expand Down
4 changes: 2 additions & 2 deletions runtime/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -255,10 +255,10 @@ pub const VERSION: RuntimeVersion = RuntimeVersion {
spec_name: create_runtime_str!("sora-substrate"),
impl_name: create_runtime_str!("sora-substrate"),
authoring_version: 1,
spec_version: 104,
spec_version: 105,
impl_version: 1,
apis: RUNTIME_API_VERSIONS,
transaction_version: 104,
transaction_version: 105,
state_version: 0,
};

Expand Down
5 changes: 4 additions & 1 deletion runtime/src/migrations.rs
Original file line number Diff line number Diff line change
Expand Up @@ -28,4 +28,7 @@
// STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
// USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.

pub type Migrations = (xor_fee::migrations::remove_vxor_remint::Migrate<crate::Runtime>,);
pub type Migrations = (
xor_fee::migrations::remove_vxor_remint::Migrate<crate::Runtime>,
kensetsu::migrations::v4_to_v5::UpgradeToV5<crate::Runtime>,
);
Loading