fuzz, txncache: add transaction cache fuzzer#10303
Open
two-heart wants to merge 1 commit into
Open
Conversation
Prompt To Fix All With AIThis is a comment left during a code review.
Path: src/flamenco/runtime/fuzz_txncache_fork_graph.c
Line: 129
Comment:
**Missing `seed` argument to `fd_txncache_shmem_new`**
`fd_txncache_shmem_new` takes 4 parameters (`shmem`, `max_live_slots`, `max_txn_per_slot`, `seed`), but this call only passes 3. Every other call site in the codebase (e.g. `test_txncache.c`, `fd_svm_mini.c`) passes `0UL` as the seed. This will cause a compilation error.
```suggestion
fd_txncache_shmem_t * shtc = fd_txncache_shmem_join( fd_txncache_shmem_new( fuzz_shmem, max_live_slots, max_txn_per_slot, 0UL ) );
```
How can I resolve this? If you propose a fix, please make it concise.
---
This is a comment left during a code review.
Path: src/flamenco/runtime/fuzz_txncache_fork_graph.c
Line: 836-838
Comment:
**Wrong fork_id passed to `fd_txncache_insert`**
`fd_txncache_insert`'s first fork argument is the *executing* fork (the fork the transaction ran on), not the ancestor holding the blockhash. Here `block_fork_id` (the ancestor) is passed instead of `fork_id` (the executing fork).
This causes two problems:
1. If `block_fork` is `FORK_FINAL` (frozen==2), the assertion `FD_TEST( fork->shmem->frozen<=1 )` inside `fd_txncache_insert` will fire.
2. If `block_fork` is `FORK_HASHED` (frozen==1), the transaction is stored with the wrong `fork_id`, causing model/target query mismatches since the model records `txn_fork = fork_id` while the target stores `fork_id = block_fork`.
Compare with `model_insert_one` (line 859) which correctly passes `fork_id`:
```suggestion
fd_txncache_insert( m->tc, (fd_txncache_fork_id_t){ .val = fork_id }, m->fork[ block_fork ].blockhash.uc, txnhash->uc );
```
How can I resolve this? If you propose a fix, please make it concise.Reviews (1): Last reviewed commit: "fuzz, txncache: add transaction cache fu..." | Re-trigger Greptile |
067ca6b to
31b2dca
Compare
Keeps a model to track invariants. Finds firedancer-io#9517
31b2dca to
66cee3e
Compare
|
Reviews (2): Last reviewed commit: "fuzz, txncache: add transaction cache fu..." | Re-trigger Greptile |
|
|
||
| for( ulong action_idx=0UL; action_idx<FUZZ_MAX_ACTIONS && cur.rem; action_idx++ ) { | ||
| switch( fuzz_u8( &cur ) & 15U ) { | ||
| case 0U: |
Contributor
There was a problem hiding this comment.
I assume this is supposed to model a probability distribution?
intrigus-lgtm
left a comment
Contributor
There was a problem hiding this comment.
Any reason to not move check_invariants to the txncache directly as e.g. done for fd_rdisp or fd_forest?
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Keeps a model to track invariants. Finds #9517