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

createFork for same block number multiple times adds an extra / for every call #6759

Closed
2 tasks done
maa105 opened this issue Jan 11, 2024 · 4 comments · Fixed by #6765
Closed
2 tasks done

createFork for same block number multiple times adds an extra / for every call #6759

maa105 opened this issue Jan 11, 2024 · 4 comments · Fixed by #6765
Labels
T-bug Type: bug

Comments

@maa105
Copy link

maa105 commented Jan 11, 2024

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 (71d8ea5 2024-01-09T14:41:14.837767655Z)

What command(s) is the bug in?

createFork/createSelectFork

Operating System

Linux

Describe the bug

each time you use a createFork for a specific block number it adds a / to the rpcUrl. try:

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

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

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

contract MyTest is Test {
    function testStart() public {
        vm.createFork('ws://valid-rpc-url:1000', 18983785);
        vm.createFork('ws://valid-rpc-url:1000', 18983785);
        vm.createFork('ws://valid-rpc-url:1000', 18983785); // <-- it will fail here
    }
}

Error:

    ├─ [0] VM::createFork("ws://valid-rpc-url:1000", 18983785 [18.98e6])
    │   └─ ← Could not instantiate forked environment with fork url: ws://valid-rpc-url:1000//
    └─ ← Could not instantiate forked environment with fork url: ws://valid-rpc-url:1000//

notice the error the fork url adds 2 /

we tried

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

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

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

contract MyTest is Test {
    function testStart() public {
        vm.createFork('ws://valid-rpc-url:1000/', 18983785);
        vm.createFork('ws://valid-rpc-url:1000/', 18983785); // <-- it will fail here
        vm.createFork('ws://valid-rpc-url:1000/', 18983785);
    }
}

Notice here we added a / here explicitly. it failed one statement before with the same error with two /

even if we add different block# for createFork it will break only on the third of the same block number.

@maa105 maa105 added the T-bug Type: bug label Jan 11, 2024
@maa105
Copy link
Author

maa105 commented Jan 11, 2024

notice valid-rpc-url:1000 is dummy replacement for our real node

@mattsse
Copy link
Member

mattsse commented Jan 11, 2024

the added slash was a previous hotfix

properly fixed with #6765

@maa105
Copy link
Author

maa105 commented Jan 11, 2024

Thx for the fix. We noted also that forking using transaction hash has the same issue i.e. creacteFork(rpcUrl, txHash); 3 times on the same rpcUrl and txHash will cause the same issue. Not sure if this helps

@maa105
Copy link
Author

maa105 commented Jan 12, 2024

you are awesome guys! tested it with block number and transaction hash both work as expected thanks!

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

Successfully merging a pull request may close this issue.

2 participants