Skip to content

Commit a928abc

Browse files
committed
fix merge conflict
2 parents 2d6312d + cc50b16 commit a928abc

File tree

9 files changed

+67
-60
lines changed

9 files changed

+67
-60
lines changed

Cargo.lock

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

crates/anvil/core/Cargo.toml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,6 @@ alloy-rlp.workspace = true
3030
alloy-eips.workspace = true
3131
alloy-consensus = { workspace = true, features = ["k256", "kzg"] }
3232
alloy-dyn-abi = { workspace = true, features = ["std", "eip712"] }
33-
alloy-trie.workspace = true
3433
op-alloy-consensus = { workspace = true, features = ["serde"] }
3534
alloy-network.workspace = true
3635
serde.workspace = true

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ use foundry_common::serde_helpers::{
1818
};
1919

2020
pub mod block;
21-
pub mod proof;
2221
pub mod subscription;
2322
pub mod transaction;
2423
pub mod wallet;

crates/anvil/core/src/eth/proof.rs

Lines changed: 0 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -1,25 +0,0 @@
1-
//! Return types for `eth_getProof`
2-
3-
//use crate::eth::trie::KECCAK_NULL_RLP;
4-
use alloy_primitives::{B256, U256};
5-
use alloy_trie::EMPTY_ROOT_HASH;
6-
use revm::primitives::KECCAK_EMPTY;
7-
8-
#[derive(Clone, Debug, PartialEq, Eq, alloy_rlp::RlpEncodable, alloy_rlp::RlpDecodable)]
9-
pub struct BasicAccount {
10-
pub nonce: U256,
11-
pub balance: U256,
12-
pub storage_root: B256,
13-
pub code_hash: B256,
14-
}
15-
16-
impl Default for BasicAccount {
17-
fn default() -> Self {
18-
Self {
19-
balance: U256::ZERO,
20-
nonce: U256::ZERO,
21-
code_hash: KECCAK_EMPTY,
22-
storage_root: EMPTY_ROOT_HASH,
23-
}
24-
}
25-
}

crates/anvil/core/src/types.rs

Lines changed: 2 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,6 @@
1-
use alloy_primitives::{Bytes, B256, U256};
1+
use alloy_primitives::Bytes;
22
use alloy_rpc_types::TransactionRequest;
3-
use serde::{Deserialize, Serialize, Serializer};
4-
5-
/// Represents the result of `eth_getWork`.
6-
///
7-
/// This may or may not include the block number.
8-
#[derive(Debug, Default, PartialEq, Eq)]
9-
pub struct Work {
10-
pub pow_hash: B256,
11-
pub seed_hash: B256,
12-
pub target: B256,
13-
pub number: Option<u64>,
14-
}
15-
16-
impl Serialize for Work {
17-
fn serialize<S>(&self, s: S) -> Result<S::Ok, S::Error>
18-
where
19-
S: Serializer,
20-
{
21-
if let Some(num) = self.number {
22-
(&self.pow_hash, &self.seed_hash, &self.target, U256::from(num)).serialize(s)
23-
} else {
24-
(&self.pow_hash, &self.seed_hash, &self.target).serialize(s)
25-
}
26-
}
27-
}
3+
use serde::Deserialize;
284

295
/// Represents the options used in `anvil_reorg`
306
#[derive(Debug, Clone, Deserialize)]

crates/anvil/src/eth/api.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ use alloy_rpc_types::{
6161
},
6262
txpool::{TxpoolContent, TxpoolInspect, TxpoolInspectSummary, TxpoolStatus},
6363
AccessList, AccessListResult, BlockId, BlockNumberOrTag as BlockNumber, BlockTransactions,
64-
EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log,
64+
EIP1186AccountProofResponse, FeeHistory, Filter, FilteredParams, Index, Log, Work,
6565
};
6666
use alloy_serde::WithOtherFields;
6767
use alloy_transport::TransportErrorKind;
@@ -75,7 +75,7 @@ use anvil_core::{
7575
wallet::{WalletCapabilities, WalletError},
7676
EthRequest,
7777
},
78-
types::{ReorgOptions, TransactionData, Work},
78+
types::{ReorgOptions, TransactionData},
7979
};
8080
use anvil_rpc::{error::RpcError, response::ResponseResult};
8181
use foundry_common::provider::ProviderBuilder;

crates/cheatcodes/src/script.rs

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,10 @@ use alloy_sol_types::SolValue;
1010
use foundry_wallets::{multi_wallet::MultiWallet, WalletSigner};
1111
use parking_lot::Mutex;
1212
use revm::{
13-
bytecode::Bytecode, context::JournalTr, context_interface::transaction::SignedAuthorization,
14-
primitives::hardfork::SpecId,
13+
bytecode::Bytecode,
14+
context::JournalTr,
15+
context_interface::transaction::SignedAuthorization,
16+
primitives::{hardfork::SpecId, KECCAK_EMPTY},
1517
};
1618
use std::sync::Arc;
1719

@@ -131,8 +133,13 @@ fn write_delegation(ccx: &mut CheatsCtxt, auth: SignedAuthorization) -> Result<(
131133
return Err("invalid nonce".into());
132134
}
133135
authority_acc.data.info.nonce += 1;
134-
let bytecode = Bytecode::new_eip7702(*auth.address());
135-
ccx.ecx.journaled_state.set_code(authority, bytecode);
136+
if auth.address.is_zero() {
137+
// Set empty code if the delegation address of authority is 0x.
138+
ccx.ecx.journaled_state.set_code_with_hash(authority, Bytecode::default(), KECCAK_EMPTY);
139+
} else {
140+
let bytecode = Bytecode::new_eip7702(*auth.address());
141+
ccx.ecx.journaled_state.set_code(authority, bytecode);
142+
}
136143
Ok(())
137144
}
138145

crates/forge/tests/it/repros.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -401,3 +401,6 @@ test_repro!(7238);
401401

402402
// https://github.com/foundry-rs/foundry/issues/10302
403403
test_repro!(10302);
404+
405+
// https://github.com/foundry-rs/foundry/issues/10477
406+
test_repro!(10477);
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
// SPDX-License-Identifier: MIT OR Apache-2.0
2+
pragma solidity ^0.8.18;
3+
4+
import "ds-test/test.sol";
5+
import "cheats/Vm.sol";
6+
7+
contract SimpleDelegate {
8+
function call(address target, bytes memory data) external returns (bool callResult, bytes memory callData) {
9+
(callResult, callData) = target.call(data);
10+
}
11+
}
12+
13+
contract Counter {
14+
uint256 public value = 0;
15+
16+
function increment() external {
17+
value++;
18+
}
19+
}
20+
21+
contract Issue10477Test is DSTest {
22+
Vm constant vm = Vm(HEVM_ADDRESS);
23+
24+
address payable ALICE_ADDRESS = payable(0x70997970C51812dc3A010C7d01b50e0d17dc79C8);
25+
uint256 constant ALICE_PK = 0x59c6995e998f97a5a0044966f0945389dc9e86dae88c7a8412f4603b6b78690d;
26+
27+
function test_reset_delegate_indicator() public {
28+
SimpleDelegate delegate = new SimpleDelegate();
29+
Counter counter = new Counter();
30+
31+
vm.startBroadcast(ALICE_PK);
32+
vm.signAndAttachDelegation(address(delegate), ALICE_PK);
33+
assertTrue(ALICE_ADDRESS.code.length > 0);
34+
35+
(bool callResult, bytes memory callData) =
36+
SimpleDelegate(ALICE_ADDRESS).call(address(counter), abi.encodeCall(Counter.increment, ()));
37+
38+
assertTrue(callResult);
39+
assertTrue(callData.length == 0);
40+
41+
vm.signAndAttachDelegation(address(0), ALICE_PK);
42+
43+
// Expected to succeed here
44+
assertTrue(ALICE_ADDRESS.code.length == 0);
45+
assertTrue(ALICE_ADDRESS.codehash == 0xc5d2460186f7233c927e7db2dcc703c0e500b653ca82273b7bfad8045d85a470);
46+
47+
vm.stopBroadcast();
48+
}
49+
}

0 commit comments

Comments
 (0)