Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

State syncer mempool syncing and test suite updates #1442

Open
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

lazynina
Copy link
Member

No description provided.

@superzordon superzordon changed the title Z/testing suite State syncer mempool syncing and test suite updates Mar 3, 2025
@superzordon superzordon marked this pull request as ready for review March 3, 2025 19:38
@superzordon superzordon requested a review from a team as a code owner March 3, 2025 19:38
Copy link
Member Author

@lazynina lazynina left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Overall looks great!

lib/db_utils.go Outdated
// We check if we've already read this key and stored it in the cache.
// Otherwise, we fetch the current value of this record from the DB.
ancestralValue, getError = DBGetWithTxn(txn, snap, key)
if isState || (isCoreState && eventManager != nil && eventManager.isMempoolManager) {
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if isState || (isCoreState && eventManager != nil && eventManager.isMempoolManager) {
if isState || (eventManager != nil && eventManager.isMempoolManager && isCoreStateKey(key)) {

This is very minor, but we can avoid the extra call to isCoreStateKey if we reorder this and check the event manager first.

Also can we add a comment about why we check for isCoreState here? something like If this is a coreState prefix and running a state syncer that is syncing mempool/uncommitted state, we need to get the last committed value for this badger key.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

addressed in #1447 (comment/documentation still should be addressed).

// Decode the ancestral record.
ancestralRecord, err := DecodeStateKey(stateChangeEntry.KeyBytes, stateChangeEntry.AncestralRecordBytes)
if err != nil {
glog.Fatalf("Server._handleStateSyncerOperation: Error decoding ancestral record: %v", err)
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fatal is going to kill the node if we hit this error. Are we sure that's what we want?

Comment on lines +470 to +471
stateChangeEntry.AncestralRecord = ancestralRecord
stateChangeEntry.AncestralRecordBytes = nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why do we set AncestralRecordBytes to nil?

@@ -899,77 +911,45 @@ func (stateChangeSyncer *StateChangeSyncer) SyncMempoolToStateSyncer(server *Ser
startTime = time.Now()
glog.V(2).Infof("Mempool synced len after flush: %d", len(stateChangeSyncer.MempoolSyncedKeyValueMap))

//Check to see if every txn hash in our cached txns is in the first n txns in the mempool.
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Love that we're getting rid of this cache in here.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants