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

Fork caching bug #2849

Closed
cptartur opened this issue Jan 14, 2025 · 0 comments · Fixed by #2857
Closed

Fork caching bug #2849

cptartur opened this issue Jan 14, 2025 · 0 comments · Fixed by #2857
Assignees
Labels
bug Something isn't working snforge

Comments

@cptartur
Copy link
Member

cptartur commented Jan 14, 2025

When using forking, fork_state_reader in

self.dict_state_reader
is used as a fallback for all dict_state_reader methods.

This is a problem because it is possible for dict_state_reader to return error for local contracts, where it doesn't make sense to fallback to fork state. For example: when calling and uninitialized storage key, dict_state_reader will return an error. Then, request to fork_state_reader will be made and only after it fails, default value will be used. This way, we are making an request to the RPC that is not cached and that doesn't make sense in the first place, because the contract is local.

Update the code to prevent not-cached request to the RPC in state.rs.

Either we do not fallback to RPC if the contract is only defined locally (could be tricky to check) or update the fork-state_reader logic to cache these kind of requests.

@cptartur cptartur converted this from a draft issue Jan 14, 2025
@github-actions github-actions bot added the new label Jan 14, 2025
@cptartur cptartur added snforge bug Something isn't working and removed new labels Jan 14, 2025
@cptartur cptartur moved this from TODO to In Progress in Starknet foundry Jan 20, 2025
github-merge-queue bot pushed a commit that referenced this issue Jan 20, 2025
<!-- Reference any GitHub issues resolved by this PR -->

Closes #2849

## Introduced changes

<!-- A brief description of the changes -->

Update the logic of `ForkStateReader` - if we receive
`StarknetError::ContractNotFound`, we additionaly cache such request.

## Checklist

<!-- Make sure all of these are complete -->

- [x] Linked relevant issue
- [x] Updated relevant documentation
- [x] Added relevant tests
- [x] Performed self-review of the code
- [x] Added changes to `CHANGELOG.md`

---------

Co-authored-by: ddoktorski <[email protected]>
@github-project-automation github-project-automation bot moved this from In Progress to Done in Starknet foundry Jan 20, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working snforge
Projects
Status: Done
Development

Successfully merging a pull request may close this issue.

2 participants