@@ -249,6 +249,18 @@ impl<T: Config> Default for CallResources<T> {
249249 }
250250}
251251
252+ /// Stored inside the `Stack` for each contract that is scheduled for termination.
253+ struct TerminateArgs < T : Config > {
254+ /// Where to send the free balance of the terminated contract.
255+ beneficiary : T :: AccountId ,
256+ /// The storage child trie of the contract that needs to be deleted.
257+ trie_id : TrieId ,
258+ /// The code referenced by the contract. Will be deleted if refcount drops to zero.
259+ code_hash : H256 ,
260+ /// Triggered by the EVM opcode.
261+ only_if_same_tx : bool ,
262+ }
263+
252264/// Environment functions only available to host functions.
253265pub trait Ext : PrecompileWithInfoExt {
254266 /// Execute code in the current frame.
@@ -2490,44 +2502,23 @@ pub fn is_precompile<T: Config, E: Executable<T>>(address: &H160) -> bool {
24902502}
24912503
24922504#[ cfg( feature = "runtime-benchmarks" ) ]
2493- pub fn terminate_contract_for_benchmark < T : Config > (
2494- origin : T :: AccountId ,
2495- contract : & T :: AccountId ,
2496- info : & ContractInfo < T > ,
2505+ pub fn bench_do_terminate < T : Config > (
2506+ transaction_meter : & mut TransactionMeter < T > ,
2507+ exec_config : & ExecConfig < T > ,
2508+ contract_account : & T :: AccountId ,
2509+ origin : & Origin < T > ,
24972510 beneficiary : T :: AccountId ,
2498- ) -> Result < ( ) , DispatchError > {
2499- use crate :: TransactionLimits ;
2500- use num_traits:: Bounded ;
2501-
2502- let mut transaction_meter = TransactionMeter :: new ( TransactionLimits :: WeightAndDeposit {
2503- weight_limit : Default :: default ( ) ,
2504- deposit_limit : BalanceOf :: < T > :: max_value ( ) ,
2505- } )
2506- . unwrap ( ) ;
2507- Stack :: < T , crate :: ContractBlob < T > > :: do_terminate (
2508- & mut transaction_meter,
2509- & ExecConfig :: new_substrate_tx ( ) ,
2510- contract,
2511- & Origin :: from_account_id ( origin) ,
2512- & TerminateArgs {
2513- beneficiary,
2514- trie_id : info. trie_id . clone ( ) ,
2515- code_hash : info. code_hash ,
2516- only_if_same_tx : false ,
2517- } ,
2518- )
2519- }
2520-
2521- /// Stored inside the `Stack` for each contract that is scheduled for termination.
2522- struct TerminateArgs < T : Config > {
2523- /// Where to send the free balance of the terminated contract.
2524- beneficiary : T :: AccountId ,
2525- /// The storage child trie of the contract that needs to be deleted.
25262511 trie_id : TrieId ,
2527- /// The code referenced by the contract. Will be deleted if refcount drops to zero.
25282512 code_hash : H256 ,
2529- /// Triggered by the EVM opcode.
25302513 only_if_same_tx : bool ,
2514+ ) -> Result < ( ) , DispatchError > {
2515+ Stack :: < T , crate :: ContractBlob < T > > :: do_terminate (
2516+ transaction_meter,
2517+ exec_config,
2518+ contract_account,
2519+ origin,
2520+ & TerminateArgs { beneficiary, trie_id, code_hash, only_if_same_tx } ,
2521+ )
25312522}
25322523
25332524mod sealing {
0 commit comments