fix(kona): ensure chain_id is always set for trie hints in interop provider#20164
fix(kona): ensure chain_id is always set for trie hints in interop provider#20164
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## develop #20164 +/- ##
===========================================
Coverage 76.7% 76.8%
===========================================
Files 691 508 -183
Lines 76359 65817 -10542
===========================================
- Hits 58584 50559 -8025
+ Misses 17631 15258 -2373
+ Partials 144 0 -144
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
820ffdc to
b8df94c
Compare
e9f12b0 to
a84314d
Compare
b8df94c to
ad2f78a
Compare
If header_by_hash() is called before header_by_number(), the chain_id field is never set, causing all subsequent TrieHinter calls to emit hints without a chain_id. Extract a set_chain_id() method (matching the non-interop provider pattern) and call it from both header_by_hash() and header_by_number(). Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Replace the `Arc<RwLock<Option<u64>>>` chain_id field on OracleInteropProvider with an explicit ChainScopedHinter wrapper. This eliminates hidden mutable state and makes the chain ID binding explicit at each call site. The ChainScopedHinter borrows the oracle and holds a fixed chain_id, implementing TrieHinter with that chain_id always set. The provider's scoped_hinter() method creates instances as needed. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
ad2f78a to
8de77c3
Compare
digorithm
left a comment
There was a problem hiding this comment.
Very clean! Is this worth adding a regression test (since it was a Cantina finding)? I'm ok either way given that the scope is small and now this is strictly enforced by the type system.
|
It always worked and we have tests that effectively guarantee it work because otherwise interop can't supply the required preimages. So I don't think we need more testing, it just makes it a lot easier to understand where the chain ID in hints comes from. |
Summary
Fixes a bug where
OracleInteropProvidercould emitTrieHinterhints without achain_idwhenheader_by_hash()was called beforeheader_by_number(). Then refactors to eliminate the hidden mutable state so the bug class cannot recur.Context
Cantina audit finding.
Fixes ethereum-optimism/optimism-private#502
Originally opened privately as ethereum-optimism/optimism-private#523 (fix) and ethereum-optimism/optimism-private#526 (refactor); moved to the public repo as a combined PR on top of #20163.