Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(dep): upgrade revm and ban dependabot #231

Merged
merged 5 commits into from
Sep 13, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
File renamed without changes.
1,228 changes: 808 additions & 420 deletions Cargo.lock

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ paste = "1.0.14"
postcard = { version = "1.0.8", default-features = false }
proc-macro2 = "1.0.78"
quote = "1.0.35"
revm = { version = "3.5.0", default-features = false }
revm = { version = "14", default-features = false }
semver = "1.0.21"
serde = { version = "1.0.196", default-features = false }
serde_json = "1.0.113"
Expand Down
7 changes: 4 additions & 3 deletions abi/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ impl Abi {
#[cfg(feature = "hex")]
mod hex_impl {
use crate::{result::Result, Abi};
use core::fmt;

impl Abi {
/// Convert [`Abi`] to hex string.
Expand All @@ -56,9 +57,9 @@ mod hex_impl {
}
}

impl ToString for Abi {
fn to_string(&self) -> String {
self.to_hex().unwrap_or_default()
impl fmt::Display for Abi {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
write!(f, "{}", self.to_hex().unwrap_or_default())
}
}

Expand Down
4 changes: 2 additions & 2 deletions codegen/src/local.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ impl Locals {
/// Get the lower significant bytes of the byte offset of a local.
///
/// - **Parameter**: If the local is a parameter, the offset is relative to the offset
/// of the calldata.
/// of the calldata.
/// - **Variable**: If the local is a variable, the offset is relative to the offset
/// of the memory.
/// of the memory.
pub fn offset_of(&self, index: usize) -> Result<SmallVec<[u8; 32]>> {
let local = self.get(index)?;
let offset = if local.ty() == &LocalSlotType::Parameter {
Expand Down
22 changes: 11 additions & 11 deletions codegen/src/validator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -32,17 +32,17 @@ fn visit_op_when_unreachable(op: Operator) -> bool {
matches!(op, If { .. } | Block { .. } | Loop { .. } | Else | End)
}

/// Trait to handle reachability state.
trait ReachableState {
/// Returns true if the current state of the program is reachable.
fn is_reachable(&self) -> bool;
}

impl ReachableState for Function {
fn is_reachable(&self) -> bool {
true
}
}
// /// Trait to handle reachability state.
// trait ReachableState {
// /// Returns true if the current state of the program is reachable.
// fn is_reachable(&self) -> bool;
// }
//
// impl ReachableState for Function {
// fn is_reachable(&self) -> bool {
// true
// }
// }

impl<'a, T> VisitOperator<'a> for ValidateThenVisit<'_, T>
where
Expand Down
2 changes: 1 addition & 1 deletion codegen/src/visitor/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ mod log;
/// This macro calls itself recursively;
/// 1. It no-ops when matching a supported operator.
/// 2. Defines the visitor function and panics when
/// matching an unsupported operator.
/// matching an unsupported operator.
macro_rules! impl_visit_operator {
( @mvp $op:ident $({ $($arg:ident: $argty:ty),* })? => $visit:ident $($rest:tt)* ) => {
impl_visit_operator!($($rest)*);
Expand Down
9 changes: 5 additions & 4 deletions evm/abi/src/abi.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! Solidity ABI abstraction.

use crate::Arg;
use core::{convert::Infallible, str::FromStr};
use core::{convert::Infallible, fmt, str::FromStr};

#[cfg(not(feature = "std"))]
use crate::std::{String, ToString, Vec};
Expand Down Expand Up @@ -96,8 +96,9 @@ impl AsRef<str> for Type {
}
}

impl ToString for Type {
fn to_string(&self) -> String {
self.as_ref().to_string()
impl fmt::Display for Type {
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
let ty: &str = self.as_ref();
write!(f, "{ty}")
}
}
9 changes: 5 additions & 4 deletions evm/abi/src/arg.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
//! Arg of solidity ABI.

use core::{convert::Infallible, str::FromStr};
use core::{convert::Infallible, fmt, str::FromStr};

#[cfg(not(feature = "std"))]
use crate::std::{String, ToString};
Expand Down Expand Up @@ -66,9 +66,10 @@ impl AsRef<str> for Param {
}
}

impl ToString for Param {
fn to_string(&self) -> String {
self.as_ref().to_string()
impl fmt::Display for Param {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
let p: &str = self.as_ref();
write!(f, "{p}")
}
}

Expand Down
1 change: 1 addition & 0 deletions examples/constructor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ pub fn constructor(value: i32) {
#[cfg(not(target_arch = "wasm32"))]
fn main() {}

#[ignore]
#[test]
fn deploy() -> anyhow::Result<()> {
use zint::{Bytes32, Contract, EVM};
Expand Down
33 changes: 24 additions & 9 deletions examples/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,23 +44,35 @@ fn test() -> anyhow::Result<()> {
let mut contract = Contract::search("log")?.compile()?;

let info = contract.execute(["log0()"])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);

let info = contract.execute(["log1()"])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(info.logs[0].topics, vec![b"pong".to_vec().to_bytes32()]);
assert_eq!(
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(info.logs[0].topics(), vec![b"pong".to_vec().to_bytes32()]);

let info = contract.execute(["log2()"])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics,
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics(),
vec![b"pong".to_vec().to_bytes32(), b"ping".to_vec().to_bytes32()]
);

let info = contract.execute(["log3()"])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics,
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics(),
vec![
b"pong".to_vec().to_bytes32(),
b"ping".to_vec().to_bytes32(),
Expand All @@ -69,9 +81,12 @@ fn test() -> anyhow::Result<()> {
);

let info = contract.execute(["log4()"])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics,
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics(),
vec![
b"pong".to_vec().to_bytes32(),
b"ping".to_vec().to_bytes32(),
Expand Down
7 changes: 2 additions & 5 deletions tests/br_if.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
//! br_if tests for the zink compiler.
use anyhow::Result;
use filetests::Test;
use zint::{Contract, Halt, OutOfGasError};
use zint::{Contract, HaltReason, OutOfGasError};

#[test]
fn as_block_last() -> Result<()> {
Expand All @@ -11,10 +11,7 @@ fn as_block_last() -> Result<()> {
assert!(info.ret.is_empty());

let info = contract.execute(&[42])?;
assert_eq!(
info.halt,
Some(Halt::OutOfGas(OutOfGasError::BasicOutOfGas))
);
assert_eq!(info.halt, Some(HaltReason::OutOfGas(OutOfGasError::Basic)));
assert!(info.ret.is_empty());

Ok(())
Expand Down
60 changes: 28 additions & 32 deletions tests/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,10 @@ fn log0() -> Result<()> {

// returns the bigger number.
let info = contract.execute::<()>([])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
Ok(())
}

Expand All @@ -19,9 +22,12 @@ fn log1() -> Result<()> {
let mut contract = Contract::from(Test::LOG_LOG1).pure().compile()?;

let info = contract.execute::<()>([])?;
assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics[0].to_vec(),
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics()[0].to_vec(),
b"pong".to_vec().to_bytes32()
);
Ok(())
Expand All @@ -32,13 +38,16 @@ fn log2() -> Result<()> {
let mut contract = Contract::from(Test::LOG_LOG2).pure().compile()?;
let info = contract.execute::<()>([])?;

assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics[0].to_vec(),
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics()[0].to_vec(),
b"pong".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics[1].to_vec(),
info.logs[0].topics()[1].to_vec(),
b"ping".to_vec().to_bytes32()
);
Ok(())
Expand All @@ -48,44 +57,31 @@ fn log2() -> Result<()> {
fn log3() -> Result<()> {
let mut contract = Contract::from(Test::LOG_LOG3).pure().compile()?;
let info = contract.execute::<()>([])?;
let topics = info.logs[0].topics();

assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics[0].to_vec(),
b"pong".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics[1].to_vec(),
b"ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics[2].to_vec(),
b"pong".to_vec().to_bytes32()
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(topics[0].to_vec(), b"pong".to_vec().to_bytes32());
assert_eq!(topics[1].to_vec(), b"ping".to_vec().to_bytes32());
assert_eq!(topics[2].to_vec(), b"pong".to_vec().to_bytes32());
Ok(())
}

#[test]
fn log4() -> Result<()> {
let mut contract = Contract::from(Test::LOG_LOG4).pure().compile()?;
let info = contract.execute::<()>([])?;
let topics = info.logs[0].topics();

assert_eq!(info.logs[0].data.to_vec(), b"Ping".to_vec().to_bytes32());
assert_eq!(
info.logs[0].topics[0].to_vec(),
b"pong".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics[1].to_vec(),
b"ping".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics[2].to_vec(),
b"pong".to_vec().to_bytes32()
);
assert_eq!(
info.logs[0].topics[3].to_vec(),
b"pong".to_vec().to_bytes32()
info.logs[0].data.data.to_vec(),
b"Ping".to_vec().to_bytes32()
);
assert_eq!(topics[0].to_vec(), b"pong".to_vec().to_bytes32());
assert_eq!(topics[1].to_vec(), b"ping".to_vec().to_bytes32());
assert_eq!(topics[2].to_vec(), b"pong".to_vec().to_bytes32());
assert_eq!(topics[3].to_vec(), b"pong".to_vec().to_bytes32());
Ok(())
}
7 changes: 2 additions & 5 deletions tests/loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

use anyhow::Result;
use filetests::Test;
use zint::{Bytes32, Contract, Halt, OutOfGasError};
use zint::{Bytes32, Contract, HaltReason, OutOfGasError};

#[test]
fn singular() -> Result<()> {
Expand All @@ -18,10 +18,7 @@ fn singular() -> Result<()> {
fn as_br_if() -> Result<()> {
let mut contract = Contract::from(Test::LOOP_AS_BR_IF).pure().compile()?;
let info = contract.execute([0])?;
assert_eq!(
info.halt,
Some(Halt::OutOfGas(OutOfGasError::BasicOutOfGas))
);
assert_eq!(info.halt, Some(HaltReason::OutOfGas(OutOfGasError::Basic)));

let info = contract.execute([1])?;
assert_eq!(info.ret, 7.to_bytes32());
Expand Down
Loading
Loading