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

Forge test hangs forever #4728

Closed
2 tasks done
jdbertron opened this issue Apr 12, 2023 · 8 comments
Closed
2 tasks done

Forge test hangs forever #4728

jdbertron opened this issue Apr 12, 2023 · 8 comments
Labels
C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug

Comments

@jdbertron
Copy link

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 (388c3c0 2023-04-12T03:09:53.984763822Z)

What command(s) is the bug in?

forge test --ffi

Operating System

Linux

Describe the bug

I have a diamond contract that has multiple facets. The high level description is that one facet lets a user publish a series of puzzles, keyed by hashes and tracked by owner. One facet lets anyone query the puzzles.
I can retrieve all but the first puzzle. Attempting to retrieve any other hangs the test.
I have a separate issue in which the EVM runs out of gas calling a separate method (see bottom of #3971) . I have looked at expanding the gas and memory limits, but none seem to have an impact.
The code works fine on Goerli.

You can check out the test here https://github.com/BqETH/solidity/commit/4ecf04021a11736d6f956c51cc18bea99d0cd3e4 and run
forge test --ffi -vvvv -m "testCanRegisterPuzzle"

to make it hang.
If I try the debugger, it also hangs and never gives me the debugger screen.
I'm not sure what else I can do.

@jdbertron jdbertron added the T-bug Type: bug label Apr 12, 2023
@gakonst gakonst added this to Foundry Apr 12, 2023
@github-project-automation github-project-automation bot moved this to Todo in Foundry Apr 12, 2023
@brockelmore
Copy link
Member

Strangely if you run this command with RUST_LOG=forge it fails
Screen Shot 2023-04-12 at 5 38 26 PM

@mds1 mds1 added Cmd-forge-test Command: forge test C-forge Command: forge labels Apr 13, 2023
@jdbertron
Copy link
Author

Interesting. So that's equivalent to -vvvvv and I get the same error. Thanks for pointing that out.
I'll research why that might be. Presumably a revert during setup should prevent the tests from attempting to run, that should be a fail-fast regarding of the logging level.

@trojanMcAfee
Copy link

I have two open issues where forge test hangs, and I'm also using a Diamond: #4656 and #4735.

In case you want to have a look.

@jdbertron
Copy link
Author

Lol. Ok, that's not really the source of the bug.
The RUST_LOG=forge environment gets passed on to the "forge inspect facet methods" invocation within the HelperContract that tries to extract method selectors for adding them to the diamond. So instead of getting a nice list of method:selector it gets a blob from the contract artifact and all the parsing gets out of whack, causing that error.

@jdbertron
Copy link
Author

jdbertron commented Apr 13, 2023

Ok, the problem you found was just caused by the RUST_LOG setting.
I fixed that problem in the Diamond deployment code. See this: FydeTreasury/Diamond-Foundry@7551443
You can check out the lasted commit https://github.com/BqETH/solidity or
just change the HelperContract:generateSelectors method to this:
`
// return array of function selectors for given facet name
function generateSelectors(string memory _facetName)
internal
returns (bytes4[] memory selectors)
{
//get string of contract methods
string[] memory cmd = new string;
cmd[0] = "forge";
cmd[1] = "inspect";
cmd[2] = _facetName;
cmd[3] = "methods";
bytes memory res = vm.ffi(cmd);
string memory st = string(res);

    // extract function signatures and take first 4 bytes of keccak
    strings.slice memory s = st.toSlice();

    // Skip TRACE lines if any
    strings.slice memory nl = '\n'.toSlice();
    strings.slice memory trace = 'TRACE'.toSlice();
    while (s.contains(trace) ) {
        s.split(nl);
    }

    strings.slice memory colon = ":".toSlice();
    strings.slice memory comma = ",".toSlice();
    strings.slice memory dbquote = '"'.toSlice();
    selectors = new bytes4[]((s.count(colon)));

    for(uint i = 0; i < selectors.length; i++) {
        s.split(dbquote);   // advance to next doublequote
        // split at colon, extract string up to next doublequote for methodname
        strings.slice memory method = s.split(colon).until(dbquote);
        selectors[i] = bytes4(method.keccak());
        strings.slice memory selectr = s.split(comma).until(dbquote);     // advance s to the next comma
    }
    return selectors;
}

`

The results have not changed. The hanging bug still hangs and the OutOfGas error still happens too.
The RUST_LOG=forge added nothing useful in the TRACE.

@jdbertron
Copy link
Author

Can someone look at this please ? My pull request to the Diamond Foundry project has been merged. FydeTreasury/Diamond-Foundry#6 The problem still persists.

@sambacha
Copy link
Contributor

Could this be because the gas_limit number too large to fit in target type, since max value that can be used is 9_223_372_036_854_775_807 ?

@grandizzy
Copy link
Collaborator

I cannot reproduce this with latest commit and running forge test --ffi @mattsse I think this one can be closed @jdbertron pls reopen if still an issue

@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-test Command: forge test T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests

7 participants