bug: resource exhausted (Too many open files)
mds1 opened this issue · comments
Matt Solomon commented
Full error is:
hevm: /usr/bin/security: createProcess: runInteractiveProcess: pipe: resource exhausted (Too many open files)
To reproduce, create a test file with the below content and run dapp test --rpc-url $ETH_RPC_URL
. This test simulates a call to shutdown Convex, which is a large transaction that uses about 16M gas
pragma solidity ^0.8.6;
import "ds-test/test.sol";
interface Hevm {
function store(address c, bytes32 loc, bytes32 val) external;
}
interface IConvex {
function owner() external view returns (address);
function shutdownSystem() external;
}
contract ConvexTest is DSTest {
Hevm constant hevm = Hevm(address(uint160(uint256(keccak256('hevm cheat code')))));
IConvex convex = IConvex(0xF403C135812408BFbE8713b5A23a04b3D48AAE31);
function testShutdownCost() public {
hevm.store(address(convex), bytes32(uint256(4)), bytes32(uint256(uint160(address(this)))));
assertEq(convex.owner(), address(this));
uint256 _startGas = gasleft();
convex.shutdownSystem();
emit log_named_uint("shutdown gas used", _startGas - gasleft());
}
}
Matt Solomon commented
Created a repo with this code here: https://github.com/mds1/convex-shutdown-simulation
Matt Solomon commented
This also seems to only happen on macOS, as it works on linux
sam bacha commented
running on MacOS 10.15.7 (19H2)
$ ./scripts/benchmark-foundry.sh
compiling...
no files changed, compilation skippped.
Running 1 test for "ConvexTest.json":ConvexTest
[PASS] testShutdownCost() (gas: 18876589)
real 6m52.588s
user 0m1.586s
sys 0m0.462s
$ ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
file size (blocks, -f) unlimited
max locked memory (kbytes, -l) unlimited
max memory size (kbytes, -m) unlimited
open files (-n) 8192
pipe size (512 bytes, -p) 1
stack size (kbytes, -s) 8192
cpu time (seconds, -t) unlimited
max user processes (-u) 5568
virtual memory (kbytes, -v) unlimited
Edit: only included the foundry run, here is the dapptools results
$ ./scripts/benchmark-dapptools.sh
dapp-test: rpc block: 13724056
Running 1 tests for src/Convex.t.sol:ConvexTest
[PASS] testShutdownCost() (gas: 16779553)
real 27m8.004s
user 12m4.388s
sys 5m24.722s
Matt Solomon commented
Apparently not! Just updated dapptools to the latest master, and ran make benchmark-dapptools
in the linked repo twice, and it worked both times
$ make benchmark-dapptools
bash scripts/benchmark-dapptools.sh
dapp-test: rpc block: 13724056
Running 1 tests for src/Convex.t.sol:ConvexTest
[PASS] testShutdownCost() (gas: 16779553)
real 5m16.308s
user 10m22.356s
sys 5m34.274s