Skip to content

Commit 49ff38c

Browse files
authored
Fix bonded prefix (#155)
* Fix bonded prefix * Restore * Fix
1 parent 5138fd0 commit 49ff38c

File tree

3 files changed

+8
-6
lines changed

3 files changed

+8
-6
lines changed

precompile/staking/src/lib.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -50,14 +50,14 @@ where
5050
<Runtime::RuntimeCall as Dispatchable>::RuntimeOrigin: From<Option<Runtime::AccountId>>,
5151
<Runtime as frame_system::Config>::AccountId: From<H160>,
5252
<<Runtime as frame_system::Config>::RuntimeCall as Dispatchable>::RuntimeOrigin: OriginTrait,
53-
<<Runtime as darwinia_staking::Config>::Deposit as Stake>::Item: From<u16>,
53+
<<Runtime as darwinia_staking::Config>::Deposit as Stake>::Item: From<u8>,
5454
{
5555
#[precompile::public("stake(uint256,uint256,uint8[])")]
5656
fn stake(
5757
handle: &mut impl PrecompileHandle,
5858
ring_amount: U256,
5959
kton_amount: U256,
60-
deposits: Vec<u16>,
60+
deposits: Vec<u8>,
6161
) -> EvmResult<bool> {
6262
let origin = handle.context().caller.into();
6363
let deposits = deposits.into_iter().map(|i| i.into()).collect();
@@ -79,7 +79,7 @@ where
7979
handle: &mut impl PrecompileHandle,
8080
ring_amount: U256,
8181
kton_amount: U256,
82-
deposits: Vec<u16>,
82+
deposits: Vec<u8>,
8383
) -> EvmResult<bool> {
8484
let origin = handle.context().caller.into();
8585
let deposits = deposits.into_iter().map(|i| i.into()).collect();

tool/state-processor/src/staking/mod.rs

+3-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,9 @@ impl Processor {
1515

1616
log::info!("take solo `Staking::Bonded`, `Staking::Ledger`, `Staking::RingPool`, `Staking::KtonPool` and `Staking::LivingTime`");
1717
self.solo_state
18-
.take_raw_map(&item_key(b"Staking", b"Bonded"), &mut bonded, get_identity_key)
18+
.take_raw_map(&item_key(b"Staking", b"Bonded"), &mut bonded, |key, from| {
19+
replace_first_match(key, from, &item_key(b"AccountMigration", b"Bonded"))
20+
})
1921
.take_map(b"Staking", b"Ledger", &mut ledgers, get_identity_key)
2022
.take_value(b"Staking", b"RingPool", "", &mut ring_pool_storage)
2123
.take_value(b"Staking", b"KtonPool", "", &mut kton_pool_storage)

tool/state-processor/src/type_registry.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -91,8 +91,8 @@ pub struct Unbonding {
9191
pub struct Ledger {
9292
pub staked_ring: u128,
9393
pub staked_kton: u128,
94-
pub staked_deposits: Vec<u8>,
94+
pub staked_deposits: Vec<u16>,
9595
pub unstaking_ring: Vec<(u128, u32)>,
9696
pub unstaking_kton: Vec<(u128, u32)>,
97-
pub unstaking_deposits: Vec<(u8, u32)>,
97+
pub unstaking_deposits: Vec<(u16, u32)>,
9898
}

0 commit comments

Comments
 (0)