diff --git a/Cargo.toml b/Cargo.toml index 2a2134771..7b0a5fea0 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,4 +1,15 @@ +[workspace] +members = [ + "interpreter", + "jsontests", + "precompile", + "tracer", +] +resolver = "2" + [workspace.package] +edition = "2021" +rust-version = "1.60.0" license = "Apache-2.0" authors = ["rust-evm Developers "] repository = "https://github.com/rust-ethereum/evm" @@ -7,7 +18,8 @@ keywords = ["no_std", "ethereum", "evm"] [package] name = "evm" version = "1.0.0-dev" -edition = "2021" +edition = { workspace = true } +rust-version = { workspace = true } license = { workspace = true } authors = { workspace = true } repository = { workspace = true } @@ -27,20 +39,12 @@ std = [ "sha3/std", "evm-interpreter/std", ] -with-codec = [ +scale = [ "primitive-types/codec", "primitive-types/scale-info", - "evm-interpreter/with-codec", + "evm-interpreter/scale", ] -with-serde = [ +serde = [ "primitive-types/impl-serde", - "evm-interpreter/with-serde", -] - -[workspace] -members = [ - "interpreter", - "jsontests", - "precompile", - "tracer", + "evm-interpreter/serde", ] diff --git a/interpreter/Cargo.toml b/interpreter/Cargo.toml index a4583ffb9..e23509501 100644 --- a/interpreter/Cargo.toml +++ b/interpreter/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "evm-interpreter" version = "1.0.0-dev" -edition = "2021" +edition = { workspace = true } +rust-version = { workspace = true } license = { workspace = true } authors = { workspace = true } repository = { workspace = true } @@ -9,8 +10,8 @@ keywords = { workspace = true } description = "The interpreter part of Ethereum Virtual Machine" [dependencies] -auto_impl = "1.1" -paste = "1.0.15" +auto_impl = "1.2" +paste = "1.0" primitive-types = { version = "0.12", default-features = false, features = ["rlp"] } rlp = { version = "0.5", default-features = false } scale-codec = { package = "parity-scale-codec", version = "3.2", default-features = false, features = ["derive", "full"], optional = true } @@ -26,17 +27,17 @@ default = ["std"] std = [ "primitive-types/std", "rlp/std", - "serde/std", "scale-codec/std", "scale-info/std", + "serde/std", "sha3/std", ] -with-codec = [ +scale = [ "scale-codec", "scale-info", "primitive-types/impl-codec", ] -with-serde = [ - "serde", +serde = [ + "dep:serde", "primitive-types/impl-serde", ] diff --git a/interpreter/src/error.rs b/interpreter/src/error.rs index 69c1d5ff7..aaf74fbcb 100644 --- a/interpreter/src/error.rs +++ b/interpreter/src/error.rs @@ -33,10 +33,10 @@ pub type ExitResult = Result; /// Exit reason. #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr( - feature = "with-codec", + feature = "scale", derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo) )] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ExitError { /// Machine returns a normal EVM error. Exception(ExitException), @@ -74,10 +74,10 @@ impl std::fmt::Display for ExitError { /// Exit succeed reason. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr( - feature = "with-codec", + feature = "scale", derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo) )] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ExitSucceed { /// Machine encountered an explicit stop. Stopped, @@ -96,67 +96,67 @@ impl From for ExitResult { /// Exit error reason. #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr( - feature = "with-codec", + feature = "scale", derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo) )] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ExitException { /// Trying to pop from an empty stack. - #[cfg_attr(feature = "with-codec", codec(index = 0))] + #[cfg_attr(feature = "scale", codec(index = 0))] StackUnderflow, /// Trying to push into a stack over stack limit. - #[cfg_attr(feature = "with-codec", codec(index = 1))] + #[cfg_attr(feature = "scale", codec(index = 1))] StackOverflow, /// Jump destination is invalid. - #[cfg_attr(feature = "with-codec", codec(index = 2))] + #[cfg_attr(feature = "scale", codec(index = 2))] InvalidJump, /// An opcode accesses memory region, but the region is invalid. - #[cfg_attr(feature = "with-codec", codec(index = 3))] + #[cfg_attr(feature = "scale", codec(index = 3))] InvalidRange, /// Encountered the designated invalid opcode. - #[cfg_attr(feature = "with-codec", codec(index = 4))] + #[cfg_attr(feature = "scale", codec(index = 4))] DesignatedInvalid, /// Call stack is too deep (runtime). - #[cfg_attr(feature = "with-codec", codec(index = 5))] + #[cfg_attr(feature = "scale", codec(index = 5))] CallTooDeep, /// Create opcode encountered collision (runtime). - #[cfg_attr(feature = "with-codec", codec(index = 6))] + #[cfg_attr(feature = "scale", codec(index = 6))] CreateCollision, /// Create init code exceeds limit (runtime). - #[cfg_attr(feature = "with-codec", codec(index = 7))] + #[cfg_attr(feature = "scale", codec(index = 7))] CreateContractLimit, /// Invalid opcode during execution or starting byte is 0xef ([EIP-3541](https://github.com/ethereum/EIPs/blob/master/EIPS/eip-3541.md)). - #[cfg_attr(feature = "with-codec", codec(index = 15))] + #[cfg_attr(feature = "scale", codec(index = 15))] InvalidOpcode(Opcode), /// An opcode accesses external information, but the request is off offset /// limit (runtime). - #[cfg_attr(feature = "with-codec", codec(index = 8))] + #[cfg_attr(feature = "scale", codec(index = 8))] OutOfOffset, /// Execution runs out of gas (runtime). - #[cfg_attr(feature = "with-codec", codec(index = 9))] + #[cfg_attr(feature = "scale", codec(index = 9))] OutOfGas, /// Not enough fund to start the execution (runtime). - #[cfg_attr(feature = "with-codec", codec(index = 10))] + #[cfg_attr(feature = "scale", codec(index = 10))] OutOfFund, /// PC underflowed (unused). #[allow(clippy::upper_case_acronyms)] - #[cfg_attr(feature = "with-codec", codec(index = 11))] + #[cfg_attr(feature = "scale", codec(index = 11))] PCUnderflow, /// Attempt to create an empty account (runtime, unused). - #[cfg_attr(feature = "with-codec", codec(index = 12))] + #[cfg_attr(feature = "scale", codec(index = 12))] CreateEmpty, /// Nonce reached maximum value of 2^64-1 /// https://eips.ethereum.org/EIPS/eip-2681 - #[cfg_attr(feature = "with-codec", codec(index = 14))] + #[cfg_attr(feature = "scale", codec(index = 14))] MaxNonce, /// Other normal errors. - #[cfg_attr(feature = "with-codec", codec(index = 13))] + #[cfg_attr(feature = "scale", codec(index = 13))] Other(Cow<'static, str>), } @@ -175,10 +175,10 @@ impl From for ExitError { /// Exit fatal reason. #[derive(Clone, Debug, Eq, PartialEq)] #[cfg_attr( - feature = "with-codec", + feature = "scale", derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo) )] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub enum ExitFatal { /// The operation is not supported. NotSupported, diff --git a/interpreter/src/opcode.rs b/interpreter/src/opcode.rs index b4d0a4746..25b668d2b 100644 --- a/interpreter/src/opcode.rs +++ b/interpreter/src/opcode.rs @@ -1,10 +1,10 @@ /// Opcode enum. One-to-one corresponding to an `u8` value. #[derive(Clone, Copy, Debug, Eq, PartialEq)] #[cfg_attr( - feature = "with-codec", + feature = "scale", derive(scale_codec::Encode, scale_codec::Decode, scale_info::TypeInfo) )] -#[cfg_attr(feature = "with-serde", derive(serde::Serialize, serde::Deserialize))] +#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] pub struct Opcode(pub u8); // Core opcodes. diff --git a/jsontests/Cargo.toml b/jsontests/Cargo.toml index 95c902f90..7cd6f5aa8 100644 --- a/jsontests/Cargo.toml +++ b/jsontests/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "jsontests" version = "0.0.0-dev" -edition = "2021" +edition = { workspace = true } +rust-version = { workspace = true } license = { workspace = true } authors = { workspace = true } repository = { workspace = true } diff --git a/precompile/Cargo.toml b/precompile/Cargo.toml index f412a35b1..eac21091e 100644 --- a/precompile/Cargo.toml +++ b/precompile/Cargo.toml @@ -1,8 +1,8 @@ [package] name = "evm-precompile" version = "0.0.0-dev" -edition = "2021" -license = { workspace = true } +edition = { workspace = true } +rust-version = "1.65.0" authors = { workspace = true } repository = { workspace = true } keywords = { workspace = true } diff --git a/tracer/Cargo.toml b/tracer/Cargo.toml index a5c1ddb87..c56c01150 100644 --- a/tracer/Cargo.toml +++ b/tracer/Cargo.toml @@ -1,7 +1,8 @@ [package] name = "evm-tracer" version = "0.0.0-dev" -edition = "2021" +edition = { workspace = true } +rust-version = { workspace = true } license = { workspace = true } authors = { workspace = true } repository = { workspace = true }