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

EvmError: MemoryOOG error when deploying a contract #92

Open
ledboot opened this issue Jan 22, 2025 · 4 comments
Open

EvmError: MemoryOOG error when deploying a contract #92

ledboot opened this issue Jan 22, 2025 · 4 comments

Comments

@ledboot
Copy link

ledboot commented Jan 22, 2025

In a deploy script i want to deploy 13 contrancts. Then I encountered this error [MemoryOOG] EvmError: MemoryOOG

Image

@ericglau
Copy link
Member

ericglau commented Jan 22, 2025

Hi, thanks for reporting this.

You can avoid this error by setting the block_gas_limit configuration in your Foundry environment to a higher value, so that your script is able to run without being out of gas. After Foundry runs the script with this higher limit to create the transactions locally, it will then broadcast the transactions to your connected chain as normal.

For example, you can set the following in foundry.toml:

block_gas_limit = 3000000000

Side note: It looks like you are pre-deploying the implementation contracts in your initContract() function. This isn't necessary when using Upgrades.deployTransparentProxy, because Upgrades.deployTransparentProxy automatically deploys the implementation before the proxy.

@ledboot
Copy link
Author

ledboot commented Jan 23, 2025

ok,i will setup block_gas_limit = 3000000000 in foundry.toml try again.

Additionally, in initContract() i want to pre-deploying contracts. If I don't do this, I'll get this error.

← [Revert] vm.getCode: no bytecode for contract; is it abstract or unlinked?
    └─ ← [Revert] vm.getCode: no bytecode for contract; is it abstract or unlinked?

@ericglau
Copy link
Member

ericglau commented Jan 23, 2025

Additionally, in initContract() i want to pre-deploying contracts. If I don't do this, I'll get this error.
← [Revert] vm.getCode: no bytecode for contract; is it abstract or unlinked?
└─ ← [Revert] vm.getCode: no bytecode for contract; is it abstract or unlinked?

Are you using linked libraries in your contracts? That error looks like it is caused by foundry-rs/book#1361 since we use vm.getCode to get the implementation contract to deploy.

With your initContract() approach, you could try moving that outside of the broadcast section, so that the pre-deploys are not broadcast onchain. Otherwise, the implementations would be deployed twice (which isn't a problem but just wastes gas).

For example:

function run() public {
  ...
  initContract();
  vm.startBroadcast(privateKey);
  ...

@ledboot
Copy link
Author

ledboot commented Jan 23, 2025

yeah,it's good advertise to move initContract() out of broadcast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants