Skip to content
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
feat: cache RPC responses
build: add "@actions/cache" and "@actions/github" as deps
build: add "prettier" as dev dep
build: regenerate "dist" files
chore: add Prettier configuration and Prettier ignore file
docs: change author to "Foundry"
feat: run "save" function on post
style: format JavaScript files with Prettier
  • Loading branch information
PaulRBerg committed Jan 7, 2023
commit c604ee80613d14e4f8516c163d5341923970467c
2 changes: 2 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
dist
node_modules
7 changes: 7 additions & 0 deletions .prettierrc.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
bracketSpacing: true
printWidth: 120
proseWrap: "always"
singleQuote: false
tabWidth: 2
trailingComma: "all"
useTabs: false
17 changes: 17 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,23 @@ jobs:
| --------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------ | -------- |
| `version` | No | `nightly` | Version to install, e.g. `nightly` or `1.0.0`. **Note:** Foundry only has nightly builds for the time being. | string |

### RPC Caching

This action matches Forge's behavior and caches all RPC responses in the `~/.foundry/cache/rpc` directory. This is done to
speed up the tests and avoid hitting the rate limit of your RPC provider.

The logic of the caching is as follows:

- Always load the latest valid cache, and always create a new one with the updated cache.
- When there are no changes to the fork tests, the cache does not change but the restore key does, since the key is based on the commit hash.
- When the fork tests are changed, both the cache and the store key are updated.
Copy link

Choose a reason for hiding this comment

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

What does this bullet mean / what is the store key and restore key? More generally I think I'm unclear on why the logic isn't simpler to just "always cache all responses, clear cache if user changes the cache key". Basically just want to sanity check that the cache isn't deleted if I add/remove new fork blocks or networks to tests.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

It can't be that simple, unfortunately.

As Twitter user ultrasecreth explained here, we want a mechanism whereby if the fork tests change, the cache is updated too.

If you don't specify the git commit in the cache key, then the cache will never update, even if you completely redesign your tests. Quote from the README:

If the provided key matches an existing cache, a new cache is not created.

Copy link

@mds1 mds1 Jan 9, 2023

Choose a reason for hiding this comment

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

Got it, I see. And is "store key" the same as the "restore keys" in the actions/cache repo?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Oh my goodness, I have completely butchered the terminology in the proposed README. I'm sorry, I must have been off-caffeine on the day when I opened the PR.

I have pushed a commit to fix the wording, you can see the diff here:

607b0c5

Basically, I should have just said "key", because the "restore keys" never change on the same OS platform. It's the "key" (simple key, no restore) that changes all the time because it's dependent upon the commit hash.

Copy link

Choose a reason for hiding this comment

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

Heh got it, thanks! Deferring to @gakonst and co. for review/merge 🙂

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks @mds1 for the review thus far.


#### Fuzzing

Note that if you are fuzzing in your fork tests, the RPC cache strategy above will not work unless you set a
[fuzz seed](https://book.getfoundry.sh/reference/config/testing#seed). You might also want to reduce your number
of RPC calls by using [Multicall](https://github.com/mds1/multicall).

### Summaries

You can add the output of Forge and Cast commands to GitHub step summaries. The summaries support GitHub flavored Markdown.
Expand Down
6 changes: 4 additions & 2 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
name: "foundry-toolchain"
description: "Install Foundry"
author: "Oliver Nordbjerg"
author: "Foundry"
branding:
color: "gray-dark"
icon: "play-circle"

inputs:
version:
default: "nightly"
Expand All @@ -18,3 +18,5 @@ inputs:
runs:
using: "node16"
main: "dist/index.js"
post: "dist/save/index.js"
post-if: "success()"
72,673 changes: 67,701 additions & 4,972 deletions dist/index.js

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

67,111 changes: 67,111 additions & 0 deletions dist/save/index.js

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/save/index.js.map

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions dist/save/sourcemap-register.js

Large diffs are not rendered by default.

Loading