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(syncer,cache): use compare and swap loop and add comments (#2873)
<!--
Please read and fill out this form before submitting your PR.
Please make sure you have reviewed our contributors guide before
submitting your
first PR.
NOTE: PR titles should follow semantic commits:
https://www.conventionalcommits.org/en/v1.0.0/
-->
## Overview
Small cleanups, adding more comments to describe cache behavior.
Make sure CompareAndSwap succeeds for da height setting in cache.
<!--
Please provide an explanation of the PR, including the appropriate
context,
background, goal, and rationale. If there is an issue with this
information,
please provide a tl;dr and link the issue.
Ex: Closes #<issue number>
-->
// Start dedicated workers for DA, and pending processing
142
141
s.startSyncWorkers()
@@ -175,16 +174,6 @@ func (s *Syncer) SetLastState(state types.State) {
175
174
s.lastState.Store(&state)
176
175
}
177
176
178
-
// GetDAHeight returns the current DA height
179
-
func (s*Syncer) GetDAHeight() uint64 {
180
-
returnmax(s.daHeight.Load(), s.cache.DaHeight())
181
-
}
182
-
183
-
// SetDAHeight updates the DA height
184
-
func (s*Syncer) SetDAHeight(heightuint64) {
185
-
s.daHeight.Store(height)
186
-
}
187
-
188
177
// initializeState loads the current sync state
189
178
func (s*Syncer) initializeState() error {
190
179
// Load state from store
@@ -216,14 +205,13 @@ func (s *Syncer) initializeState() error {
216
205
}
217
206
s.SetLastState(state)
218
207
219
-
// Set DA height
220
-
// we get the max from the genesis da height, the state da height and the cache (fetched) da height
221
-
// if a user has messed up and sync da too far ahead, on restart they can clear the cache (--clear-cache) and the retrieve will restart fetching from the last known block synced and executed from DA or the set genesis da height.
// Set DA height to the maximum of the genesis start height, the state's DA height, and the cached DA height.
209
+
// This ensures we resume from the highest known DA height, even if the cache is cleared on restart. If the DA height is too high because of a user error, reset it with --evnode.clear_cache. The DA height will be back to the last highest known executed DA height for a height.
0 commit comments