├── .config
└── nextest.toml
├── .github
├── CODEOWNERS
├── PULL_REQUEST_TEMPLATE.md
├── scripts
│ └── install_test_binaries.sh
└── workflows
│ └── ci.yml
├── .gitignore
├── CHANGELOG.md
├── CONTRIBUTING.md
├── Cargo.toml
├── LICENSE-APACHE
├── LICENSE-MIT
├── README.md
├── cliff.toml
├── clippy.toml
├── deny.toml
├── release.toml
├── rustfmt.toml
├── scripts
├── changelog.sh
└── check_no_std.sh
├── src
├── backend.rs
├── cache.rs
├── error.rs
└── lib.rs
└── test-data
└── storage.json
/.config/nextest.toml:
--------------------------------------------------------------------------------
1 | [profile.default]
2 | retries = { backoff = "exponential", count = 2, delay = "2s", jitter = true }
3 | slow-timeout = { period = "30s", terminate-after = 4 }
4 |
--------------------------------------------------------------------------------
/.github/CODEOWNERS:
--------------------------------------------------------------------------------
1 | * @danipopes @mattsse @klkvr
2 |
--------------------------------------------------------------------------------
/.github/PULL_REQUEST_TEMPLATE.md:
--------------------------------------------------------------------------------
1 |
12 |
13 |
14 |
15 | ## Motivation
16 |
17 |
22 |
23 | ## Solution
24 |
25 |
29 |
30 | ## PR Checklist
31 |
32 | - [ ] Added Tests
33 | - [ ] Added Documentation
34 | - [ ] Breaking changes
35 |
--------------------------------------------------------------------------------
/.github/scripts/install_test_binaries.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | # Installs Solc and Geth binaries
3 | # Note: intended for use only with CI (x86_64 Ubuntu, MacOS or Windows)
4 | set -e
5 |
6 | GETH_BUILD=${GETH_BUILD:-"1.11.2-73b01f40"}
7 |
8 | BIN_DIR=${BIN_DIR:-"$HOME/bin"}
9 |
10 | PLATFORM="$(uname -s | awk '{print tolower($0)}')"
11 | if [ "$PLATFORM" != "linux" ] && [ "$PLATFORM" != "darwin" ]; then
12 | EXT=".exe"
13 | fi
14 |
15 | main() {
16 | mkdir -p "$BIN_DIR"
17 | cd "$BIN_DIR"
18 | export PATH="$BIN_DIR:$PATH"
19 | if [ "$GITHUB_PATH" ]; then
20 | echo "$BIN_DIR" >> "$GITHUB_PATH"
21 | fi
22 |
23 | install_geth
24 |
25 | echo ""
26 | echo "Installed Geth:"
27 | geth version
28 | }
29 |
30 | # Installs geth from https://geth.ethereum.org/downloads
31 | install_geth() {
32 | case "$PLATFORM" in
33 | linux|darwin)
34 | name="geth-$PLATFORM-amd64-$GETH_BUILD"
35 | curl -s "https://gethstore.blob.core.windows.net/builds/$name.tar.gz" | tar -xzf -
36 | mv -f "$name/geth" ./
37 | rm -rf "$name"
38 | chmod +x geth
39 | ;;
40 | *)
41 | name="geth-windows-amd64-$GETH_BUILD"
42 | zip="$name.zip"
43 | curl -so "$zip" "https://gethstore.blob.core.windows.net/builds/$zip"
44 | unzip "$zip"
45 | mv -f "$name/geth.exe" ./
46 | rm -rf "$name" "$zip"
47 | ;;
48 | esac
49 | }
50 |
51 | main
52 |
--------------------------------------------------------------------------------
/.github/workflows/ci.yml:
--------------------------------------------------------------------------------
1 | name: CI
2 |
3 | on:
4 | push:
5 | branches: [main]
6 | pull_request:
7 |
8 | env:
9 | CARGO_TERM_COLOR: always
10 |
11 | concurrency:
12 | group: ${{ github.workflow }}-${{ github.head_ref || github.run_id }}
13 | cancel-in-progress: true
14 |
15 | jobs:
16 | test:
17 | name: test ${{ matrix.rust }} ${{ matrix.flags }}
18 | runs-on: ubuntu-latest
19 | timeout-minutes: 30
20 | strategy:
21 | fail-fast: false
22 | matrix:
23 | rust: ["stable", "nightly", "1.83"] # MSRV
24 | flags: ["--no-default-features", "", "--all-features"]
25 | exclude:
26 | # Some features have higher MSRV.
27 | - rust: "1.83" # MSRV
28 | flags: "--all-features"
29 | steps:
30 | - uses: actions/checkout@v3
31 | - uses: dtolnay/rust-toolchain@master
32 | with:
33 | toolchain: ${{ matrix.rust }}
34 | - name: Install Anvil
35 | uses: foundry-rs/foundry-toolchain@v1
36 | with:
37 | version: nightly
38 | - name: Install test binaries
39 | shell: bash
40 | run: ./.github/scripts/install_test_binaries.sh
41 | - uses: Swatinem/rust-cache@v2
42 | with:
43 | cache-on-failure: true
44 | # Only run tests on latest stable and above
45 | - name: Install cargo-nextest
46 | if: ${{ matrix.rust != '1.83' }} # MSRV
47 | uses: taiki-e/install-action@nextest
48 | - name: build
49 | if: ${{ matrix.rust == '1.83' }} # MSRV
50 | run: cargo build --workspace ${{ matrix.flags }}
51 | - name: test
52 | if: ${{ matrix.rust != '1.83' }} # MSRV
53 | run: cargo nextest run --workspace ${{ matrix.flags }}
54 |
55 | doctest:
56 | runs-on: ubuntu-latest
57 | timeout-minutes: 30
58 | steps:
59 | - uses: actions/checkout@v4
60 | - uses: dtolnay/rust-toolchain@stable
61 | - uses: Swatinem/rust-cache@v2
62 | with:
63 | cache-on-failure: true
64 | - run: cargo test --workspace --doc
65 | - run: cargo test --all-features --workspace --doc
66 |
67 | no-std:
68 | runs-on: ubuntu-latest
69 | timeout-minutes: 30
70 | steps:
71 | - uses: actions/checkout@v3
72 | - uses: dtolnay/rust-toolchain@stable
73 | with:
74 | target: riscv32imac-unknown-none-elf
75 | - uses: taiki-e/install-action@cargo-hack
76 | - uses: Swatinem/rust-cache@v2
77 | with:
78 | cache-on-failure: true
79 | - name: check
80 | run: ./scripts/check_no_std.sh
81 |
82 | feature-checks:
83 | runs-on: ubuntu-latest
84 | timeout-minutes: 30
85 | steps:
86 | - uses: actions/checkout@v3
87 | - uses: dtolnay/rust-toolchain@stable
88 | - uses: taiki-e/install-action@cargo-hack
89 | - uses: Swatinem/rust-cache@v2
90 | with:
91 | cache-on-failure: true
92 | - name: cargo hack
93 | run: cargo hack check --feature-powerset --depth 1
94 |
95 | clippy:
96 | runs-on: ubuntu-latest
97 | timeout-minutes: 30
98 | steps:
99 | - uses: actions/checkout@v4
100 | - uses: dtolnay/rust-toolchain@master
101 | with:
102 | toolchain: stable
103 | components: clippy
104 | - uses: Swatinem/rust-cache@v2
105 | with:
106 | cache-on-failure: true
107 | - run: cargo +stable clippy --workspace --all-targets --all-features
108 | env:
109 | RUSTFLAGS: -Dwarnings
110 |
111 | docs:
112 | runs-on: ubuntu-latest
113 | timeout-minutes: 30
114 | steps:
115 | - uses: actions/checkout@v3
116 | - uses: dtolnay/rust-toolchain@nightly
117 | - uses: Swatinem/rust-cache@v2
118 | with:
119 | cache-on-failure: true
120 | - run: cargo doc --workspace --all-features --no-deps --document-private-items
121 | env:
122 | RUSTDOCFLAGS: --cfg docsrs -D warnings --show-type-layout --generate-link-to-definition --enable-index-page -Zunstable-options
123 |
124 | fmt:
125 | runs-on: ubuntu-latest
126 | timeout-minutes: 30
127 | steps:
128 | - uses: actions/checkout@v3
129 | - uses: dtolnay/rust-toolchain@nightly
130 | with:
131 | components: rustfmt
132 | - run: cargo fmt --all --check
133 |
134 | deny:
135 | uses: ithacaxyz/ci/.github/workflows/deny.yml@main
136 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | /target
2 | /Cargo.lock
3 | .vscode
4 | .idea
5 | .env
6 | .DS_Store
7 |
--------------------------------------------------------------------------------
/CHANGELOG.md:
--------------------------------------------------------------------------------
1 | # Changelog
2 |
3 | All notable changes to this project will be documented in this file.
4 |
5 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
6 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
7 |
8 | ## [0.15.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.15.0) - 2025-05-23
9 |
10 | ### Dependencies
11 |
12 | - Bump revm to 24.0.0 ([#50](https://github.com/foundry-rs/foundry-fork-db/issues/50))
13 |
14 | ## [0.14.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.14.0) - 2025-05-15
15 |
16 | ### Miscellaneous Tasks
17 |
18 | - Release 0.14.0
19 | - Alloy 1.0 ([#49](https://github.com/foundry-rs/foundry-fork-db/issues/49))
20 |
21 | ## [0.13.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.13.0) - 2025-05-08
22 |
23 | ### Dependencies
24 |
25 | - [deps] Alloy 0.15 ([#46](https://github.com/foundry-rs/foundry-fork-db/issues/46))
26 |
27 | ### Features
28 |
29 | - Bump revm to `21.0.0` and alloy to `0.13.0` ([#44](https://github.com/foundry-rs/foundry-fork-db/issues/44))
30 |
31 | ### Miscellaneous Tasks
32 |
33 | - Release 0.13.0
34 |
35 | ## [0.12.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.12.0) - 2025-03-07
36 |
37 | ### Dependencies
38 |
39 | - [deps] Alloy 0.12 ([#43](https://github.com/foundry-rs/foundry-fork-db/issues/43))
40 |
41 | ### Miscellaneous Tasks
42 |
43 | - Release 0.12.0
44 |
45 | ## [0.11.1](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.11.1) - 2025-02-18
46 |
47 | ### Features
48 |
49 | - Expose cache_path for JsonBlockCacheDB ([#42](https://github.com/foundry-rs/foundry-fork-db/issues/42))
50 |
51 | ### Miscellaneous Tasks
52 |
53 | - Release 0.11.1
54 |
55 | ## [0.11.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.11.0) - 2025-01-31
56 |
57 | ### Dependencies
58 |
59 | - Bump alloy 0.11 ([#41](https://github.com/foundry-rs/foundry-fork-db/issues/41))
60 |
61 | ### Miscellaneous Tasks
62 |
63 | - Release 0.11.0
64 |
65 | ## [0.10.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.10.0) - 2024-12-30
66 |
67 | ### Features
68 |
69 | - Update revm 19 alloy 09 ([#39](https://github.com/foundry-rs/foundry-fork-db/issues/39))
70 |
71 | ### Miscellaneous Tasks
72 |
73 | - Release 0.10.0
74 |
75 | ## [0.9.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.9.0) - 2024-12-10
76 |
77 | ### Dependencies
78 |
79 | - Bump alloy 0.8 ([#38](https://github.com/foundry-rs/foundry-fork-db/issues/38))
80 | - Bump MSRV to 1.81 ([#37](https://github.com/foundry-rs/foundry-fork-db/issues/37))
81 | - Bump breaking deps ([#36](https://github.com/foundry-rs/foundry-fork-db/issues/36))
82 |
83 | ### Miscellaneous Tasks
84 |
85 | - Release 0.9.0
86 | - Update deny.toml ([#35](https://github.com/foundry-rs/foundry-fork-db/issues/35))
87 |
88 | ### Other
89 |
90 | - Move deny to ci ([#34](https://github.com/foundry-rs/foundry-fork-db/issues/34))
91 |
92 | ## [0.8.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.8.0) - 2024-11-28
93 |
94 | ### Dependencies
95 |
96 | - Bump alloy ([#33](https://github.com/foundry-rs/foundry-fork-db/issues/33))
97 |
98 | ### Miscellaneous Tasks
99 |
100 | - Release 0.8.0
101 |
102 | ## [0.7.2](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.7.2) - 2024-11-27
103 |
104 | ### Documentation
105 |
106 | - Fix typo in changelog generator 2
107 | - Fix typo in changelog generator
108 |
109 | ### Features
110 |
111 | - [backend] Add support for arbitrary provider requests with AnyRequest ([#32](https://github.com/foundry-rs/foundry-fork-db/issues/32))
112 |
113 | ### Miscellaneous Tasks
114 |
115 | - Release 0.7.2
116 |
117 | ## [0.7.1](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.7.1) - 2024-11-09
118 |
119 | ### Bug Fixes
120 |
121 | - Accept generic header in meta builder ([#30](https://github.com/foundry-rs/foundry-fork-db/issues/30))
122 |
123 | ### Miscellaneous Tasks
124 |
125 | - Release 0.7.1
126 |
127 | ## [0.7.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.7.0) - 2024-11-08
128 |
129 | ### Dependencies
130 |
131 | - [deps] Bump alloy 0.6.2 ([#29](https://github.com/foundry-rs/foundry-fork-db/issues/29))
132 |
133 | ### Documentation
134 |
135 | - Update docs
136 |
137 | ### Miscellaneous Tasks
138 |
139 | - Release 0.7.0
140 |
141 | ## [0.6.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.6.0) - 2024-10-23
142 |
143 | ### Dependencies
144 |
145 | - Bump revm ([#27](https://github.com/foundry-rs/foundry-fork-db/issues/27))
146 |
147 | ### Miscellaneous Tasks
148 |
149 | - Release 0.6.0
150 |
151 | ## [0.5.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.5.0) - 2024-10-18
152 |
153 | ### Dependencies
154 |
155 | - Bump alloy 0.5 ([#26](https://github.com/foundry-rs/foundry-fork-db/issues/26))
156 |
157 | ### Miscellaneous Tasks
158 |
159 | - Release 0.5.0
160 |
161 | ## [0.4.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.4.0) - 2024-09-30
162 |
163 | ### Dependencies
164 |
165 | - Bump alloy 0.4 ([#24](https://github.com/foundry-rs/foundry-fork-db/issues/24))
166 |
167 | ### Miscellaneous Tasks
168 |
169 | - Release 0.4.0
170 |
171 | ## [0.3.2](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.3.2) - 2024-09-29
172 |
173 | ### Features
174 |
175 | - BlockchainDbMeta builder ([#22](https://github.com/foundry-rs/foundry-fork-db/issues/22))
176 |
177 | ### Miscellaneous Tasks
178 |
179 | - Release 0.3.2
180 | - Use more alloy_primitives::map
181 |
182 | ## [0.3.1](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.3.1) - 2024-09-21
183 |
184 | ### Dependencies
185 |
186 | - [deps] Disable default features for revm ([#20](https://github.com/foundry-rs/foundry-fork-db/issues/20))
187 |
188 | ### Miscellaneous Tasks
189 |
190 | - Release 0.3.1
191 |
192 | ### Other
193 |
194 | - Don't deploy docs
195 |
196 | ## [0.3.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.3.0) - 2024-08-29
197 |
198 | ### Bug Fixes
199 |
200 | - Fix fmt
201 |
202 | ### Dependencies
203 |
204 | - Merge pull request [#19](https://github.com/foundry-rs/foundry-fork-db/issues/19) from foundry-rs/matt/bump-alloy03
205 | - Bump alloy
206 |
207 | ### Miscellaneous Tasks
208 |
209 | - Release 0.3.0
210 |
211 | ### Other
212 |
213 | - Update
214 | - Merge pull request [#18](https://github.com/foundry-rs/foundry-fork-db/issues/18) from nkysg/unbound_channel
215 | - Rm clone
216 | - Replace bounded channel with unbounded channel
217 |
218 | ## [0.2.1](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.2.1) - 2024-08-08
219 |
220 | ### Bug Fixes
221 |
222 | - Fix clippy
223 | - Fix-tests after checking
224 |
225 | ### Dependencies
226 |
227 | - Merge pull request [#17](https://github.com/foundry-rs/foundry-fork-db/issues/17) from foundry-rs/matt/bump-revm13
228 | - Bump revm 13
229 | - Undo bump version
230 | - Bump version of crate
231 | - Merge bump-revm
232 |
233 | ### Documentation
234 |
235 | - Docs to functions
236 | - Docs
237 |
238 | ### Miscellaneous Tasks
239 |
240 | - Release 0.2.1
241 |
242 | ### Other
243 |
244 | - Merge pull request [#16](https://github.com/foundry-rs/foundry-fork-db/issues/16) from m1stoyanov/patch-1
245 | - Remove the unnecessary result from the helper functions
246 | - Provide helper methods for MemDb data
247 | - Merge pull request [#13](https://github.com/foundry-rs/foundry-fork-db/issues/13) from nkysg/sharedbackend_behaviour
248 | - Update process logic
249 | - Add BlockingMod::Block process
250 | - add configure for SharedBackend block_in_place or not
251 | - Merge pull request [#10](https://github.com/foundry-rs/foundry-fork-db/issues/10) from Ethanol48/update_state
252 | - Eliminated tmp ETH_RPC
253 | - Added tmp file for testing
254 | - Eliminate reduntant code
255 | - Add tests to verify if the data was properly updated
256 | - Added db to test to verify data
257 | - Add minor changes
258 | - Update block hashes
259 | - Typo
260 | - Update address in db
261 | - Update revm
262 | - Merge pull request [#12](https://github.com/foundry-rs/foundry-fork-db/issues/12) from Ethanol48/flush_to_file
263 | - Change to &Path
264 | - Eliminate reduntant code
265 | - Merge branch 'main' of https://github.com/Ethanol48/foundry-fork-db into flush_to_file
266 |
267 | ### Refactor
268 |
269 | - Refactor and storage update
270 | - Refactoring
271 |
272 | ## [0.2.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.2.0) - 2024-07-17
273 |
274 | ### Dependencies
275 |
276 | - Merge pull request [#8](https://github.com/foundry-rs/foundry-fork-db/issues/8) from foundry-rs/klkvr/bump-revm
277 | - Bump revm
278 | - Merge pull request [#7](https://github.com/foundry-rs/foundry-fork-db/issues/7) from foundry-rs/matt/bump-revm-alloy
279 | - Bump alloy and revm
280 |
281 | ### Miscellaneous Tasks
282 |
283 | - Release 0.2.0
284 |
285 | ### Other
286 |
287 | - Formating
288 | - Add documentation
289 | - Add flush to arbitrary file
290 |
291 | ## [0.1.1](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.1.1) - 2024-07-15
292 |
293 | ### Dependencies
294 |
295 | - Merge pull request [#5](https://github.com/foundry-rs/foundry-fork-db/issues/5) from foundry-rs/matt/bump-msrv
296 | - Bump msrv 79
297 | - Merge pull request [#4](https://github.com/foundry-rs/foundry-fork-db/issues/4) from m1stoyanov/main
298 | - Bump alloy [provider, rpc-types, serde, transport, rpc-client, transport-http] to 0.1.4, alloy-primitives to 0.7.7 and revm to 11.0.0
299 |
300 | ### Miscellaneous Tasks
301 |
302 | - Release 0.1.1
303 |
304 | ### Other
305 |
306 | - Remove redundant check
307 | - Update Cargo.toml according to the reviews
308 |
309 | ## [0.1.0](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v0.1.0) - 2024-07-02
310 |
311 | ### Bug Fixes
312 |
313 | - Clippy
314 | - Cargo deny
315 | - Clippy + fmt
316 | - Tests
317 |
318 | ### Miscellaneous Tasks
319 |
320 | - Release 0.1.0
321 | - Init changelog
322 | - Fix cliff.toml
323 | - Add description
324 |
325 | ### Other
326 |
327 | - Update naming ([#2](https://github.com/foundry-rs/foundry-fork-db/issues/2))
328 | - Merge pull request [#1](https://github.com/foundry-rs/foundry-fork-db/issues/1) from klkvr/klkvr/init
329 | - DatabaseError -> BackendError
330 | - Initial commit
331 | - Update readme
332 | - Update name
333 | - Initial commit
334 |
335 |
336 |
--------------------------------------------------------------------------------
/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | ## Contributing to Foundry
2 |
3 | Thanks for your interest in improving Foundry!
4 |
5 | There are multiple opportunities to contribute at any level. It doesn't matter if you are just getting started with Rust or are the most weathered expert, we can use your help.
6 |
7 | This document will help you get started. **Do not let the document intimidate you**.
8 | It should be considered as a guide to help you navigate the process.
9 |
10 | The [dev Telegram][dev-tg] is available for any concerns you may have that are not covered in this guide.
11 |
12 | ### Code of Conduct
13 |
14 | The Foundry project adheres to the [Rust Code of Conduct][rust-coc]. This code of conduct describes the _minimum_ behavior expected from all contributors.
15 |
16 | Instances of violations of the Code of Conduct can be reported by contacting the team at [me@gakonst.com](mailto:me@gakonst.com).
17 |
18 | ### Ways to contribute
19 |
20 | There are fundamentally four ways an individual can contribute:
21 |
22 | 1. **By opening an issue:** For example, if you believe that you have uncovered a bug
23 | in Foundry, creating a new issue in the issue tracker is the way to report it.
24 | 2. **By adding context:** Providing additional context to existing issues,
25 | such as screenshots and code snippets, which help resolve issues.
26 | 3. **By resolving issues:** Typically this is done in the form of either
27 | demonstrating that the issue reported is not a problem after all, or more often,
28 | by opening a pull request that fixes the underlying problem, in a concrete and
29 | reviewable manner.
30 |
31 | **Anybody can participate in any stage of contribution**. We urge you to participate in the discussion
32 | around bugs and participate in reviewing PRs.
33 |
34 | ### Contributions Related to Spelling and Grammar
35 |
36 | At this time, we will not be accepting contributions that only fix spelling or grammatical errors in documentation, code or
37 | elsewhere.
38 |
39 | ### Asking for help
40 |
41 | If you have reviewed existing documentation and still have questions, or you are having problems, you can get help in the following ways:
42 |
43 | - **Asking in the support Telegram:** The [Foundry Support Telegram][support-tg] is a fast and easy way to ask questions.
44 | - **Opening a discussion:** This repository comes with a discussions board where you can also ask for help. Click the "Discussions" tab at the top.
45 |
46 | As Foundry is still in heavy development, the documentation can be a bit scattered.
47 | The [Foundry Book][foundry-book] is our current best-effort attempt at keeping up-to-date information.
48 |
49 | ### Submitting a bug report
50 |
51 | When filing a new bug report in the issue tracker, you will be presented with a basic form to fill out.
52 |
53 | If you believe that you have uncovered a bug, please fill out the form to the best of your ability. Do not worry if you cannot answer every detail; just fill in what you can. Contributors will ask follow-up questions if something is unclear.
54 |
55 | The most important pieces of information we need in a bug report are:
56 |
57 | - The Foundry version you are on (and that it is up to date)
58 | - The platform you are on (Windows, macOS, an M1 Mac or Linux)
59 | - Code snippets if this is happening in relation to testing or building code
60 | - Concrete steps to reproduce the bug
61 |
62 | In order to rule out the possibility of the bug being in your project, the code snippets should be as minimal
63 | as possible. It is better if you can reproduce the bug with a small snippet as opposed to an entire project!
64 |
65 | See [this guide][mcve] on how to create a minimal, complete, and verifiable example.
66 |
67 | ### Submitting a feature request
68 |
69 | When adding a feature request in the issue tracker, you will be presented with a basic form to fill out.
70 |
71 | Please include as detailed of an explanation as possible of the feature you would like, adding additional context if necessary.
72 |
73 | If you have examples of other tools that have the feature you are requesting, please include them as well.
74 |
75 | ### Resolving an issue
76 |
77 | Pull requests are the way concrete changes are made to the code, documentation, and dependencies of Foundry.
78 |
79 | Even minor pull requests, such as those fixing wording, are greatly appreciated. Before making a large change, it is usually
80 | a good idea to first open an issue describing the change to solicit feedback and guidance. This will increase
81 | the likelihood of the PR getting merged.
82 |
83 | Please also make sure that the following commands pass if you have changed the code:
84 |
85 | ```sh
86 | cargo check --all
87 | cargo test --all --all-features
88 | cargo +nightly fmt -- --check
89 | cargo +nightly clippy --all --all-targets --all-features -- -D warnings
90 | ```
91 |
92 | If you are working in VSCode, we recommend you install the [rust-analyzer](https://rust-analyzer.github.io/) extension, and use the following VSCode user settings:
93 |
94 | ```json
95 | "editor.formatOnSave": true,
96 | "rust-analyzer.rustfmt.extraArgs": ["+nightly"],
97 | "[rust]": {
98 | "editor.defaultFormatter": "rust-lang.rust-analyzer"
99 | }
100 | ```
101 |
102 | If you are working on a larger feature, we encourage you to open up a draft pull request, to make sure that other contributors are not duplicating work.
103 |
104 | If you would like to test the binaries built from your change, see [foundryup](https://github.com/foundry-rs/foundry/tree/master/foundryup).
105 |
106 | If you would like to use a debugger with breakpoints to debug a patch you might be working on, keep in mind we currently strip debug info for faster builds, which is *not* the default. Therefore, to use a debugger, you need to enable it on the workspace [`Cargo.toml`'s `dev` profile](https://github.com/foundry-rs/foundry/tree/master/Cargo.toml#L15-L18).
107 |
108 | #### Adding tests
109 |
110 | If the change being proposed alters code, it is either adding new functionality to Foundry, or fixing existing, broken functionality.
111 | In both of these cases, the pull request should include one or more tests to ensure that Foundry does not regress
112 | in the future.
113 |
114 | Types of tests include:
115 |
116 | - **Unit tests**: Functions which have very specific tasks should be unit tested.
117 | - **Integration tests**: For general purpose, far reaching functionality, integration tests should be added.
118 | The best way to add a new integration test is to look at existing ones and follow the style.
119 |
120 | Tests that use forking must contain "fork" in their name.
121 |
122 | #### Commits
123 |
124 | It is a recommended best practice to keep your changes as logically grouped as possible within individual commits. There is no limit to the number of commits any single pull request may have, and many contributors find it easier to review changes that are split across multiple commits.
125 |
126 | That said, if you have a number of commits that are "checkpoints" and don't represent a single logical change, please squash those together.
127 |
128 | #### Opening the pull request
129 |
130 | From within GitHub, opening a new pull request will present you with a template that should be filled out. Please try your best at filling out the details, but feel free to skip parts if you're not sure what to put.
131 |
132 | #### Discuss and update
133 |
134 | You will probably get feedback or requests for changes to your pull request.
135 | This is a big part of the submission process, so don't be discouraged! Some contributors may sign off on the pull request right away, others may have more detailed comments or feedback.
136 | This is a necessary part of the process in order to evaluate whether the changes are correct and necessary.
137 |
138 | **Any community member can review a PR, so you might get conflicting feedback**.
139 | Keep an eye out for comments from code owners to provide guidance on conflicting feedback.
140 |
141 | #### Reviewing pull requests
142 |
143 | **Any Foundry community member is welcome to review any pull request**.
144 |
145 | All contributors who choose to review and provide feedback on pull requests have a responsibility to both the project and individual making the contribution. Reviews and feedback must be helpful, insightful, and geared towards improving the contribution as opposed to simply blocking it. If there are reasons why you feel the PR should not be merged, explain what those are. Do not expect to be able to block a PR from advancing simply because you say "no" without giving an explanation. Be open to having your mind changed. Be open to working _with_ the contributor to make the pull request better.
146 |
147 | Reviews that are dismissive or disrespectful of the contributor or any other reviewers are strictly counter to the Code of Conduct.
148 |
149 | When reviewing a pull request, the primary goals are for the codebase to improve and for the person submitting the request to succeed. **Even if a pull request is not merged, the submitter should come away from the experience feeling like their effort was not unappreciated**. Every PR from a new contributor is an opportunity to grow the community.
150 |
151 | ##### Review a bit at a time
152 |
153 | Do not overwhelm new contributors.
154 |
155 | It is tempting to micro-optimize and make everything about relative performance, perfect grammar, or exact style matches. Do not succumb to that temptation..
156 |
157 | Focus first on the most significant aspects of the change:
158 |
159 | 1. Does this change make sense for Foundry?
160 | 2. Does this change make Foundry better, even if only incrementally?
161 | 3. Are there clear bugs or larger scale issues that need attending?
162 | 4. Are the commit messages readable and correct? If it contains a breaking change, is it clear enough?
163 |
164 | Note that only **incremental** improvement is needed to land a PR. This means that the PR does not need to be perfect, only better than the status quo. Follow-up PRs may be opened to continue iterating.
165 |
166 | When changes are necessary, _request_ them, do not _demand_ them, and **do not assume that the submitter already knows how to add a test or run a benchmark**.
167 |
168 | Specific performance optimization techniques, coding styles and conventions change over time. The first impression you give to a new contributor never does.
169 |
170 | Nits (requests for small changes that are not essential) are fine, but try to avoid stalling the pull request. Most nits can typically be fixed by the Foundry maintainers merging the pull request, but they can also be an opportunity for the contributor to learn a bit more about the project.
171 |
172 | It is always good to clearly indicate nits when you comment, e.g.: `Nit: change foo() to bar(). But this is not blocking`.
173 |
174 | If your comments were addressed but were not folded after new commits, or if they proved to be mistaken, please, [hide them][hiding-a-comment] with the appropriate reason to keep the conversation flow concise and relevant.
175 |
176 | ##### Be aware of the person behind the code
177 |
178 | Be aware that _how_ you communicate requests and reviews in your feedback can have a significant impact on the success of the pull request. Yes, we may merge a particular change that makes Foundry better, but the individual might just not want to have anything to do with Foundry ever again. The goal is not just having good code.
179 |
180 | ##### Abandoned or stale pull requests
181 |
182 | If a pull request appears to be abandoned or stalled, it is polite to first check with the contributor to see if they intend to continue the work before checking if they would mind if you took it over (especially if it just has nits left). When doing so, it is courteous to give the original contributor credit for the work they started, either by preserving their name and e-mail address in the commit log, or by using the `Author: ` or `Co-authored-by: ` metadata tag in the commits.
183 |
184 | _Adapted from the [ethers-rs contributing guide](https://github.com/gakonst/ethers-rs/blob/master/CONTRIBUTING.md)_.
185 |
186 | ### Releasing
187 |
188 | Releases are automatically done by the release workflow when a tag is pushed, however, these steps still need to be taken:
189 |
190 | 1. Ensure that the versions in the relevant `Cargo.toml` files are up-to-date.
191 | 2. Update documentation links
192 | 3. Perform a final audit for breaking changes.
193 |
194 | [rust-coc]: https://github.com/rust-lang/rust/blob/master/CODE_OF_CONDUCT.md
195 | [dev-tg]: https://t.me/foundry_rs
196 | [foundry-book]: https://github.com/foundry-rs/foundry-book
197 | [support-tg]: https://t.me/foundry_support
198 | [mcve]: https://stackoverflow.com/help/mcve
199 | [hiding-a-comment]: https://help.github.com/articles/managing-disruptive-comments/#hiding-a-comment
--------------------------------------------------------------------------------
/Cargo.toml:
--------------------------------------------------------------------------------
1 | [package]
2 | name = "foundry-fork-db"
3 | description = "Fork database used by Foundry"
4 | version = "0.15.0"
5 | edition = "2021"
6 | # Remember to update clippy.toml as well
7 | rust-version = "1.83"
8 | authors = ["Foundry Contributors"]
9 | license = "MIT OR Apache-2.0"
10 | homepage = "https://github.com/foundry-rs/foundry-fork-db"
11 | repository = "https://github.com/foundry-rs/foundry-fork-db"
12 |
13 | [lints]
14 | rust.unused_must_use = "deny"
15 | rust.rust_2018_idioms = { level = "deny", priority = -1 }
16 | rustdoc.all = "warn"
17 |
18 | [lints.clippy]
19 | missing_const_for_fn = "allow" # TODO: https://github.com/rust-lang/rust-clippy/issues/14020
20 | use_self = "warn"
21 | option_if_let_else = "warn"
22 |
23 | [package.metadata.docs.rs]
24 | all-features = true
25 | rustdoc-args = ["--cfg", "docsrs"]
26 |
27 | [dependencies]
28 | alloy-primitives = { version = "1.0", features = ["map"] }
29 | alloy-provider = { version = "1.0.3", default-features = false }
30 | alloy-rpc-types = { version = "1.0.3", features = ["eth"] }
31 | alloy-consensus = { version = "1.0.3", default-features = false }
32 |
33 | eyre = "0.6"
34 | futures = "0.3"
35 |
36 | parking_lot = "0.12"
37 |
38 | revm = { version = "24.0.0", features = ["std", "serde"] }
39 |
40 | serde = "1.0"
41 | serde_json = "1.0"
42 |
43 | thiserror = "2"
44 | tokio = { version = "1", features = ["rt-multi-thread"] }
45 | tracing = "0.1"
46 |
47 | url = "2"
48 |
49 | [dev-dependencies]
50 | alloy-rpc-client = "1.0.3"
51 | tiny_http = "0.12"
52 |
53 | # [patch.crates-io]
54 | # alloy-provider = { git = "https://github.com/alloy-rs/alloy", rev = "a4e7099" }
55 | # alloy-rpc-types = { git = "https://github.com/alloy-rs/alloy", rev = "a4e7099" }
56 | # alloy-consensus = { git = "https://github.com/alloy-rs/alloy", rev = "a4e7099" }
57 | # alloy-rpc-client = { git = "https://github.com/alloy-rs/alloy", rev = "a4e7099" }
58 |
--------------------------------------------------------------------------------
/LICENSE-APACHE:
--------------------------------------------------------------------------------
1 | Apache License
2 | Version 2.0, January 2004
3 | http://www.apache.org/licenses/
4 |
5 | TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
6 |
7 | 1. Definitions.
8 |
9 | "License" shall mean the terms and conditions for use, reproduction,
10 | and distribution as defined by Sections 1 through 9 of this document.
11 |
12 | "Licensor" shall mean the copyright owner or entity authorized by
13 | the copyright owner that is granting the License.
14 |
15 | "Legal Entity" shall mean the union of the acting entity and all
16 | other entities that control, are controlled by, or are under common
17 | control with that entity. For the purposes of this definition,
18 | "control" means (i) the power, direct or indirect, to cause the
19 | direction or management of such entity, whether by contract or
20 | otherwise, or (ii) ownership of fifty percent (50%) or more of the
21 | outstanding shares, or (iii) beneficial ownership of such entity.
22 |
23 | "You" (or "Your") shall mean an individual or Legal Entity
24 | exercising permissions granted by this License.
25 |
26 | "Source" form shall mean the preferred form for making modifications,
27 | including but not limited to software source code, documentation
28 | source, and configuration files.
29 |
30 | "Object" form shall mean any form resulting from mechanical
31 | transformation or translation of a Source form, including but
32 | not limited to compiled object code, generated documentation,
33 | and conversions to other media types.
34 |
35 | "Work" shall mean the work of authorship, whether in Source or
36 | Object form, made available under the License, as indicated by a
37 | copyright notice that is included in or attached to the work
38 | (an example is provided in the Appendix below).
39 |
40 | "Derivative Works" shall mean any work, whether in Source or Object
41 | form, that is based on (or derived from) the Work and for which the
42 | editorial revisions, annotations, elaborations, or other modifications
43 | represent, as a whole, an original work of authorship. For the purposes
44 | of this License, Derivative Works shall not include works that remain
45 | separable from, or merely link (or bind by name) to the interfaces of,
46 | the Work and Derivative Works thereof.
47 |
48 | "Contribution" shall mean any work of authorship, including
49 | the original version of the Work and any modifications or additions
50 | to that Work or Derivative Works thereof, that is intentionally
51 | submitted to Licensor for inclusion in the Work by the copyright owner
52 | or by an individual or Legal Entity authorized to submit on behalf of
53 | the copyright owner. For the purposes of this definition, "submitted"
54 | means any form of electronic, verbal, or written communication sent
55 | to the Licensor or its representatives, including but not limited to
56 | communication on electronic mailing lists, source code control systems,
57 | and issue tracking systems that are managed by, or on behalf of, the
58 | Licensor for the purpose of discussing and improving the Work, but
59 | excluding communication that is conspicuously marked or otherwise
60 | designated in writing by the copyright owner as "Not a Contribution."
61 |
62 | "Contributor" shall mean Licensor and any individual or Legal Entity
63 | on behalf of whom a Contribution has been received by Licensor and
64 | subsequently incorporated within the Work.
65 |
66 | 2. Grant of Copyright License. Subject to the terms and conditions of
67 | this License, each Contributor hereby grants to You a perpetual,
68 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
69 | copyright license to reproduce, prepare Derivative Works of,
70 | publicly display, publicly perform, sublicense, and distribute the
71 | Work and such Derivative Works in Source or Object form.
72 |
73 | 3. Grant of Patent License. Subject to the terms and conditions of
74 | this License, each Contributor hereby grants to You a perpetual,
75 | worldwide, non-exclusive, no-charge, royalty-free, irrevocable
76 | (except as stated in this section) patent license to make, have made,
77 | use, offer to sell, sell, import, and otherwise transfer the Work,
78 | where such license applies only to those patent claims licensable
79 | by such Contributor that are necessarily infringed by their
80 | Contribution(s) alone or by combination of their Contribution(s)
81 | with the Work to which such Contribution(s) was submitted. If You
82 | institute patent litigation against any entity (including a
83 | cross-claim or counterclaim in a lawsuit) alleging that the Work
84 | or a Contribution incorporated within the Work constitutes direct
85 | or contributory patent infringement, then any patent licenses
86 | granted to You under this License for that Work shall terminate
87 | as of the date such litigation is filed.
88 |
89 | 4. Redistribution. You may reproduce and distribute copies of the
90 | Work or Derivative Works thereof in any medium, with or without
91 | modifications, and in Source or Object form, provided that You
92 | meet the following conditions:
93 |
94 | (a) You must give any other recipients of the Work or
95 | Derivative Works a copy of this License; and
96 |
97 | (b) You must cause any modified files to carry prominent notices
98 | stating that You changed the files; and
99 |
100 | (c) You must retain, in the Source form of any Derivative Works
101 | that You distribute, all copyright, patent, trademark, and
102 | attribution notices from the Source form of the Work,
103 | excluding those notices that do not pertain to any part of
104 | the Derivative Works; and
105 |
106 | (d) If the Work includes a "NOTICE" text file as part of its
107 | distribution, then any Derivative Works that You distribute must
108 | include a readable copy of the attribution notices contained
109 | within such NOTICE file, excluding those notices that do not
110 | pertain to any part of the Derivative Works, in at least one
111 | of the following places: within a NOTICE text file distributed
112 | as part of the Derivative Works; within the Source form or
113 | documentation, if provided along with the Derivative Works; or,
114 | within a display generated by the Derivative Works, if and
115 | wherever such third-party notices normally appear. The contents
116 | of the NOTICE file are for informational purposes only and
117 | do not modify the License. You may add Your own attribution
118 | notices within Derivative Works that You distribute, alongside
119 | or as an addendum to the NOTICE text from the Work, provided
120 | that such additional attribution notices cannot be construed
121 | as modifying the License.
122 |
123 | You may add Your own copyright statement to Your modifications and
124 | may provide additional or different license terms and conditions
125 | for use, reproduction, or distribution of Your modifications, or
126 | for any such Derivative Works as a whole, provided Your use,
127 | reproduction, and distribution of the Work otherwise complies with
128 | the conditions stated in this License.
129 |
130 | 5. Submission of Contributions. Unless You explicitly state otherwise,
131 | any Contribution intentionally submitted for inclusion in the Work
132 | by You to the Licensor shall be under the terms and conditions of
133 | this License, without any additional terms or conditions.
134 | Notwithstanding the above, nothing herein shall supersede or modify
135 | the terms of any separate license agreement you may have executed
136 | with Licensor regarding such Contributions.
137 |
138 | 6. Trademarks. This License does not grant permission to use the trade
139 | names, trademarks, service marks, or product names of the Licensor,
140 | except as required for reasonable and customary use in describing the
141 | origin of the Work and reproducing the content of the NOTICE file.
142 |
143 | 7. Disclaimer of Warranty. Unless required by applicable law or
144 | agreed to in writing, Licensor provides the Work (and each
145 | Contributor provides its Contributions) on an "AS IS" BASIS,
146 | WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
147 | implied, including, without limitation, any warranties or conditions
148 | of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
149 | PARTICULAR PURPOSE. You are solely responsible for determining the
150 | appropriateness of using or redistributing the Work and assume any
151 | risks associated with Your exercise of permissions under this License.
152 |
153 | 8. Limitation of Liability. In no event and under no legal theory,
154 | whether in tort (including negligence), contract, or otherwise,
155 | unless required by applicable law (such as deliberate and grossly
156 | negligent acts) or agreed to in writing, shall any Contributor be
157 | liable to You for damages, including any direct, indirect, special,
158 | incidental, or consequential damages of any character arising as a
159 | result of this License or out of the use or inability to use the
160 | Work (including but not limited to damages for loss of goodwill,
161 | work stoppage, computer failure or malfunction, or any and all
162 | other commercial damages or losses), even if such Contributor
163 | has been advised of the possibility of such damages.
164 |
165 | 9. Accepting Warranty or Additional Liability. While redistributing
166 | the Work or Derivative Works thereof, You may choose to offer,
167 | and charge a fee for, acceptance of support, warranty, indemnity,
168 | or other liability obligations and/or rights consistent with this
169 | License. However, in accepting such obligations, You may act only
170 | on Your own behalf and on Your sole responsibility, not on behalf
171 | of any other Contributor, and only if You agree to indemnify,
172 | defend, and hold each Contributor harmless for any liability
173 | incurred by, or claims asserted against, such Contributor by reason
174 | of your accepting any such warranty or additional liability.
175 |
176 | END OF TERMS AND CONDITIONS
177 |
--------------------------------------------------------------------------------
/LICENSE-MIT:
--------------------------------------------------------------------------------
1 | Permission is hereby granted, free of charge, to any
2 | person obtaining a copy of this software and associated
3 | documentation files (the "Software"), to deal in the
4 | Software without restriction, including without
5 | limitation the rights to use, copy, modify, merge,
6 | publish, distribute, sublicense, and/or sell copies of
7 | the Software, and to permit persons to whom the Software
8 | is furnished to do so, subject to the following
9 | conditions:
10 |
11 | The above copyright notice and this permission notice
12 | shall be included in all copies or substantial portions
13 | of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF
16 | ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED
17 | TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A
18 | PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT
19 | SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
20 | CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21 | OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR
22 | IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
23 | DEALINGS IN THE SOFTWARE.
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # foundry-fork-db
2 |
3 | #### License
4 |
5 |
6 | Licensed under either of Apache License, Version
7 | 2.0 or MIT license at your option.
8 |
9 |
10 |
11 |
12 |
13 | Unless you explicitly state otherwise, any contribution intentionally submitted
14 | for inclusion in these crates by you, as defined in the Apache-2.0 license,
15 | shall be dual licensed as above, without any additional terms or conditions.
16 |
17 |
--------------------------------------------------------------------------------
/cliff.toml:
--------------------------------------------------------------------------------
1 | # Configuration file for [`git-cliff`](https://github.com/orhun/git-cliff)
2 | # See https://git-cliff.org/docs/configuration
3 |
4 | [changelog]
5 | header = """
6 | # Changelog
7 |
8 | All notable changes to this project will be documented in this file.
9 |
10 | The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
11 | and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).\n
12 | """
13 | # https://tera.netlify.app/docs/#introduction
14 | body = """
15 | {% if version %}\
16 | ## [{{ version | trim_start_matches(pat="v") }}](https://github.com/foundry-rs/foundry-fork-db/releases/tag/v{{ version | trim_start_matches(pat="v") }}) - {{ timestamp | date(format="%Y-%m-%d") }}
17 | {% endif %}\
18 | {% for group, commits in commits | group_by(attribute="group") %}
19 | ### {{ group | title }}
20 | {% for commit in commits %}
21 | - {% if commit.scope %}[{{ commit.scope }}] {% endif %}{{ commit.message | upper_first | split(pat="\\n") | first }}\
22 | {% endfor %}
23 | {% endfor %}\n
24 | """
25 | trim = true
26 | footer = ""
27 |
28 | [git]
29 | conventional_commits = true
30 | filter_unconventional = false
31 | commit_preprocessors = [
32 | { pattern = '#(\d+)', replace = "[#$1](https://github.com/foundry-rs/foundry-fork-db/issues/$1)" },
33 | ]
34 | commit_parsers = [
35 | { message = "^[Ff]eat", group = "Features" },
36 | { message = "^[Ff]ix", group = "Bug Fixes" },
37 | { message = "^[Dd]oc", group = "Documentation" },
38 | { message = ".*\\b([Dd]eps|[Dd]ependencies|[Bb]ump)\\b", group = "Dependencies" },
39 | { message = "^[Pp]erf", group = "Performance" },
40 | { message = "^[Rr]efactor", group = "Refactor" },
41 | { message = ".*\\b([Ss]tyle|[Ff]mt|[Ff]ormat)\\b", group = "Styling" },
42 | { message = "^[Tt]est", group = "Testing" },
43 | { message = "^[Cc]hore", group = "Miscellaneous Tasks" },
44 |
45 | { message = ".*", group = "Other" },
46 | ]
47 | protect_breaking_commits = false
48 | filter_commits = false
49 | tag_pattern = "v[0-9]*"
50 | skip_tags = "beta|alpha"
51 | ignore_tags = "rc"
52 | sort_commits = "newest"
53 |
--------------------------------------------------------------------------------
/clippy.toml:
--------------------------------------------------------------------------------
1 | msrv = "1.83"
2 |
--------------------------------------------------------------------------------
/deny.toml:
--------------------------------------------------------------------------------
1 | [advisories]
2 | version = 2
3 | yanked = "warn"
4 | ignore = [
5 | # https://github.com/dtolnay/paste
6 | "RUSTSEC-2024-0436",
7 | ]
8 |
9 | [bans]
10 | multiple-versions = "warn"
11 | wildcards = "deny"
12 | highlight = "all"
13 |
14 | [licenses]
15 | confidence-threshold = 0.9
16 | # copyleft = "deny"
17 |
18 | allow = [
19 | "MIT",
20 | "MIT-0",
21 | "Apache-2.0",
22 | "Apache-2.0 WITH LLVM-exception",
23 | "BSD-2-Clause",
24 | "BSD-3-Clause",
25 | "ISC",
26 | "Unicode-DFS-2016",
27 | "Unicode-3.0",
28 | "Unlicense",
29 | "MPL-2.0",
30 | "Zlib",
31 | # https://github.com/briansmith/ring/issues/902
32 | "LicenseRef-ring",
33 | # https://github.com/briansmith/webpki/issues/148
34 | "LicenseRef-webpki",
35 | ]
36 |
37 | exceptions = [
38 | # CC0 is a permissive license but somewhat unclear status for source code
39 | # so we prefer to not have dependencies using it
40 | # https://tldrlegal.com/license/creative-commons-cc0-1.0-universal
41 | { allow = ["CC0-1.0"], name = "tiny-keccak" },
42 | { allow = ["CC0-1.0"], name = "aurora-engine-modexp" },
43 | { allow = ["CC0-1.0"], name = "secp256k1" },
44 | { allow = ["CC0-1.0"], name = "secp256k1-sys" },
45 | ]
46 |
47 | [[licenses.clarify]]
48 | name = "ring"
49 | expression = "LicenseRef-ring"
50 | license-files = [{ path = "LICENSE", hash = 0xbd0eed23 }]
51 |
52 | [[licenses.clarify]]
53 | name = "webpki"
54 | expression = "LicenseRef-webpki"
55 | license-files = [{ path = "LICENSE", hash = 0x001c7e6c }]
56 |
57 | [sources]
58 | unknown-registry = "deny"
59 | unknown-git = "deny"
60 |
--------------------------------------------------------------------------------
/release.toml:
--------------------------------------------------------------------------------
1 | # Configuration file for [`cargo-release`](https://github.com/crate-ci/cargo-release)
2 | # See: https://github.com/crate-ci/cargo-release/blob/master/docs/reference.md
3 |
4 | allow-branch = ["main"]
5 | sign-commit = true
6 | sign-tag = true
7 | shared-version = true
8 | pre-release-commit-message = "chore: release {{version}}"
9 | tag-prefix = "" # tag only once instead of per every crate
10 | pre-release-hook = ["sh", "-c", "$WORKSPACE_ROOT/scripts/changelog.sh --tag {{version}}"]
11 |
--------------------------------------------------------------------------------
/rustfmt.toml:
--------------------------------------------------------------------------------
1 | reorder_imports = true
2 | use_field_init_shorthand = true
3 | use_small_heuristics = "Max"
4 |
5 | # Nightly
6 | max_width = 100
7 | comment_width = 100
8 | imports_granularity = "Crate"
9 | wrap_comments = true
10 | format_code_in_doc_comments = true
11 | doc_comment_code_block_width = 100
12 | format_macro_matchers = true
13 |
--------------------------------------------------------------------------------
/scripts/changelog.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -e -o pipefail
3 |
4 | root=$(dirname "$(dirname "$0")")
5 | cmd=(git cliff --workdir "$root" --output "$root/CHANGELOG.md" "$@")
6 |
7 | if [ "$DRY_RUN" = "true" ]; then
8 | echo "skipping due to dry run: ${cmd[*]}" >&2
9 | exit 0
10 | else
11 | "${cmd[@]}"
12 | fi
--------------------------------------------------------------------------------
/scripts/check_no_std.sh:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env bash
2 | set -eo pipefail
3 |
4 | no_std_packages=(
5 | )
6 |
7 | for package in "${no_std_packages[@]}"; do
8 | cmd="cargo +stable build -p $package --target riscv32imac-unknown-none-elf --no-default-features"
9 | if [ -n "$CI" ]; then
10 | echo "::group::$cmd"
11 | else
12 | printf "\n%s:\n %s\n" "$package" "$cmd"
13 | fi
14 |
15 | $cmd
16 |
17 | if [ -n "$CI" ]; then
18 | echo "::endgroup::"
19 | fi
20 | done
21 |
--------------------------------------------------------------------------------
/src/backend.rs:
--------------------------------------------------------------------------------
1 | //! Smart caching and deduplication of requests when using a forking provider.
2 |
3 | use crate::{
4 | cache::{BlockchainDb, FlushJsonBlockCacheDB, MemDb, StorageInfo},
5 | error::{DatabaseError, DatabaseResult},
6 | };
7 | use alloy_primitives::{keccak256, Address, Bytes, B256, U256};
8 | use alloy_provider::{
9 | network::{AnyNetwork, AnyRpcBlock, AnyRpcTransaction},
10 | Provider,
11 | };
12 | use alloy_rpc_types::BlockId;
13 | use eyre::WrapErr;
14 | use futures::{
15 | channel::mpsc::{unbounded, UnboundedReceiver, UnboundedSender},
16 | stream::Stream,
17 | task::{Context, Poll},
18 | Future, FutureExt,
19 | };
20 | use revm::{
21 | database::DatabaseRef,
22 | primitives::{
23 | map::{hash_map::Entry, AddressHashMap, HashMap},
24 | KECCAK_EMPTY,
25 | },
26 | state::{AccountInfo, Bytecode},
27 | };
28 | use std::{
29 | collections::VecDeque,
30 | fmt,
31 | future::IntoFuture,
32 | path::Path,
33 | pin::Pin,
34 | sync::{
35 | mpsc::{channel as oneshot_channel, Sender as OneshotSender},
36 | Arc,
37 | },
38 | };
39 |
40 | /// Logged when an error is indicative that the user is trying to fork from a non-archive node.
41 | pub const NON_ARCHIVE_NODE_WARNING: &str = "\
42 | It looks like you're trying to fork from an older block with a non-archive node which is not \
43 | supported. Please try to change your RPC url to an archive node if the issue persists.";
44 |
45 | // Various future/request type aliases
46 |
47 | type AccountFuture =
48 | Pin, Address)> + Send>>;
49 | type StorageFuture = Pin, Address, U256)> + Send>>;
50 | type BlockHashFuture = Pin, u64)> + Send>>;
51 | type FullBlockFuture = Pin<
52 | Box, Err>, BlockId)> + Send>,
53 | >;
54 | type TransactionFuture =
55 | Pin, B256)> + Send>>;
56 |
57 | type AccountInfoSender = OneshotSender>;
58 | type StorageSender = OneshotSender>;
59 | type BlockHashSender = OneshotSender>;
60 | type FullBlockSender = OneshotSender>;
61 | type TransactionSender = OneshotSender>;
62 |
63 | type AddressData = AddressHashMap;
64 | type StorageData = AddressHashMap;
65 | type BlockHashData = HashMap;
66 |
67 | struct AnyRequestFuture {
68 | sender: OneshotSender>,
69 | future: Pin> + Send>>,
70 | }
71 |
72 | impl fmt::Debug for AnyRequestFuture {
73 | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
74 | f.debug_tuple("AnyRequestFuture").field(&self.sender).finish()
75 | }
76 | }
77 |
78 | trait WrappedAnyRequest: Unpin + Send + fmt::Debug {
79 | fn poll_inner(&mut self, cx: &mut Context<'_>) -> Poll<()>;
80 | }
81 |
82 | /// @dev Implements `WrappedAnyRequest` for `AnyRequestFuture`.
83 | ///
84 | /// - `poll_inner` is similar to `Future` polling but intentionally consumes the Future