Skip to content
This repository has been archived by the owner on Mar 30, 2023. It is now read-only.

Commit

Permalink
Pangolin2 preparation (#174)
Browse files Browse the repository at this point in the history
* New data path

* Simplify staking migration

* Refactor

* Build spec automatically

* Download specs automatically

* Use `take`

* Remove unnecessary doc
  • Loading branch information
AurevoirXavier authored Jan 4, 2023
1 parent 2e78ca7 commit 7a77e00
Show file tree
Hide file tree
Showing 13 changed files with 868 additions and 400 deletions.
2 changes: 0 additions & 2 deletions node/src/chain_spec/crab.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ pub fn local_config() -> ChainSpec {
pub fn genesis_config() -> ChainSpec {
// TODO: update this before final release
ChainSpec::from_genesis(
// Name
"Crab2",
// ID
"crab2",
ChainType::Live,
move || {
Expand Down
2 changes: 0 additions & 2 deletions node/src/chain_spec/darwinia.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ pub fn local_config() -> ChainSpec {
pub fn genesis_config() -> ChainSpec {
// TODO: update this before final release
ChainSpec::from_genesis(
// Name
"Darwinia2",
// ID
"darwinia2",
ChainType::Live,
move || {
Expand Down
2 changes: 0 additions & 2 deletions node/src/chain_spec/pangolin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -138,9 +138,7 @@ pub fn local_config() -> ChainSpec {
pub fn genesis_config() -> ChainSpec {
// TODO: update this before final release
ChainSpec::from_genesis(
// Name
"Pangolin2",
// ID
"pangolin2",
ChainType::Live,
move || {
Expand Down
14 changes: 3 additions & 11 deletions pallet/account-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -145,20 +145,12 @@ pub mod pallet {
#[pallet::getter(fn deposit_of)]
pub type Deposits<T: Config> = StorageMap<_, Blake2_128Concat, AccountId32, Vec<Deposit>>;

/// [`darwinia_staking::Bonded`] data.
///
/// <https://github.dev/darwinia-network/darwinia-common/blob/6a9392cfb9fe2c99b1c2b47d0c36125d61991bb7/frame/staking/src/lib.rs#L592>
#[pallet::storage]
#[pallet::getter(fn bonded)]
pub type Bonded<T: Config> = StorageMap<_, Twox64Concat, AccountId32, AccountId32>;

/// [`darwinia_staking::Ledgers`] data.
#[pallet::storage]
#[pallet::getter(fn ledger_of)]
pub type Ledgers<T: Config> = StorageMap<_, Blake2_128Concat, AccountId32, Ledger<T>>;

// TODO: identity storages
// TODO: proxy storages

#[pallet::call]
impl<T: Config> Pallet<T> {
Expand Down Expand Up @@ -189,7 +181,7 @@ pub mod pallet {
a,
);
}
if let Some(v) = <Vestings<T>>::get(&from) {
if let Some(v) = <Vestings<T>>::take(&from) {
let locked = v.iter().map(|v| v.locked()).sum();

<pallet_vesting::Vesting<T>>::insert(
Expand All @@ -203,8 +195,8 @@ pub mod pallet {
// https://github.dev/paritytech/substrate/blob/19162e43be45817b44c7d48e50d03f074f60fbf4/frame/vesting/src/lib.rs#L86
<pallet_balances::Pallet<T>>::set_lock(*b"vesting ", &to, locked, reasons);
}
if let Some(l) = <Bonded<T>>::get(&from).and_then(<Ledgers<T>>::get) {
if let Some(ds) = <Deposits<T>>::get(&from) {
if let Some(l) = <Ledgers<T>>::take(&from) {
if let Some(ds) = <Deposits<T>>::take(&from) {
<pallet_balances::Pallet<T> as Currency<_>>::transfer(
&to,
&darwinia_deposit::account_id(),
Expand Down
3 changes: 3 additions & 0 deletions tool/state-processor/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,8 @@ target
## npm
node_modules

# Data
data

# Test data
test-data
Loading

0 comments on commit 7a77e00

Please sign in to comment.