@@ -207,6 +207,7 @@ pub fn apply_entry<'db, 'a>(db: &'db TransactionDB<MultiThreaded>, pk: &[u8], sk
207207 }
208208 }
209209 } ) ) ;
210+
210211 applyenv. exec_track = false ;
211212
212213 let tx_cost = txu. map_get ( crate :: atoms:: tx_cost ( ) ) . unwrap ( ) . decode :: < i128 > ( ) . unwrap ( ) ;
@@ -243,10 +244,7 @@ pub fn apply_entry<'db, 'a>(db: &'db TransactionDB<MultiThreaded>, pk: &[u8], sk
243244*/
244245 let mut m = std:: collections:: HashMap :: new ( ) ;
245246 m. insert ( "error" . to_string ( ) , "ok" . to_string ( ) ) ;
246- m. insert ( "exec_used" . to_string ( ) , tx_cost. clone ( ) ) ;
247- if applyenv. caller_env . entry_height >= protocol:: FORKHEIGHT {
248- m. insert ( "exec_used" . to_string ( ) , exec_cost_total. clone ( ) ) ;
249- }
247+ m. insert ( "exec_used" . to_string ( ) , exec_cost_total. clone ( ) ) ;
250248 applyenv. result_log . push ( m) ;
251249 }
252250 Err ( payload) => {
@@ -257,18 +255,12 @@ pub fn apply_entry<'db, 'a>(db: &'db TransactionDB<MultiThreaded>, pk: &[u8], sk
257255 if let Some ( & s) = payload. downcast_ref :: < & ' static str > ( ) {
258256 let mut m = std:: collections:: HashMap :: new ( ) ;
259257 m. insert ( "error" . to_string ( ) , s. to_string ( ) ) ;
260- m. insert ( "exec_used" . to_string ( ) , tx_cost. clone ( ) ) ;
261- if applyenv. caller_env . entry_height >= protocol:: FORKHEIGHT {
262- m. insert ( "exec_used" . to_string ( ) , exec_cost_total. clone ( ) ) ;
263- }
258+ m. insert ( "exec_used" . to_string ( ) , exec_cost_total. clone ( ) ) ;
264259 applyenv. result_log . push ( m) ;
265260 } else {
266261 let mut m = std:: collections:: HashMap :: new ( ) ;
267262 m. insert ( "error" . to_string ( ) , "unknown" . to_string ( ) ) ;
268- m. insert ( "exec_used" . to_string ( ) , tx_cost. clone ( ) ) ;
269- if applyenv. caller_env . entry_height >= protocol:: FORKHEIGHT {
270- m. insert ( "exec_used" . to_string ( ) , exec_cost_total. clone ( ) ) ;
271- }
263+ m. insert ( "exec_used" . to_string ( ) , exec_cost_total. clone ( ) ) ;
272264 applyenv. result_log . push ( m) ;
273265 }
274266 }
@@ -404,22 +396,20 @@ impl ToTerm for Vec<HashMap<String, String>> {
404396
405397fn refund_exec_deposit ( applyenv : & mut ApplyEnv ) {
406398 //Refund remainer of the exec budget
407- if applyenv. caller_env . entry_height >= protocol:: FORKHEIGHT {
408- applyenv. muts = Vec :: new ( ) ;
409- applyenv. muts_rev = Vec :: new ( ) ;
410- let refund = applyenv. exec_left . max ( 0 ) ;
411- if refund > 0 {
412- let key = & crate :: bcat ( & [ b"account:" , & applyenv. caller_env . account_origin , b":balance:AMA" ] ) ;
413- consensus_kv:: kv_increment ( applyenv, key, refund) ;
414- }
415- // Increment validator / burn
416- let cost = applyenv. exec_max - refund;
417- consensus_kv:: kv_increment ( applyenv, & crate :: bcat ( & [ b"account:" , & applyenv. caller_env . entry_signer , b":balance:AMA" ] ) , cost/2 ) ;
418- consensus_kv:: kv_increment ( applyenv, & crate :: bcat ( & [ b"account:" , & consensus:: bic:: coin:: BURN_ADDRESS , b":balance:AMA" ] ) , cost/2 ) ;
419-
420- applyenv. muts_final . append ( & mut applyenv. muts ) ;
421- applyenv. muts_final_rev . append ( & mut applyenv. muts_rev ) ;
399+ applyenv. muts = Vec :: new ( ) ;
400+ applyenv. muts_rev = Vec :: new ( ) ;
401+ let refund = applyenv. exec_left . max ( 0 ) ;
402+ if refund > 0 {
403+ let key = & crate :: bcat ( & [ b"account:" , & applyenv. caller_env . account_origin , b":balance:AMA" ] ) ;
404+ consensus_kv:: kv_increment ( applyenv, key, refund) ;
422405 }
406+ // Increment validator / burn
407+ let cost = applyenv. exec_max - refund;
408+ consensus_kv:: kv_increment ( applyenv, & crate :: bcat ( & [ b"account:" , & applyenv. caller_env . entry_signer , b":balance:AMA" ] ) , cost/2 ) ;
409+ consensus_kv:: kv_increment ( applyenv, & crate :: bcat ( & [ b"account:" , & consensus:: bic:: coin:: BURN_ADDRESS , b":balance:AMA" ] ) , cost/2 ) ;
410+
411+ applyenv. muts_final . append ( & mut applyenv. muts ) ;
412+ applyenv. muts_final_rev . append ( & mut applyenv. muts_rev ) ;
423413}
424414
425415fn call_txs_pre_upfront_cost < ' a > ( env : & mut ApplyEnv , txus : & [ rustler:: Term < ' a > ] ) {
@@ -437,15 +427,10 @@ fn call_txs_pre_upfront_cost<'a>(env: &mut ApplyEnv, txus: &[rustler::Term<'a>])
437427 consensus_kv:: kv_put ( env, & crate :: bcat ( & [ b"account:" , & tx_signer, b":attribute:nonce" ] ) , & tx_nonce. to_string ( ) . into_bytes ( ) ) ;
438428
439429 // Deduct tx historical cost
440- if env. caller_env . entry_height >= protocol:: FORKHEIGHT {
441- let tx_historical_cost = txu. map_get ( crate :: atoms:: tx_historical_cost ( ) ) . unwrap ( ) . decode :: < i128 > ( ) . unwrap ( ) ;
442- protocol:: pay_cost ( env, tx_historical_cost) ;
443- //lock 0.1 AMA during execution
444- consensus_kv:: kv_increment ( env, & crate :: bcat ( & [ b"account:" , & env. caller_env . account_origin , b":balance:AMA" ] ) , -protocol:: AMA_10_CENT ) ;
445- } else {
446- let tx_cost = txu. map_get ( crate :: atoms:: tx_cost ( ) ) . unwrap ( ) . decode :: < i128 > ( ) . unwrap ( ) ;
447- protocol:: pay_cost ( env, tx_cost) ;
448- }
430+ let tx_historical_cost = txu. map_get ( crate :: atoms:: tx_historical_cost ( ) ) . unwrap ( ) . decode :: < i128 > ( ) . unwrap ( ) ;
431+ protocol:: pay_cost ( env, tx_historical_cost) ;
432+ //lock 0.1 AMA during execution
433+ consensus_kv:: kv_increment ( env, & crate :: bcat ( & [ b"account:" , & env. caller_env . account_origin , b":balance:AMA" ] ) , -protocol:: AMA_10_CENT ) ;
449434 }
450435 env. muts_final . append ( & mut env. muts ) ;
451436 env. muts_final_rev . append ( & mut env. muts_rev ) ;
0 commit comments