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 test tracing does not seem to respect the Etherscan or signature caches when running tests with high verbosity #6792

Closed
2 tasks done
emo-eth opened this issue Jan 14, 2024 · 2 comments · Fixed by foundry-rs/block-explorers#40 or #7672
Assignees
Labels
T-bug Type: bug

Comments

@emo-eth
Copy link
Contributor

emo-eth commented Jan 14, 2024

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 (293fad7 2024-01-14T00:19:24.272194000Z)

What command(s) is the bug in?

forge test

Operating System

macOS (Apple Silicon)

Describe the bug

See #6791 for more context.

Foundry appears to keep a cache of Etherscan ABIs and OpenChain signatures (at ~/.foundry/cache/etherscan/... and ~/./foundry/cache/signatures, respectively), but running tests with high verbosity on a slow internet connection results in extremely slow test runs, presumably due to pulling Etherscan/OpenChain metadata to format the traces.

It's possible that I'm misunderstanding what these caches are meant to be used for, or the root of the slow test runs issues on slow internet.

@emo-eth emo-eth added the T-bug Type: bug label Jan 14, 2024
@gakonst gakonst added this to Foundry Jan 14, 2024
@github-project-automation github-project-automation bot moved this to Todo in Foundry Jan 14, 2024
@mattsse
Copy link
Member

mattsse commented Jan 15, 2024

this is probably the same issue as #6791 where slow etherscan requests slow everything down.

could you run with RUST_LOG=etherscanidentifier and check the relevant etherscan settings in forge config perhaps there's a config bug resulting in wrong etherscan url

@zerosnacks
Copy link
Member

zerosnacks commented Apr 4, 2024

Potentially identified a cause here: foundry-rs/block-explorers@main...zerosnacks:block-explorers:fix/cache-is-always-invalidated where the expiry is subtracted from the current timestamp, resulting in a checked underflow -> None, indicating a cache miss when it actually hit.

let res = client.contract_source_code(addr).await;

calls to:

https://github.com/foundry-rs/block-explorers/blob/1845b1067b4bb85209fe23f8469047f9c346d755/src/contract.rs#L398-L420

I haven't looked at the signature cache.

I'll need to do more testing and write tests for foundry-block-explorer to confirm this is actually the case.

mattsse pushed a commit to foundry-rs/block-explorers that referenced this issue Apr 15, 2024
Closes: foundry-rs/foundry#6792

Due to a small logical error and a missing smoke test the Etherscan
cache was constantly being invalidated.

On a large codebase with 197 tests, without this optimization:
foundry-rs/foundry#7606

Comparison:

1. Ran 17 test suites in 53.41s (64.87s CPU time): 197 tests passed, 0
failed, 0 skipped (197 total tests) (no cache)
2. Ran 17 test suites in 6.29s (49.10s CPU time): 197 tests passed, 0
failed, 0 skipped (197 total tests) (with cache)
@jenpaff jenpaff moved this from Todo to Completed in Foundry Sep 30, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-bug Type: bug
Projects
Status: Completed
3 participants