foundry: bug(`forge script`): buffer overrun while deserializing

Component

Forge

Have you ensured that all of these are up to date?

  • Foundry
  • Foundryup

What version of Foundry are you on?

forge 0.2.0 (af97b2c 2024-07-18T00:22:15.301937000Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

When I’m trying deploying the contract with forge script, it crashes.

Script is like:

address constant ZERO = address(0xc0b0);
address dummy = new MyContract(ZERO, ZERO);

Error message:

[⠒] Compiling...
No files changed, compilation skipped
Enter keystore password:
Script ran successfully.

## Setting up 1 EVM.
2024-07-18T03:08:39.237259Z ERROR forge_script::transaction: Failed to decode constructor arguments contract=Some("MyContract") signature=constructor(address,address) is_create2=false constructor_args=0000000000000000000000c0b0000000000000000000000000000000000000000000000000000000000000c0b0
Error: 
buffer overrun while deserializing

Context:
- buffer overrun while deserializing

It looks like the constructor_args, which should be 64 bytes but 45 byte here, is incorrectly sliced.

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Comments: 21 (9 by maintainers)

Most upvoted comments

On the latest stable release of foundry by running ./scripts/deploy_anvil.sh from the contracts/ directory of https://github.com/worldcoin/world-chain/tree/osiris/buffer-overrun-poc/contracts

@0xOsiris thank you for details, was able to reproduce with given steps, will check why this happens

  • start anvil anvil --chain-id 31337 --block-time 2
  • run script
export PRIVATE_KEY=0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
forge script scripts/DeployDevnet.s.sol:DeployDevnet --rpc-url http://127.0.0.1:8545 --chain-id $CHAIN_ID --broadcast

results in

== Logs ==
  Deploying: EntryPoint, PBHEntryPoint, PBHEntryPointImplV1, PBHSignatureAggregator, PBHSafe4337Module, WorldChainBlockRegistry
  PBHEntryPointImplV1 Deployed at:  0x5FbDB2315678afecb367f032d93F642f64180aa3
  PBHEntryPoint Deployed at:  0xe7f1725E7734CE288F8367e1Bb143E90bb3F0512
  PBHSignatureAggregator Deployed at:  0x9fE46736679d2D9a65F0992F2272dE9f3c7fa6e0
2025-03-31T18:09:19.617098Z ERROR forge_script::transaction: Failed to decode constructor arguments contract=Some("ERC1967Proxy") signature=constructor(address,bytes) is_create2=false constructor_args=5b3d5ffd0000000000000000000000005fbdb2315678afecb367f032d93f642f64180aa30000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000010401a8afba0000000000000000000000005fbdb2315678afecb367f032d93f642f64180aa30000000000000000000000000000000071727de22e5e9d8baf0edac6f37da03200000000000000000000000000000000000000000000000000000000000000ff0000000000000000000000000000000000000000000000000000000001c9c38000000000000000000000000000000000000000000000000000000000000000c00000000000000000000000001804c8ab1f12e6bbf3894d4083f33e07309d1f38000000000000000000000000000000000000000000000000000000000000000100000000000000000000000070997970c51812dc3a010c7d01b50e0d17dc79c800000000000000000000000000000000000000000000000000000000
Error: ABI decoding failed: buffer overrun while deserializing

(Pretty sure related to using the proxy contract rather than the PBHEntryPoint - https://github.com/worldcoin/world-chain/blob/bd1cd9c1cf79b76162b8551ae61df4180a2ef79e/contracts/src/PBHEntryPoint.sol#L28C5-L31) Most probably similar with https://github.com/foundry-rs/foundry/pull/9050 where we had to use both deployed and creation code to identify proper artifact

Hi @zerosnacks, I fixed the issue by running forge clean and unfortunately can’t reproduce it anymore. My script was similar to the one mentioned in this post, and I was using the latest stable release on Mac (with Apple Silicon)

Sorry 😦 I should have stopped and done a proper write up, my mistake. I ended up using a workaround, and I’ve lost the context of what the issue was. I was doing something a little bizarre so this probably is an edge case.

Whoever comes across this next should do a proper write-up please 😃

I am also running into this. I cannot reopen the issue.

I’m running into the same issue. Seems to be somewhat random across builds that I’ve done.

Unfortunately running foundryup hasn’t worked for me. The error is periodic in nature for me (i.e., I restart anvil and re-run my deploy script and it goes away). Are there any other fixes?

Thanks for flagging @yungwkndllc

Optimistically marking as resolved, @lmy375 / @diyahir please leave a comment / re-open with a minimal example if this is still an issue you are facing with the latest version of Foundry after running foundryup

running foundryup fixed this for me