foundry icon indicating copy to clipboard operation
foundry copied to clipboard

Support EIP3860 after Shanghai upgrade

Open rayeaster opened this issue 1 year ago • 7 comments

Component

Forge

Describe the feature you would like

With EIP 3860, the contract size limit should be doubled from 24KB to 48KB?

https://github.com/foundry-rs/foundry/blob/master/common/src/compile.rs#L175

-  const CONTRACT_SIZE_LIMIT: usize = 24576;
+ const CONTRACT_SIZE_LIMIT: usize = 24576 * 2;

Additional context

No response

rayeaster avatar Apr 20 '23 13:04 rayeaster

what's the current impact of this?

mattsse avatar Apr 20 '23 13:04 mattsse

what's the current impact of this?

@mattsse @gakonst Not sure if I understand it correctly, but seems that EIP3860 introduce a new limit for initcode during contract creation, instead of increasing limit for runtime bytecode? Adding a new metric around initcode size might make sense

rayeaster avatar Apr 21 '23 04:04 rayeaster

Right, so prior to EIP-3860 there was no size limit on creation code (initcode), and just a 24576 byte size limit on runtime code

EIP-3860 went live in shangai so now there is both (1) a 24576 byte size limit on runtime code, AND (2) a new 24576 * 2 = 49152 byte size limit on initcode.

Not all EVM chains have this limit, however accounting for this by default in forge seems like a sensible default since that's more conservative.

My suggestion would be to update forge build --sizes to have a second table for initcode size, and exit with an error if either creation code OR initcode is above the size limit, and add a --ignore-eip-3860 flag (or something) to turn it off for users targeting other chains

mds1 avatar Apr 21 '23 15:04 mds1

Right, so prior to EIP-3860 there was no size limit on creation code (initcode), and just a 24576 byte size limit on runtime code

EIP-3860 went live in shangai so now there is both (1) a 24576 byte size limit on runtime code, AND (2) a new 24576 * 2 = 49152 byte size limit on initcode.

Not all EVM chains have this limit, however accounting for this by default in forge seems like a sensible default since that's more conservative.

My suggestion would be to update forge build --sizes to have a second table for initcode size, and exit with an error if either creation code OR initcode is above the size limit, and add a --ignore-eip-3860 flag (or something) to turn it off for users targeting other chains

You definitely right, this is a desirable feature. I am facing a initcode limit issue when deploying a contract now and I have no idea how to handle it, because locally it goes right in a fork (anvil should have a flag for setting a maximum initcode size too). Meanwhile, do you know how can I know the creation code size so I can reduce it or split transactions?

Thanks!

victormer avatar May 05 '23 06:05 victormer

Any updates on this? revm seems to already support EIP-3860, foundry's version of it might need to be updated tho

Philogy avatar Aug 15 '23 14:08 Philogy

We're working on it - bumping to the latest.

gakonst avatar Aug 15 '23 22:08 gakonst

Any updates on this? Doesn't look like it's been implemented.

simplyoptimistic avatar Apr 22 '24 05:04 simplyoptimistic