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

Add option to clear etherscan cache #1807

Merged
merged 4 commits into from Jun 4, 2022

Conversation

jaeaster
Copy link
Contributor

@jaeaster jaeaster commented Jun 1, 2022

Motivation

Currently forge cache clean only clears RPC cache, but it would be beneficial to also be able to clear the Etherscan verification status cache.

Solves #1477

Solution

This PR:

  • Adds the --etherscan flag to forge cache clean

  • Displays the etherscan cache storage with forge cache ls:

-️ mainnet (6.7 kB)
        -️ Block Explorer (0.0 B)

        -️ Block 14880985 (3.4 kB)
        -️ Block 14881100 (3.3 kB)
  • Restructures the cache directory structure:
cache/
    - rpc/{mainnet,...}
    - etherscan/{mainnet,...}

…lock data and etherscan data, respectively.

before:
~/.foundry/cache/<chain>/block, ~/.foundry/cache/<chain>/etherscan

after:

~/.foundry/cache/rpc/<chain>, ~/.foundry/cache/etherscan/<chain>
@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 1, 2022

Hi folks!

I'm a rust noob and still learning idiomatic rust so please feel free to nitpick to your heart's content.

Also, I wanted to add some unit tests but wasn't sure exactly where to put them and couldn't find pre-existing tests for forge cache ...

@@ -1049,9 +1049,13 @@ impl Config {
}
if let Ok(entries) = cache_dir.as_path().read_dir() {
for entry in entries.flatten().filter(|x| x.path().is_dir()) {
let chain = Chain::from_str(&entry.file_name().to_string_lossy()).unwrap();
Copy link
Contributor Author

Choose a reason for hiding this comment

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

As of now, every entry inside the cache/rpc directory is a valid chain_id. Maybe this changes in the future...

Is it a bad idea to use unwrap() here instead of handling the exceptional case?

Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't happen but just to be safe we could filter here by Some and continue the loop otherwise?

cache.chains.push(ChainCache {
name: entry.file_name().to_string_lossy().into_owned(),
blocks: Self::get_cached_blocks(&entry.path())?,
block_explorer: Self::get_cached_block_explorer_data(
&Config::foundry_etherscan_chain_cache_dir(chain).unwrap(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Similar to above ... this will panic if $HOME doesn't exist. It's a rare scenario, but my assumption is that unwrap() is not ok here.

Copy link
Member

Choose a reason for hiding this comment

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

it should available for most OS but I agree, let's return an error in that case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added explicit handling with clear error message if this directory doesn't exist

for block in chain_path
.read_dir()?
.flatten()
.filter(|x| x.file_type().unwrap().is_dir() && !x.file_name().eq("etherscan"))
Copy link
Contributor Author

Choose a reason for hiding this comment

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

removed the "etherscan" filter as I changed the cache directory structure to hoist the etherscan cache outside of this directory.

NumberPrefix::Standalone(size) => {
writeln!(f, "-️ {} ({:.1} B)", chain.name, size)?;
}
NumberPrefix::Prefixed(prefix, size) => {
writeln!(f, "-️ {} ({:.1} {}B)", chain.name, size, prefix)?;
}
}
match NumberPrefix::decimal(chain.block_explorer as f32) {
NumberPrefix::Standalone(size) => {
writeln!(f, "\t-️ Block Explorer ({:.1} B)\n", size)?;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Note the additional newline - it was cleaner to my eye to add an additional line to separate the etherscan data and the block data

#[derive(Debug)]
pub struct ChainCache {
/// The name of the chain
pub name: String,

/// A tuple containing block number and the block directory size in bytes
pub blocks: Vec<(String, u64)>,

/// The size of the block explorer directory in bytes
pub block_explorer: u64,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I suppose this could be block_explorer_size. Could also be named etherscan_size to keep it consistent with the flag --etherscan. It's always difficult to determine whether to keep names specific to ethereum or generalize for all EVM chains.

@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 1, 2022

Found some integration tests here so will add a few of my own!

https://github.com/foundry-rs/foundry/blob/master/cli/tests/it/cmd.rs#L41

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.

thanks so much,

looking good already, just some smol nits.

re integration tests, they're useful for debugging but we should then ignore them otherwise we'll always clean our local cache if we run tests

@@ -1049,9 +1049,13 @@ impl Config {
}
if let Ok(entries) = cache_dir.as_path().read_dir() {
for entry in entries.flatten().filter(|x| x.path().is_dir()) {
let chain = Chain::from_str(&entry.file_name().to_string_lossy()).unwrap();
Copy link
Member

Choose a reason for hiding this comment

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

this shouldn't happen but just to be safe we could filter here by Some and continue the loop otherwise?

cache.chains.push(ChainCache {
name: entry.file_name().to_string_lossy().into_owned(),
blocks: Self::get_cached_blocks(&entry.path())?,
block_explorer: Self::get_cached_block_explorer_data(
&Config::foundry_etherscan_chain_cache_dir(chain).unwrap(),
Copy link
Member

Choose a reason for hiding this comment

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

it should available for most OS but I agree, let's return an error in that case?

Comment on lines 1072 to 1071
let block_explorer_data_size = match Config::foundry_etherscan_chain_cache_dir(chain) {
Some(cache_dir) => Self::get_cached_block_explorer_data(&cache_dir).unwrap(),
None => 0,
};
Copy link
Member

Choose a reason for hiding this comment

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

let's make it consistently no unwrap

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Removed all unwraps in favor of skipping or explicit errors. Also simplified the code by reusing the method to list a single cache entry when listing all cache entries.

@jaeaster jaeaster force-pushed the etherscanCache branch 2 times, most recently from f89fb53 to 89faba0 Compare June 2, 2022 12:46
…eleting the etherscan cache data.

e.g.
forge cache clean --etherscan # deletes ~/.foundry/cache/etherscan
forge cache clean mainnet --etherscan # deletes ~/.foundry/cache/etherscan/mainnet

* test: Add tests for cache clean --etherscan
@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 2, 2022

  • Added ignored integration tests for cache clean --etherscan.
  • Modified existing tests to use a clean cache directory on each run.
  • Modified existing tests to account for new directory structure
  • Lastly, fixed a failing test for --blocks option due to typo.

Oh and last thing, if you specify the --blocks option, the etherscan cache stays in-tact. This matches with the original behavior before this PR.

On this note ^, I could use clap::ArgGroup to disallow something like forge cache clean --blocks 100,101 --etherscan
e.g.
clap-rs/clap#2621 (comment)

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.

thanks so much,

TIL ArgGroup, let's add that for incompatible args @diligentcodoor

@gakonst
Copy link
Member

gakonst commented Jun 2, 2022

Is this working properly?

./target/local/forge cache ls
➜  foundry git:(etherscanCache) forge cache ls
-️ rinkeby (375.0 B)
        -️ Block 10074295 (375.0 B)
-️ mainnet (4.3 MB)
        -️ Block 14602789 (1.1 MB)
        -️ Block 14723772 (4.3 kB)
        -️ Block 14724797 (128.2 kB)
        -️ Block 14720229 (9.1 kB)
        -️ Block 14725939 (191.3 kB)
        -️ Block 14121827 (2.7 MB)
        -️ Block 14720119 (140.6 kB)
        -️ Block 13633752 (28.2 kB)
        -️ Block 14608400 (4.0 kB)
        -️ Block 14795731 (24.5 kB)

Doesn't seem to detect any chain now. Should we remove the forgetest_ignore and actually run the tests?

@onbjerg onbjerg added the T-feature Type: feature label Jun 2, 2022
@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 3, 2022

A few more updates:
@mattsse Will add the ArgGroup tomorrow 👍

@gakonst I believe it is working correctly. If it isn't, you should be getting an error message, rather than a silent non-print. What does your cache layout look like?

The tricky thing about the cache integration tests is they share the filesystem state. So it's inconvenient for devs as you have to blow up your own cache and it's inconvenient for CI as you have to run them single-threaded. At the moment, they're really only useful to automate manual testing rather than ensuring correctness.

On second thought, I can convert my integration test to a few unit tests for cache ls.

Lastly, I caught a bug calculating the cache size. The size was a shallow calculation rather than summing the files within subdirectories. Added a test for this as well.

test: add integration test for 'forge cache ls'

fix: calculate etherscan cache size based on all files in each subdirectory

test: Unit test cache.to_string() used in 'forge cache ls'
@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 3, 2022

I added a unit test to cover the discrepancy in cache output that you experienced @gakonst
Also added clap::ArgGroup so you can use either --blocks or --etherscan in forge cache clean @mattsse

For future reference, is it better to wait until the PR is in a final state to squash commits? I know I keep making fixes and then overwriting previous commits and that may be difficult to see what has changed since a prior review.

@gakonst
Copy link
Member

gakonst commented Jun 3, 2022

No need to squash before merging, we always do squash merge via Github so it's not required for you to do it!

@gakonst
Copy link
Member

gakonst commented Jun 3, 2022

This is how my cache looks like:

$ tree
.
├── mainnet
│   ├── 13633752
│   │   └── storage.json
│   ├── 14121827
│   │   └── storage.json
│   ├── 14602789
│   │   └── storage.json
│   ├── 14608400
│   │   └── storage.json
│   ├── 14720119
│   │   └── storage.json
│   ├── 14720229
│   │   └── storage.json
│   ├── 14723772
│   │   └── storage.json
│   ├── 14724797
│   │   └── storage.json
│   ├── 14725939
│   │   └── storage.json
│   ├── 14795731
│   │   └── storage.json
│   └── etherscan
│       └── sources
│           ├── 0x0000000000000000000000000000000000000001.json
│           ├── 0x0000000000000000000000000000000000000004.json
│           ├── 0x000000000000000000000000000000000000bbbb.json
│           ├── 0x000000000000000000636f6e736f6c652e6c6f67.json
│           ├── 0x028171bca77440897b824ca71d1c56cac55b68a3.json
│           ├── 0x02d341ccb60faaf662bc0554d13778015d1b285c.json
│           ├── 0x03ab458634910aad20ef5f1c8ee96f1d6ac54919.json
│           ├── 0x055be5ddb7a925bfef3417fc157f53ca77ca7222.json
│           ├── 0x05ca5c01629a8e5845f12ea3a03ff7331932233a.json
│           ├── 0x06325440d014e39736583c165c2963ba99faf14e.json
│           ├── 0x075b1bb99792c9e1041ba13afef80c91a1e70fb3.json
│           ├── 0x08380a4999be1a958e2abba07968d703c7a3027c.json
│           ├── 0x0a758a25997167762e187f960dd0539a4ae3e9a6.json
│           ├── 0x0accf637e4f05eea8b1d215c8c9e9e576dc63d33.json
│           ├── 0x0b1aa88aa16b2b7192b6f4bece3bd4793f700ecf.json
│           ├── 0x11137b10c210b579405c21a07489e28f3c040ab1.json
│           ├── 0x12dcd9e8d1577b5e4f066d8e7d404404ef045342.json
│           ├── 0x13c1542a468319688b89e323fe9a3be3a90ebb27.json
│           ├── 0x16c2bee6f55dab7f494dba643ff52ef2d47fba36.json
│           ├── 0x1750a3a3d80a3f5333bbe9c4695b0fad41061ab1.json
│           ├── 0x1820a4b7618bde71dce8cdc73aab6c95905fad24.json
│           ├── 0x182b723a58739a9c974cfdb385ceadb237453c28.json
│           ├── 0x194ebd173f6cdace046c53eacce9b953f28411d1.json
│           ├── 0x19b080fe1ffa0553469d20ca36219f17fcf03859.json
│           ├── 0x1aef73d49dedc4b1778d0706583995958dc862e6.json
│           ├── 0x1b3e14157ed33f60668f2103bcd5db39a1573e5b.json
│           ├── 0x1c050bca8babe53ef769d0d2e411f556e1a27e7b.json
│           ├── 0x1c5dcdd006ea78a7e4783f9e6021c32935a10fb4.json
│           ├── 0x1c86b3cdf2a60ae3a574f7f71d44e2c50bddb87e.json
│           ├── 0x1cebdb0856dd985fae9b8fea2262469360b8a3a6.json
│           ├── 0x1e212e054d74ed136256fc5a5dddb4867c6e003f.json
│           ├── 0x1f57cc62113c3a6346882dcf3ed49120411ac2d2.json
│           ├── 0x20c36f062a31865bed8a5b1e512d9a1a20aa333a.json
│           ├── 0x213be373fdff327658139c7df330817dad2d5bbe.json
│           ├── 0x23d231f37c8f5711468c8abbfbf1757d1f38fda2.json
│           ├── 0x24d937143d3f5cf04c72ba112735151a8cae2262.json
│           ├── 0x25f0ce4e2f8dba112d9b115710ac297f816087cd.json
│           ├── 0x2b33cf282f867a7ff693a66e11b0fcc5552e4425.json
│           ├── 0x2db0e83599a91b508ac268a6197b8b14f5e72840.json
│           ├── 0x2f50d538606fa9edd2b11e2446beb18c9d5846bb.json
│           ├── 0x2fa53e8fa5fadb81f4332c8ece39fe62ea2f919e.json
│           ├── 0x2fe94ea3d5d4a175184081439753de15aef9d614.json
│           ├── 0x330416c863f2acce7af9c9314b422d24c672534a.json
│           ├── 0x33b63042865242739ba410ac32ab68723e6cf4b9.json
│           ├── 0x3432b6a60d23ca0dfca7761b7ab56459d9c964d0.json
│           ├── 0x346c7bb1a7a6a30c8e81c14e90fc2f0fbddc54d8.json
│           ├── 0x34cfac646f301356faa8b21e94227e3583fe3f5f.json
│           ├── 0x3547dfca04358540891149559e691b146c6b0043.json
│           ├── 0x359fd5d6417ae3d8d6497d9b2e7a890798262ba4.json
│           ├── 0x3a283d9c08e8b55966afb64c515f5143cf907611.json
│           ├── 0x3a2a88e21fcad15e4ac3f059e13139e76c4224ca.json
│           ├── 0x3a664ab939fd8482048609f652f9a0b0677337b9.json
│           ├── 0x3a70dfa7d2262988064a2d051dd47521e43c9bdd.json
│           ├── 0x3b2a77058a1eb4403a90b94585fab16bc512e703.json
│           ├── 0x3b3ac5386837dc563660fb6a0937dfaa5924333b.json
│           ├── 0x3b6831c0077a1e44ed0a21841c3bc4dc11bce833.json
│           ├── 0x3b7020743bc2a4ca9eaf9d0722d42e20d6935855.json
│           ├── 0x3b7382805a1d887b73e98570796c5cefea32a462.json
│           ├── 0x3c0ffff15ea30c35d7a85b85c0782d6c94e1d238.json
│           ├── 0x3c9d6c1c73b31c837832c72e04d3152f051fc1a9.json
│           ├── 0x3d229e1b4faab62f621ef2f6a610961f7bd7b23b.json
│           ├── 0x3ed3b47dd13ec9a98b44e6204a523e766b225811.json
│           ├── 0x3f06560cfb7af6e6b5102c358f679de5150b3b4c.json
│           ├── 0x3f1b0278a9ee595635b61817630cc19de792f506.json
│           ├── 0x3f87b818f94f3cc21e47fd3bf015e8d8183a3e08.json
│           ├── 0x3fb78e61784c9c637d560ede23ad57ca1294c14a.json
│           ├── 0x410e3e86ef427e30b9235497143881f717d93c2a.json
│           ├── 0x43b4fdfd4ff969587185cdb6f0bd875c5fc83f8c.json
│           ├── 0x448d330affa0ad31264c2e6a7b5d2bf579608065.json
│           ├── 0x462253b8f74b72304c145db0e4eebd326b22ca39.json
│           ├── 0x46e4d8a1322b9448905225e52f914094dbd6dddf.json
│           ├── 0x4807862aa8b2bf68830e4c8dc86d0e9a998e085a.json
│           ├── 0x49849c98ae39fff122806c06791fa73784fb3675.json
│           ├── 0x4a4d7868390ef5cac51cda262888f34bd3025c3f.json
│           ├── 0x4b9ca5607f1ff8019c1c6a3c2f0cc8de622d5b82.json
│           ├── 0x4c18e409dc8619bfb6a1cb56d114c3f592e0ae79.json
│           ├── 0x4da27a545c0c5b758a6ba100e3a049001de870f5.json
│           ├── 0x4dc4a289a8e33600d8bd4cf5f6313e43a37adec7.json
│           ├── 0x4e68ccd3e89f51c3074ca5072bbac773960dfa36.json
│           ├── 0x4ed9c0dca0479bc64d8f4eb3007126d5791f7851.json
│           ├── 0x4f3e8f405cf5afc05d68142f3783bdfe13811522.json
│           ├── 0x4fd86ce7ecea88f7e0aa78dc12625996fb3a04bc.json
│           ├── 0x50b085f2e5958c4a87baf93a8ab79f6bec068494.json
│           ├── 0x515e87cb3fec986050f202a2bbfa362a2188bc3f.json
│           ├── 0x5282a4ef67d9c33135340fb3289cc1711c13638c.json
│           ├── 0x531842cebbdd378f8ee36d171d6cc9c4fcf475ec.json
│           ├── 0x53a901d48795c58f485cbb38df08fa96a24669d5.json
│           ├── 0x55a8a39bc9694714e2874c1ce77aa1e599461e18.json
│           ├── 0x5777d92f208679db4b9778590fa3cab3ac9e2168.json
│           ├── 0x5a6a4d54456819380173272a5e8e9b9904bdf41b.json
│           ├── 0x5a98fcbea516cf06857215779fd812ca3bef1b32.json
│           ├── 0x5ae854b098727a9f1603a1e21c50d52dc834d846.json
│           ├── 0x5b1b5fea1b99d83ad479df0c222f0492385381dd.json
│           ├── 0x5b3b5df2bf2b6543f78e053bd91c4bdd820929f1.json
│           ├── 0x5b5cfe992adac0c9d48e05854b2d91c73a003858.json
│           ├── 0x5c69bee701ef814a2b6a3edd4b1652cb9cc5aa6f.json
│           ├── 0x5f3b5dfeb7b28cdbd7faba78963ee202a494e2a2.json
│           ├── 0x5f626c30ec1215f4edcc9982265e8b1f411d1352.json
│           ├── 0x5f890841f657d90e081babdb532a05996af79fe6.json
│           ├── 0x5f98805a4e8be255a32880fdec7f6728c6568ba0.json
│           ├── 0x6070fbd4e608ee5391189e7205d70cc4a274c017.json
│           ├── 0x619beb58998ed2278e08620f97007e1116d5d25b.json
│           ├── 0x6326debbaa15bcfe603d831e7d75f4fc10d9b43e.json
│           ├── 0x63d9f3ab7d0c528797a12a0684e50c397e9e79dc.json
│           ├── 0x64aa3364f17a4d01c6f1751fd97c2bd3d7e7f1d5.json
│           ├── 0x64e3c23bfc40722d3b649844055f1d51c1ac041d.json
│           ├── 0x64eda51d3ad40d56b9dfc5554e06f94e1dd786fd.json
│           ├── 0x6523ac15ec152cb70a334230f6c5d62c5bd963f1.json
│           ├── 0x65ca7dc5cb661fc58de57b1e1af404649a27ad35.json
│           ├── 0x66ec719045bbd62db5ebb11184c18237d3cc2e62.json
│           ├── 0x6828bcf74279ee32f2723ec536c22c51eed383c6.json
│           ├── 0x6955a55416a06839309018a8b0cb72c4ddc11f15.json
│           ├── 0x69fb7c45726cfe2badee8317005d3f94be838840.json
│           ├── 0x6b175474e89094c44da98b954eedeac495271d0f.json
│           ├── 0x6ba5b4e438fa0aaf7c1bd179285af65d13bd3d90.json
│           ├── 0x6c3c78838c761c6ac7be9f59fe808ea2a6e4379d.json
│           ├── 0x6c3f90f043a72fa612cbac8115ee7e52bde6e490.json
│           ├── 0x6c5024cd4f8a59110119c56f8933403a539555eb.json
│           ├── 0x6d10ed2cf043e6fcf51a0e7b4c2af3fa06695707.json
│           ├── 0x6dea81c8171d0ba574754ef6f8b412f2ed88c54d.json
│           ├── 0x705350c4bcd35c9441419ddd5d2f097d7a55410f.json
│           ├── 0x7109709ecfa91a80626ff3989d68f67f5b1dd12d.json
│           ├── 0x728ad672409da288ca5b9aa85d1a55b803ba97d7.json
│           ├── 0x72e158d38dbd50a483501c24f792bdaaa3e7d55c.json
│           ├── 0x744c2be04d079eddb21c1a9bb13bb5259a368614.json
│           ├── 0x7590dcc7ae7ce770c1243808ddf5677cbd913257.json
│           ├── 0x778a13d3eeb110a4f7bb6529f99c000119a08e92.json
│           ├── 0x79224bc0bf70ec34f0ef56ed8251619499a59def.json
│           ├── 0x7b0fce54574d9746414d11367f54c9ab94e53dca.json
│           ├── 0x7b2a3cf972c3193f26cdec6217d27379b6417bd0.json
│           ├── 0x7ca5b0a2910b33e9759dc7ddb0413949071d7575.json
│           ├── 0x7d2768de32b0b80b7a3454c06bdac94a69ddc7a9.json
│           ├── 0x7e1444ba99dcdffe8fbdb42c02f0005d14f13be1.json
│           ├── 0x7eb40e450b9655f4b3cc4259bcc731c63ff55ae6.json
│           ├── 0x7fc66500c84a76ad7e9c93437bfc5ac33e2ddae9.json
│           ├── 0x824f13f1a2f29cfeea81154b46c0fc820677a637.json
│           ├── 0x8282bd15dca2ea2bdf24163e8f2781b30c43a2ef.json
│           ├── 0x8290333cef9e6d528dd5618fb97a76f268f3edd4.json
│           ├── 0x83d055d382f25e6793099713505c68a5c7535a35.json
│           ├── 0x845838df265dcd2c412a1dc9e959c7d08537f8a2.json
│           ├── 0x8461a004b50d321cb22b7d034969ce6803911899.json
│           ├── 0x8484673ca7bff40f82b041916881aea15ee84834.json
│           ├── 0x85aa7f78bdb2de8f3e0c0010d99ad5853ffcfc63.json
│           ├── 0x85dc02bbba4484e80f709c703d98f35746035f17.json
│           ├── 0x85eee30c52b0b379b046fb0f85f4f3dc3009afec.json
│           ├── 0x8762db106b2c2a0bccb3a80d1ed41273552616e8.json
│           ├── 0x87650d7bbfc3a9f10587d7778206671719d9910d.json
│           ├── 0x87898263b6c5babe34b4ec53f22d98430b91e371.json
│           ├── 0x8818a9bb44fbf33502be7c15c500d0c783b73067.json
│           ├── 0x88e6a0c2ddd26feeb64f039a2c41296fcb3f5640.json
│           ├── 0x89ab32156e46f46d02ade3fecbe5fc4243b9aaed.json
│           ├── 0x89efefca3ed3eeb460f74c55d9f6469c7e4ef475.json
│           ├── 0x8a32f49ffba88aba6eff96f45d8bd1d4b3f35c7d.json
│           ├── 0x8cae0596bc1ed42dc3f04c4506cfe442b3e74e27.json
│           ├── 0x8e0c00ed546602fd9927df742bbabf726d5b0d16.json
│           ├── 0x8fa728f393588e8d8dd1ca397e9a710e53fa553a.json
│           ├── 0x903da6213a5a12b61c821598154efad98c3b20e4.json
│           ├── 0x90bb609649e0451e5ad952683d64bd2d1f245840.json
│           ├── 0x92e187a03b6cd19cb6af293ba17f2745fd2357d5.json
│           ├── 0x94e131324b6054c0d789b190b2dac504e4361b53.json
│           ├── 0x9582c4adacb3bce56fea3e590f05c3ca2fb9c477.json
│           ├── 0x96d7bc17912e4f320c4894194564cf8425cfe8d9.json
│           ├── 0x97e2768e8e73511ca874545dc5ff8067eb19b787.json
│           ├── 0x989aeb4d175e16225e39e87d0d97a3360524ad80.json
│           ├── 0x99ac10631f69c753ddb595d074422a0922d9056b.json
│           ├── 0x99e81edbcab512d393638c087fd29c3dc6c9b00e.json
│           ├── 0x99fb76f75501039089aac8f20f487bf84e51d76f.json
│           ├── 0x9af13a7b1f1bbf1a2b05c6fbf23ac23a9e573b4e.json
│           ├── 0x9b8519a9a00100720ccdc8a120fbed319ca47a14.json
│           ├── 0x9c2c8910f113181783c249d8f6aa41b51cde0f0c.json
│           ├── 0x9c8ff314c9bc7f6e59a9d9225fb22946427edc03.json
│           ├── 0x9d0464996170c6b9e75eed71c68b99ddedf279e8.json
│           ├── 0x9d4578c813d69745092a4f951753ed2b28056279.json
│           ├── 0x9fc689ccada600b6df723d9e47d84d76664a1f23.json
│           ├── 0x9ff4f50efd40c915f7d1476bf36acb8908e0c56d.json
│           ├── 0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48.json
│           ├── 0xa2327a938febf5fec13bacfb16ae10ecbc4cbdcf.json
│           ├── 0xa3bed4e1c75d00fa6f4e5e6922db7261b5e9acd2.json
│           ├── 0xa3d87fffce63b53e0d54faa1cc983b7eb0b74a9c.json
│           ├── 0xa4da2f06abb690347659b391f63370b8f0013be1.json
│           ├── 0xa90996896660decc6e997655e065b23788857849.json
│           ├── 0xaa17a236f2badc98ddc0cf999abb47d47fc0a6cf.json
│           ├── 0xaa26f57cafcf46ff37a190c4a74984ce80af8d3d.json
│           ├── 0xaa5a67c256e27a5d80712c51971408db3370927d.json
│           ├── 0xab6119e9bec89eb19e005c30af9846dbe6f922e1.json
│           ├── 0xad4768f408dd170e62e074188d81a29ae31b8fd8.json
│           ├── 0xaea6c312f4b3e04d752946d329693f7293bc2e6d.json
│           ├── 0xaf379f0228ad0d46bb7b4f38f9dc9bcc1ad0360c.json
│           ├── 0xb0f5d00e5916c8b8981e99191a1458704b587b2b.json
│           ├── 0xb15ffb543211b558d40160811e5dcbcd7d5aaac9.json
│           ├── 0xb19059ebb43466c323583928285a49f558e572fd.json
│           ├── 0xb1f2cdec61db658f091671f5f199635aef202cac.json
│           ├── 0xb3ce1973784fd2f763d87ffe4dbdee369b53caab.json
│           ├── 0xb518f5e3242393d4ec792bd3f44946a3b98d0e48.json
│           ├── 0xb53c1a33016b2dc2ff3653530bff1848a515c8c5.json
│           ├── 0xb76256d1091e93976c61449d6e500d9f46d827d4.json
│           ├── 0xb86bf4f8742784e767fb4a05809b46a1e4c88758.json
│           ├── 0xb8ffc3cd6e7cf5a098a1c92f48009765b24088dc.json
│           ├── 0xb9446c4ef5ebe66268da6700d26f96273de3d571.json
│           ├── 0xbaaa1f5dba42c3389bdbc2c9d2de134f5cd0dc89.json
│           ├── 0xbbbaf1adf4d39b2843928cca1e65564e5ce99ccc.json
│           ├── 0xbc19712feb3a26080ebf6f2f7849b417fdd792ca.json
│           ├── 0xbc89cd85491d81c6ad2954e6d0362ee29fca8f53.json
│           ├── 0xbcca60bb61934080951369a648fb03df4f96263c.json
│           ├── 0xbebc44782c7db0a1a60cb6fe97d0b483032ff1c7.json
│           ├── 0xbfcf63294ad7105dea65aa58f8ae5be2d9d0952a.json
│           ├── 0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f.json
│           ├── 0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2.json
│           ├── 0xc13eac3b4f9eed480045113b7af00f7b5655ece8.json
│           ├── 0xc1e088fc1323b20bcbee9bd1b9fc9546db5624c5.json
│           ├── 0xc25a3a3b969415c80451098fa907ec722572917f.json
│           ├── 0xc270b3b858c335b6ba5d5b10e2da8a09976005ad.json
│           ├── 0xc2b1df84112619d190193e48148000e3990bf627.json
│           ├── 0xc2ee6b0334c261ed60c72f6054450b61b8f18e35.json
│           ├── 0xc4ad29ba4b3c580e6d59105fff484999997675ff.json
│           ├── 0xc4c319e2d4d66cca4464c0c2b32c9bd23ebe784e.json
│           ├── 0xc5cfada84e902ad92dd40194f0883ad49639b023.json
│           ├── 0xc6845a5c768bf8d7681249f8927877efda425baf.json
│           ├── 0xc6a8466d128fbfd34ada64a9fffce325d57c9a52.json
│           ├── 0xc95bdf13a08a547e4dd9f29b00ab7ff08c5d093d.json
│           ├── 0xca3d75ac011bf5ad07a98d02f18225f9bd9a6bdf.json
│           ├── 0xcb08717451aae9ef950a2524e33b6dcaba60147b.json
│           ├── 0xce71065d4017f316ec606fe4422e11eb2c47c246.json
│           ├── 0xceaf7747579696a2f0bb206a14210e3c9e6fb269.json
│           ├── 0xcee60cfa923170e4f8204ae08b4fa6a3f5656f3a.json
│           ├── 0xcee63697ccaa5b14d20bb111639b13e78fc64ab0.json
│           ├── 0xd23a44eb2db8ad0817c994d3533528c030279f7c.json
│           ├── 0xd2967f45c4f384deea880f807be904762a3dea07.json
│           ├── 0xd30dd0b919cb4012b3add78f6dcb6eb7ef225ac8.json
│           ├── 0xd4b22fedca85e684919955061fdf353b9d38389b.json
│           ├── 0xd533a949740bb3306d119cc777fa900ba034cd52.json
│           ├── 0xd632f22692fac7611d2aa1c0d552930d43caed3b.json
│           ├── 0xd652c40fbb3f06d6b58cb9aa9cff063ee63d465d.json
│           ├── 0xd662908ada2ea1916b3318327a97eb18ad588b5d.json
│           ├── 0xd6ac1cb9019137a896343da59dde6d097f710538.json
│           ├── 0xd784927ff2f95ba542bfc824c8a8a98f3495f6b5.json
│           ├── 0xd7d147c6bb90a718c3de8c0568f9b560c79fa416.json
│           ├── 0xd8b712d29381748db89c36bca0138d7c75866ddf.json
│           ├── 0xd905e2eaebe188fc92179b6350807d8bd91db0d8.json
│           ├── 0xd9171b067eb9825c0529934befa2fbefd0945451.json
│           ├── 0xd9277b0d007464eff133622ec0d42081c93cef02.json
│           ├── 0xd9acb0baeed77c99305017821167674cc7e82f7a.json
│           ├── 0xdac17f958d2ee523a2206206994597c13d831ec7.json
│           ├── 0xdbdb4d16eda451d0503b854cf79d55697f90c8df.json
│           ├── 0xdc01020857afbae65224cfcedb265d1216064c59.json
│           ├── 0xdc59ac4fefa32293a95889dc396682858d52e5db.json
│           ├── 0xdcb6a51ea3ca5d3fd898fd6564757c7aaec3ca92.json
│           ├── 0xde3a93028f2283cc28756b3674bd657eafb992f4.json
│           ├── 0xde5331ac4b3630f94853ff322b66407e0d6331e8.json
│           ├── 0xde92d7967eb21adfb278c0d9db9212f283c4926a.json
│           ├── 0xdefd8fdd20e0f34115c7018ccfb655796f6b2168.json
│           ├── 0xdf5e0e81dff6faf3a7e52ba697820c5e32d806a8.json
│           ├── 0xdfc7adfa664b08767b735de28f9e84cd30492aee.json
│           ├── 0xe0ad1806fd3e7edf6ff52fdb822432e847411033.json
│           ├── 0xe0fc79183a22106229b84ecdd55ca017a07eddca.json
│           ├── 0xe42f02713aec989132c1755117f768dbea523d2f.json
│           ├── 0xe4922afab0bbadd8ab2a88e0c79d884ad337fca6.json
│           ├── 0xe5ecf73603d98a0128f05ed30506ac7a663dbb69.json
│           ├── 0xe5f41acad47849c6eb28b93913ca81893fb5a2a6.json
│           ├── 0xe5f4b89e0a16578b3e0e7581327bdb4c712e44de.json
│           ├── 0xe6e6e25efda5f69687aa9914f8d750c523a1d261.json
│           ├── 0xe712d0b0ea852f68ff5d91efd97508028eab3da5.json
│           ├── 0xe8060ad8971450e624d5289a10017dd30f5da85f.json
│           ├── 0xe91d55ab2240594855abd11b3faae801fd4c4687.json
│           ├── 0xeb31da939878d1d780fdbcc244531c0fb80a2cf3.json
│           ├── 0xecd5e75afb02efa118af914515d6521aabd189f1.json
│           ├── 0xed279fdd11ca84beef15af5d39bb4d4bee23f0ca.json
│           ├── 0xed4064f376cb8d68f770fb1ff088a3d0f3ff5c4d.json
│           ├── 0xef3a930e1ffffacd2fc13434ac81bd278b0ecc8d.json
│           ├── 0xeff437a56a22d7dd86c1202a308536ed8c7da7c1.json
│           ├── 0xf403c135812408bfbe8713b5a23a04b3d48aae31.json
│           ├── 0xf480ee81a54e21be47aa02d0f9e29985bc7667c4.json
│           ├── 0xf5194c3325202f456c95c1cf0ca36f8475c1949f.json
│           ├── 0xf73a1260d222f447210581ddf212d915c09a3249.json
│           ├── 0xf7977edc1fa61aa9b5f90d70a74a3fbc46e9dad3.json
│           ├── 0xf7f52dd34bc21eda08c0b804c7c1dbc48375820f.json
│           ├── 0xf98450b5602fa59cc66e1379dffb6fddc724cfc4.json
│           ├── 0xf9fea7787b7241435f81d36d237d3e19c8e178d0.json
│           ├── 0xfa712ee4788c042e2b7bb55e6cb8ec569c4530c1.json
│           ├── 0xfbdca68601f835b27790d98bbb8ec7f05fdeaa9b.json
│           ├── 0xfd2a8fa60abd58efe3eee34dd494cd491dc14900.json
│           ├── 0xfd4d8a17df4c27c1dd245d153ccf4499e806c87d.json
│           ├── 0xfd5db7463a3ab53fd211b4af195c5bccc1a03890.json
│           └── 0xfffe32106a68aa3ed39ccce673b646423eeab62a.json
└── rinkeby
    ├── 10074295
    │   └── storage.json
    └── etherscan
        └── sources
            ├── 0x6e85f3e7f7236c228bcb79721d1f52ff8e9180e3.json
            ├── 0x7109709ecfa91a80626ff3989d68f67f5b1dd12d.json
            ├── 0x841ee0f6edd38bd69cc1770118aee1907e93def7.json
            ├── 0xd882f90b50c0820aebd2b83a44aaa802212cbf59.json
            ├── 0xdb3d5491dd7c87cc8719ffc379634a9c922f8929.json
            ├── 0xde521fd08ca291959a633112c81f90a0c248fb61.json
            └── 0xdeebf07507a28e6eba74e3b9ac1ee45d391dbfd8.json

17 directories, 302 files

@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 3, 2022

I think you may not have run the code from this branch. The reason I think so is because the layout of the cache has changed. The code now expects:

# block data
~/.foundry/cache/rpc/<chain>/<block>

# etherscan data
~/.foundry/cache/etherscan/<chain>/sources/<address>

Without the rpc directory present, the code should short-circuit and print an empty cache (no output).
https://github.com/diligentcodoor/foundry/blob/etherscanCache/config/src/lib.rs#L1047

Copy link
Member

@gakonst gakonst left a comment

Choose a reason for hiding this comment

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

let's see how this works - should we also be using this for e.g. constructor-args on forge create etc.?

@gakonst gakonst merged commit 1616380 into foundry-rs:master Jun 4, 2022
@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 6, 2022

closes #1477

@jaeaster
Copy link
Contributor Author

jaeaster commented Jun 6, 2022

let's see how this works - should we also be using this for e.g. constructor-args on forge create etc.?

Do you mean adding an option like --constructor-args-etherscan to source args from a previously deployed contract?

I can open a separate issue to track this if you think it is a worthwhile use case.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-feature Type: feature
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants