Skip to content

Commit

Permalink
Merge branch 'echo/bls-opt-ark' of https://github.com/darwinia-networ…
Browse files Browse the repository at this point in the history
…k/darwinia into echo/bls-opt-ark
  • Loading branch information
hujw77 committed Mar 9, 2023
2 parents 9a492be + 064f68a commit c0e8a91
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 20 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ jobs:
cd tool/state-processor
mkdir -p data
cd data
curl -L https://github.com/darwinia-network/darwinia-2.0/releases/download/crab2/crab-state.tar.zst | tar x -I pzstd
curl -L https://github.com/darwinia-network/darwinia/releases/download/crab2/crab-state.tar.zst | tar x -I pzstd
cd ..
- name: Check state
run: |
Expand Down
16 changes: 13 additions & 3 deletions pallet/account-migration/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ use frame_support::{
};
use frame_system::{pallet_prelude::*, AccountInfo, RawOrigin};
use pallet_balances::AccountData;
use pallet_identity::Registration;
use pallet_identity::{Judgement, Registration};
use pallet_vesting::VestingInfo;
use sp_core::sr25519::{Public, Signature};
use sp_io::hashing;
Expand Down Expand Up @@ -361,9 +361,12 @@ pub mod pallet {
}

fn migrate_inner(from: AccountId32, to: AccountId20) -> DispatchResult {
let account = <Accounts<T>>::take(&from)
let mut account = <Accounts<T>>::take(&from)
.expect("[pallet::account-migration] already checked in `pre_dispatch`; qed");

account.data.free += account.data.reserved;
account.data.reserved = 0;

<frame_system::Account<T>>::insert(to, account);

if let Some(a) = <KtonAccounts<T>>::take(&from) {
Expand Down Expand Up @@ -411,7 +414,14 @@ 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(i) = <Identities<T>>::take(&from) {
if let Some(mut i) = <Identities<T>>::take(&from) {
i.deposit = 0;
i.judgements.iter_mut().for_each(|(_, j)| {
if let Judgement::FeePaid(f) = j {
*f = 0;
};
});

migration::put_storage_value(
b"Identity",
b"IdentityOf",
Expand Down
4 changes: 2 additions & 2 deletions runtime/common/src/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -384,9 +384,9 @@ macro_rules! impl_account_migration_tests {
},
);

assert_ok!(migrate(from, to,));
assert_ok!(migrate(from, to));
assert_eq!(Identity::identity(to).unwrap().info, info);
assert_eq!(Identity::identity(to).unwrap().deposit, RING_AMOUNT);
assert_eq!(Identity::identity(to).unwrap().deposit, 0);
assert_eq!(Identity::identity(to).unwrap().judgements.len(), 0);
});
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/crab/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
Self(Default::default())
}

pub fn used_addresses() -> [sp_core::H160; 15] {
pub fn used_addresses() -> [sp_core::H160; 14] {
[
addr(1),
addr(2),
Expand All @@ -66,7 +66,7 @@ where
addr(1026),
addr(1536),
addr(1537),
addr(2048),
// addr(2048),
]
}
}
Expand Down Expand Up @@ -118,8 +118,8 @@ where
a if a == addr(1537) =>
Some(<darwinia_precompile_staking::Staking<Runtime>>::execute(handle)),
// [2048..) reserved for the experimental precompiles.
a if a == addr(2048) =>
Some(<darwinia_precompile_bls12_381::BLS12381<Runtime>>::execute(handle)),
// a if a == addr(2048) =>
// Some(<darwinia_precompile_bls12_381::BLS12381<Runtime>>::execute(handle)),
_ => None,
}
}
Expand Down
8 changes: 4 additions & 4 deletions runtime/darwinia/src/pallets/evm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ where
Self(Default::default())
}

pub fn used_addresses() -> [sp_core::H160; 15] {
pub fn used_addresses() -> [sp_core::H160; 14] {
[
addr(1),
addr(2),
Expand All @@ -66,7 +66,7 @@ where
addr(1026),
addr(1536),
addr(1537),
addr(2048),
// addr(2048),
]
}
}
Expand Down Expand Up @@ -118,8 +118,8 @@ where
a if a == addr(1537) =>
Some(<darwinia_precompile_staking::Staking<Runtime>>::execute(handle)),
// [2048..) reserved for the experimental precompiles.
a if a == addr(2048) =>
Some(<darwinia_precompile_bls12_381::BLS12381<Runtime>>::execute(handle)),
// a if a == addr(2048) =>
// Some(<darwinia_precompile_bls12_381::BLS12381<Runtime>>::execute(handle)),
_ => None,
}
}
Expand Down
22 changes: 16 additions & 6 deletions tool/state-processor/src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ impl Tester {

let mut solo_state = State::from_file("data/crab-solo.json").unwrap();
let mut para_state = State::from_file("data/crab-para.json").unwrap();
let mut shell_state = State::from_file("data/crab-processed.json").unwrap();
let mut shell_state = State::from_file("data/crab-processed-test.json").unwrap();

// solo chain
let mut solo_accounts = <Map<AccountInfo>>::default();
Expand Down Expand Up @@ -181,7 +181,8 @@ fn solo_chain_substrate_account() {
assert_eq!(m_account.consumers, 2);
assert_eq!(m_account.providers, 1);
assert_eq!(m_account.sufficients, 1);
assert_eq!(m_account.data.free, solo_account.data.free * GWEI);
// 30_976_316_716_418_406_400 is the unclaimed staking reward
assert_eq!(m_account.data.free, solo_account.data.free * GWEI + 30_976_316_716_418_406_400);
assert_eq!(m_account.data.free_kton_or_misc_frozen, 0);
// the kton part moved to the asset pallet
let asset_account = tester.migration_kton_accounts.get(addr).unwrap();
Expand Down Expand Up @@ -319,7 +320,7 @@ fn ring_total_issuance() {
);

assert_eq!(
migrated_total_issuance - 155_223_151_710_u128,
migrated_total_issuance - 161_223_151_710_u128,
solo_issuance * GWEI + para_issuance
);
});
Expand Down Expand Up @@ -349,8 +350,7 @@ fn kton_total_issuance() {
&blake2_128_concat_to_string(KTON_ID.encode()),
&mut details,
);

assert_eq!(details.supply - 4_999_999_999_u128, total_issuance * GWEI);
assert_eq!(details.supply - 5_999_999_999_u128, total_issuance * GWEI);
});
}

Expand Down Expand Up @@ -730,7 +730,17 @@ fn stake_ledgers_values() {
&blake2_128_concat_to_string(addr.encode()),
&mut m_ledger,
);
assert_eq!(m_ledger.staked_ring, ledger.active * GWEI);

let mut m_deposits: Vec<Deposit> = Vec::new();
tester.shell_state.get_value(
b"AccountMigration",
b"Deposits",
&blake2_128_concat_to_string(addr.encode()),
&mut m_deposits,
);

assert_eq!(ledger.active * GWEI, m_deposits.iter().map(|d| d.value).sum());
assert_eq!(m_ledger.staked_ring, 0);
assert_eq!(m_ledger.staked_kton, ledger.active_kton * GWEI);
});
}
Expand Down

0 comments on commit c0e8a91

Please sign in to comment.