Skip to content

forge script --verify suppresses console logs if not broadcasted #11009

@0xDirmes

Description

@0xDirmes

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge Version: 1.2.3-stable

What version of Foundryup are you on?

foundryup: 1.0.0foundryup: 1.0.0

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

When running forge script with the --verify flag, logs are not displayed if the transaction is not broadcasted. However, if the transaction does get broadcasted, the logs show up correctly.

Reproduction Steps

  • Run a forge script with --verify flag but without broadcast flags
  • Logs are not displayed
  • Run the same script without --verify
  • Observe that logs are now displayed

This affects debugging and monitoring of script execution, as developers expect to see logs regardless of broadcast status when verification is enabled.

PoC

// SPDX-License-Identifier: MIT
pragma solidity ^0.8.21;

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

contract DummyImplementation {
    function name() public pure returns (string memory) {
        return "DummyImplementation";
    }
}

contract DeployDummy is Script {
    function run() public {
        console.log("Starting deployment script...");
        
        vm.startBroadcast(0x123);
        
        console.log("About to deploy DummyImplementation");
        DummyImplementation dummy = new DummyImplementation();
        console.log("DummyImplementation deployed at:", address(dummy));
        console.log("Contract name:", dummy.name());
        
        vm.stopBroadcast();
        
        console.log("Deployment script completed!");
    }
}

Running it with --verify flag (and not broadcasting)

forge script src/actions/stable-swap/DeployDummy.s.sol:DeployDummy \
    --rpc-url "${LOCAL_OWNER_RPC_URL}/${NETWORK}" \
    --sender $PROXY_ADMIN_OWNER \
    --optimizer-runs 100000000 \
    --etherscan-api-key "$EXPLORER_API_KEY" \
    --verify 
➜  evm-deployments git:(main) ✗ bash run/stable-swap/issue.sh -n 80002
🔌  Deploy network: 80002
[⠊] Compiling...
No files changed, compilation skipped

SIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) 
to the previous command. See forge script --help for more.

Transactions saved to: /Users/jordi/workspace/evm-deployments/broadcast/DeployDummy.s.sol/80002/ru
n-latest.json

Sensitive values saved to: /Users/jordi/workspace/evm-deployments/cache/DeployDummy.s.sol/80002/ru
n-latest.json

Running with --verify flag and broadcasting it

forge script src/actions/stable-swap/DeployDummy.s.sol:DeployDummy \
    --rpc-url "${LOCAL_OWNER_RPC_URL}/${NETWORK}" \
    --sender $PROXY_ADMIN_OWNER \
    --optimizer-runs 100000000 \
    --etherscan-api-key "$EXPLORER_API_KEY" \
    --verify \
    $BROADCAST_FLAGS
➜  evm-deployments git:(main) ✗ bash run/stable-swap/issue.sh -n 80002 --broadcast
🔌  Deploy network: 80002
🚀  Broadcast flags enabled
[⠊] Compiling...
No files changed, compilation skipped
Warning: EIP-3855 is not supported in one or more of the RPCs used.
Unsupported Chain IDs: 80002.
Contracts deployed with a Solidity version equal or higher than 0.8.20 might not work properly.
For more information, please see https://eips.ethereum.org/EIPS/eip-3855
Script ran successfully.

== Logs ==
  Starting deployment script...
  About to deploy DummyImplementation
  DummyImplementation deployed at: 0x07624A3706d4185aBB6a222FBC20DF4817A72cfA
  Contract name: DummyImplementation
  Deployment script completed!

## Setting up 1 EVM.

==========================

Chain 80002

Estimated gas price: 109.037511224 gwei

Estimated total gas used for script: 145567

Estimated amount required: 0.015872263396344008 POL

==========================

##### amoy
✅  [Success] Hash: 0x3e204464e5c5a4c600429f2a201e6428b404800f454996421fe38e674b5e8f0c
Contract Address: 0x07624A3706d4185aBB6a222FBC20DF4817A72cfA
Block: 23908808
Paid: 0.012209475312252975 ETH (111975 gas * 109.037511161 gwei)

✅ Sequence #1 on amoy | Total Paid: 0.012209475312252975 ETH (111975 gas * avg 109.037511161 gwei
)
                                                                                                  

==========================

ONCHAIN EXECUTION COMPLETE & SUCCESSFUL.
##
Start verification for (1) contracts
Start verifying contract `0x07624A3706d4185aBB6a222FBC20DF4817A72cfA` deployed on amoy
EVM version: cancun
Compiler version: 0.8.28
Optimizations:    100000000
Error: Failed to verify contract: Failed to get standard json input; cannot resolve file at "/User
s/jordi/workspace/evm-deployments/src/actions/stable-swap/DeployDummy.s.sol"

Transactions saved to: /Users/jordi/workspace/evm-deployments/broadcast/DeployDummy.s.sol/80002/ru
n-latest.json

Sensitive values saved to: /Users/jordi/workspace/evm-deployments/cache/DeployDummy.s.sol/80002/ru
n-latest.json

Error: Not all (0 / 1) contracts were verified!

Running it without --verify flag

forge script src/actions/stable-swap/DeployDummy.s.sol:DeployDummy \
    --rpc-url "${LOCAL_OWNER_RPC_URL}/${NETWORK}" \
    --sender $PROXY_ADMIN_OWNER \
    --verify 
➜  evm-deployments git:(main) ✗ bash run/stable-swap/issue.sh -n 80002
🔌  Deploy network: 80002
[⠊] Compiling...
No files changed, compilation skipped
Warning: EIP-3855 is not supported in one or more of the RPCs used.
Unsupported Chain IDs: 80002.
Contracts deployed with a Solidity version equal or higher than 0.8.20 might not work properly.
For more information, please see https://eips.ethereum.org/EIPS/eip-3855
Script ran successfully.

== Logs ==
  Starting deployment script...
  About to deploy DummyImplementation
  DummyImplementation deployed at: 0x07624A3706d4185aBB6a222FBC20DF4817A72cfA
  Contract name: DummyImplementation
  Deployment script completed!

## Setting up 1 EVM.

==========================

Chain 80002

Estimated gas price: 92.321310401 gwei

Estimated total gas used for script: 145567

Estimated amount required: 0.013438936191142367 POL

==========================

SIMULATION COMPLETE. To broadcast these transactions, add --broadcast and wallet configuration(s) 
to the previous command. See forge script --help for more.

Transactions saved to: /Users/jordi/workspace/evm-deployments/broadcast/DeployDummy.s.sol/80002/dr
y-run/run-latest.json

Sensitive values saved to: /Users/jordi/workspace/evm-deployments/cache/DeployDummy.s.sol/80002/dr
y-run/run-latest.json


Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    Status

    Backlog

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions