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

forge verify-contract is unable to verify contracts with --via-ir option #3507

Closed
2 tasks done
davetist opened this issue Oct 18, 2022 · 44 comments
Closed
2 tasks done
Labels
A-verification Area: verification C-forge Command: forge Cmd-forge-verify Command: forge verify-contract/check T-bug Type: bug T-to-investigate Type: to investigate
Milestone

Comments

@davetist
Copy link

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 (fb4a836 2022-10-18T00:07:33.891597Z)

What command(s) is the bug in?

forge verify-contract 0x82c1e732d00dc8850ed723d326fc859e21641302 src/Circlets.sol:Circlets --watch --num-of-optimizations 200

Operating System

macOS (Apple Silicon)

Describe the bug

I think this might be similar to #2996

I compile my contract with --via-ir option, I added the --verifyoption when I executed the deploy contract but it failed to verify forge script script/Counter.s.sol:CounterScript --rpc-url url --gas-price 15 --broadcast --verify --via-ir -vvvv

Start verification for (1) contracts

Submitting verification for [src/Circlets.sol:Circlets] "0x82C1e732D00DC8850Ed723D326FC859e21641302".
Submitted contract for verification:
	Response: `OK`
	GUID: `kgsiiumttlafyz75snewzmmigpvffbteye4kpmd96rbtzhrl7k`
	URL:
        https://etherscan.io/address/0x82c1e732d00dc8850ed723d326fc859e21641302
Waiting for verification result...
Contract verification failed:
Response: `NOTOK`
Details: `Fail - Unable to verify`

I also got this error during the first simulation, which I don't know if it's related or not:

2022-10-18T00:52:49.201545Z ERROR foundry_cli::cmd::forge::script::transaction: Failed to extract constructor args from CREATE data constructor="constructor()" contract=Some("Circlets") bytecode="60806040523462000178576200001462000194565b602067436972636c65747360c01b8183015262000030620001c9565b634349524360e01b82820152825190916001600160401b03821162000168575b620000688262000062600254620001fe565b6200023b565b80601f8311600114620000d757508190620000a194600092620000cb575b50508160011b916000199060031b1c191617600255620002ed565b60008055620000b03362000494565b620000bb33620003f1565b6040516124ea9081620004e38239f35b01519050388062000086565b60026000529193601f1985167f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace936000905b8282106200014f575050916001939186620000a197941062000135575b505050811b01600255620002ed565b015160001960f88460031b161c1916905538808062000126565b8060018697829497870151815501960194019062000109565b620001726200017d565b62000050565b600080fd5b50634e487b7160e01b600052604160045260246000fd5b60408051919082016001600160401b03811183821017620001b9575b60405260088252565b620001c36200017d565b620001b0565b60408051919082016001600160401b03811183821017620001ee575b60405260048252565b620001f86200017d565b620001e5565b90600182811c9216801562000230575b60208310146200021a57565b634e487b7160e01b600052602260045260246000fd5b91607f16916200020e565b601f811162000248575050565b6000906002825260208220906020601f850160051c8301941062000289575b601f0160051c01915b8281106200027d57505050565b81815560010162000270565b909250829062000267565b601f8111620002a1575050565b6000906003825260208220906020601f850160051c83019410620002e2575b601f0160051c01915b828110620002d657505050565b818155600101620002c9565b9092508290620002c0565b80519091906001600160401b038111620003e1575b6200031a8162000314600354620001fe565b62000294565b602080601f83116001146200035957508192936000926200034d575b50508160011b916000199060031b1c191617600355565b01519050388062000336565b6003600052601f198316949091907fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b926000905b878210620003c8575050836001959610620003ae575b505050811b01600355565b015160001960f88460031b161c19169055388080620003a3565b806001859682949686015181550195019301906200038d565b620003eb6200017d565b62000302565b600080549160018060a01b0316808252600560205260408220680f000000000000000f815401905582825260046020524260a01b81176040832055600f8301927fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef818385838180a460018092015b858103620004845750505015620004735755565b604051622e076360e81b8152600490fd5b8083918587858180a4016200045f565b600880546001600160a01b039283166001600160a01b031982168117909255604051919216907f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e090600090a356fe60806040526004361015610013575b600080fd5b60003560e01c806301ffc9a7146101b757806306fdde03146101ae578063081812fc146101a5578063095ea7b31461019c57806318160ddd1461019357806323b872dd1461018a57806332cb6b0c1461018157806342842e0e146101785780636352211e1461016f57806370a0823114610166578063715018a61461015d5780638da5cb5b1461015457806395d89b411461014b578063a0712d6814610142578063a0ef91df14610139578063a22cb46514610130578063b88d4fde14610127578063c002d23d1461011e578063c87b56dd14610115578063e985e9c51461010c5763f2fde38b1461010457600080fd5b61000e610e5d565b5061000e610dff565b5061000e610b28565b5061000e610b05565b5061000e610a80565b5061000e61090b565b5061000e610888565b5061000e6107c7565b5061000e610703565b5061000e6106d9565b5061000e610677565b5061000e61061a565b5061000e6105ea565b5061000e6105a7565b5061000e610589565b5061000e610574565b5061000e61051b565b5061000e610460565b5061000e6103bc565b5061000e6102af565b5061000e6101d2565b6001600160e01b031981160361000e57565b503461000e57602036600319011261000e5760206004356101f2816101c0565b63ffffffff60e01b166301ffc9a760e01b8114908115610230575b811561021f575b506040519015158152f35b635b5e139f60e01b14905038610214565b6380ac58cd60e01b8114915061020d565b918091926000905b82821061026157501161025a575050565b6000910152565b91508060209183015181860152018291610249565b9060209161028f81518092818552858086019101610241565b601f01601f1916010190565b9060206102ac928181520190610276565b90565b503461000e576000806003193601126103b95760405190806002549060019180831c928082169283156103af575b602092838610851461039b57858852602088019490811561037a5750600114610321575b61031d8761031181890382610a12565b6040519182918261029b565b0390f35b600260005294509192917f405787fa12a823e0f2b7631cc41b3ba8828b3321ca811111fa75cd3aa3bb5ace5b83861061036957505050910190506103118261031d3880610301565b80548587015294820194810161034d565b60ff191685525050505090151560051b0190506103118261031d3880610301565b634e487b7160e01b82526022600452602482fd5b93607f16936102dd565b80fd5b503461000e57602036600319011261000e57600435600054811080610418575b15610406576000908152600660209081526040918290205491516001600160a01b03909216825290f35b6040516333d1c03960e21b8152600490fd5b50600081815260046020526040902054600160e01b16156103dc565b600435906001600160a01b038216820361000e57565b602435906001600160a01b038216820361000e57565b50604036600319011261000e57610475610434565b6001600160a01b03906024358261048b82610f2e565b168033036104e8575b600082815260066020526040812080546001600160a01b0319166001600160a01b038616179055936040519316907f8c5be1e5ebec7d5bd14f71427d1e84f3dd0314c0f7b2291e5b200ac8c7c3b9258585a4f35b600081815260076020908152604080832033845290915290205460ff16610494576040516367d9dca160e11b8152600490fd5b503461000e57600036600319011261000e5760206000546001549003604051908152f35b606090600319011261000e576001600160a01b0390600435828116810361000e5791602435908116810361000e579060443590565b506105876105813661053f565b91610f9c565b005b503461000e57600036600319011261000e5760206040516101008152f35b506105876105b43661053f565b90604051926020840184811067ffffffffffffffff8211176105dd575b60405260008452611183565b6105e561099a565b6105d1565b503461000e57602036600319011261000e5760206001600160a01b03610611600435610f2e565b16604051908152f35b503461000e57602036600319011261000e576001600160a01b0361063c610434565b168015610665576000526005602052602067ffffffffffffffff60406000205416604051908152f35b6040516323d3ad8160e21b8152600490fd5b503461000e576000806003193601126103b9576106926112e6565b600880546001600160a01b031981169091556040519082906001600160a01b03167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08284a3f35b503461000e57600036600319011261000e576008546040516001600160a01b039091168152602090f35b503461000e576000806003193601126103b95760405190806003549060019180831c928082169283156107bd575b602092838610851461039b57858852602088019490811561037a57506001146107645761031d8761031181890382610a12565b600360005294509192917fc2575a0e9e593c00f959f8c92f12db2869c3395a3b0502d05e2516446f71f85b5b8386106107ac57505050910190506103118261031d3880610301565b805485870152948201948101610790565b93607f1693610731565b50602036600319011261000e5760043580156108525780790734aca5f6226f0ada6175f343cc4d4d9dfb8b60d6e93f84291e6105879211600116610845575b61081b81662386f26fc100000234101561137a565b61083f61010061083883610833600054600154900390565b61142a565b1115611436565b33611477565b61084d61133e565b610806565b60405162461bcd60e51b815260206004820152600e60248201526d1a5b9d985b1a5908185b5bdd5b9d60921b6044820152606490fd5b503461000e576000806003193601126103b9576108a36112e6565b60085460405182918291829147906001600160a01b03165af16108c461120d565b50156108cf57604051f35b60405162461bcd60e51b81526020600482015260146024820152732330b4b632b2103a379039b2b7321022ba3432b960611b6044820152606490fd5b503461000e57604036600319011261000e57610925610434565b6024359081151580920361000e573360009081526007602090815260408083206001600160a01b0385168452909152902060ff1981541660ff841617905560405191825260018060a01b0316907f17307eab39ab6107e8899845ad3d59bd9653f200f220920489ca2b5937696c3160203392a3005b50634e487b7160e01b600052604160045260246000fd5b6040810190811067ffffffffffffffff8211176109cd57604052565b6109d561099a565b604052565b6060810190811067ffffffffffffffff8211176109cd57604052565b6020810190811067ffffffffffffffff8211176109cd57604052565b90601f8019910116810190811067ffffffffffffffff8211176109cd57604052565b60405190610100820182811067ffffffffffffffff8211176109cd57604052565b60209067ffffffffffffffff8111610a73575b601f01601f19160190565b610a7b61099a565b610a68565b50608036600319011261000e57610a95610434565b610a9d61044a565b6064359167ffffffffffffffff831161000e573660238401121561000e57826004013591610aca83610a55565b92610ad86040519485610a12565b808452366024828701011161000e5760208160009260246105879801838801378501015260443591611183565b503461000e57600036600319011261000e576020604051662386f26fc100008152f35b503461000e57602036600319011261000e57600435600054811015610dcb57610dbf610311610c3d610d8a6020610d76610d67610d04610c3d610d2561031d9a610b7061154c565b50610c3d610b7d82611764565b959092610c3d610c43610bb2610bac610ba6610ba189610b9b611578565b9d611b30565b611689565b946115ba565b966115ba565b986040519e8f9d8e016063907f7b226465736372697074696f6e223a22436972636c657473206172652061206681527f6573746976616c206f66206c6967687420616e64206d6f76656d656e7420737460208201527f6f726564206f6e2d636861696e20666f72657665722e2045616368206f66207460408201526203432960ed1b60608201520190565b90611565565b7f20436972636c65747320726570726573656e74732074686520736572656e646981527f70697479206f66206c69666520616e6420686f7720736f6d652070656f706c6560208201527f2063616e206368616e67652074686520636f6c6f72206f66206576657279746860408201527f696e67206a757374206279206265696e672061726f756e642e222c22696d616760608201527f65223a22646174613a696d6167652f7376672b786d6c3b6261736536342c00006080820152609e0190565b74222c226e616d65223a2022436972636c657473202360581b815260150190565b7f222c2261747472696275746573223a5b7b2274726169745f74797065223a224381526f34b931b632b99116113b30b63ab2911d60811b602082015260300190565b627d5d7d60e81b815260030190565b0391610ba1601f1993848101835282610a12565b6040517f646174613a6170706c69636174696f6e2f6a736f6e3b6261736536342c0000006020820152938491603d8301610c3d565b03908101835282610a12565b60405162461bcd60e51b815260206004820152600c60248201526b1a59081b9bdd08199bdd5b9960a21b6044820152606490fd5b503461000e57604036600319011261000e57602060ff610e51610e20610434565b610e2861044a565b6001600160a01b0391821660009081526007865260408082209290931681526020919091522090565b54166040519015158152f35b503461000e57602036600319011261000e57610e77610434565b610e7f6112e6565b6001600160a01b03908116908115610eda5760009160085491816bffffffffffffffffffffffff60a01b84161760085560405192167f8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e08484a3f35b60405162461bcd60e51b815260206004820152602660248201527f4f776e61626c653a206e6577206f776e657220697320746865207a65726f206160448201526564647265737360d01b6064820152608490fd5b60008181548110610f4c575b604051636f96cda160e11b8152600490fd5b81526004906020918083526040928383205494600160e01b861615610f7357505050610f3a565b93929190935b8515610f8757505050505090565b60001901808352818552838320549550610f79565b90610fa683610f2e565b6001600160a01b038381169282821684900361115f57600086815260066020526040902080549092610feb6001600160a01b03881633908114908414171590565b1590565b611104575b82169586156110f25761104393611021926110e8575b506001600160a01b0316600090815260056020526040902090565b80546000190190556001600160a01b0316600090815260056020526040902090565b80546001019055600160e11b804260a01b85171761106b866000526004602052604060002090565b5581161561109e575b507fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef6000604051a4565b600184016110b6816000526004602052604060002090565b54156110c3575b50611074565b60005481146110bd576110e0906000526004602052604060002090565b5538806110bd565b6000905538611006565b604051633a954ecd60e21b8152600490fd5b611148610fe76111413361112a8b60018060a01b03166000526007602052604060002090565b9060018060a01b0316600052602052604060002090565b5460ff1690565b15610ff057604051632ce44b5f60e11b8152600490fd5b60405162a1148160e81b8152600490fd5b6040519061117d826109f6565b60008252565b929190611191828286610f9c565b803b61119e575b50505050565b6111a79361123d565b156111b55738808080611198565b6040516368d2bf6b60e11b8152600490fd5b9081602091031261000e57516102ac816101c0565b6001600160a01b0391821681529116602082015260408101919091526080606082018190526102ac92910190610276565b3d15611238573d9061121e82610a55565b9161122c6040519384610a12565b82523d6000602084013e565b606090565b92602091611266936000604051809681958294630a85bd0160e11b9a8b855233600486016111dc565b03926001600160a01b03165af1600091816112b6575b506112a85761128961120d565b805190816112a3576040516368d2bf6b60e11b8152600490fd5b602001fd5b6001600160e01b0319161490565b6112d891925060203d81116112df575b6112d08183610a12565b8101906111c7565b903861127c565b503d6112c6565b6008546001600160a01b031633036112fa57565b606460405162461bcd60e51b815260206004820152602060248201527f4f776e61626c653a2063616c6c6572206973206e6f7420746865206f776e65726044820152fd5b50634e487b7160e01b600052601160045260246000fd5b6001600160fe1b03811160011661136d575b60021b90565b61137561133e565b611367565b1561138157565b60405162461bcd60e51b81526020600482015260156024820152741b9bdd08195b9bdd59da08195d1a195c881c185a59605a1b6044820152606490fd5b60029060021981116113ce570190565b6113d661133e565b0190565b60649060641981116113ce570190565b600a90600a1981116113ce570190565b60059060051981116113ce570190565b60019060011981116113ce570190565b60149060141981116113ce570190565b811981116113ce570190565b1561143d57565b60405162461bcd60e51b81526020600482015260126024820152711b585e081cdd5c1c1b1e481c995858da195960721b6044820152606490fd5b90600090815492811561153a576001600160a01b0381166000908152600560205260409020805468010000000000000001840201905560008481526004602052604090206001600160a01b03909116916001914260a01b83831460e11b1784179055840193817fddf252ad1be2c89b69c2b068fc378daa952ba7f163c4a11628f55a4df523b3ef91808587858180a4015b85810361152b575050501561151a5755565b604051622e076360e81b8152600490fd5b8083918587858180a401611508565b60405163b562e8dd60e01b8152600490fd5b60405190611559826109b1565b60006020838281520152565b906113d660209282815194859201610241565b6040519060a08201604052608082019160008352610100925b6000190192600a90603082820601855304928361159157809350608091030191601f1901918252565b9060405160a08101604052608081019260008452926000190192600a90603082820601855304928361159157809350608091030191601f1901918252565b60405190611605826109da565b604082527f6768696a6b6c6d6e6f707172737475767778797a303132333435363738392b2f6040837f4142434445464748494a4b4c4d4e4f505152535455565758595a61626364656660208201520152565b9061166182610a55565b61166e6040519182610a12565b828152809261167f601f1991610a55565b0190602036910137565b80511561175b576116986115f8565b6116bc6116b76116b26116ab85516113be565b6003900490565b611355565b611657565b9160208301918182518301915b828210611709575050506003905106806001146116f6576002146116eb575090565b603d90600019015390565b50603d9081600019820153600119015390565b9091936004906003809401938451600190603f9082828260121c16880101518553828282600c1c16880101518386015382828260061c16880101516002860153168501015190820153019391906116c9565b506102ac611170565b9061176d61154c565b506040519161177b836109b1565b82526003602083016000815261178f61154c565b50610a008151106117c0575b8051600a80820490925206811981116117b357019190565b6117bb61133e565b019190565b835160405160208101918252602081526117d9816109b1565b519020808552815261179b565b6117ee61154c565b5080916020820191610e00835110611810575b50815191600e80840693049052565b80516040516020810191825260208152611829816109b1565b519020809152825238611801565b61183f61154c565b5080916020820191612400835110611861575b50815191602480840693049052565b8051604051602081019182526020815261187a816109b1565b519020809152825238611852565b61189061154c565b5080916020820191620104008351106118b4575b5081519161010480840693049052565b805160405160208101918252602081526118cd816109b1565b5190208091528252386118a4565b6118e361154c565b5080916020820191611400835110611905575b50815191601480840693049052565b8051604051602081019182526020815261191e816109b1565b5190208091528252386118f6565b61193461154c565b5080916020820191610500835110611956575b50815191600580840693049052565b8051604051602081019182526020815261196f816109b1565b519020809152825238611947565b61198561154c565b50809160208201916103008351106119a7575b50815191600380840693049052565b805160405160208101918252602081526119c0816109b1565b519020809152825238611998565b6119d661154c565b50809160208201916164008351106119f8575b50815191606480840693049052565b80516040516020810191825260208152611a11816109b1565b5190208091528252386119e9565b611a2761154c565b5080916020820191610f00835110611a49575b50815191600f80840693049052565b80516040516020810191825260208152611a62816109b1565b519020809152825238611a3a565b611a7861154c565b508091602082019162010000835110611a9c575b5081519160ff83169260081c9052565b80516040516020810191825260208152611ab5816109b1565b519020809152825238611a8c565b60405190610100820182811067ffffffffffffffff821117611b13575b6040528160e060609182815282602082015282604082015282808201528260808201528260a08201528260c08201520152565b611b1b61099a565b611ae0565b60019060001981146113ce570190565b9060609182611b3d611ac3565b506000905b838210611bf557505091611be7611bd5611b626102ac94610c3d96611e13565b92604051958694610c3d60208701604c907f3c73766720786d6c6e733d22687474703a2f2f7777772e77332e6f72672f323081527f30302f737667222076657273696f6e3d22312e32222076696577426f783d223060208201526b10181018981810189818111f60a11b60408201520190565b651e17b9bb339f60d11b815260060190565b03601f198101835282610a12565b908094611c00611ac3565b5082611c0b856117e6565b6001829392911615600014611dad5750611c63610c3d611c2d611c5d946117e6565b909490600a811115611d9f57611be7611c4d611c476121a4565b926115ba565b6040519485936020850190611565565b92611837565b6004819392931180611d95575b15611d8c5750611c7e612187565b91610c3d611d54611d6797611d6196611be7956003611cbf611cbf611ce6611ce0611cd8611cd2611cca611cc4611cb7611cbf9f611888565b9f909f6113da565b6115ba565b9d6118db565b9690966113ea565b946118db565b9390936113ea565b9161192c565b90931180159290611d7e57611cf96121e4565b925b15611d6d57611d1e611cbf611d17611d116121c1565b966118db565b90506113fa565b94611d27610a34565b96875260209c8d88015260409a8b880152860152608085015260a084015260c083015260e0820152612209565b9151958694850190611565565b94611b20565b90611b42565b611d1e611cbf611d17611d116121e4565b611d866121c1565b92611cfb565b611c7e906115ba565b50601e8110611c70565b611be7611c4d611c47611170565b9150611c63611c5d612187565b60405190611dc7826109da565b60606040838281528260208201520152565b60405190611de6826109b1565b60018252603560f81b6020830152565b60405190611e03826109b1565b60018252603360f81b6020830152565b606091611e1e611dba565b506000915b818310611e6a575050506102ac611e5791611be7604051938492610c3d60208501600690651e3232b3399f60d11b81520190565b661e17b232b3399f60c91b815260070190565b92611e8d611e86611e7f611e9494959661197d565b91906119ce565b9290611a1f565b949061211c565b91909194611ea7611c47611cbf8a61140a565b936001611ebf611cbf611eb9846115ba565b9461141a565b911661210e57611ecd611df6565b905b84519260209687870151956040809801519751998a998a01611ef091611565565b7f3c72616469616c4772616469656e742069643d224772616469656e74000000008152601c01611f1f91611565565b7f222063783d22353025222063793d22353025222066783d2200000000000000008152601801611f4e91611565565b601760f91b8152600101611f6191611565565b7f25222066793d223530252220723d222e35223e3c616e696d617465206174747281527334b13aba32a730b6b29e91333c1110323ab91e9160611b6020820152603401611fad91611565565b6d73222076616c7565733d2230253b60901b8152600e01611fcd91611565565b7f253b30252220726570656174436f756e743d22696e646566696e697465222f3e81527f3c73746f70206f66667365743d223025222073746f702d636f6c6f723d2272676020820152620c4c2560eb1b604082015260430161202f9082611565565b61016160f51b81526002016120449083611565565b61016160f51b81526002016120599084611565565b7f2c203129222f3e3c73746f70206f66667365743d2231303025222073746f702d81526b0c6ded8dee47a44e4cec4c2560a31b6020820152602c0161209d91611565565b61016160f51b81526002016120b191611565565b61016160f51b81526002016120c591611565565b7f2c203029222f3e3c2f72616469616c4772616469656e743e0000000000000000815260180103601f19810182526120fd9082610a12565b9261210790611b20565b9190611e23565b612116611dd9565b90611ecf565b9061215561215d61216961216361214761214e96612138611dba565b5061214161154c565b50611a70565b9690611a70565b9490611a70565b9390966115ba565b936115ba565b916115ba565b9060405192612177846109da565b8352602083015260408201529190565b60405190612194826109b1565b60018252600360fc1b6020830152565b604051906121b1826109b1565b60018252602d60f81b6020830152565b604051906121ce826109b1565b60078252660302035302035360cc1b6020830152565b604051906121f1826109b1565b600982526803336302035302035360bc1b6020830152565b80519060208101519261221b9061140a565b612224906115ba565b906040810151606082015160808301519060a08401519260c08501519460e001519560405198899860208a0161226a90600990681e3932b1ba103c1e9160b91b81520190565b61227391611565565b651291103c9e9160d11b815260060161228b91611565565b7f25222077696474683d223130302522206865696768743d2231303025222066698152701b1b0f489d5c9b0a08d1dc98591a595b9d607a1b60208201526031016122d491611565565b740524440e8e4c2dce6ccdee4da7a44e4dee8c2e8ca5605b1b81526015016122fb91611565565b7f20353020353029223e3c616e696d617465206174747269627574654e616d653d815268113c1110323ab91e9160b91b602082015260290161233c91611565565b7f73222076616c7565733d2230253b3235253b30252220726570656174436f756e81527f743d22696e646566696e697465222f3e3c616e696d617465206174747269627560208201526f3a32a730b6b29e913c9110323ab91e9160811b60408201526050016123aa91611565565b7f73222076616c7565733d2230253b3235253b30252220726570656174436f756e81527f743d22696e646566696e697465222f3e3c616e696d6174655472616e73666f7260208201527f6d206174747269627574654e616d653d227472616e73666f726d22207479706560408201526f1e913937ba30ba329110333937b69e9160811b606082015260700161243e91611565565b6511103a379e9160d11b815260060161245691611565565b661110323ab91e9160c91b815260070161246f91611565565b7f732220726570656174436f756e743d22696e646566696e697465222f3e3c2f7281526332b1ba1f60e11b602082015260240103601f19810182526102ac9082610a1256fea26469706673582212204939115ffe171f6c9ab78d7de2b502a8a513b1c8955d2330be2305a284cd686a64736f6c634300080f0033"

This is the deployed contract: https://etherscan.io/address/0x82c1e732d00dc8850ed723d326fc859e21641302

The same error happens when I run forge verify-contract 0x82c1e732d00dc8850ed723d326fc859e21641302 src/Circlets.sol:Circlets --watch --num-of-optimizations 200

Submitted contract for verification:
	Response: `OK`
	GUID: `b3vd1jhhu1txlvshfmpmaf9kgvemryn7ufg58urwdi5irgvfre`
	URL:
        https://etherscan.io/address/0x82c1e732d00dc8850ed723d326fc859e21641302
Waiting for verification result...
Contract verification failed:
Response: `NOTOK`
Details: `Fail - Unable to verify`

I've tried to verify it manually in Etherscan with the flatten option, but I get
CompilerError: Stack too deep. Try compiling with --via-ir(cli) or the equivalentviaIR: true (standard JSON) while enabling the optimizer. Otherwise, try removing local variables. When compiling inline assembly: Variable length is 2 slot(s) too deep inside the stack. which I can't see any option to add it there?

Let me know if I can help to debug this, this is the whole flattened contract in case it helps https://gist.github.com/apeblond/014e76bde633791270809daacb68df34

@davetist davetist added the T-bug Type: bug label Oct 18, 2022
@gakonst gakonst added this to Foundry Oct 18, 2022
@gakonst gakonst moved this to Todo in Foundry Oct 18, 2022
@davetist
Copy link
Author

I think this could be related ethereum/solidity#13311 (comment)

@rkrasiuk rkrasiuk added C-forge Command: forge Cmd-forge-verify Command: forge verify-contract/check labels Oct 18, 2022
@rkrasiuk
Copy link
Collaborator

hey @apeblond, thanks for reporting. this is an issue our users have been experiencing for a while now, we're chatting with etherscan to see how we can resolve the resulting bytecode mismatch

@davetist
Copy link
Author

davetist commented Oct 18, 2022

hey @apeblond, thanks for reporting. this is an issue our users have been experiencing for a while now, we're chatting with etherscan to see how we can resolve the resulting bytecode mismatch

Thank you for your quick response! @rkrasiuk I didn't know exactly if the problem was something caused by me or not taking into account it's a bit of a black-box for me!

Do you know if there is a way for me to verify the contract manually somehow, or is it just that Etherscan doesn't support this new compilation? Appreciate you taking the time to discuss it with them!

In theory Etherscan allows to pass the via-ir option via standard json, but I wasn't able to make it work either (tried with the json in ./out/Circlets.sol/Circlets.json)

@eugenioclrc
Copy link

same issue here :S :S

@degatchi
Copy link

Same issue here. When I deploy the contract I can't verify it manually with the flatten command either - shows different bytecode.

@seanconnollydev
Copy link

Experiencing this as well but surprisingly not for every project where I've had to set via_ir = true.

I also have not found a way to perform the verification manually. I've tried uploading a standard-json-input at Etherscan's behest but I can't figure out how to get foundry to build the output in a way that Etherscan is pleased with.

I've tried forge build --extra-output-files metadata and then uploading the file under /out/MyContract.sol/MyContract.metadata.json but Etherscan doesn't permit URLs in the source fields:

Unable to process the standard-input-json you uploaded. ErrCode: Only literal contents of the source file, Source using URLS are not supported

Etherscan lists these recommendations:

  1. Contract sources in the json file must be formatted as Literal contents and NOT as urls
  2. Use multiple literal {"content": "", ...} for multi part contracts containing multiple source files
  3. A serializing raw text tool for converting objects to JSON string is also available.

I assume 1 or 2 are relevant here but I don't really know how to act on that.

Is there a way to update foundry.toml or pass an argument to forge build that formats sources in the json file as "literal contents"?

@Raunaque97
Copy link

Raunaque97 commented Feb 3, 2023

I also had to use the --via-ir option during compiling. Now I am not able to verify in etherscan. I am using the following,
forge verify-contract --chain-id 5 --num-of-optimizations 20000 --watch --compiler-version v0.8.17+commit.8df45f5f 0x3B1574a84A09432150FF0B436cB646F06165977c src/Pots.sol:Pots.
I am not sure whether its related to this or I am just forgetting to pass additional parameters. The deployed contract has no constructor args.

@nnnnicholas
Copy link

Same issue. forge create with via-ir and verify deploys successfully but returns the following error during verification:

Contract verification status:
Response: `NOTOK`
Details: `Fail - Unable to verify. Solidity Compilation Error: Compiler error (circleci\project\libsolidity\codegen\LValue.cpp:56):Stack too deep. Try compiling with `--via-ir` (cli) or the equivalent `viaIR: true` (standard JSON) while enabling the optimizer. Otherwise, try removing local variables.`

@ioannist
Copy link

same problem, but I am using truffle, so this is probably something etherscan needs to fix

@0xV4L3NT1N3
Copy link

gm all, chiming in here from Etherscan, could anyone try manually submitting a standard-json verification from the web interface with the viaIR setting specified ?

This will help debug if its something related to the endpoint, though can confirm we've added support for viaIR

@ioannist
Copy link

ioannist commented Feb 17, 2023

We tried submitting with the truffle verify plugin which I believe submits the json files, and got this:

Verifying contracts on moonscan
   Fail - Unable to verify
   Failed to verify 1 contract(s): Oracle
Verifying contracts on sourcify
   Verifying Oracle
   Pass - Verified: https://sourcify.dev/#/lookup/0xC3a6F635a4696Cbf8436f9e917F16D4e4D9673Fe
   Successfully verified 1 contract(s).

Moonscan isEtherscan for moonbeam/moonriver EVMs, so the same thing basically

Also, using json files in Moonscan does not work cause the binaries don't match, which I believe is the same error as above.

Here is the relevant bit of the metadata of the Oracle json file:
"optimizer\":{\"enabled\":true,\"runs\":438000},\"remappings\":[],\"viaIR\":true}

@unordered-set
Copy link

unordered-set commented Mar 13, 2023

@0xV4L3NT1N3 success!

So, steps are:

  1. forge verify-contract ADDRESS CONTRACT ETHERSCANKEY --optimizer-runs=100 --constructor-args "<ABI encoded ctor args>" --show-standard-json-input > etherscan.json
  2. patch manually etherscan.json : "optimizer":{"enabled":true,"runs":100} -> "optimizer":{"enabled":true,"runs":100},"viaIR":true (or something of that sort)
  3. upload json to etherscan manually

@eugenioclrc
Copy link

@0xV4L3NT1N3 success!

So, steps are:

  1. forge verify-contract ADDRESS CONTRACT ETHERSCANKEY --optimizer-runs=100 --constructor-args "<ABI encoded ctor args>" --show-standard-json-input > etherscan.json
  2. patch manually etherscan.json : "optimizer":{"enabled":true,"runs":100} -> "optimizer":{"enabled":true,"runs":100},"viaIR":true (or something of that sort)
  3. upload json to etherscan manually

Awesomeeeeee

@codemedici
Copy link

I.e. it is not possible to pass the --verify flag to the forge script command during deployment?

@le-kag
Copy link

le-kag commented Mar 24, 2023

Same issue but on Arbiscan this time. Seems like the only option is to submit solc-input-contracts.json, does anyone know a work around?

@captain-woof
Copy link

@unordered-set Thanks so much for this. I confirm it works.

@Alexangelj
Copy link

lifesaver thank you!

@shuhuiluo
Copy link

@0xV4L3NT1N3 success!
So, steps are:

  1. forge verify-contract ADDRESS CONTRACT ETHERSCANKEY --optimizer-runs=100 --constructor-args "<ABI encoded ctor args>" --show-standard-json-input > etherscan.json
  2. patch manually etherscan.json : "optimizer":{"enabled":true,"runs":100} -> "optimizer":{"enabled":true,"runs":100},"viaIR":true (or something of that sort)
  3. upload json to etherscan manually

Awesomeeeeee

Confirmed it works. But Etherscan has a more restrictive limitation on runs. I think the compiler supports up to 2**32 - 1 = 4294967295. However Etherscan may not be happy with numbers greater than 2**22. The exact upper bound is unknown. When it fails, it says things like "unable to parse json" which makes you think it's a json format issue.

sbauch added a commit to sbauch/book that referenced this issue Jul 13, 2023
I found this option in this issue - foundry-rs/foundry#3507

This was helpful for verifying a contract on Zora's blockscout based explorer.

I don't really know where this standard comes from or anything about it, so hoping someone more knowledgeable is willing to take this over the finish line.
Evalir pushed a commit to foundry-rs/book that referenced this issue Jul 13, 2023
I found this option in this issue - foundry-rs/foundry#3507

This was helpful for verifying a contract on Zora's blockscout based explorer.

I don't really know where this standard comes from or anything about it, so hoping someone more knowledgeable is willing to take this over the finish line.
@spengrah
Copy link

spengrah commented Aug 6, 2023

So, steps are:

  1. forge verify-contract ADDRESS CONTRACT ETHERSCANKEY --optimizer-runs=100 --constructor-args "<ABI encoded ctor args>" --show-standard-json-input > etherscan.json

  2. patch manually etherscan.json : "optimizer":{"enabled":true,"runs":100} -> "optimizer":{"enabled":true,"runs":100},"viaIR":true (or something of that sort)

  3. upload json to etherscan manually

This worked for me too!

@codemedici
Copy link

Confirmed it is just an ether scan problem not supporting more than 2^22 optimizer runs :(

@swan-of-bodom
Copy link

@0xV4L3NT1N3 success!

So, steps are:

  1. forge verify-contract ADDRESS CONTRACT ETHERSCANKEY --optimizer-runs=100 --constructor-args "<ABI encoded ctor args>" --show-standard-json-input > etherscan.json
  2. patch manually etherscan.json : "optimizer":{"enabled":true,"runs":100} -> "optimizer":{"enabled":true,"runs":100},"viaIR":true (or something of that sort)
  3. upload json to etherscan manually

Confirm this works, just verified it on polygon zkevm.

@ytham
Copy link

ytham commented Dec 18, 2023

@0xV4L3NT1N3 just to confirm, the json file generated from forge verify-contract, correct?

@PaulRBerg
Copy link
Contributor

PaulRBerg commented Dec 18, 2023

Context

Just bumped into this issue, too. It looks like a recent change has introduced a bug in the verify-contract command, @mattsse, @Evalir.

Reproduction

Let's attempt to verify this contract on Ethereum Mainnet:

https://etherscan.io/address/0xe99AEff5BB41d0d7340e7B0c8001F593768ba0E5

Using this standard JSON input file:

https://gist.github.com/PaulRBerg/5b130690330ffa6cf28fc5fa238e56ce

I generated that file by running this command:

$ FOUNDRY_PROFILE=optimized \
forge verify-contract 0xe99AEff5BB41d0d7340e7B0c8001F593768ba0E5 \
./src/SablierV2LockupLinear.sol:SablierV2LockupLinear \
--chain mainnet \
--etherscan-api-key $API_KEY_ETHERSCAN \
--watch \
--constructor-args \
0x00000000000000000000000079fb3e81aac012c08501f41296ccc145a1e15844000000000000000000000000c3be6bffaeab7b297c03383b4254aa3af2b9a5ba00000000000000000000000023ed5da55af4286c0de55facb414dee2e317f4cb

In this GitHub repo (tag v1.1.1).

Error

The verification will fail with this error:

Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.

Uploading the file manually on Etherscan yields the same error. I have prepared a diff between the actual contract (what the bytecode is according to the local compilation output) and the contract bytecode expected by Etherscan:

As you can see, there are a lot of differences.

Possible Explanation

It looks like Foundry generates the standard JSON input file incorrectly, or at least not in the way that Etherscan expects. As @seanconnollydev pointed out above, Etherscan wants "literal contents not URLs". But in the file generated by Foundry, the useLiteralContent setting is set to false.

Cc @harithk in case he is able to confirm my understanding here.

SCR-20231218-pota

Environment

  • solidity v0.8.21
    • EVM version: "paris"
    • viaIR: enabled
    • optimized: enabled
    • optimizer runs: 1,000
  • forge 0.2.0 (477b345 2023-12-18T00:29:33.818665000Z)

@Evalir
Copy link
Member

Evalir commented Dec 18, 2023

@PaulRBerg ack—i know this is a lot of work, but these issues are extremely time consuming to debug, but do you think you could try and track down the last commit this was working before it broke? lmk if you need more instructions. This way we can fix this faster

@PaulRBerg
Copy link
Contributor

PaulRBerg commented Dec 20, 2023

No worries, @Evalir - that's understandable. FWIW, I have tried to install an older version of Foundry with foundryup, but that didn't work. As in, running forge --version was still returning the present-day version.

Anyway ..

More Context

After a long and painful debugging session, we have managed to obtain more clarity on this issue. It appears that there are two bugs:

  1. A bug in Solidity v0.8.13-v0.8.21 causes the viaIR-generated bytecode to differ depending on how the dependencies are imported. For more details, see my report on Twitter.
  2. A bug in the way Foundry generates the standard JSON input leads to a compilation error.

Below, I will focus on the 2nd bug, because it applies even after upgrading to Solidity v0.8.23.

Repro

  1. Clone https://github.com/sablier-labs/v2-core
  2. Checkout branch bug/foundry-sji-repro
  3. Run pnpm install (you need to have pnpm installed)
  4. Fill .env by following the .env.example
  5. Run the verification command below
  6. You should get the following error:
Response: `NOTOK`
Details: `Fail - Unable to verify. Solidity Compilation Error: Source "node_modules/@openzeppelin/contracts/interfaces/IERC165.sol" not found: File not found. Searched the following locations: "".`
Contract failed to verify.

Verification Command

FOUNDRY_PROFILE=optimized \
forge verify-contract 0x4259557F6665eCF5907c9019a30f3Cb009c20Ae7 \
./src/SablierV2LockupLinear.sol:SablierV2LockupLinear \
--chain goerli \
--etherscan-api-key $API_KEY_ETHERSCAN \
--watch \
--constructor-args \
$( cast abi-encode "constructor(address,address,address)" 0xBAbE000000000000000000000000000000000000 0xbeeF000000000000000000000000000000000000 0xCAFE000000000000000000000000000000000000 )

Deployment Command (Optional)

Here's a deployment command in case you want to tinker with a new contract (this is what I used):

FOUNDRY_PROFILE=optimized \
forge script script/DeployLockupLinear.s.sol \
--broadcast \
--rpc-url goerli \
--sig "run(address,address,address)" \
0xBAbE000000000000000000000000000000000000 \
0xbeeF000000000000000000000000000000000000 \
0xCAFE000000000000000000000000000000000000 \
-vvvv

Even More Context

Installing the Node.js dependencies with Yarn instead of PNPM makes the verification command work, which leads me to suspect that PNPM's symbolic links are the culprit. They may be throwing a wrench in the standard JSON input file generated by Foundry.

There are two categories of potential solutions:

  1. Handle symlinks in verify-contract
  2. Throw an error when symlinks are detected in the user's dependencies (well, not quite a solution, more like a hot fix - but it would save people's time)

Questions

  1. Could this bug be related to etherscan verification failure (when remapping points to external file) #5307? Or forge struggles to handle the way pnpm links node_modules in pnpm-workspaces #2714?
  2. For those of you who have encountered similar errors this week, can you mention whether you were also using PNPM and a Solidity version between 0.8.13 and 0.8.21?

@DaniPopes
Copy link
Member

DaniPopes commented Jan 18, 2024

@PaulRBerg Just succeeded locally with your latest repro (#3507 (comment)) using #6846 (foundryup --branch master or when it hits the next nightly in a few hours)

Still don't know if that's the fix, but would appreciate some feedback.

https://goerli.etherscan.io/address/0x4259557f6665ecf5907c9019a30f3cb009c20ae7#code

$ FOUNDRY_PROFILE=optimized \
forge2 verify-contract 0x4259557F6665eCF5907c9019a30f3Cb009c20Ae7 \
./src/SablierV2LockupLinear.sol:SablierV2LockupLinear \
--chain goerli \
--etherscan-api-key $API_KEY_ETHERSCAN \
--watch \
--constructor-args \
$( cast abi-encode "constructor(address,address,address)" 0xBAbE000000000000000000000000000000000000 0xbeeF000000000000000000000000000000000000 0xCAFE000000000000000000000000000000000000 )
Start verifying contract `0x4259557F6665eCF5907c9019a30f3Cb009c20Ae7` deployed on goerli

Submitting verification for [src/SablierV2LockupLinear.sol:SablierV2LockupLinear] 0x4259557F6665eCF5907c9019a30f3Cb009c20Ae7.
Submitted contract for verification:
        Response: `OK`
        GUID: `q3vtdrpmzx1kqzyf17uuenifqgzrixbrsgjebz553s6g7yrbrn`
        URL:
        https://goerli.etherscan.io/address/0x4259557f6665ecf5907c9019a30f3cb009c20ae7
Contract verification status:
Response: `NOTOK`
Details: `Pending in queue`
Contract verification status:
Response: `OK`
Details: `Pass - Verified`
Contract successfully verified

@PaulRBerg
Copy link
Contributor

Thanks @DaniPopes.

Unfortunately, I cannot remember what other contracts I deployed at that time, which I could test now.

I will trust that your fix has effectively solved this issue - combined with my PSA about the use of viaIR in Solidity v0.8.13-v0.8.21, there shouldn't be any other problem here.

@vm06007
Copy link

vm06007 commented Jan 30, 2024

facing issue with arbiscan and trying to verify 0.8.24 contracts: says invalid or unsupported solc version, although it is on the list and can be verified manually through arbiscan but not by using command seen below:

Screenshot_2024-01-30_at_9 33 18_PM

@DaniPopes
Copy link
Member

@vm06007 that is not relevant to this issue, they probably haven't updated the valid version list yet.

@vm06007
Copy link

vm06007 commented Jan 31, 2024

@vm06007 that is not relevant to this issue, they probably haven't updated the valid version list yet.

the list looks updated though, you can also choose 0.8.24 when verifying manually and is present on the link for solcversions. Unless we are assuming when doing through manual verification using arbiscan FE they do not use their own API to do the verification? Could it be foundry is sending wrong data? I have not tried to verify this on etherscan yet. Maybe worth to give it a shot, just curious if anyone had problems with 0.8.24 recently.

@z0r0z
Copy link

z0r0z commented Feb 23, 2024

chiming in here that I am running into a similar issue verifying a contract on arbiscan using 0.8.24 solidity and via_ir true

@sambacha
Copy link
Contributor

chiming in here that I am running into a similar issue verifying a contract on arbiscan using 0.8.24 solidity and via_ir true

have you tried using https://sourcify.dev/ instead ?

@sambacha
Copy link
Contributor

Confirmed it is just an ether scan problem not supporting more than 2^22 optimizer runs :(

For what its worth, etherscan says 10,000,000 is the limit. you can however spoof the amount of optimizer runs you feed etherscan api for verification.

https://gist.github.com/sambacha/9d2fde4f9a286f5411b69c1ca363ea03#file-find_optimizer_runs-sh-L9

@gosuto-inzasheru
Copy link

this is solved by #6781 and works in the latest version (forge 0.2.0 (ef62fdb 2024-07-12T00:22:06.894449000Z))

it was still undocumented, solving through foundry-rs/book#1241

@anajuliabit
Copy link

anajuliabit commented Jul 16, 2024

@gosuto-inzasheru I'm still having issues even when using --via-ir flag

Forge version:
forge 0.2.0 (VERGEN_IDEMPOTENT_OUTPUT 2024-07-15T11:19:03.935375000Z)

Command:

forge verify-contract  --chain sepolia --rpc-url testnet 0x8B5E338c47Dee476e7437060f625aDD05d0CFED7 src/RewardsDistributor.sol:RewardsDistributor --watch --optimizer-runs=20 --via-ir

Output:

Response: `NOTOK`
Details: `Fail - Unable to verify. Compiled contract deployment bytecode does NOT match the transaction deployment bytecode.`
Error: 
Checking verification result failed

@gosuto-inzasheru
Copy link

there might be some other reason the bytecode does not match. did you really deploy with only 20 optimizer runs? maybe it was compiled with a different solidity version?

@zerosnacks zerosnacks added this to the v1.0.0 milestone Jul 26, 2024
@zerosnacks
Copy link
Member

Marking as resolved by #6781 as indicated by @gosuto-inzasheru

Was able to verify a contract with --via-ir without issue here: https://holesky.etherscan.io/address/0x631e818149cF985B850e5D060Dc7D0B4BB5aC96f#code with forge verify-contract

@anajuliabit please open a new ticket if you are still facing issues with a minimal reproduction

@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
togetherAll7 pushed a commit to togetherAll7/foundry-book that referenced this issue Nov 17, 2024
I found this option in this issue - foundry-rs/foundry#3507

This was helpful for verifying a contract on Zora's blockscout based explorer.

I don't really know where this standard comes from or anything about it, so hoping someone more knowledgeable is willing to take this over the finish line.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-verification Area: verification C-forge Command: forge Cmd-forge-verify Command: forge verify-contract/check T-bug Type: bug T-to-investigate Type: to investigate
Projects
Archived in project
Development

No branches or pull requests