Skip to content

Commit 6928687

Browse files
authored
alloy update (#8660)
* Take 1 * cargo * Latest alloy * Fix revm
1 parent b34b0f7 commit 6928687

File tree

15 files changed

+380
-488
lines changed

15 files changed

+380
-488
lines changed

Cargo.lock

Lines changed: 296 additions & 455 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ alloy-node-bindings = { version = "0.2.1", default-features = false }
182182
alloy-provider = { version = "0.2.1", default-features = false }
183183
alloy-pubsub = { version = "0.2.1", default-features = false }
184184
alloy-rpc-client = { version = "0.2.1", default-features = false }
185-
alloy-rpc-types = { version = "0.2.1", default-features = false }
185+
alloy-rpc-types = { version = "0.2.1", default-features = true }
186186
alloy-serde = { version = "0.2.1", default-features = false }
187187
alloy-signer = { version = "0.2.1", default-features = false }
188188
alloy-signer-aws = { version = "0.2.1", default-features = false }
@@ -264,3 +264,29 @@ soldeer = "0.2.19"
264264

265265
proptest = "1"
266266
comfy-table = "7"
267+
268+
[patch.crates-io]
269+
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
270+
alloy-contract = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
271+
alloy-eips = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
272+
alloy-genesis = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
273+
alloy-json-rpc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
274+
alloy-network = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
275+
alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
276+
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
277+
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
278+
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
279+
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
280+
alloy-serde = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
281+
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
282+
alloy-signer-aws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
283+
alloy-signer-gcp = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
284+
alloy-signer-ledger = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
285+
alloy-signer-local = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
286+
alloy-signer-trezor = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
287+
alloy-transport = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
288+
alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
289+
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
290+
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "511ae98" }
291+
revm = { git = "https://github.com/bluealloy/revm", rev = "228b034" }
292+
revm-primitives = { git = "https://github.com/bluealloy/revm", rev = "228b034" }

crates/anvil/core/src/eth/transaction/mod.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1071,6 +1071,28 @@ impl TryFrom<RpcTransaction> for TypedTransaction {
10711071
tx.hash,
10721072
)))
10731073
}
1074+
TxType::Eip7702 => {
1075+
let eip7702 = TxEip7702 {
1076+
chain_id: tx.chain_id.ok_or(ConversionError::MissingChainId)?,
1077+
nonce: tx.nonce,
1078+
gas_limit: tx.gas,
1079+
max_fee_per_gas: tx.gas_price.ok_or(ConversionError::MissingGasPrice)?,
1080+
max_priority_fee_per_gas: tx
1081+
.max_priority_fee_per_gas
1082+
.ok_or(ConversionError::MissingMaxPriorityFeePerGas)?,
1083+
to: tx.to.map_or(TxKind::Create, TxKind::Call),
1084+
value: tx.value,
1085+
access_list: tx.access_list.ok_or(ConversionError::MissingAccessList)?,
1086+
input: tx.input,
1087+
authorization_list: tx.authorization_list.unwrap_or_default(),
1088+
};
1089+
let signature = tx
1090+
.signature
1091+
.ok_or(ConversionError::MissingSignature)?
1092+
.try_into()
1093+
.map_err(ConversionError::SignatureError)?;
1094+
Ok(Self::EIP7702(Signed::new_unchecked(eip7702, signature, tx.hash)))
1095+
}
10741096
}
10751097
}
10761098
}

crates/anvil/src/eth/backend/fork.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -417,7 +417,7 @@ impl ClientFork {
417417
// Since alloy doesn't indicate in the result whether the block exists,
418418
// this is being temporarily implemented in anvil.
419419
if self.predates_fork_inclusive(number) {
420-
let receipts = self.provider().get_block_receipts(BlockNumber::Number(number)).await?;
420+
let receipts = self.provider().get_block_receipts(BlockId::from(number)).await?;
421421
let receipts = receipts
422422
.map(|r| {
423423
r.into_iter()

crates/anvil/src/pubsub.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ use crate::{
33
StorageInfo,
44
};
55
use alloy_primitives::{TxHash, B256};
6-
use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log};
6+
use alloy_rpc_types::{pubsub::SubscriptionResult, FilteredParams, Log, Transaction};
77
use anvil_core::eth::{block::Block, subscription::SubscriptionId, transaction::TypedReceipt};
88
use anvil_rpc::{request::Version, response::ResponseResult};
99
use futures::{channel::mpsc::Receiver, ready, Stream, StreamExt};
@@ -112,7 +112,7 @@ impl EthSubscription {
112112
}
113113
Self::PendingTransactions(tx, id) => {
114114
let res = ready!(tx.poll_next_unpin(cx))
115-
.map(SubscriptionResult::TransactionHash)
115+
.map(SubscriptionResult::<Transaction>::TransactionHash)
116116
.map(to_rpc_result)
117117
.map(|result| {
118118
let params = EthSubscriptionParams { subscription: id.clone(), result };

crates/anvil/tests/it/eip7702.rs

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
11
use crate::utils::http_provider;
22
use alloy_consensus::{transaction::TxEip7702, SignableTransaction};
3-
use alloy_eips::eip7702::OptionalNonce;
43
use alloy_network::{ReceiptResponse, TransactionBuilder, TxSignerSync};
5-
use alloy_primitives::{bytes, TxKind};
4+
use alloy_primitives::{bytes, TxKind, U256};
65
use alloy_provider::Provider;
76
use alloy_rpc_types::{Authorization, TransactionRequest};
87
use alloy_serde::WithOtherFields;
@@ -45,9 +44,9 @@ async fn can_send_eip7702_tx() {
4544

4645
let contract = receipt.contract_address.unwrap();
4746
let authorization = Authorization {
48-
chain_id: 31337,
47+
chain_id: U256::from(31337u64),
4948
address: contract,
50-
nonce: OptionalNonce::new(Some(provider.get_transaction_count(from).await.unwrap())),
49+
nonce: provider.get_transaction_count(from).await.unwrap(),
5150
};
5251
let signature = wallets[0].sign_hash_sync(&authorization.signature_hash()).unwrap();
5352
let authorization = authorization.into_signed(signature);

crates/anvil/tests/it/traces.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use crate::{
33
fork::fork_config,
44
utils::http_provider_with_signer,
55
};
6+
use alloy_eips::BlockId;
67
use alloy_network::{EthereumWallet, TransactionBuilder};
78
use alloy_primitives::{hex, Address, Bytes, U256};
89
use alloy_provider::{
@@ -18,7 +19,7 @@ use alloy_rpc_types::{
1819
},
1920
parity::{Action, LocalizedTransactionTrace},
2021
},
21-
BlockNumberOrTag, TransactionRequest,
22+
TransactionRequest,
2223
};
2324
use alloy_serde::WithOtherFields;
2425
use alloy_sol_types::sol;
@@ -132,7 +133,7 @@ async fn test_transfer_debug_trace_call() {
132133

133134
let traces = handle
134135
.http_provider()
135-
.debug_trace_call(tx, BlockNumberOrTag::Latest, GethDebugTracingCallOptions::default())
136+
.debug_trace_call(tx, BlockId::latest(), GethDebugTracingCallOptions::default())
136137
.await
137138
.unwrap();
138139

@@ -178,7 +179,7 @@ async fn test_call_tracer_debug_trace_call() {
178179
.http_provider()
179180
.debug_trace_call(
180181
internal_call_tx.clone(),
181-
BlockNumberOrTag::Latest,
182+
BlockId::latest(),
182183
GethDebugTracingCallOptions::default().with_tracing_options(
183184
GethDebugTracingOptions::default()
184185
.with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer))
@@ -206,7 +207,7 @@ async fn test_call_tracer_debug_trace_call() {
206207
.http_provider()
207208
.debug_trace_call(
208209
internal_call_tx.clone(),
209-
BlockNumberOrTag::Latest,
210+
BlockId::latest(),
210211
GethDebugTracingCallOptions::default().with_tracing_options(
211212
GethDebugTracingOptions::default()
212213
.with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer))
@@ -235,7 +236,7 @@ async fn test_call_tracer_debug_trace_call() {
235236
.http_provider()
236237
.debug_trace_call(
237238
direct_call_tx,
238-
BlockNumberOrTag::Latest,
239+
BlockId::latest(),
239240
GethDebugTracingCallOptions::default().with_tracing_options(
240241
GethDebugTracingOptions::default()
241242
.with_tracer(GethDebugTracerType::from(GethDebugBuiltInTracerType::CallTracer))

crates/cheatcodes/src/evm.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ impl Cheatcode for loadCall {
8989
let Self { target, slot } = *self;
9090
ensure_not_precompile!(&target, ccx);
9191
ccx.ecx.load_account(target)?;
92-
let (val, _) = ccx.ecx.sload(target, slot.into())?;
92+
let val = ccx.ecx.sload(target, slot.into())?;
9393
Ok(val.abi_encode())
9494
}
9595
}
@@ -590,7 +590,7 @@ impl Cheatcode for setBlockhashCall {
590590
}
591591

592592
pub(super) fn get_nonce<DB: DatabaseExt>(ccx: &mut CheatsCtxt<DB>, address: &Address) -> Result {
593-
let (account, _) = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?;
593+
let account = ccx.ecx.journaled_state.load_account(*address, &mut ccx.ecx.db)?;
594594
Ok(account.info.nonce.abi_encode())
595595
}
596596

crates/cheatcodes/src/evm/mock.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ impl Cheatcode for clearMockedCallsCall {
4949
impl Cheatcode for mockCall_0Call {
5050
fn apply_stateful<DB: DatabaseExt>(&self, ccx: &mut CheatsCtxt<DB>) -> Result {
5151
let Self { callee, data, returnData } = self;
52-
let (acc, _) = ccx.ecx.load_account(*callee)?;
52+
let acc = ccx.ecx.load_account(*callee)?;
5353

5454
// Etches a single byte onto the account if it is empty to circumvent the `extcodesize`
5555
// check Solidity might perform.

crates/cheatcodes/src/inspector.rs

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,6 @@ pub trait CheatcodesExecutor {
9292
db: &mut ccx.ecx.db as &mut dyn DatabaseExt,
9393
error,
9494
l1_block_info,
95-
valid_authorizations: std::mem::take(&mut ccx.ecx.valid_authorizations),
9695
};
9796

9897
let mut evm = new_evm_with_existing_context(inner, &mut inspector as _);
@@ -103,7 +102,6 @@ pub trait CheatcodesExecutor {
103102
ccx.ecx.env = evm.context.evm.inner.env;
104103
ccx.ecx.l1_block_info = evm.context.evm.inner.l1_block_info;
105104
ccx.ecx.error = evm.context.evm.inner.error;
106-
ccx.ecx.valid_authorizations = evm.context.evm.inner.valid_authorizations;
107105

108106
Ok(res)
109107
}
@@ -647,7 +645,7 @@ impl Cheatcodes {
647645
crate::Vm::AccountAccessKind::Create as u8
648646
);
649647
if let Some(address) = outcome.address {
650-
if let Ok((created_acc, _)) =
648+
if let Ok(created_acc) =
651649
ecx.journaled_state.load_account(address, &mut ecx.db)
652650
{
653651
create_access.newBalance = created_acc.info.balance;
@@ -888,7 +886,7 @@ impl Cheatcodes {
888886
// nonce, a non-zero KECCAK_EMPTY codehash, or non-empty code
889887
let initialized;
890888
let old_balance;
891-
if let Ok((acc, _)) = ecx.load_account(call.target_address) {
889+
if let Ok(acc) = ecx.load_account(call.target_address) {
892890
initialized = acc.info.exists();
893891
old_balance = acc.info.balance;
894892
} else {
@@ -1130,7 +1128,7 @@ impl<DB: DatabaseExt> Inspector<DB> for Cheatcodes {
11301128
// Depending on the depth the cheat was called at, there may not be any pending
11311129
// calls to update if execution has percolated up to a higher depth.
11321130
if call_access.depth == ecx.journaled_state.depth() {
1133-
if let Ok((acc, _)) = ecx.load_account(call.target_address) {
1131+
if let Ok(acc) = ecx.load_account(call.target_address) {
11341132
debug_assert!(access_is_call(call_access.kind));
11351133
call_access.newBalance = acc.info.balance;
11361134
}
@@ -1438,13 +1436,13 @@ impl Cheatcodes {
14381436
let target = Address::from_word(B256::from(target));
14391437
let (initialized, old_balance) = ecx
14401438
.load_account(target)
1441-
.map(|(account, _)| (account.info.exists(), account.info.balance))
1439+
.map(|account| (account.info.exists(), account.info.balance))
14421440
.unwrap_or_default();
14431441

14441442
// load balance of this account
14451443
let value = ecx
14461444
.balance(interpreter.contract().target_address)
1447-
.map(|(b, _)| b)
1445+
.map(|b| b.data)
14481446
.unwrap_or(U256::ZERO);
14491447

14501448
// register access for the target account
@@ -1479,8 +1477,8 @@ impl Cheatcodes {
14791477
let mut present_value = U256::ZERO;
14801478
// Try to load the account and the slot's present value
14811479
if ecx.load_account(address).is_ok() {
1482-
if let Ok((previous, _)) = ecx.sload(address, key) {
1483-
present_value = previous;
1480+
if let Ok(previous) = ecx.sload(address, key) {
1481+
present_value = previous.data;
14841482
}
14851483
}
14861484
let access = crate::Vm::StorageAccess {
@@ -1503,8 +1501,8 @@ impl Cheatcodes {
15031501
// not set (zero value)
15041502
let mut previous_value = U256::ZERO;
15051503
if ecx.load_account(address).is_ok() {
1506-
if let Ok((previous, _)) = ecx.sload(address, key) {
1507-
previous_value = previous;
1504+
if let Ok(previous) = ecx.sload(address, key) {
1505+
previous_value = previous.data;
15081506
}
15091507
}
15101508

@@ -1532,7 +1530,7 @@ impl Cheatcodes {
15321530
Address::from_word(B256::from(try_or_return!(interpreter.stack().peek(0))));
15331531
let initialized;
15341532
let balance;
1535-
if let Ok((acc, _)) = ecx.load_account(address) {
1533+
if let Ok(acc) = ecx.load_account(address) {
15361534
initialized = acc.info.exists();
15371535
balance = acc.info.balance;
15381536
} else {

0 commit comments

Comments
 (0)