Skip to content

Commit

Permalink
Merge pull request #30 from aurora-is-near/feat/merge-upstream
Browse files Browse the repository at this point in the history
feat: merge changes from the upstream
  • Loading branch information
aleksuss authored Sep 22, 2023
2 parents a33ac87 + 9125fbd commit 016e449
Show file tree
Hide file tree
Showing 29 changed files with 1,205 additions and 1,233 deletions.
3 changes: 1 addition & 2 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ on:
push:
branches: [ master ]
pull_request:
branches: [ master ]

env:
CARGO_TERM_COLOR: always
Expand All @@ -17,7 +16,7 @@ jobs:
- name: Rustfmt
run: cargo fmt --all -- --check
- name: Clippy
run: cargo clippy --all
run: cargo clippy --workspace --all-targets -- -D clippy::all -D clippy::nursery
build:
runs-on: ubuntu-latest
steps:
Expand Down
4 changes: 3 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ evm-gasometer = { version = "0.39", path = "gasometer", default-features = false
evm-runtime = { version = "0.39", path = "runtime", default-features = false }

[dev-dependencies]
criterion = "0.4"
criterion = "0.5"
hex = "0.4"

[[bench]]
Expand Down Expand Up @@ -66,13 +66,15 @@ with-serde = [
]
tracing = [
"environmental",
"evm-core/tracing",
"evm-gasometer/tracing",
"evm-runtime/tracing",
]
force-debug = [
"evm-core/force-debug",
"evm-gasometer/force-debug",
]
create-fixed = []

[workspace]
members = [
Expand Down
3 changes: 2 additions & 1 deletion core/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,5 @@ with-serde = [
]
force-debug = [
"log",
]
]
tracing = []
12 changes: 8 additions & 4 deletions core/src/error.rs
Original file line number Diff line number Diff line change
Expand Up @@ -35,22 +35,26 @@ pub enum ExitReason {

impl ExitReason {
/// Whether the exit is succeeded.
pub fn is_succeed(&self) -> bool {
#[must_use]
pub const fn is_succeed(&self) -> bool {
matches!(self, Self::Succeed(_))
}

/// Whether the exit is error.
pub fn is_error(&self) -> bool {
#[must_use]
pub const fn is_error(&self) -> bool {
matches!(self, Self::Error(_))
}

/// Whether the exit is revert.
pub fn is_revert(&self) -> bool {
#[must_use]
pub const fn is_revert(&self) -> bool {
matches!(self, Self::Revert(_))
}

/// Whether the exit is fatal.
pub fn is_fatal(&self) -> bool {
#[must_use]
pub const fn is_fatal(&self) -> bool {
matches!(self, Self::Fatal(_))
}
}
Expand Down
33 changes: 25 additions & 8 deletions core/src/eval/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,11 +17,15 @@ macro_rules! try_or_fail {
};
}

macro_rules! pop {
macro_rules! pop_h256 {
( $machine:expr, $( $x:ident ),* ) => (
$(
let $x = match $machine.stack.pop() {
Ok(value) => value,
Ok(value) => {
let mut res = H256([0; 32]);
value.to_big_endian(&mut res[..]);
res
},
Err(e) => return Control::Exit(e.into()),
};
)*
Expand All @@ -32,17 +36,17 @@ macro_rules! pop_u256 {
( $machine:expr, $( $x:ident ),* ) => (
$(
let $x = match $machine.stack.pop() {
Ok(value) => U256::from_big_endian(&value[..]),
Ok(value) => value,
Err(e) => return Control::Exit(e.into()),
};
)*
);
}

macro_rules! push {
macro_rules! push_h256 {
( $machine:expr, $( $x:expr ),* ) => (
$(
match $machine.stack.push($x) {
match $machine.stack.push(U256::from_big_endian(&$x[..])) {
Ok(()) => (),
Err(e) => return Control::Exit(e.into()),
}
Expand All @@ -53,16 +57,29 @@ macro_rules! push {
macro_rules! push_u256 {
( $machine:expr, $( $x:expr ),* ) => (
$(
let mut value = H256::default();
$x.to_big_endian(&mut value[..]);
match $machine.stack.push(value) {
match $machine.stack.push($x) {
Ok(()) => (),
Err(e) => return Control::Exit(e.into()),
}
)*
)
}

/// Pops top element of the stack and converts it to `usize`.
///
/// The top element **must** be not greater than `usize::MAX`.
/// This non-local invariant is enforced by gas metering infrastructure.
macro_rules! pop_usize {
( $machine:expr, $( $x:ident ),* ) => (
$(
let $x = match $machine.stack.pop() {
Ok(value) => value.as_usize(),
Err(e) => return Control::Exit(e.into()),
};
)*
);
}

macro_rules! op1_u256_fn {
( $machine:expr, $op:path ) => {{
pop_u256!($machine, op1);
Expand Down
Loading

0 comments on commit 016e449

Please sign in to comment.