public ExecutionStatus Execute() { var method = Exports.GetMethod("start"); if (method is null) { return(ExecutionStatus.MissingEntry); } var gasLimitField = Exports.GetField("💩 GasLimit"); gasLimitField.SetValue(null, GasLimit); try { CompiledInstance.Exports.start(); } catch (OverflowException e) { Logger.LogWarning($"Overflow exception {e}"); throw new OutOfGasException(GasUsed); } catch (InvalidProgramException e) { Logger.LogWarning($"Invalid program exception {e}"); return(ExecutionStatus.JitCorruption); } return(ExecutionStatus.Ok); }
public void UseGas(ulong gas) { var gasLimitField = Exports.GetField("💩 GasLimit"); var currentGas = (ulong)gasLimitField.GetValue(null); Logger.LogDebug($"UseGas: current {currentGas}, use {gas}"); checked { currentGas -= gas; } gasLimitField.SetValue(null, currentGas); }