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

fix(forge): fix verify-contract etherscan cloudflare bug #6079

Merged
merged 3 commits into from
Oct 22, 2023

Conversation

tsite
Copy link
Contributor

@tsite tsite commented Oct 22, 2023

Etherscan verification for non-mainnet chains requires a question mark at the end of the verifier url in order to prevent a forward slash from being added to the url which trips a cloudflare rule on requests from ec2 boxes.

Verification on both Goerli and Sepolia fails without this character present.

Hardhat-verify does not add the extra forward slash to the verifier url and has no issues verifying contracts on etherscan.

Fixes #4865, #5251, #5741

Motivation

Fix etherscan contract verification on non-mainnet chains.

Solution

Add a question mark to the end of the verifier url.

tsite added 2 commits October 22, 2023 07:17
Etherscan verification for non-mainnet chains requires a question
mark at the end of the verifier url in order to prevent a forward slash
from being added to the url which trips a cloudflare rule on requests
from ec2 boxes.

Verification on both Goerli and Sepolia both fails without this
character present.

Hardhat-verify does not add the extra forward slash to the verifier url
and has no issues verifying contracts on etherscan.

Fixes foundry-rs#4865, foundry-rs#5251, foundry-rs#5741
@tsite tsite changed the title fix forge verify-contract etherscan cloudflare bug fix(forge): fix verify-contract etherscan cloudflare bug Oct 22, 2023
Copy link
Member

@mattsse mattsse left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh wow very nice find

crates/forge/bin/cmd/verify/etherscan/mod.rs Outdated Show resolved Hide resolved
Copy link
Member

@Evalir Evalir left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

super nice find—I think I had seen this on the foundry chat for people running non-conventional setups

pending mattsse's nit!

Also apply the fix to --verifier-url urls
@tsite tsite requested a review from mattsse October 22, 2023 09:54
@mattsse mattsse merged commit ba6c851 into foundry-rs:master Oct 22, 2023
16 checks passed
mattsse added a commit to foundry-rs/block-explorers that referenced this pull request Jan 5, 2024
ref foundry-rs/foundry#6079

previously we were always adding a trailing / to the API URL resulting
in cloudfare issues with certain API calls.

the alloy-chan now never include a trialing slash so this is no longer
necessary.
instead of format!(url/api) we're now using url.join which takes care of
adding missing /

this can then be removed in foundry


https://github.com/foundry-rs/foundry/blob/6fc74638b797b8e109452d3df8e26758f86f31fe/crates/forge/bin/cmd/verify/etherscan/mod.rs#L272-L272
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

Successfully merging this pull request may close these issues.

Failed to deserialize response: expected value at line 1 column 1
3 participants