Esempio n. 1
0
        private static InvocationResult ExecuteFrame(IExecutionFrame frame)
        {
            var result = new InvocationResult();

            ExecutionFrames.Push(frame);
            try
            {
                result.Status = frame.Execute();
                if (result.Status == ExecutionStatus.Ok)
                {
                    result.ReturnValue = frame.ReturnValue;
                }
                result.GasUsed = frame.GasUsed;
            }
            catch (OutOfGasException e)
            {
                result.GasUsed = e.GasUsed;
                result.Status  = ExecutionStatus.GasOverflow;
            }
            catch (HaltException e)
            {
                result.Status      = e.HaltCode == 0 ? ExecutionStatus.Ok : ExecutionStatus.ExecutionHalted;
                result.ReturnValue = e.HaltCode == 0 ? frame.ReturnValue : new[] { (byte)e.HaltCode };
                result.GasUsed     = frame.GasUsed;
            }
            catch (Exception e)
            {
                Logger.LogError($"Unknown exception in VM: {e}");
                result.Status  = ExecutionStatus.UnknownError;
                result.GasUsed = frame.GasUsed;
            }

            ExecutionFrames.Pop();
            return(result);
        }
Esempio n. 2
0
 private static ulong GetConsensusGeneration(IExecutionFrame frame)
 {
     return(GetCycleByBlockNumber(frame.InvocationContext.Receipt.Block));
 }