Skip to content

Commit

Permalink
Rename some features (#284)
Browse files Browse the repository at this point in the history
- rename feature `with-codec` => `scale`
- rename feature `with-serde` => `serde`
  • Loading branch information
koushiro authored May 19, 2024
1 parent 36f25ac commit 0c114ed
Show file tree
Hide file tree
Showing 7 changed files with 57 additions and 50 deletions.
30 changes: 17 additions & 13 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>"]
repository = "https://github.com/rust-ethereum/evm"
Expand All @@ -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 }
Expand All @@ -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",
]
15 changes: 8 additions & 7 deletions interpreter/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,16 +1,17 @@
[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 }
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 }
Expand All @@ -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",
]
48 changes: 24 additions & 24 deletions interpreter/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,10 +33,10 @@ pub type ExitResult = Result<ExitSucceed, ExitError>;
/// 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),
Expand Down Expand Up @@ -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,
Expand All @@ -96,67 +96,67 @@ impl From<ExitSucceed> 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>),
}

Expand All @@ -175,10 +175,10 @@ impl From<ExitException> 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,
Expand Down
4 changes: 2 additions & 2 deletions interpreter/src/opcode.rs
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
3 changes: 2 additions & 1 deletion jsontests/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
4 changes: 2 additions & 2 deletions precompile/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down
3 changes: 2 additions & 1 deletion tracer/Cargo.toml
Original file line number Diff line number Diff line change
@@ -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 }
Expand Down

0 comments on commit 0c114ed

Please sign in to comment.