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

scripting: vm.startBroadcast() in setUp() increases nonce by 1 #4197

Closed
2 tasks done
0xlosh opened this issue Jan 26, 2023 · 1 comment
Closed
2 tasks done

scripting: vm.startBroadcast() in setUp() increases nonce by 1 #4197

0xlosh opened this issue Jan 26, 2023 · 1 comment
Labels
T-bug Type: bug

Comments

@0xlosh
Copy link
Contributor

0xlosh commented Jan 26, 2023

Component

Forge

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

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0

What command(s) is the bug in?

forge script

Operating System

Linux

Describe the bug

Contract.sol

contract Contract {
    uint256 public number = 1;
}

Contract.s.sol

contract ContractScript is Script {
    
    function setUp() public {
        vm.startBroadcast();
    }

    function run() public {
        new Contract();
    }
    
}

running
forge script script/Contract.s.sol -f goerli --private-key $pk --broadcast
increases the nonce of the deployer by 1, there is no pending tx/creation after waiting for 1min.

to fix the issue, one have to make a tx from e.g. metamask, i did a self transfer:
Screenshot 2023-01-27 at 00 05 12
as you can see in the screenshot above, the contract creation tx appears!

and confirms:
Screenshot 2023-01-27 at 00 05 39

this only happens when vm.startBroadcast() is in setUp() as far as i know.

@0xlosh 0xlosh added the T-bug Type: bug label Jan 26, 2023
@zerosnacks
Copy link
Member

vm.startBroadcast is setup now yields:

Traces:
  [101253] → new CounterScript@0x7FA9385bE102ac3EAc297483Dd6233D62b3e1496
    └─ ← [Return] 395 bytes of code

  [2979] CounterScript::setUp()
    ├─ [0] VM::startBroadcast()
    │   └─ ← [Return] 
    └─ ← [Stop] 

  [3011] CounterScript::run()
    ├─ [0] VM::broadcast()
    │   └─ ← [Revert] a broadcast is active already
    └─ ← [Revert] a broadcast is active already


Gas used: 24075
Error: 
script failed: a broadcast is active alread

Marking this as resolved by #5998 as user cannot encounter the reported issue anymore

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

No branches or pull requests

2 participants