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

chore: bump alloy deps #1623

Merged
merged 2 commits into from
Jul 16, 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
60 changes: 34 additions & 26 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 1 addition & 6 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,4 @@ debug = true

[profile.ethtests]
inherits = "test"
opt-level = 3

[patch.crates-io]
alloy-eips = { git = "https://github.com/alloy-rs/alloy.git", rev = "678617e" }
alloy-provider = { git = "https://github.com/alloy-rs/alloy.git", rev = "678617e" }
alloy-transport = { git = "https://github.com/alloy-rs/alloy.git", rev = "678617e" }
opt-level = 3
2 changes: 1 addition & 1 deletion crates/primitives/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ rust_2018_idioms = "deny"
all = "warn"

[dependencies]
alloy-eips = { version = "0.1", default-features = false, features = ["k256"] }
alloy-eips = { version = "0.2", default-features = false, features = ["k256"] }
alloy-primitives = { version = "0.7.7", default-features = false, features = [
"rlp",
] }
Expand Down
71 changes: 61 additions & 10 deletions crates/primitives/src/env/eip7702.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
pub use alloy_eips::eip7702::{Authorization, RecoveredAuthorization, SignedAuthorization};
pub use alloy_eips::eip7702::{Authorization, SignedAuthorization};
pub use alloy_primitives::Signature;

use crate::Address;
use core::ops::Deref;
use std::{boxed::Box, vec::Vec};

/// Authorization list for EIP-7702 transaction type.
Expand All @@ -11,6 +13,18 @@ pub enum AuthorizationList {
Recovered(Vec<RecoveredAuthorization>),
}

impl From<Vec<SignedAuthorization>> for AuthorizationList {
fn from(signed: Vec<SignedAuthorization>) -> Self {
Self::Signed(signed)
}
}

impl From<Vec<RecoveredAuthorization>> for AuthorizationList {
fn from(recovered: Vec<RecoveredAuthorization>) -> Self {
Self::Recovered(recovered)
}
}

impl AuthorizationList {
/// Returns length of the authorization list.
pub fn len(&self) -> usize {
Expand All @@ -33,9 +47,7 @@ impl AuthorizationList {
/// Returns iterator of recovered Authorizations.
pub fn recovered_iter<'a>(&'a self) -> Box<dyn Iterator<Item = RecoveredAuthorization> + 'a> {
match self {
Self::Signed(signed) => {
Box::new(signed.iter().map(|signed| signed.clone().into_recovered()))
}
Self::Signed(signed) => Box::new(signed.iter().map(|signed| signed.clone().into())),
Self::Recovered(recovered) => Box::new(recovered.clone().into_iter()),
}
}
Expand All @@ -45,11 +57,50 @@ impl AuthorizationList {
let Self::Signed(signed) = self else {
return self;
};
Self::Recovered(
signed
.into_iter()
.map(|signed| signed.into_recovered())
.collect(),
)
Self::Recovered(signed.into_iter().map(|signed| signed.into()).collect())
}
}

/// A recovered authorization.
#[derive(Debug, Clone, Hash, Eq, PartialEq)]
#[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))]
pub struct RecoveredAuthorization {
#[cfg_attr(feature = "serde", serde(flatten))]
inner: Authorization,
authority: Option<Address>,
}

impl RecoveredAuthorization {
/// Instantiate without performing recovery. This should be used carefully.
pub const fn new_unchecked(inner: Authorization, authority: Option<Address>) -> Self {
Self { inner, authority }
}

/// Get the `authority` for the authorization.
///
/// If this is `None`, then the authority could not be recovered.
pub const fn authority(&self) -> Option<Address> {
self.authority
}

/// Splits the authorization into parts.
pub const fn into_parts(self) -> (Authorization, Option<Address>) {
(self.inner, self.authority)
}
}

impl From<SignedAuthorization> for RecoveredAuthorization {
fn from(signed_auth: SignedAuthorization) -> Self {
let authority = signed_auth.recover_authority().ok();
let (authorization, _) = signed_auth.into_parts();
Self::new_unchecked(authorization, authority)
}
}

impl Deref for RecoveredAuthorization {
type Target = Authorization;

fn deref(&self) -> &Self::Target {
&self.inner
}
}
8 changes: 4 additions & 4 deletions crates/revm/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,9 +49,9 @@ ethers-providers = { version = "2.0", optional = true }
ethers-core = { version = "2.0", optional = true }

# alloydb
alloy-provider = { version = "0.1", optional = true, default-features = false }
alloy-eips = { version = "0.1", optional = true, default-features = false }
alloy-transport = { version = "0.1", optional = true, default-features = false }
alloy-provider = { version = "0.2", optional = true, default-features = false }
alloy-eips = { version = "0.2", optional = true, default-features = false }
alloy-transport = { version = "0.2", optional = true, default-features = false }

[dev-dependencies]
alloy-sol-types = { version = "0.7.7", default-features = false, features = [
Expand All @@ -64,7 +64,7 @@ indicatif = "0.17"
reqwest = { version = "0.12" }
rstest = "0.21.0"

alloy-provider = "0.1"
alloy-provider = "0.2"

[features]
default = ["std", "c-kzg", "secp256k1", "portable", "blst"]
Expand Down
Loading