Skip to content

Commit

Permalink
Cache RPC responses (#19)
Browse files Browse the repository at this point in the history
  • Loading branch information
PaulRBerg authored Jan 9, 2023
1 parent 8998d1b commit fceaa77
Show file tree
Hide file tree
Showing 15 changed files with 136,254 additions and 5,034 deletions.
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
29 changes: 22 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## `foundry-toolchain` Action

This GitHub Action installs [Foundry](https://github.com/foundry-rs/foundry).
This GitHub Action installs [Foundry](https://github.com/foundry-rs/foundry), the blazing fast, portable and modular toolkit for Ethereum application development.

### Example workflow

Expand All @@ -20,8 +20,6 @@ jobs:

- name: Install Foundry
uses: foundry-rs/foundry-toolchain@v1
with:
version: nightly

- name: Run tests
run: forge test -vvv
Expand All @@ -32,10 +30,27 @@ jobs:
### Inputs
| **Name** | **Required** | **Description** | **Type** |
|-----------|--------------|---------------------------------------------------------------------------------------------------------------|----------|
| `version` | Yes | Version to install, e.g. `nightly` or `1.0.0`. **Note:** Foundry only has nightly builds for the time being. | string |
| **Name** | **Required** | **Default** | **Description** | **Type** |
| --------- | ------------ | ----------- | ------------------------------------------------------------------------------------------------------------ | -------- |
| `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 key does, since the key is based on the
commit hash.
- When the fork tests are changed, both the cache and the key are updated.

#### 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

Expand All @@ -48,4 +63,4 @@ For example, to add the output of `forge snapshot` to a summary, you would chang
run: NO_COLOR=1 forge snapshot >> $GITHUB_STEP_SUMMARY
```

See the offical [GitHub docs](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary) for more information.
See the official [GitHub docs](https://docs.github.com/en/actions/using-workflows/workflow-commands-for-github-actions#adding-a-job-summary) for more information.
19 changes: 12 additions & 7 deletions action.yml
Original file line number Diff line number Diff line change
@@ -1,17 +1,22 @@
name: 'foundry-toolchain'
description: 'Install Foundry'
author: 'Oliver Nordbjerg'
name: "foundry-toolchain"
description: "Install Foundry"
author: "Foundry"
branding:
icon: play-circle
color: black
color: "gray-dark"
icon: "play-circle"

inputs:
version:
default: "nightly"
description: |
Foundry version.
This version number has to match a released version of Foundry.
Alternatively you can also specify `nightly` for the latest nightly build.
required: false

runs:
using: node16
main: dist/index.js
using: "node16"
main: "dist/index.js"
post: "dist/save/index.js"
post-if: "success()"
Loading

0 comments on commit fceaa77

Please sign in to comment.