foundry icon indicating copy to clipboard operation
foundry copied to clipboard

bug(`anvil`): forge script deployment hangs awaiting receipt finalization

Open jistro opened this issue 6 months ago • 6 comments

Component

Anvil

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

  • [x] Foundry
  • [x] Foundryup

What version of Foundry are you on?

1.1.0-stable

What version of Foundryup are you on?

1.1.0

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

Description:

When attempting to deploy a contract using the forge script command, the deployment appears successful, but the process gets stuck waiting for the transaction receipt to finalize.

Steps to Reproduce:

  1. Run the following command:
    forge script script/Deploy.s.sol:DeployScript \
    		--rpc-url http://0.0.0.0:8545 \
    		--private-key $(DEFAULT_ANVIL_KEY) \
    		--broadcast \
    		-vvvv
    

Expected Behavior:

The forge script command should complete and finalize the transaction receipt promptly after a successful deployment.

Actual Behavior:

The command outputs a success message for the deployment hash, but then continuously waits for pending transactions and receipts. The console shows repeated eth_getTransactionReceipt and eth_blockNumber calls without finalization.

Relevant Logs:

##### anvil-hardhat
✅  [Success] Hash: 0xc95c3e3da8a734676fcd432fd94c15ed7c85699ed13248ef78caf9957eeeecf3
Block: 1
Paid: 0.000228795000228795 ETH (228795 gas * 1.000000001 gwei)

⠐ Sequence #1 on anvil-hardhat | Waiting for pending transactions
    ⡀ [Pending] 0x8d873c972851a1b30850f50c741926056cbab91c314c3cb9aa33308b9edc86ac
    ⠉ [00:00:54] [#############################################################################] 2/2 txes (0.0s)
    ⠉ [00:00:54] [##################################>----------------------------------] 1/2 receipts (12014.5s)
eth_sendRawTransaction

    Transaction: 0xc95c3e3da8a734676fcd432fd94c15ed7c85699ed13248ef78caf9957eeeecf3
    Gas used: 228795

    Block Number: 1
    Block Hash: 0x796ffd2f555df1df3d2b34d0a1a11394fdb24467cd8c00a81c32d14ab43d4bff
    Block Time: "Sun, 25 May 2025 20:48:47 +0000"

eth_sendRawTransaction

    Block Number: 2
    Block Hash: 0x7aa9a39591aa5fbadb005f4e4c44f3902bba62e2afede7f4316d37244287d31a
    Block Time: "Sun, 25 May 2025 20:48:47 +0000"

eth_getTransactionReceipt
eth_getTransactionReceipt
eth_getTransactionReceipt
eth_blockNumber
eth_getBlockByNumber
eth_getTransactionReceipt
eth_getTransactionReceipt
eth_blockNumber
eth_getTransactionReceipt
eth_blockNumber
eth_getTransactionReceipt
eth_blockNumber
eth_getTransactionReceipt
eth_blockNumber
eth_getTransactionReceipt
eth_blockNumber

jistro avatar May 25 '25 20:05 jistro

@jistro please provide a mre of script to reproduce and command you launch anvil with (you may want to set a mining block time), do you use EIP7702 cheatcodes?

grandizzy avatar May 26 '25 04:05 grandizzy

@jistro please provide a mre of script to reproduce and command you launch anvil with (you may want to set a mining block time), do you use EIP7702 cheatcodes?

No, I did not use an EIP7702 Cheat code, this is the script I use

// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.13;

import {Script, console2} from "forge-std/Script.sol";
import {EvvmMock} from "@EVVM/playground/core/EvvmMock.sol";
import {SMateMock} from "@EVVM/playground/core/staking/SMateMock.sol";

contract DeployMock is Script {
    SMateMock sMate;

    function run() public {
        vm.broadcast();
        deployEvvm();
    }

    function deployEvvm() public returns (address sMateAddress) {
        sMate = new SMateMock(msg.sender);
        console2.log("sMate address: ", address(sMate));
        console2.log("Evvm address: ", sMate.getEvvmAddress());
        console2.log(
            "MNS address: ",
            EvvmMock(sMate.getEvvmAddress()).getMateNameServiceAddress()
        );
        return address(sMate);
    }
}

jistro avatar May 26 '25 20:05 jistro

@jistro are you launching Anvil with any special commands or flags?

Would you mind trying with --block-time 1?

Are the contracts you are deploying very large (>24kb)?

zerosnacks avatar May 27 '25 10:05 zerosnacks

@jistro are you launching Anvil with any special commands or flags?

Would you mind trying with --block-time 1?

Are the contracts you are deploying very large (>24kb)?

I haven't used that flag but some contracts I use are over 24kb

jistro avatar May 27 '25 16:05 jistro

@jistro are you launching Anvil with any special commands or flags? Would you mind trying with --block-time 1? Are the contracts you are deploying very large (>24kb)?

I haven't used that flag but some contracts I use are over 24kb

anvil can be started with --disable-code-size-limit for such, maybe you can try and see if any difference https://book.getfoundry.sh/reference/cli/anvil

grandizzy avatar May 27 '25 16:05 grandizzy

@jistro are you launching Anvil with any special commands or flags? Would you mind trying with --block-time 1? Are the contracts you are deploying very large (>24kb)?

I haven't used that flag but some contracts I use are over 24kb

anvil can be started with --disable-code-size-limit for such, maybe you can try and see if any difference https://book.getfoundry.sh/reference/cli/anvil

The --disable-code-size-limit works. The tx doesn't get stuck waiting for the receipt.

jistro avatar May 27 '25 21:05 jistro

closing per above, please reopen if you think it needs more changes. thank you!

grandizzy avatar Sep 25 '25 10:09 grandizzy