foundry-rs / foundry

Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
https://getfoundry.sh
Apache License 2.0
8.17k stars 1.7k forks source link

meta(`releases`): reduce size of foundry binaries #8671

Open karmacoma-eth opened 1 month ago

karmacoma-eth commented 1 month ago

Component

Forge, Cast, Anvil, Chisel

Describe the feature you would like

on macOS, with last week's foundry, I noticed that the foundry binaries are quite large:

du -h ~/.foundry/bin
forge 0.2.0 (7f0f5b4 2024-08-08T00:20:13.526170000Z)
 22M    ~/.foundry/bin/anvil
 44M    ~/.foundry/bin/cast
 30M    ~/.foundry/bin/chisel
 66M    ~/.foundry/bin/forge

after foundryup, some of them got even bigger:

forge 0.2.0 (3e3b30c 2024-08-15T00:22:08.655383000Z)
 23M    ~/.foundry/bin/anvil
 44M    ~/.foundry/bin/cast
 31M    ~/.foundry/bin/chisel
 67M    ~/.foundry/bin/forge

This also contributes significantly to the size of docker images that install foundry. Thanks!

Additional context

No response

DaniPopes commented 2 weeks ago

A few more ideas:

  1. ethers removal https://github.com/foundry-rs/foundry/pull/8826
  2. using dyn more in cheatcodes/db generic (this should be bigger) https://github.com/foundry-rs/foundry/issues/8404
DaniPopes commented 1 week ago

Improvements since first post:

Before (forge 0.2.0 (3e3b30c 2024-08-15T00:19:22.864621297Z))

26M ./anvil
26M ./anvil.stripped
50M ./cast
50M ./cast.stripped
35M ./chisel
35M ./chisel.stripped
76M ./forge
76M ./forge.stripped

After (forge 0.2.0 (1d2379a 2024-09-22T00:23:17.631577994Z))

22M ./anvil
20M ./anvil.stripped
41M ./cast
36M ./cast.stripped
29M ./chisel
25M ./chisel.stripped
60M ./forge
54M ./forge.stripped

Compare with February version (forge 0.2.0 (2cb8757 2024-02-03T00:16:46.961268899Z))

20M ./anvil
18M ./anvil.stripped
34M ./cast
31M ./cast.stripped
23M ./chisel
21M ./chisel.stripped
46M ./forge
42M ./forge.stripped

Note that the February version doesn't include much of alloy, has revm 3 which is pre-handlers, pre-eof, pre-soldeer etc; a ton less cheatcodes, config options... So some size increase is to be expected, but we can still do better