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

Upgrade to latest version of Alloy and port Anvil tests #7701

Merged
merged 123 commits into from
Apr 26, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
123 commits
Select commit Hold shift + click to select a range
82e33b3
add: alloy utils and fix anvil tests
yash-atreya Apr 10, 2024
874fb90
fix: clippy
yash-atreya Apr 10, 2024
c6429ca
migrate`can_order_transactions` test
yash-atreya Apr 10, 2024
ffb6ad1
migrate(anvil/tests): transactions - `can_respect_nonces`, `can_repla…
yash-atreya Apr 10, 2024
21b1bee
add: provider with signer utils
yash-atreya Apr 11, 2024
9de8e93
use: sol! in abi
yash-atreya Apr 11, 2024
79c4029
start porting anvil_api tests
zerosnacks Apr 11, 2024
1e78cc9
additional tests
zerosnacks Apr 11, 2024
25de99b
add: can_impersonate_gnosis_safe
zerosnacks Apr 11, 2024
672bf06
add: can_impersonate_multiple_account
zerosnacks Apr 11, 2024
f6edad6
add: can_mine_manually + test_set_next_timestamp
zerosnacks Apr 11, 2024
4c5a384
more tests
zerosnacks Apr 11, 2024
41bde70
add: test_can_set_storage_bsc_fork
zerosnacks Apr 11, 2024
82a54c9
port the rest of the tests, final test is blocked on lack of txpool_i…
zerosnacks Apr 11, 2024
b4df74d
simplify types
zerosnacks Apr 11, 2024
8d46a87
use provider_with_signer, unclear exactly if it will interact as expe…
zerosnacks Apr 11, 2024
ec3c0c0
migrate(anvil/tests): `can_deploy_greeter_http`, `can_deploy_and_mine…
yash-atreya Apr 11, 2024
ee25c3e
migrate(anvil/tests): `can_mine_automatically`, `can_call_greeter_his…
yash-atreya Apr 11, 2024
b0d5728
migrate(anvil/test): tx tests migrated to alloy - TODOs remaining
yash-atreya Apr 11, 2024
00a02cc
migrate transaction::test_tx_access_list to alloy
yash-atreya Apr 11, 2024
76362bd
nit
yash-atreya Apr 11, 2024
0490776
migrate(anvil/tests): transactions::call_past_state
yash-atreya Apr 11, 2024
4024780
migrate(anvil/tests): can_handle_multiple_concurrent_deploys_with_sam…
yash-atreya Apr 11, 2024
f43a53a
migrate: tx test stream_pending_txs - fix TODO
yash-atreya Apr 11, 2024
52a8b61
Merge branch 'master' into zerosnacks/port-anvil-to-alloy
zerosnacks Apr 12, 2024
156959d
start on api
zerosnacks Apr 12, 2024
94c52b2
finish api examples, softly blocked on simulated call overrides - nee…
zerosnacks Apr 12, 2024
1018243
clean up imports
zerosnacks Apr 12, 2024
dc697e7
specify from on contract builder
zerosnacks Apr 12, 2024
764722e
finish ganache tests
zerosnacks Apr 12, 2024
a9d9034
wrap up ganache, start on gas
zerosnacks Apr 12, 2024
a51d172
add gas tests
zerosnacks Apr 12, 2024
20d7166
considering these tests are ignored is it necessary to keep them around?
zerosnacks Apr 12, 2024
b710b72
add back ganache and geth
zerosnacks Apr 12, 2024
9a2ee43
port geth
zerosnacks Apr 12, 2024
35bd024
add ipc
zerosnacks Apr 12, 2024
e1ccd1c
add txpool, missing methods
zerosnacks Apr 12, 2024
87da597
migrates(anvil/tests): `fork` tests to alloy - fix TODOs
yash-atreya Apr 12, 2024
ac41d4b
migrate(anvil/tests): trace tests to alloy - fix `debug_*` TODO
yash-atreya Apr 12, 2024
5f0d914
Merge branch 'master' into zerosnacks/port-anvil-to-alloy
zerosnacks Apr 16, 2024
776f40f
bump alloy - satisfy clippy
yash-atreya Apr 17, 2024
0fcdd5f
bump alloy & migrate sign examples
yash-atreya Apr 17, 2024
a88d57b
apply merge fixes
zerosnacks Apr 18, 2024
8df28db
apply latest changes from master
zerosnacks Apr 18, 2024
813eb2a
fix revm-inspectors
zerosnacks Apr 18, 2024
6938da2
use latest evm-inspectors version
zerosnacks Apr 18, 2024
cc25128
start fixing broken test ports
zerosnacks Apr 18, 2024
ce92ec3
fix test_tip_above_fee_cap
zerosnacks Apr 18, 2024
4c33b1c
fix broken tests, long running websocket / ipc tests still have issues
zerosnacks Apr 18, 2024
95588fc
add can_call_with_state_override test
zerosnacks Apr 18, 2024
7eee134
re-enable txpool test body
zerosnacks Apr 18, 2024
613ec71
add logs:get_past_events test
zerosnacks Apr 18, 2024
59df2bf
add logs:get_all_events
zerosnacks Apr 18, 2024
a326971
add logs:watch_events
zerosnacks Apr 18, 2024
5490931
pubsub utils
yash-atreya Apr 18, 2024
a6046a2
yash/anvil-to-alloy (#7705)
yash-atreya Apr 18, 2024
4770a7d
migrate(anvil/tests): pubsub
yash-atreya Apr 18, 2024
bb3cffa
pubsub tests to alloy
yash-atreya Apr 18, 2024
3ac8f92
nit
yash-atreya Apr 18, 2024
995d3b1
nits
yash-atreya Apr 18, 2024
3d5c65a
nit:test_sub_new_heads_fast
yash-atreya Apr 18, 2024
498bb8a
fix api:can_get_pending_block
zerosnacks Apr 19, 2024
d94cfdd
temporarily change ipc_provider to connect_pubsub, add ignores to bre…
zerosnacks Apr 19, 2024
90029bf
fix gas:test_respect_base_fee
zerosnacks Apr 19, 2024
aeb70b2
fix api:can_call_on_pending_block
zerosnacks Apr 19, 2024
e1338bc
add note on broken test to revisit, all tests should run now
zerosnacks Apr 19, 2024
42cacd2
add temp attempt at optimism port, not behaving an expected and a lot…
zerosnacks Apr 19, 2024
f84844b
revert for now
zerosnacks Apr 19, 2024
378ad1e
start porting otterscan
zerosnacks Apr 19, 2024
5128967
continue adding otterscan tests
zerosnacks Apr 19, 2024
c411687
another otterscan test case
zerosnacks Apr 19, 2024
b04b14a
finish otterscan tests
zerosnacks Apr 19, 2024
414b373
clean up imports
zerosnacks Apr 19, 2024
b33d384
start porting revert tests
zerosnacks Apr 19, 2024
4b2bf76
fix(anvil/tests): TODOs
yash-atreya Apr 19, 2024
cfeffd5
bump alloy
yash-atreya Apr 19, 2024
e6b47ad
nit
yash-atreya Apr 19, 2024
a3f51e9
Merge branch 'zerosnacks/port-anvil-to-alloy' into yash/anvil-to-allo…
yash-atreya Apr 19, 2024
8ec5103
nits
yash-atreya Apr 19, 2024
98247e8
bump alloy to fix test_fork_uncles_fetch
yash-atreya Apr 20, 2024
7051a55
fmt nits
yash-atreya Apr 20, 2024
ca114d2
nit
yash-atreya Apr 20, 2024
1a25145
rm abigen from abi
yash-atreya Apr 20, 2024
744923e
nit
yash-atreya Apr 20, 2024
a2acf0e
rm unused ethers utils
yash-atreya Apr 20, 2024
27180f5
finish revert examples
zerosnacks Apr 22, 2024
4bef6e5
Merge branch 'yash/anvil-to-alloy' into zerosnacks/port-anvil-to-alloy
zerosnacks Apr 22, 2024
112a28b
merge in master
zerosnacks Apr 22, 2024
c7df409
clean up imports and commits, use dynamic complilation where previous…
zerosnacks Apr 22, 2024
c522be3
port optimism
zerosnacks Apr 22, 2024
72a7aae
lift comment to todo
zerosnacks Apr 22, 2024
d47500a
clean up imports, start porting leftover ethers references
zerosnacks Apr 22, 2024
9f67802
inline alloy namespace in foundry-common
zerosnacks Apr 22, 2024
900c432
remove runtime_client, unnecessary imports
zerosnacks Apr 22, 2024
dc30b84
pull in changes from master, fix merge conflicts
zerosnacks Apr 22, 2024
b73d67c
fix: test_sub_new_heads_fast using workaround
yash-atreya Apr 23, 2024
e33f6cc
Merge branch 'master' into zerosnacks/port-anvil-to-alloy
zerosnacks Apr 23, 2024
871acd1
resolve conflicts
yash-atreya Apr 24, 2024
2d55039
Merge branch 'zerosnacks/port-anvil-to-alloy' of github.com:foundry-r…
zerosnacks Apr 24, 2024
3b8da6c
port jwt
zerosnacks Apr 24, 2024
7b82a27
update alloy / alloy-core / evm-inspectors
zerosnacks Apr 24, 2024
1ad5222
remove hex dep
zerosnacks Apr 24, 2024
5699f65
add missing hex
zerosnacks Apr 24, 2024
9b1f677
implement txkind change, issues around test running - spotty
zerosnacks Apr 24, 2024
ea6148b
cast differently, still not working
zerosnacks Apr 24, 2024
192f840
rm ignore fork tests
yash-atreya Apr 24, 2024
1deb3b3
resolve conflicts
yash-atreya Apr 25, 2024
6ad0bcb
fix: clippy
yash-atreya Apr 25, 2024
c577832
nits
yash-atreya Apr 25, 2024
fe9c6bd
fix flaky test, make sure block is available by mining it
zerosnacks Apr 25, 2024
7afe160
fix cargo hack check
zerosnacks Apr 25, 2024
ef2e909
ignore specific ipc error on windows
zerosnacks Apr 25, 2024
61bec81
append to previous commit, same ipc issue
zerosnacks Apr 25, 2024
21ac9b0
http_provider(&handle.http_endpoint()) -> handle.http_provider()
zerosnacks Apr 25, 2024
13f67b9
apply for ws_provider and ipc_provider as well, re-enable can_remove_…
zerosnacks Apr 25, 2024
5e5f6ea
refactor test_sub_new_heads_fast
zerosnacks Apr 25, 2024
12de063
remove redundant RpcUrl alias
zerosnacks Apr 25, 2024
1555a87
temp enable ipc tests for windows with debug
zerosnacks Apr 25, 2024
841dd79
attempt fix of ipc issue with tempfile, as used in Alloy test suite
zerosnacks Apr 25, 2024
772944b
fix(anvil/tests): can_replace_transaction
yash-atreya Apr 25, 2024
0f02894
explicitly enable mocking for tests
zerosnacks Apr 26, 2024
615040a
attempt ipc prefix
zerosnacks Apr 26, 2024
5f801b4
enhance error, ignore failing ipc tests on windows for now
zerosnacks Apr 26, 2024
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
79 changes: 61 additions & 18 deletions Cargo.lock

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

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -155,7 +155,6 @@ ethers-contract = { version = "2.0.14", default-features = false }
ethers-contract-abigen = { version = "2.0.14", default-features = false }
ethers-providers = { version = "2.0.14", default-features = false }
ethers-signers = { version = "2.0.14", default-features = false }
ethers-middleware = { version = "2.0.14", default-features = false }

## alloy
alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
Expand All @@ -168,6 +167,7 @@ alloy-node-bindings = { git = "https://github.com/alloy-rs/alloy", rev = "8808d2
alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-pubsub = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-rpc-types-engine = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-rpc-types-trace = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-signer = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
Expand All @@ -180,10 +180,10 @@ alloy-transport-http = { git = "https://github.com/alloy-rs/alloy", rev = "8808d
alloy-transport-ipc = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-transport-ws = { git = "https://github.com/alloy-rs/alloy", rev = "8808d21", default-features = false }
alloy-primitives = { version = "0.7.1", features = ["getrandom"] }
alloy-dyn-abi = "0.7.0"
alloy-json-abi = "0.7.0"
alloy-sol-types = "0.7.0"
syn-solidity = "0.7.0"
alloy-dyn-abi = "0.7.1"
alloy-json-abi = "0.7.1"
alloy-sol-types = "0.7.1"
syn-solidity = "0.7.1"
alloy-chains = "0.1"
alloy-trie = "0.3.1"
alloy-rlp = "0.3.3"
Expand Down
19 changes: 16 additions & 3 deletions crates/anvil/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,11 @@ path = "src/anvil.rs"
required-features = ["cli"]

[build-dependencies]
vergen = { workspace = true, default-features = false, features = ["build", "git", "gitcl"] }
vergen = { workspace = true, default-features = false, features = [
"build",
"git",
"gitcl",
] }

[dependencies]
# foundry internal
Expand All @@ -34,6 +38,7 @@ k256.workspace = true
ethers = { workspace = true, features = ["rustls", "ws", "ipc", "optimism"] }
alloy-primitives = { workspace = true, features = ["serde"] }
alloy-consensus = { workspace = true, features = ["k256", "kzg"] }
alloy-contract = { workspace = true, features = ["pubsub"] }
alloy-network.workspace = true
alloy-eips.workspace = true
alloy-rlp.workspace = true
Expand Down Expand Up @@ -77,7 +82,11 @@ rand = "0.8"
eyre.workspace = true

# cli
clap = { version = "4", features = ["derive", "env", "wrap_help"], optional = true }
clap = { version = "4", features = [
"derive",
"env",
"wrap_help",
], optional = true }
clap_complete = { version = "4", optional = true }
chrono.workspace = true
auto_impl = "1"
Expand All @@ -94,8 +103,12 @@ alloy-json-abi.workspace = true
ethers = { workspace = true, features = ["abigen", "optimism"] }
ethers-core = { workspace = true, features = ["optimism"] }
foundry-compilers = { workspace = true, features = ["project-util", "full"] }
alloy-rpc-client = { workspace = true, features = ["pubsub"] }
alloy-transport-ipc = { workspace = true, features = ["mock"] }
alloy-transport-ws.workspace = true
alloy-json-rpc.workspace = true
alloy-pubsub.workspace = true
foundry-test-utils.workspace = true

pretty_assertions.workspace = true
tokio = { version = "1", features = ["full"] }
crc = "3.0.1"
Expand Down
16 changes: 9 additions & 7 deletions crates/anvil/core/src/eth/transaction/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,13 +58,12 @@ pub fn transaction_request_to_typed(
other,
} = tx;

let to = if let Some(TxKind::Call(to)) = to { TxKind::Call(to) } else { TxKind::Create };
// Special case: OP-stack deposit tx
if transaction_type == Some(126) {
return Some(TypedTransactionRequest::Deposit(DepositTransactionRequest {
from: from.unwrap_or_default(),
source_hash: other.get_deserialized::<B256>("sourceHash")?.ok()?,
kind: to,
kind: to.unwrap_or_default(),
mint: other.get_deserialized::<U256>("mint")?.ok()?,
value: value.unwrap_or_default(),
gas_limit: gas.unwrap_or_default(),
Expand Down Expand Up @@ -93,7 +92,7 @@ pub fn transaction_request_to_typed(
gas_limit: gas.unwrap_or_default(),
value: value.unwrap_or(U256::ZERO),
input: input.into_input().unwrap_or_default(),
to,
to: to.unwrap_or_default(),
chain_id: None,
}))
}
Expand All @@ -106,7 +105,7 @@ pub fn transaction_request_to_typed(
gas_limit: gas.unwrap_or_default(),
value: value.unwrap_or(U256::ZERO),
input: input.into_input().unwrap_or_default(),
to,
to: to.unwrap_or_default(),
chain_id: 0,
access_list: access_list.unwrap_or_default(),
}))
Expand All @@ -124,13 +123,13 @@ pub fn transaction_request_to_typed(
gas_limit: gas.unwrap_or_default(),
value: value.unwrap_or(U256::ZERO),
input: input.into_input().unwrap_or_default(),
to,
to: to.unwrap_or_default(),
chain_id: 0,
access_list: access_list.unwrap_or_default(),
}))
}
// EIP4844
(Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), TxKind::Call(to)) => {
(Some(3), None, _, _, _, Some(_), Some(_), Some(sidecar), Some(to)) => {
let tx = TxEip4844 {
nonce: nonce.unwrap_or_default(),
max_fee_per_gas: max_fee_per_gas.unwrap_or_default(),
Expand All @@ -139,7 +138,10 @@ pub fn transaction_request_to_typed(
gas_limit: gas.unwrap_or_default(),
value: value.unwrap_or(U256::ZERO),
input: input.into_input().unwrap_or_default(),
to,
to: match to {
TxKind::Call(to) => to,
TxKind::Create => Address::ZERO,
},
chain_id: 0,
access_list: access_list.unwrap_or_default(),
blob_versioned_hashes: blob_versioned_hashes.unwrap_or_default(),
Expand Down
3 changes: 1 addition & 2 deletions crates/anvil/src/config.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,7 @@ use alloy_signer_wallet::{
use alloy_transport::{Transport, TransportError};
use anvil_server::ServerConfig;
use foundry_common::{
provider::alloy::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING,
REQUEST_TIMEOUT,
provider::ProviderBuilder, ALCHEMY_FREE_TIER_CUPS, NON_ARCHIVE_NODE_WARNING, REQUEST_TIMEOUT,
};
use foundry_config::Config;
use foundry_evm::{
Expand Down
6 changes: 3 additions & 3 deletions crates/anvil/src/eth/api.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ use anvil_core::{
},
};
use anvil_rpc::{error::RpcError, response::ResponseResult};
use foundry_common::provider::alloy::ProviderBuilder;
use foundry_common::provider::ProviderBuilder;
use foundry_evm::{
backend::DatabaseError,
decode::RevertDecoder,
Expand Down Expand Up @@ -2188,11 +2188,11 @@ impl EthApi {
{
// If the request is a simple native token transfer we can optimize
// We assume it's a transfer if we have no input data.
let to = if let Some(TxKind::Call(to)) = request.to { Some(to) } else { None };
let to = request.to.as_ref().and_then(TxKind::to);
let likely_transfer = request.input.clone().into_input().is_none();
if likely_transfer {
if let Some(to) = to {
if let Ok(target_code) = self.backend.get_code_with_state(&state, to) {
if let Ok(target_code) = self.backend.get_code_with_state(&state, *to) {
if target_code.as_ref().is_empty() {
return Ok(MIN_TRANSACTION_GAS);
}
Expand Down
2 changes: 1 addition & 1 deletion crates/anvil/src/eth/backend/fork.rs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ use alloy_rpc_types_trace::{
};
use alloy_transport::TransportError;
use anvil_core::eth::transaction::{convert_to_anvil_receipt, ReceiptResponse};
use foundry_common::provider::alloy::{ProviderBuilder, RetryProvider};
use foundry_common::provider::{ProviderBuilder, RetryProvider};
use parking_lot::{
lock_api::{RwLockReadGuard, RwLockWriteGuard},
RawRwLock, RwLock,
Expand Down
Loading
Loading