EIP-2315: Simple Subroutines for the EVM (#11629)

This commit is contained in:
adria0.eth
2020-08-07 20:41:07 +03:00
committed by Artem Vorotnikov
parent 751210c963
commit 1460f6cc27
11 changed files with 452 additions and 40 deletions

View File

@@ -34,6 +34,12 @@ pub enum Error {
StackUnderflow,
/// When execution would exceed defined Stack Limit
OutOfStack,
/// When there is not enough subroutine stack elements to return from
SubStackUnderflow,
/// When execution would exceed defined subroutine Stack Limit
OutOfSubStack,
/// When the code walks into a subroutine, that is not allowed
InvalidSubEntry,
/// When builtin contract failed on input data
BuiltIn,
/// Returned on evm internal error. Should never be ignored during development.
@@ -57,6 +63,9 @@ impl<'a> From<&'a VmError> for Error {
VmError::BadInstruction { .. } => Error::BadInstruction,
VmError::StackUnderflow { .. } => Error::StackUnderflow,
VmError::OutOfStack { .. } => Error::OutOfStack,
VmError::SubStackUnderflow { .. } => Error::SubStackUnderflow,
VmError::OutOfSubStack { .. } => Error::OutOfSubStack,
VmError::InvalidSubEntry { .. } => Error::InvalidSubEntry,
VmError::BuiltIn { .. } => Error::BuiltIn,
VmError::Wasm { .. } => Error::Wasm,
VmError::Internal(_) => Error::Internal,
@@ -82,7 +91,10 @@ impl fmt::Display for Error {
BadInstruction => "Bad instruction",
StackUnderflow => "Stack underflow",
OutOfStack => "Out of stack",
SubStackUnderflow => "Subroutine stack underflow",
OutOfSubStack => "Subroutine stack overflow",
BuiltIn => "Built-in failed",
InvalidSubEntry => "Invalid subroutine entry",
Wasm => "Wasm runtime error",
Internal => "Internal error",
MutableCallInStaticContext => "Mutable Call In Static Context",
@@ -108,6 +120,9 @@ impl Encodable for Error {
Wasm => 8,
OutOfBounds => 9,
Reverted => 10,
SubStackUnderflow => 11,
OutOfSubStack => 12,
InvalidSubEntry => 13,
};
s.append_internal(&value);
@@ -130,6 +145,9 @@ impl Decodable for Error {
8 => Ok(Wasm),
9 => Ok(OutOfBounds),
10 => Ok(Reverted),
11 => Ok(SubStackUnderflow),
12 => Ok(OutOfSubStack),
13 => Ok(InvalidSubEntry),
_ => Err(DecoderError::Custom("Invalid error type")),
}
}