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

Failed to decode constructor arguments #3229

Closed
2 tasks done
0xPhaze opened this issue Sep 15, 2022 · 14 comments
Closed
2 tasks done

Failed to decode constructor arguments #3229

0xPhaze opened this issue Sep 15, 2022 · 14 comments
Assignees
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug

Comments

@0xPhaze
Copy link

0xPhaze commented Sep 15, 2022

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 (359dd77 2022-09-15T00:04:51.833948Z)

What command(s) is the bug in?

forge script

Operating System

macOS (Apple Silicon)

Describe the bug

I'm getting the following error when deploying via forge script.

Error: 
Transaction failed when running the on-chain simulation. Check the trace above for more information.

Context:
- Failed to decode constructor arguments for contract Some("ERC1967Proxy"): constructor(address,bytes)
        bytecode="608060405260405161037e38038061037e833981016040819052610022916101f8565b61002c8282610033565b50506102fb565b816001600160a01b03163b60000361005e576040516309ee12d560e01b815260040160405180910390fd5b60008051602061035e83398151915260001b826001600160a01b03166352d1902d6040518163ffffffff1660e01b8152600401602060405180830381865afa1580156100ae573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906100d291906102c6565b146100f0576040516303ed501d60e01b815260040160405180910390fd5b805115610166576000826001600160a01b03168260405161011191906102df565b600060405180830381855af49150503d806000811461014c576040519150601f19603f3d011682016040523d82523d6000602084013e610151565b606091505b5050905080610164573d6000803e3d6000fd5b505b60008051602061035e83398151915280546001600160a01b0319166001600160a01b0384169081179091556040517fbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b90600090a25050565b634e487b7160e01b600052604160045260246000fd5b60005b838110156101ef5781810151838201526020016101d7565b50506000910152565b6000806040838503121561020b57600080fd5b82516001600160a01b038116811461022257600080fd5b60208401519092506001600160401b038082111561023f57600080fd5b818501915085601f83011261025357600080fd5b815181811115610265576102656101be565b604051601f8201601f19908116603f0116810190838211818310171561028d5761028d6101be565b816040528281528860208487010111156102a657600080fd5b6102b78360208301602088016101d4565b80955050505050509250929050565b6000602082840312156102d857600080fd5b5051919050565b600082516102f18184602087016101d4565b9190910192915050565b6055806103096000396000f3fe608060405236600080376000803660007f360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc545af43d6000803e80156042573d6000f35b503d6000fdfea164736f6c6343000810000a360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc00000000000000000000000004d7478fdf318c3c22cece62da9d78ff94807d77000000000000000000000000000000000000000000000000000000000000004000000000000000000000000000000000000000000000000000000000000000c47029144c0000000000000000000000000000000000000000000000000000000000000040000000000000000000000000000000000000000000000000000000000000008000000000000000000000000000000000000000000000000000000000000000064d79204e4654000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000044e4654580000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000"

This only happens when passing in an --rpc-url. Tested on mumbai testnet, but also anvil.

I tried creating a minimum reproducible example from a completely clean repo, but couldn't get it to work. The closest I got to was using this repository:

git clone git@github.com:0xPhaze/upgrade-scripts
cd upgrade-scripts/example
forge install
forge script deploy --rpc-url http://127.0.0.1:8545 --private-key 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80 -vvv --ffi
@0xPhaze 0xPhaze added the T-bug Type: bug label Sep 15, 2022
@gakonst gakonst added this to Foundry Sep 15, 2022
@gakonst gakonst moved this to Todo in Foundry Sep 15, 2022
@rkrasiuk rkrasiuk added C-forge Command: forge Cmd-forge-script Command: forge script labels Sep 16, 2022
@varunsrin
Copy link

I'm also running into this issue, using forge 0.2.0 (7dda095 2022-09-17T00:17:33.315742Z)

The issue can be reproduced by running the IdRegistry or NameRegistry deploy scripts here using the command:
forge script script/IdRegistry.s.sol:IdRegistryScript --rpc-url $GOERLI_RPC_URL --private-key $GOERLI_PRIVATE_KEY --broadcast --verify --etherscan-api-key $ETHERSCAN_KEY -vvvv

It produces the error:

ERROR foundry_cli::cmd::forge::script::transaction: Failed to extract constructor args from CREATE data constructor="constructor(address)" contract=Some("IdRegistry") bytecode="...."

@mattsse mattsse self-assigned this Sep 17, 2022
@JasoonS
Copy link

JasoonS commented Sep 19, 2022

Could this be what is causing my contract etherscan verifications to fail? (I'm getting the same errors)

Thanks 🙏

@mattsse
Copy link
Member

mattsse commented Sep 19, 2022

likely,
I'm about to fix this properly.

@mattsse
Copy link
Member

mattsse commented Sep 23, 2022

this should be fixed now, if you encounter this again, please reopen

@mattsse mattsse closed this as completed Sep 23, 2022
Repository owner moved this from Todo to Done in Foundry Sep 23, 2022
@varunsrin
Copy link

confirming, fixed for me

@radeksvarz
Copy link

Encountered again:

foundryup: installed - forge 0.2.0 (eb2141c 2023-12-20T00:19:37.580705466Z)
foundryup: installed - cast 0.2.0 (eb2141c 2023-12-20T00:19:37.571749310Z)
foundryup: installed - anvil 0.2.0 (eb2141c 2023-12-20T00:19:37.979429891Z)
foundryup: installed - chisel 0.2.0 (eb2141c 2023-12-20T00:19:37.566230315Z)

ERROR forge::cmd::script::transaction: Failed to decode constructor arguments constructor="constructor(address,bytes)" contract=Some("ERC1967Proxy") bytecode="6080;

for contracts inheriting other contract with constructors passing args like this:

contract Entrypoint is ERC1967Proxy {
    // solhint-disable-next-line no-empty-blocks
    constructor(address _logic, bytes memory _data) payable ERC1967Proxy(_logic, _data) {}
}

@gakonst
Copy link
Member

gakonst commented Jan 30, 2024

Ty - taking another look.

@mattsse
Copy link
Member

mattsse commented Jan 30, 2024

how can I repro this @radeksvarz ?
could you please open a new issue for this @radeksvarz

@codyx
Copy link

codyx commented Feb 12, 2024

I also ran into the same issue by deploying an ERC1967Proxy containing an initializer that invokes __Ownable_init(...) from OwnableUpgradeable.

Looks like something breaks during the Etherscan verification.

Managed to find a quick workaroud that worked for me which is to clear Foundry output folders (i.e., out, broadcast, cache).

@omnifient
Copy link

I was also getting this error and couldn't understand why

tried @codyx 's suggestion (ran foundry clean and deleted the broadcast/ folder) and can confirm that it works

reproducing the issue was easy:

  • have a clean state
  • run something that deploys an ERC1967Proxy (e.g. forge script <...>), will work
  • run the same, will fail
  • clean things
  • re-run the same, will work

@zakrad
Copy link

zakrad commented Jul 23, 2024

I get the same error forge_script::transaction: Failed to decode constructor arguments contract=Some("ERC1967Proxy")
with

Failed with `custom error 4c9c8ce3:000000000000000000000000f70bd0dc3f39ff53bb32d6d57de6cef8308ef609`:
Error: 
buffer overrun while deserializing

on ## Setting up 1 EVM with forge 0.2.0 (62cdea8 2024-07-23T00:18:49.756549000Z)
I have 2 multichain script first one deploys a uups contract fine, second one deploys a new uups and call it which throw this error, tried different rpcs and clean cache, broadcast, out no success

@highskore
Copy link

highskore commented Oct 13, 2024

same issue here, trying to deploy OZ ERC1967Proxy

## Setting up 1 EVM.
2024-10-13T13:25:30.424770Z ERROR forge_script::transaction: Failed to decode constructor arguments contract=Some("ERC1967Proxy") signature=constructor(address,bytes) is_create2=false constructor_args=3d5ffdfea164736f6c6343000819000a000000000000000000000000a5c0ed05d5405f485f70322419901bffa7b9452300000000000000000000000000000000000000000000000000000000000000400000000000000000000000000000000000000000000000000000000000000024c4d66de8000000000000000000000000af06c9e7e54e6bf00ef50c4a2cdf3ef73094465b00000000000000000000000000000000000000000000000000000000
Error:
buffer overrun while deserializing

Context:
- buffer overrun while deserializing

@radeksvarz
Copy link

same issue here, trying to deploy OZ ERC1967Proxy

I replaced the OZ proxy with a flattened / optimised code. The issue is gone.

Example: https://github.com/radeksvarz/uupsentrypoint_example

Proxy: https://github.com/radeksvarz/erc1967uupsentrypoint

@highskore
Copy link

same issue here, trying to deploy OZ ERC1967Proxy

I replaced the OZ proxy with a flattened / optimised code. The issue is gone.

Example: https://github.com/radeksvarz/uupsentrypoint_example

Proxy: https://github.com/radeksvarz/erc1967uupsentrypoint

another fix is just turning off optimizer in foundry.toml

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-forge Command: forge Cmd-forge-script Command: forge script T-bug Type: bug
Projects
Archived in project
Development

No branches or pull requests