#Is the expiration ledger inclusive or exclusive?
49 messages · Page 1 of 1 (latest)
I expect the data would still be usable in ledger N, and would become unusable in ledger N+1, because it's more natural – speaking subjectively – to speak about periods of validity where the end is through / inclusive, rather than speak about periods of validity by specifying a value past the end of the validity.
It looks like we're using an exclusive meaning for expiration in at least one place: https://github.com/stellar/rs-soroban-env/pull/887/files#diff-adeeb34b699fbce9227100154b5e91e9432003481833fb1e20695f702d2466ebR15. I wasn't sure if it was unique to that case, or how all expiration works. I'll comment on the PR about it.
also, another question on the same topic: if I create a default persistent entry on ledger N, then is expiration ledger N+4096 or N + 4095, i.e. do we count the current ledger when computing the bump ledger?
I thought it was mentioned somewhere that the entry becomes inaccessible on the expiration ledger. It looks like @rare parrot's PR follows this as well https://github.com/stellar/stellar-core/pull/3791/files#diff-6c88e81a3ed31b544e02ec00a74c0e5c7ef2f8f84135097dc10a0eac146a7dfdR116.
Correct, entry is live iff currentLedger < expirationLedger, entry is expired iff currentLedger >= expirationLedger according to my core PRs
My thinking is that the entry expires exactly on the expirationLedger, not after
ugh
we need to fix this for auth then
though maybe we should treat it inclusive
I agree with Leigh that exclusive boundaries are easier to mess up
Well, exclusive ranges are really good in a lot of places though, like slicing data, bounds on arrays, etc.
I'm not married to this either, it's just what I've been doing
But when I think natural world examples of expiry, usually expiry is really defining a validity period.
E.g. credit card are valid in the month they expire.
E.g. passports are valid on the date they expire.
what about my other question btw?
as we all know, off-by-one errors are one of the two hardest problems in software...
E.g. drivers licenses (in California at least) are valid on the date they exipre.
I believe it's N+4096 because applyExpirationBumps in core uses the ledger num for the last closed ledger.
but since it's exclusive, the entry will live 4095 more ledgers, right?
Where N is the ledger before your tx was applied
hmm, that's actually interesting
do we pass LCL or 'current' ledger to contracts?
I think we should do current
the same goes for the time
Yeah I was just looking into this. I think there's a bug in either this code, or the bumpm/restore ops
the ops use ltx.loadHeader().current().ledgerSeq, which is the ledger being applied
Yeah we bump before applying transactions - https://github.com/stellar/stellar-core/blob/fae91b0920c8cacb56707de45058a0ac884d0cc4/src/ledger/LedgerManagerImpl.cpp#L679C7-L679C13
ok, cool
so the entry will live for 4096 ledgers counting the one when it was created... which seems ok
Well no that's the issue, the autobump/minimum enforcement code uses https://github.com/stellar/stellar-core/blob/fae91b0920c8cacb56707de45058a0ac884d0cc4/src/transactions/TransactionFrame.cpp#L1615
Which uses the last closed ledger
Unless I'm reading this wrong
Yeah I'm thinking that line should be updated to use the current ledger num
@rare parrot what do you think about using the current ledger in applyExpirationBumps?
Sounds fine, current ledger is lcl + 1 right?
Yeah it's also what's stored in ltx.loadHeader().current() during transaction application which is what we use in the bump/restore ops and pass to the host.
So did we come to consensus on if it should be inclusive vs exclusive? @tawdry portal?
I haven't been able to think of a real world situation of something that expires, and isn't usable on the expiry date.
that also needs to be consistent with approve and signature expiration
Ok I think inclusive makes sense and should be easy to switch. @rare parrot can update the logic in in his PR, and I'll update the allowance PR. Any objections?
Sounds good to me, just to double check, new behavior is isEntryLive == currentLedger <= expirationLedger