@@ -493,7 +493,7 @@ func (s *Solidity) executeContractCreation(ctx *context.WriteContext, txReq *TxR
493493 code , address , leftOverGas , err := vmenv .Create (sender , txReq .Input , txReq .GasLimit , uint256 .MustFromBig (txReq .Value ))
494494 if err != nil {
495495 gasUsed , _ := emitReceipt (ctx , vmenv , txReq , code , address , leftOverGas , err )
496- stateDB .SubBalance (sender .Address (), uint256 .NewInt (gasUsed * txReq . GasPrice . Uint64 () ), tracing .BalanceChangeUnspecified )
496+ stateDB .SubBalance (sender .Address (), uint256 .NewInt (0 ), tracing .BalanceChangeUnspecified )
497497 logrus .Errorf ("contract creation error, gasUsed:%v, gasLimit:%v, leftOver:%v, price:%v, address:%v" , gasUsed , txReq .GasLimit , leftOverGas , txReq .GasPrice , sender .Address ().String ())
498498 return txReq .GasLimit - leftOverGas , err
499499 }
@@ -504,22 +504,10 @@ func (s *Solidity) executeContractCreation(ctx *context.WriteContext, txReq *TxR
504504func (s * Solidity ) executeContractCall (ctx * context.WriteContext , txReq * TxRequest , ethState * pending_state.PendingStateWrapper , origin , coinBase common.Address , vmenv * vm.EVM , sender vm.AccountRef , rules params.Rules ) (uint64 , error ) {
505505 ethState .Prepare (rules , origin , coinBase , txReq .Address , vm .ActivePrecompiles (rules ), nil )
506506 ethState .SetNonce (txReq .Origin , ethState .GetNonce (txReq .Origin )+ 1 )
507- senderBalanceBefore := ethState .GetBalance (sender .Address ())
508507 code , leftOverGas , err := vmenv .Call (sender , * txReq .Address , txReq .Input , txReq .GasLimit , uint256 .MustFromBig (txReq .Value ))
509- senderBalanceAferExecute := ethState .GetBalance (sender .Address ())
510- isPureTransferTxn := false
511- if IsPureTransfer (sender , txReq , ethState ) {
512- isPureTransferTxn = true
513- extraTransferGas := config .GlobalConfig .ExtraBalanceGas
514- if extraTransferGas > txReq .GasLimit {
515- extraTransferGas = txReq .GasLimit
516- }
517- ethState .SubBalance (sender .Address (), uint256 .NewInt (extraTransferGas * txReq .GasPrice .Uint64 ()), tracing .BalanceChangeTransfer )
518- if leftOverGas >= extraTransferGas {
519- leftOverGas -= extraTransferGas
520- } else {
521- leftOverGas = 0
522- }
508+ isPureTransferTxn := IsPureTransfer (sender , txReq , ethState )
509+ if isPureTransferTxn {
510+ leftOverGas = txReq .GasLimit - config .GetGlobalConfig ().ExtraBalanceGas
523511 }
524512 // logrus.Printf("after transfer: account %s balance %d \n", sender.Address(), ethState.GetBalance(sender.Address()))
525513 if err != nil {
@@ -532,10 +520,6 @@ func (s *Solidity) executeContractCall(ctx *context.WriteContext, txReq *TxReque
532520 logrus .Errorf ("contract call error, gasUsed:%v, gasLimit:%v, leftOver:%v, price:%v, isPureTransferTxn:%v, sender:%v" , gasUsed , txReq .GasLimit , leftOverGas , txReq .GasPrice , isPureTransferTxn , sender .Address ().String ())
533521 return gasUsed , err
534522 }
535- senderBalanceAfterExtra := ethState .GetBalance (sender .Address ())
536- logrus .Printf ("contract call balance before:%v ,after execute:%v, after extra:%v, isPure:%v, sender:%v" ,
537- senderBalanceBefore .Uint64 (), senderBalanceAferExecute .Uint64 (), senderBalanceAfterExtra .Uint64 (), isPureTransferTxn , sender .Address ().String ())
538-
539523 _ , err2 := emitReceipt (ctx , vmenv , txReq , code , common.Address {}, leftOverGas , err )
540524 // logrus.Printf("[Execute Txn] SendTx success. Oringin code = %v, Hex Code = %v, Left Gas = %v", code, hex.EncodeToString(code), leftOverGas)
541525 return txReq .GasLimit - leftOverGas , err2
0 commit comments