Skip to content

Commit fa9f934

Browse files
grandizzy0xrusowskyDaniPopesmattsse
authored
fixes: anvil, forge(fmt, backtraces) backports to v1.4.3 (#12217)
* fix(fmt): inline call options when they fit (#12172) * fix(fmt): inline call options when they fit * fix: ensure closure only when extra box is opened * fix(anvil): get account info from db when node block > fork block (#12175) fix(anvil): return account info from db when requested block > fork block * fix(fmt): do not add underscores on fractional part with exponent (#12195) * fix(fmt): do not add underscores on fractional part with exponent * Update crates/fmt/src/state/common.rs Co-authored-by: DaniPopes <[email protected]> --------- Co-authored-by: grandizzy <[email protected]> Co-authored-by: DaniPopes <[email protected]> * fix(forge): show backtrace line only on -vvvvv (#12211) * fix(forge): show backtrace line only on -vvvvv * fix tests * Update docs * Fix --------- Co-authored-by: 0xrusowsky <[email protected]> * chore: bump v1.4.3 (#12213) * chore: fix tests * chore: fix clippy (#12167) * fix(coverage): do not account abstract contract items (#12202) * fix(coverage): exclude only virtual fns without impl (#12216) --------- Co-authored-by: 0xrusowsky <[email protected]> Co-authored-by: DaniPopes <[email protected]> Co-authored-by: Matthias Seitz <[email protected]>
1 parent 828441d commit fa9f934

File tree

33 files changed

+15505
-161
lines changed

33 files changed

+15505
-161
lines changed

Cargo.lock

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

Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ members = [
2929
resolver = "2"
3030

3131
[workspace.package]
32-
version = "1.4.2"
32+
version = "1.4.3"
3333
edition = "2024"
3434
# Remember to update clippy.toml as well
3535
rust-version = "1.89"

crates/anvil/src/eth/api.rs

Lines changed: 23 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -772,18 +772,30 @@ impl EthApi {
772772
node_info!("eth_getAccountInfo");
773773

774774
if let Some(fork) = self.get_fork() {
775+
let block_request = self.block_request(block_number).await?;
775776
// check if the number predates the fork, if in fork mode
776-
if let BlockRequest::Number(number) = self.block_request(block_number).await?
777-
&& fork.predates_fork_inclusive(number)
778-
{
779-
// if this predates the fork we need to fetch balance, nonce, code individually
780-
// because the provider might not support this endpoint
781-
let balance = fork.get_balance(address, number).map_err(BlockchainError::from);
782-
let code = fork.get_code(address, number).map_err(BlockchainError::from);
783-
let nonce = self.get_transaction_count(address, Some(number.into()));
784-
let (balance, code, nonce) = try_join!(balance, code, nonce)?;
785-
786-
return Ok(alloy_rpc_types::eth::AccountInfo { balance, nonce, code });
777+
if let BlockRequest::Number(number) = block_request {
778+
trace!(target: "node", "get_account_info: fork block {}, requested block {number}", fork.block_number());
779+
return if fork.predates_fork(number) {
780+
// if this predates the fork we need to fetch balance, nonce, code individually
781+
// because the provider might not support this endpoint
782+
let balance = fork.get_balance(address, number).map_err(BlockchainError::from);
783+
let code = fork.get_code(address, number).map_err(BlockchainError::from);
784+
let nonce = self.get_transaction_count(address, Some(number.into()));
785+
let (balance, code, nonce) = try_join!(balance, code, nonce)?;
786+
787+
Ok(alloy_rpc_types::eth::AccountInfo { balance, nonce, code })
788+
} else {
789+
// Anvil node is at the same block or higher than the fork block,
790+
// return account info from backend to reflect current state.
791+
let account_info = self.backend.get_account(address).await?;
792+
let code = self.backend.get_code(address, Some(block_request)).await?;
793+
Ok(alloy_rpc_types::eth::AccountInfo {
794+
balance: account_info.balance,
795+
nonce: account_info.nonce,
796+
code,
797+
})
798+
};
787799
}
788800
}
789801

crates/anvil/tests/it/fork.rs

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,7 @@ async fn test_fork_get_account() {
16211621

16221622
#[tokio::test(flavor = "multi_thread")]
16231623
async fn test_fork_get_account_info() {
1624-
let (_api, handle) = spawn(fork_config()).await;
1624+
let (api, handle) = spawn(fork_config()).await;
16251625
let provider = handle.http_provider();
16261626

16271627
let info = provider
@@ -1654,6 +1654,23 @@ async fn test_fork_get_account_info() {
16541654
code: Default::default(),
16551655
}
16561656
);
1657+
1658+
// Mine and check account info at new block number, see https://github.com/foundry-rs/foundry/issues/12148
1659+
api.evm_mine(None).await.unwrap();
1660+
let info = provider
1661+
.get_account_info(address!("0x19e53a7397bE5AA7908fE9eA991B03710bdC74Fd"))
1662+
// predates fork
1663+
.number(BLOCK_NUMBER + 1)
1664+
.await
1665+
.unwrap();
1666+
assert_eq!(
1667+
info,
1668+
AccountInfo {
1669+
balance: U256::from(14352720829244098514u64),
1670+
nonce: 6690,
1671+
code: Default::default(),
1672+
}
1673+
);
16571674
}
16581675

16591676
fn assert_hardfork_config(

crates/cast/src/rlp_converter.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ use std::fmt;
1111
#[derive(Clone, Debug, PartialEq, Eq)]
1212
pub enum Item {
1313
Data(Vec<u8>),
14-
Array(Vec<Item>),
14+
Array(Vec<Self>),
1515
}
1616

1717
impl Encodable for Item {

0 commit comments

Comments
 (0)