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

Move expiration enforcement to OpFrame level #3857

Merged
merged 8 commits into from
Jul 31, 2023

Conversation

SirTyson
Copy link
Contributor

Description

Resolves #3854 and #3850.

This change moves state expiration enforcement to the InvokeHostFunctionOpFrame level. By doing so, the database and "ledger state" is agnostic to expiration semantics. This simplifies BucketList invariants and makes it easier for downstream systems to ingest state related meta. This resolves the issue that crashed preview 10.

This PR also adds more state expiration unit tests.

Checklist

  • Reviewed the contributing document
  • Rebased on top of master (no merge commits)
  • Ran clang-format v8.0.0 (via make format or the Visual Studio extension)
  • Compiles
  • Ran all tests
  • If change impacts performance, include supporting evidence per the performance document

Copy link
Contributor

@dmkozh dmkozh left a comment

Choose a reason for hiding this comment

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

Looks fine overall, but shouldn't we also update the bump op as well to only bump live entries?

@sisuresh
Copy link
Contributor

Looks fine overall, but shouldn't we also update the bump op as well to only bump live entries?

Yeah this is a good catch. This PR switches load from returning live entries to all entries, so the bump op in this PR now allows bumps to expired entries. We need to audit every load call that can load a soroban entry and make sure the logic makes sense.

@@ -1300,8 +1300,7 @@ ConfigUpgradeSetFrameConstPtr
ConfigUpgradeSetFrame::makeFromKey(AbstractLedgerTxn& ltx,
ConfigUpgradeSetKey const& key)
{
auto ltxe = ltx.loadWithoutRecord(ConfigUpgradeSetFrame::getLedgerKey(key),
/*loadExpiredEntry=*/false);
auto ltxe = ltx.loadWithoutRecord(ConfigUpgradeSetFrame::getLedgerKey(key));
Copy link
Contributor

Choose a reason for hiding this comment

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

This is interesting... we don't check if the entry is live here, so we can technically upgrade using an expired entry. Should we keep this as is for more flexibility? Or should we make sure the entry is live? Checking that it's live sounds more consistent. cc @dmkozh.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I don't have a great understanding of the upgrade system, but allowing anything to use an expired entry seems very sketchy (except for restoreOp of course). I think we should add a isLive check here.

Copy link
Contributor

Choose a reason for hiding this comment

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

Yeah, I don't think we should need exceptions to the rules.

@@ -720,7 +720,7 @@ CommandHandler::getLedgerEntry(std::string const& params, std::string& retStr)

LedgerKey k;
fromOpaqueBase64(k, key);
auto le = ltx.loadWithoutRecord(k, /*loadExpiredEntry=*/false);
Copy link
Contributor

Choose a reason for hiding this comment

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

This command will now return expired entries, when it previously didn't . I'm guessing returning expired entries is what we want, but want to make sure we didn't have a good reason for ignoring them in the first place.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This should return expired entries. This is used for services like soroban-rpc to track state, and it would be helpful for these systems to know about expired entries. This not returning expired entries before was a bug.

@sisuresh
Copy link
Contributor

r+ 0ad2053

@latobarita latobarita merged commit 7e3b6f8 into stellar:master Jul 31, 2023
8 checks passed
This was referenced Jul 31, 2023
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.

Move state expiration enforcement from LedgerTxn to TransactionFrame level
4 participants