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

Cast is (likely) querying the wrong RPC provider #8831

Closed
2 tasks done
martinvol opened this issue Sep 7, 2024 · 10 comments
Closed
2 tasks done

Cast is (likely) querying the wrong RPC provider #8831

martinvol opened this issue Sep 7, 2024 · 10 comments
Labels
T-bug Type: bug T-needs-triage Type: this issue needs to be labelled

Comments

@martinvol
Copy link

martinvol commented Sep 7, 2024

Component

Cast

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (fa0e0c2 2024-08-22T00:19:05.210000000Z)

What command(s) is the bug in?

cast call

Operating System

macOS (ARM)

Describe the bug

Call #1

cast call 0xB880785961B8fC4630dDa03B439D07009464111f 0xf4d4d2f8000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000066dc774a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040d868823de1e6540e8cf0ccd9aebc96ded505b489cbc774da1aa522072bd0385e87a82de4cd91de4f191e61e64ecb1a1c293d3823de003f877d67b9467091c4eb00000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000400000000000000000000000008464135c8f25da09e49bc8782676a84730c318bc00000000000000000000000000000000000000000000000000000000000001449061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a0474657374036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008459d1d43ceb4f647bea6caa36333c816d7b46fdcb05f9466ecacc140ea8c66faf15b3d9f100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000005656d61696c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 --rpc-url https://sepolia.optimism.io --trace
Traces:
  [0] 0xB880785961B8fC4630dDa03B439D07009464111f::resolveWithProof(0x00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000066dc774a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040d868823de1e6540e8cf0ccd9aebc96ded505b489cbc774da1aa522072bd0385e87a82de4cd91de4f191e61e64ecb1a1c293d3823de003f877d67b9467091c4eb, 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000008464135c8f25da09e49bc8782676a84730c318bc00000000000000000000000000000000000000000000000000000000000001449061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a0474657374036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008459d1d43ceb4f647bea6caa36333c816d7b46fdcb05f9466ecacc140ea8c66faf15b3d9f100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000005656d61696c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
    └─ ← [Stop]


Transaction successfully executed.
Gas used: 26796

But then that address doesn't have code on OP Sepolia:

Call #2

% cast code 0xB880785961B8fC4630dDa03B439D07009464111f --rpc-url https://sepolia.optimism.io
0x

The explorer also confirms the address doesn't have any bytecode: https://sepolia-optimism.etherscan.io/address/0xB880785961B8fC4630dDa03B439D07009464111f

The contract does have bytecode in Sepolia (eth), so my guess is that cast is somehow using a Sepolia RPC, but I couldn't confirm this.

@martinvol martinvol added T-bug Type: bug T-needs-triage Type: this issue needs to be labelled labels Sep 7, 2024
@martinvol
Copy link
Author

I also tried this in someone else's laptop and got the same result.

@mattsse
Copy link
Member

mattsse commented Sep 7, 2024

could you share RUST_LOG=trace cast ..

only need the first few lines

@martinvol
Copy link
Author

% RUST_LOG=trace cast call 0xB880785961B8fC4630dDa03B439D07009464111f 0xf4d4d2f8000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000066dc774a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040d868823de1e6540e8cf0ccd9aebc96ded505b489cbc774da1aa522072bd0385e87a82de4cd91de4f191e61e64ecb1a1c293d3823de003f877d67b9467091c4eb000000000000000000000000000000000000000000000
00000000000000001c000000000000000000000000000000000000000000000000000000000000000400000000000000000000000008464135c8f25da09e49bc8782676a84730c318bc00000000000000000000000000000000000000000000000000000000000001449061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a0474657374036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008459d1d43ceb4f647bea6caa36333c816d7b46fdcb05f9466ecacc140ea8c66faf15b3d9f100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000005656d61696c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 --rpc-url https://sepolia.optimism.io --trace

2024-09-07T18:18:26.794887Z TRACE foundry_wallets::wallet: start finding signer
2024-09-07T18:18:26.795563Z TRACE alloy_rpc_client::call: polling RpcCall self.state=Prepared
2024-09-07T18:18:26.795702Z DEBUG alloy_rpc_client::call: sending request method=eth_chainId id=0
2024-09-07T18:18:26.795874Z TRACE alloy_rpc_client::call: full request params_ty=() request=Request { meta: RequestMeta { method: "eth_chainId", id: Number(0), is_subscription: false }, params: () }
2024-09-07T18:18:26.796220Z TRACE alloy_rpc_client::call: serialized request request={"method":"eth_chainId","id":0,"jsonrpc":"2.0"}
2024-09-07T18:18:26.942069Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::pool: checkout waiting for idle connection: ("https", sepolia.optimism.io)
2024-09-07T18:18:26.942140Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: reqwest::connect: starting new connection: https://sepolia.optimism.io/
2024-09-07T18:18:26.942157Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::connect::http: Http::connect; scheme=Some("https"), host=Some("sepolia.optimism.io"), port=None
2024-09-07T18:18:26.942327Z DEBUG hyper_util::client::legacy::connect::dns: resolving host="sepolia.optimism.io"
2024-09-07T18:18:26.944855Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2024-09-07T18:18:26.944866Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::connect::http: connecting to 104.18.10.221:443
2024-09-07T18:18:26.958629Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2024-09-07T18:18:26.958644Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::connect::http: connected to 104.18.10.221:443
2024-09-07T18:18:26.974770Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2024-09-07T18:18:26.975727Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::client: http1 handshake complete, spawning background dispatcher task
2024-09-07T18:18:26.975764Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2024-09-07T18:18:26.975770Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::pool: checkout dropped for ("https", sepolia.optimism.io)
2024-09-07T18:18:27.075477Z TRACE alloy_rpc_client::call: polling RpcCall self.state=AwaitingResponse
2024-09-07T18:18:27.075505Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::pool: put; add idle connection for ("https", sepolia.optimism.io)
2024-09-07T18:18:27.075512Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::pool: pooling idle connection for ("https", sepolia.optimism.io)
2024-09-07T18:18:27.075518Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: alloy_transport_http::reqwest_transport: received response from server status=200 OK
2024-09-07T18:18:27.075529Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: alloy_transport_http::reqwest_transport: retrieved response body. Use `trace` for full body bytes=45
2024-09-07T18:18:27.075576Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: alloy_transport_http::reqwest_transport: response body body={"jsonrpc":"2.0","result":"0xaa37dc","id":0}

2024-09-07T18:18:27.076637Z TRACE alloy_json_rpc::result: deserializing response ty=ruint::Uint<64, 1> json="\"0xaa37dc\""
2024-09-07T18:18:27.077017Z TRACE alloy_json_rpc::result: deserialized response response=11155420
2024-09-07T18:18:27.077048Z TRACE alloy_rpc_client::call: polling RpcCall self.state=Prepared
2024-09-07T18:18:27.077050Z DEBUG alloy_rpc_client::call: sending request method=eth_blockNumber id=0
2024-09-07T18:18:27.077054Z TRACE alloy_rpc_client::call: full request params_ty=() request=Request { meta: RequestMeta { method: "eth_blockNumber", id: Number(0), is_subscription: false }, params: () }
2024-09-07T18:18:27.077061Z TRACE alloy_rpc_client::call: serialized request request={"method":"eth_blockNumber","id":0,"jsonrpc":"2.0"}
2024-09-07T18:18:27.215038Z TRACE ReqwestTransport{url=https://sepolia.optimism.io/}: hyper_util::client::legacy::pool: checkout waiting for idle connection: ("https", sepolia.optimism.io)
2024-09-07T18:18:27.215057Z DEBUG ReqwestTransport{url=https://sepolia.optimism.io/}: reqwest::connect: starting new connection: https://sepolia.optimism.io/

@klkvr
Copy link
Member

klkvr commented Sep 7, 2024

hmm, the trace you've shared is empty, and immidiately stops, which is what a call to EOA look like, how does command output imply that address has code?

@martinvol
Copy link
Author

martinvol commented Sep 7, 2024

I am claiming that the address 0xB880785961B8fC4630dDa03B439D07009464111f does not have bytecode on OP Sepolia, so the first contract call should just revert.

@klkvr
Copy link
Member

klkvr commented Sep 7, 2024

calls to EOA do not revert, this is basically just a zero value transfer

@martinvol
Copy link
Author

martinvol commented Sep 8, 2024

Are you reffering to the first call?

cast call 0xB880785961B8fC4630dDa03B439D07009464111f 0xf4d4d2f8000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000001a0000000000000000000000000000000000000000000000000000000000000014000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000066dc774a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040d868823de1e6540e8cf0ccd9aebc96ded505b489cbc774da1aa522072bd0385e87a82de4cd91de4f191e61e64ecb1a1c293d3823de003f877d67b9467091c4eb00000000000000000000000000000000000000000000000000000000000001c000000000000000000000000000000000000000000000000000000000000000400000000000000000000000008464135c8f25da09e49bc8782676a84730c318bc00000000000000000000000000000000000000000000000000000000000001449061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a0474657374036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008459d1d43ceb4f647bea6caa36333c816d7b46fdcb05f9466ecacc140ea8c66faf15b3d9f100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000005656d61696c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000 --rpc-url https://sepolia.optimism.io --trace
Traces:
  [0] 0xB880785961B8fC4630dDa03B439D07009464111f::resolveWithProof(0x00000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000066dc774a00000000000000000000000000000000000000000000000000000000000000e000000000000000000000000000000000000000000000000000000000000000600000000000000000000000000000000000000000000000000000000000000020000000000000000000000000000000000000000000000000000000000000001074657374406578616d706c652e636f6d000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000040d868823de1e6540e8cf0ccd9aebc96ded505b489cbc774da1aa522072bd0385e87a82de4cd91de4f191e61e64ecb1a1c293d3823de003f877d67b9467091c4eb, 0x00000000000000000000000000000000000000000000000000000000000000400000000000000000000000008464135c8f25da09e49bc8782676a84730c318bc00000000000000000000000000000000000000000000000000000000000001449061b92300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000080000000000000000000000000000000000000000000000000000000000000000a0474657374036574680000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000008459d1d43ceb4f647bea6caa36333c816d7b46fdcb05f9466ecacc140ea8c66faf15b3d9f100000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000005656d61696c0000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000)
    └─ ← [Stop]


Transaction successfully executed.
Gas used: 26796

It is definitely doing something, it even has the function name resolveWithProof that exist in the contract on Sepolia.

@klkvr
Copy link
Member

klkvr commented Sep 8, 2024

It immediately stops execution (and uses 0 gas)

foundry automatically decodes the function selector and arguments from calldata for any calls, contract's code does not affect this behavior

@klkvr klkvr closed this as not planned Won't fix, can't repro, duplicate, stale Sep 8, 2024
@martinvol
Copy link
Author

To clarify, I just numbered the calls, the bug I'm reporting is for call #1. It should fail instead of making up a trace. Am I missing something?

@martinvol
Copy link
Author

If this is the expected behaviour, then I find it very misleading that it reports "Transaction successfully executed" and non-zero gas usage without a warning.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug T-needs-triage Type: this issue needs to be labelled
Projects
None yet
Development

No branches or pull requests

3 participants