@@ -26,6 +26,7 @@ use pallet_evm_precompile_blake2::Blake2F;
26
26
use pallet_evm_precompile_bn128:: { Bn128Add , Bn128Mul , Bn128Pairing } ;
27
27
use pallet_evm_precompile_dapp_staking_v3:: DappStakingV3Precompile ;
28
28
use pallet_evm_precompile_dispatch:: Dispatch ;
29
+ use pallet_evm_precompile_dispatch_lockdrop:: DispatchLockdrop ;
29
30
use pallet_evm_precompile_ed25519:: Ed25519Verify ;
30
31
use pallet_evm_precompile_modexp:: Modexp ;
31
32
use pallet_evm_precompile_sha3fips:: Sha3FIPS256 ;
@@ -34,6 +35,7 @@ use pallet_evm_precompile_sr25519::Sr25519Precompile;
34
35
use pallet_evm_precompile_substrate_ecdsa:: SubstrateEcdsaPrecompile ;
35
36
use pallet_evm_precompile_xcm:: XcmPrecompile ;
36
37
use precompile_utils:: precompile_set:: * ;
38
+ use sp_core:: ConstU32 ;
37
39
use sp_std:: fmt:: Debug ;
38
40
39
41
/// The asset precompile address prefix. Addresses that match against this prefix will be routed
@@ -65,6 +67,32 @@ impl Contains<RuntimeCall> for WhitelistedCalls {
65
67
}
66
68
}
67
69
}
70
+
71
+ /// Filter that only allows whitelisted runtime call to pass through dispatch-lockdrop precompile
72
+ pub struct WhitelistedLockdropCalls ;
73
+
74
+ impl Contains < RuntimeCall > for WhitelistedLockdropCalls {
75
+ fn contains ( t : & RuntimeCall ) -> bool {
76
+ match t {
77
+ RuntimeCall :: Utility ( pallet_utility:: Call :: batch { calls } )
78
+ | RuntimeCall :: Utility ( pallet_utility:: Call :: batch_all { calls } ) => calls
79
+ . iter ( )
80
+ . all ( |call| WhitelistedLockdropCalls :: contains ( call) ) ,
81
+ RuntimeCall :: DappStaking ( pallet_dapp_staking_v3:: Call :: unbond_and_unstake {
82
+ ..
83
+ } ) => true ,
84
+ RuntimeCall :: DappStaking ( pallet_dapp_staking_v3:: Call :: withdraw_unbonded {
85
+ ..
86
+ } ) => true ,
87
+ RuntimeCall :: Balances ( pallet_balances:: Call :: transfer_all { .. } ) => true ,
88
+ RuntimeCall :: Balances ( pallet_balances:: Call :: transfer_keep_alive { .. } ) => true ,
89
+ RuntimeCall :: Balances ( pallet_balances:: Call :: transfer_allow_death { .. } ) => true ,
90
+ RuntimeCall :: Assets ( pallet_assets:: Call :: transfer { .. } ) => true ,
91
+ _ => false ,
92
+ }
93
+ }
94
+ }
95
+
68
96
/// The PrecompileSet installed in the Astar runtime.
69
97
#[ precompile_utils:: precompile_name_from_address]
70
98
pub type AstarPrecompilesSetAt < R , C > = (
@@ -115,6 +143,18 @@ pub type AstarPrecompilesSetAt<R, C> = (
115
143
CallableByPrecompile ,
116
144
) ,
117
145
> ,
146
+ // Skipping 20485 and 20486 to make sure all network have consistent
147
+ // precompiles address
148
+ PrecompileAt <
149
+ AddressU64 < 20487 > ,
150
+ DispatchLockdrop <
151
+ R ,
152
+ DispatchFilterValidate < RuntimeCall , WhitelistedLockdropCalls > ,
153
+ ConstU32 < 8 > ,
154
+ > ,
155
+ // Not callable from smart contract nor precompiled, only EOA accounts
156
+ ( ) ,
157
+ > ,
118
158
) ;
119
159
120
160
pub type AstarPrecompiles < R , C > = PrecompileSetBuilder <
@@ -123,7 +163,7 @@ pub type AstarPrecompiles<R, C> = PrecompileSetBuilder<
123
163
// Skip precompiles if out of range.
124
164
PrecompilesInRangeInclusive <
125
165
// We take range as last precompile index, UPDATE this once new prcompile is added
126
- ( AddressU64 < 1 > , AddressU64 < 20484 > ) ,
166
+ ( AddressU64 < 1 > , AddressU64 < 20487 > ) ,
127
167
AstarPrecompilesSetAt < R , C > ,
128
168
> ,
129
169
// Prefixed precompile sets (XC20)
0 commit comments