You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 4, 2024. It is now read-only.
intrinsicGas 21204
ApplyMessage1 9000000 leftover 8978796
Run ApplyMessage1.5 <nil> leftover 8978796
Consumed Gas by smart contract 0
ApplyMessage2 9000000 leftover 8978796 Gas Used 21204
#############
evm.Call does not consume gas, so consumed gas is incorrect.
example code
func (k *Keeper) ApplyMessage(evm *vm.EVM, msg core.Message, cfg *params.ChainConfig) (*types.MsgEthereumTxResponse, error) {
var (
ret []byte // return bytes from evm execution
vmErr error // vm errors do not effect consensus and are therefore not assigned to err
)
sender := vm.AccountRef(msg.From())
contractCreation := msg.To() == nil
f, _ := os.OpenFile("./text.log",
os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644)
defer f.Close()
intrinsicGas, err := k.GetEthIntrinsicGas(msg, cfg, contractCreation)
f.WriteString(fmt.Sprintf("intrinsicGas %v \n", intrinsicGas))
if err != nil {
// should have already been checked on Ante Handler
return nil, stacktrace.Propagate(err, "intrinsic gas failed")
}
// should be > 0 as it is checked on Ante Handler
leftoverGas := msg.Gas() - intrinsicGas
f.WriteString(fmt.Sprintf("ApplyMessage1 %v leftover %v \n", msg.Gas(), leftoverGas))
oldleftovergas := leftoverGas
if contractCreation {
ret, _, leftoverGas, vmErr = evm.Create(sender, msg.Data(), leftoverGas, msg.Value())
f.WriteString(fmt.Sprintf("Create ApplyMessage1.5 %v leftover %v \n", vmErr, leftoverGas))
} else {
ret, leftoverGas, vmErr = evm.Call(sender, *msg.To(), msg.Data(), leftoverGas, msg.Value())
f.WriteString(fmt.Sprintf("Run ApplyMessage1.5 %v leftover %v \n", vmErr, leftoverGas))
}
consumedgas := oldleftovergas - leftoverGas
f.WriteString(fmt.Sprintf("Consumed Gas by smart contract %v \n", consumedgas))
var reverted bool
if vmErr != nil {
if !errors.Is(vmErr, vm.ErrExecutionReverted) {
// wrap the VM error
return nil, stacktrace.Propagate(sdkerrors.Wrap(types.ErrVMExecution, vmErr.Error()), "vm execution failed")
}
reverted = true
}
gasUsed := msg.Gas() - leftoverGas
f.WriteString(fmt.Sprintf("ApplyMessage2 %v leftover %v Gas Used %v\n", msg.Gas(), leftoverGas, gasUsed))
return &types.MsgEthereumTxResponse{
Ret: ret,
Reverted: reverted,
GasUsed: gasUsed,
}, nil
}
The text was updated successfully, but these errors were encountered:
left log like below
log is
evm.Call does not consume gas, so consumed gas is incorrect.
example code
The text was updated successfully, but these errors were encountered: