Conversation
+ sniff into file
|
Caution Review failedThe pull request is closed. ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughAdds file-based transaction sourcing and dumping to the chain-stresser: new Changes
Sequence Diagram(s)sequenceDiagram
participant CLI
participant Sniffer
participant File
participant RPC
participant Stresser
CLI->>Sniffer: start (cfg: FromFile/ToFile/RPC)
alt FromFile set (replay from file)
Sniffer->>File: open FromFile (read)
loop read batches
Sniffer->>File: read length-prefixed txs
Sniffer->>Stresser: emit virtual block (txs)
end
Sniffer->>CLI: Done / EOF
else ToFile set (dump to file)
Sniffer->>RPC: poll blocks
loop for each block
RPC->>Sniffer: block with txs
Sniffer->>File: write length-prefixed txs (processBlock)
end
Sniffer->>CLI: Done / stopped
else Realtime replay (no files)
Sniffer->>RPC: poll blocks
loop for each block
RPC->>Sniffer: block with txs
Sniffer->>Stresser: emit block for replay
end
end
Estimated code review effort🎯 4 (Complex) | ⏱️ ~45 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
There was a problem hiding this comment.
Actionable comments posted: 3
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@cmd/chain-stresser/main.go`:
- Around line 572-575: The dump-only branch currently waits for <-sniffer.Done()
and returns nil, which masks sniffer failures; after waiting on sniffer.Done()
check sniffer.Errors() and if it returns a non-nil error return that error
instead of nil so failures (e.g., exhausted RPC retries) propagate; update the
branch that checks replayCfg.ToFile and uses sniffer.Done() to inspect
sniffer.Errors() and return it when present.
In `@replay/sniffer.go`:
- Around line 125-140: The code that builds a virtual block from s.cfg.FromFile
uses a nil block sentinel when no txs are read, but because EndHeight==0 the
outer loop never exits; instead of setting block = nil when len(block.Txs) == 0,
stop the producer loop immediately: when readTxFromFile yields no txs (len==0),
break out of the surrounding production loop or return from the producing method
so Done() can close cleanly; adjust the logic around
BlockFromFileTxNum/readTxFromFile to return/terminate rather than relying on a
nil block sentinel.
- Around line 207-229: In readTxFromFile (method on Sniffer) replace the two raw
s.txsFile.Read calls with io.ReadFull to ensure buffers are completely filled
and check the returned error; treat a zero-byte length read as io.EOF and
propagate other read errors; validate the decoded uint64 length against a
reasonable maximum (e.g., a configured MaxTxSize or a constant) before
allocating txnBuf to avoid unbounded allocations, then use io.ReadFull to read
the txnBuf and return any read errors instead of ignoring them.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: defaults
Review profile: CHILL
Plan: Pro
Run ID: 80f96cc8-f627-4421-8e5c-3433dd5d9602
📒 Files selected for processing (4)
cmd/chain-stresser/main.goreplay/replay.goreplay/sniffer.gostresser.go
💤 Files with no reviewable changes (1)
- stresser.go
Adds two more flags to
tx-replaycommand:--from-filefilepath to read sniffed txs from. If omitted, will sniff txs from RPC in realtime.--to-filefilepath to store sniffed txs into. If omitted, will replay sniffed txs in realtime.When replaying from file, we batch txs into blocks by 100 tx each.
Summary by CodeRabbit
New Features
Bug Fixes