foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
7.86k stars 1.56k forks source link

calling vm.rpc reverts for no reason #8287

Closed zgorizzo69 closed 2 days ago

zgorizzo69 commented 3 days ago

Component

Forge

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

What version of Foundry are you on?

forge 0.2.0 (c4a984f 2024-06-28T00:18:36.573705176Z)

What command(s) is the bug in?

vm.rpc

Operating System

Linux

Describe the bug

I am calling a tenderly virtual testnet admin rpc end point with a simple script

// SPDX-License-Identifier: Apache-2.0

pragma solidity 0.8.20;

import {Script} from "forge-std/Script.sol";

contract RPCScript is Script {
    function run() public virtual {
        try vm.rpc(
            "tenderly_setErc20Balance",
            "[\"0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48\",\"0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e\",\"0xDE0B6B3A7640000\"]"
        ) {} catch {}
    }
}

I get this output image however in tenderly the rpc call is a success moreover when I curl the rpc command it succeeds and the return code is correct:

curl --request POST \
     --url https://virtual.mainnet.rpc.tenderly.co/YOUR_VIRTUAL_TESTNET --header 'accept: application/json' \ 
     --header 'content-type: application/json' \
     --data '
{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tenderly_setErc20Balance",
  "params": [
    "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
    "0x40BdB4497614bAe1A67061EE20AAdE3c2067AC9e",
    "0xDE0B6B3A7640000"
  ]
}
'
{"id":1,"jsonrpc":"2.0","result":"0x767762eb06369761cde6a5086c15dff74d8bc9f175863bb8757ccec01113b228"}%