Skip to content

Commit cb7470d

Browse files
committed
Add V2 staking extensions supporting delegated proxy calls for state-mutating staking functions
1 parent 2e42602 commit cb7470d

File tree

4 files changed

+780
-28
lines changed

4 files changed

+780
-28
lines changed

chain-extensions/src/lib.rs

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -531,11 +531,11 @@ where
531531
Ok(RetVal::Converging(Output::Success as u32))
532532
}
533533
// ============================================================
534-
// Proxy-aware staking functions
535-
// These allow a contract to act on behalf of a real_coldkey
536-
// if the contract has been granted appropriate proxy permissions.
534+
// V2 staking functions
535+
// These accept an explicit coldkey parameter. If the caller differs
536+
// from the coldkey, proxy permissions are verified before execution.
537537
// ============================================================
538-
FunctionId::AddStakeAsProxyV1 => {
538+
FunctionId::AddStakeV2 => {
539539
let weight = Weight::from_parts(340_800_000, 0)
540540
.saturating_add(T::DbWeight::get().reads(25_u64))
541541
.saturating_add(T::DbWeight::get().writes(15));
@@ -572,7 +572,7 @@ where
572572
}
573573
}
574574
}
575-
FunctionId::RemoveStakeAsProxyV1 => {
575+
FunctionId::RemoveStakeV2 => {
576576
let weight = Weight::from_parts(196_800_000, 0)
577577
.saturating_add(T::DbWeight::get().reads(20))
578578
.saturating_add(T::DbWeight::get().writes(10));
@@ -609,7 +609,7 @@ where
609609
}
610610
}
611611
}
612-
FunctionId::UnstakeAllAsProxyV1 => {
612+
FunctionId::UnstakeAllV2 => {
613613
let weight = Weight::from_parts(28_830_000, 0)
614614
.saturating_add(T::DbWeight::get().reads(7))
615615
.saturating_add(T::DbWeight::get().writes(0));
@@ -639,7 +639,7 @@ where
639639
}
640640
}
641641
}
642-
FunctionId::UnstakeAllAlphaAsProxyV1 => {
642+
FunctionId::UnstakeAllAlphaV2 => {
643643
let weight = Weight::from_parts(358_500_000, 0)
644644
.saturating_add(T::DbWeight::get().reads(37_u64))
645645
.saturating_add(T::DbWeight::get().writes(21_u64));
@@ -669,7 +669,7 @@ where
669669
}
670670
}
671671
}
672-
FunctionId::MoveStakeAsProxyV1 => {
672+
FunctionId::MoveStakeV2 => {
673673
let weight = Weight::from_parts(164_300_000, 0)
674674
.saturating_add(T::DbWeight::get().reads(16_u64))
675675
.saturating_add(T::DbWeight::get().writes(7_u64));
@@ -710,7 +710,7 @@ where
710710
}
711711
}
712712
}
713-
FunctionId::TransferStakeAsProxyV1 => {
713+
FunctionId::TransferStakeV2 => {
714714
let weight = Weight::from_parts(160_300_000, 0)
715715
.saturating_add(T::DbWeight::get().reads(14_u64))
716716
.saturating_add(T::DbWeight::get().writes(6_u64));
@@ -751,7 +751,7 @@ where
751751
}
752752
}
753753
}
754-
FunctionId::SwapStakeAsProxyV1 => {
754+
FunctionId::SwapStakeV2 => {
755755
let weight = Weight::from_parts(351_300_000, 0)
756756
.saturating_add(T::DbWeight::get().reads(36_u64))
757757
.saturating_add(T::DbWeight::get().writes(22_u64));
@@ -790,7 +790,7 @@ where
790790
}
791791
}
792792
}
793-
FunctionId::AddStakeLimitAsProxyV1 => {
793+
FunctionId::AddStakeLimitV2 => {
794794
let weight = Weight::from_parts(402_900_000, 0)
795795
.saturating_add(T::DbWeight::get().reads(25_u64))
796796
.saturating_add(T::DbWeight::get().writes(15));
@@ -831,7 +831,7 @@ where
831831
}
832832
}
833833
}
834-
FunctionId::RemoveStakeLimitAsProxyV1 => {
834+
FunctionId::RemoveStakeLimitV2 => {
835835
let weight = Weight::from_parts(377_400_000, 0)
836836
.saturating_add(T::DbWeight::get().reads(29_u64))
837837
.saturating_add(T::DbWeight::get().writes(14));
@@ -872,7 +872,7 @@ where
872872
}
873873
}
874874
}
875-
FunctionId::SwapStakeLimitAsProxyV1 => {
875+
FunctionId::SwapStakeLimitV2 => {
876876
let weight = Weight::from_parts(411_500_000, 0)
877877
.saturating_add(T::DbWeight::get().reads(36_u64))
878878
.saturating_add(T::DbWeight::get().writes(22_u64));
@@ -923,7 +923,7 @@ where
923923
}
924924
}
925925
}
926-
FunctionId::RemoveStakeFullLimitAsProxyV1 => {
926+
FunctionId::RemoveStakeFullLimitV2 => {
927927
let weight = Weight::from_parts(395_300_000, 0)
928928
.saturating_add(T::DbWeight::get().reads(29_u64))
929929
.saturating_add(T::DbWeight::get().writes(14_u64));
@@ -960,7 +960,7 @@ where
960960
}
961961
}
962962
}
963-
FunctionId::SetColdkeyAutoStakeHotkeyAsProxyV1 => {
963+
FunctionId::SetColdkeyAutoStakeHotkeyV2 => {
964964
let weight = Weight::from_parts(29_930_000, 0)
965965
.saturating_add(T::DbWeight::get().reads(5_u64))
966966
.saturating_add(T::DbWeight::get().writes(2_u64));

0 commit comments

Comments
 (0)