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

Rewrite state loading path on startup #4166

Merged
merged 2 commits into from
Feb 13, 2024

Conversation

marta-lokhova
Copy link
Contributor

Resolves #4163

Verified

This commit was signed with the committer’s verified signature. The key has expired.
@marta-lokhova marta-lokhova requested review from dmkozh, SirTyson and graydon and removed request for dmkozh and SirTyson January 29, 2024 17:00
Copy link
Contributor

@SirTyson SirTyson left a comment

Choose a reason for hiding this comment

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

Thanks for this refactor, cleans up the interface a ton! Looks good, just a few nits.

@@ -147,8 +147,8 @@ class LedgerManager
virtual void startNewLedger() = 0;

// loads the last ledger information from the database
// if handler is set, also loads bucket information and invokes handler.
virtual void loadLastKnownLedger(std::function<void()> handler) = 0;
virtual void loadLastKnownLedger(bool startServices,
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: It would be helpful to add what the parameters mean to this comment. startServices is pretty clear, ledgerStateReady is not obvious unless you read the implementation. Maybe slightly rewording to isLedgerStateReady would help as well.

}
};
mLedgerManager->loadLastKnownLedger(loadConfig);
mLedgerManager->loadLastKnownLedger(false, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

Nit: add /*startSevices=*/ and /*ledgerStateReady=*/ so we don't have back to back to back raw bools. Applies in a few other places as well.


while (!done && mVirtualClock.crank(true))
Copy link
Contributor

Choose a reason for hiding this comment

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

Wow this old interface was.... not good


// Step 3. Restore BucketList if we're doing a full core startup
// (startServices=true), OR when using BucketListDB
if (startServices || mApp.getConfig().EXPERIMENTAL_BUCKETLIST_DB)
Copy link
Contributor

@SirTyson SirTyson Feb 5, 2024

Choose a reason for hiding this comment

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

We should never check the raw flag, use getConfig().isUsingBucketListDB() instead.

}
handler();
// Work should only fail during graceful shutdown
releaseAssert(mApp.isStopping());
Copy link
Contributor

Choose a reason for hiding this comment

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

Should this be releaseAssertOrThrow?

@marta-lokhova
Copy link
Contributor Author

Thanks for this refactor, cleans up the interface a ton! Looks good, just a few nits.

Addressed your feedback. Thanks for reviewing!

}
}

// Step 3. Restore LedgerManager's internal state
Copy link
Contributor

Choose a reason for hiding this comment

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

Step 4?

return;
}

// Step 4. If ledger state is ready and core is in v20, load network configs
Copy link
Contributor

Choose a reason for hiding this comment

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

Step 5

// In some modes, e.g. in-memory, core's state is rebuilt asynchronously via
// catchup. In this case, we're not able to load the network config at this
// time, and instead must let catchup do it when ready.
if (!isLedgerStateReady)
Copy link
Contributor

Choose a reason for hiding this comment

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

I would rather change this to positive condition (i.e. if (isLedgerStateReady) { loadConfig() } else { LOG(...) } and get rid of the early return (it seems quite easy to forget about it and accidentally skip some logic independent of the config loading).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

ok, updated (fixed comments too)

Verified

This commit was signed with the committer’s verified signature. The key has expired.
@dmkozh
Copy link
Contributor

dmkozh commented Feb 13, 2024

r+ b57d301

@latobarita latobarita merged commit 17eb4cb into stellar:master Feb 13, 2024
15 checks passed
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.

Ledger state loading path on startup needs to be re-written
4 participants