Skip to content

Commit

Permalink
integrate phala pallets
Browse files Browse the repository at this point in the history
  • Loading branch information
h4x3rotab committed Apr 29, 2022
1 parent 2905dfb commit ad5df1d
Show file tree
Hide file tree
Showing 11 changed files with 653 additions and 224 deletions.
2 changes: 1 addition & 1 deletion pallets/phala/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
authors = ["Phala Network"]
edition = "2018"
edition = "2021"
name = "phala-pallets"
version = "5.0.0"
license = "Apache 2.0"
Expand Down
2 changes: 1 addition & 1 deletion pallets/phala/mq-runtime-api/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
[package]
name = "pallet-mq-runtime-api"
version = "0.1.0"
edition = "2018"
edition = "2021"

[dependencies]
sp-api = { git = "https://github.com/paritytech/substrate", branch = "polkadot-v0.9.18", default-features = false}
Expand Down
5 changes: 3 additions & 2 deletions pallets/phala/src/fat.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/// Public key registry for workers and contracts.
//! The Fat Contract registry
pub use self::pallet::*;

#[frame_support::pallet]
Expand Down Expand Up @@ -47,7 +48,7 @@ pub mod pallet {
type Event: From<Event<Self>> + IsType<<Self as frame_system::Config>::Event>;
}

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
8 changes: 1 addition & 7 deletions pallets/phala/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,6 @@
//! Phala Pallets
//!
//! This is the central crate of Phala tightly-coupled pallets.
//!
//! - `phala_legacy`: The legacy `pallet-phala`; will be retired gradually
//! - `mq`: The message queue to connect components in the network
//! - `registry`: Manages the public key of offchain components (i.e. workers and contracts)
//! - `mining`: Manages mining lifecycle, reward and slashes
//! - `stakepool`: Pool for collaboratively mining staking
#[cfg(target_arch = "wasm32")]
extern crate webpki_wasm as webpki;
Expand All @@ -20,7 +14,7 @@ extern crate alloc;
use utils::{accumulator, attestation, balance_convert, constants, fixed_point};

pub mod migrations;
mod utils;
pub mod utils;

pub mod fat;
pub mod mining;
Expand Down
4 changes: 3 additions & 1 deletion pallets/phala/src/migrations/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,14 @@ pub mod v5 {
pub fn migrate<T>() -> Weight
where
T: mining::Config + mq::Config + registry::Config + stakepool::Config,
MiningBalanceOf<T>: balance_convert::FixedPointConvert,
MiningBalanceOf<T>: balance_convert::FixedPointConvert + sp_std::fmt::Display,
T: mining::pallet::Config<Currency = <T as stakepool::pallet::Config>::Currency>,
{
if get_versions::<T>() == EXPECTED_STORAGE_VERSION {
let mut weight: Weight = 0;
log::info!("Ᵽ migrating phala-pallets to v5");
weight += mining::migrations::trigger_unresp_fix::<T>();
weight += stakepool::Pallet::<T>::migration_remove_assignments();
log::info!("Ᵽ pallets migrated to v5");

StorageVersion::new(5).put::<mining::Pallet<T>>();
Expand Down
Loading

0 comments on commit ad5df1d

Please sign in to comment.