You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
refactor: extract state sync logic from Chain (#12833)
Main result: number of LoC in `chain/chain/src/chain.rs` goes from 4690
to 4125.
Please let me know if you want me to split this in multiple PRs. I can
do this but I'm very tempted to just go forward because there are no
functional changes...
### Biggest part (568+ lines)
It is moving state sync-related methods from `chain/chain/src/chain.rs`
to `chain/chain/src/state_sync/adapter.rs`. This is achieved by creating
`ChainStateSyncAdapter` which needs access to much less data than
`Chain`.
### Another change (156+ lines)
To achieve the previous one, I wanted to read chain data from
`ChainStoreAdapter`, not `ChainStore`. We are currently refactoring
`ChainStore` and I didn't want to create new instances of it. We can
allow read-only access to data which already exist in storage.
For this, in turn, I needed to make `get_chunk_clone_from_header`,
`get_block_header_on_chain_by_height` and
`get_incoming_receipts_for_shard` require only `ChainStoreAdapter`
access. I was able to move these to `chain/chain/src/store/utils.rs`
without changing logic.
Another bit of context: these methods previously required
`ChainStoreAccess` in order to be queried by `ChainStoreUpdate`. But as
@shreyan-gupta discovered, we don't actually need that, at least in
almost all places of the code. So it was natural to me to simplify
access to these functions already.
### Bonus
It was very easy to move `get_state_sync_info` to `ShardTracker` and
`StateRequestTracker` to new state sync folder - a nice example of
hiding implementation details.
0 commit comments