zkevm: add bytecode worst case#1456
Conversation
There was a problem hiding this comment.
I spoke with kev about the purpose of the test and he explained that it was necessary that the contracts were not part of the pre-alloc since that would make the size of the fixture several gigabytes.
I suggested we create a factory contract that generates random code using keccak with the initcode.
We could:
- use a first transaction to deploy the factory contract.
- use N transactions to call the factory and create the desired amount of contracts.
- lastly send a transaction that uses EXTCODESIZE/HASH on all contracts that were created by the prior txs
c114004 to
afc7f13
Compare
|
Hey @marioevz could we deploy the factory contract in a separate block? And then call i.e is it possible to persist state between two blocks in a test? Asking because the contract deployments (especially its high memory usage) will eat into the gas limit of block. My understanding is that the |
|
The factory creation and calling to the factory should be in as many blocks as needed (due to gas limit). After all is ready, do the "attack" in a single separate block so you have full gas limit.
For these kind of tests, blockchain tests, you can pass multiple blocks, and the state is kept in the entire blockchain. |
|
That makes sense. One challenge I think is getting the deployed contract addresses to call in "attack" block. We could write the addresses to the factory's storage, i.e we'll spend some non-trivial amount of gas in the attack block reading from storage. |
Passing them through calldata is another option, because the created contract addresses are deterministic and known during the test function execution. |
Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> lints Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> fix Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> ruff fix Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> simplify Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> fix linter Signed-off-by: Ignacio Hagopian <jsign.uy@gmail.com> test: Implement dynamic contract deployment for worst bytecode zkevm test fix: review comments
55853d2 to
a672724
Compare
marioevz
left a comment
There was a problem hiding this comment.
Rebased and should be ready to merge :)
This PR adds a test that creates the current bytecode worst case scenario for provers.
It creates the target bytecodes as part of pre-alloc, which isn't friendly for filling. An alternative would be to generate these bytecodes with txs. That probably requires creating blocks before the attack block since you can't deploy ~300MiB of code in a single block due to gas limits. Sounds doable, but it can take some work.
To fill:
uv run fill --from=Cancun --until=Cancun -m "zkevm and blockchain_test"cc @kevaundray @marioevz