Closed yanliu18 closed 3 months ago
Thanks @yanliu18 for reporting this issue. Indeed some of the terminologies defined can be a little confusing. You've brought up a couple good points worth clarifying:
new_live_until
is treating the input as "extend by" (not including the current ledger) where as the li.max_entry_ttl
is being treated as number of ledgers to live including the current ledger. Temporary
entry cannot be attempted to be extended past the ledger max, it throws error instead of being clamped to the max. This was an intentional design (@dmkozh gave a good explanation here) but it's worth clarifying in the documentation.Although not a protocol bug, I think both of these points worth being clarified via better documentation, I will open a PR to do so.
The SDK has already been updated to make sure the max_entry_ttl
getter takes care of the boundary offset: https://github.com/stellar/rs-soroban-sdk/pull/1269, so that user can't trigger the error using it.
Thanks @yanliu18 for reporting this issue. Indeed some of the terminologies defined can be a little confusing. You've brought up a couple good points worth clarifying:
- The internal logic for calculating
new_live_until
is treating the input as "extend by" (not including the current ledger) where as theli.max_entry_ttl
is being treated as number of ledgers to live including the current ledger.- The
Temporary
entry cannot be attempted to be extended past the ledger max, it throws error instead of being clamped to the max. This was an intentional design (@dmkozh gave a good explanation here) but it's worth clarifying in the documentation.Although not a protocol bug, I think both of these points worth being clarified via better documentation, I will open a PR to do so. The SDK has already been updated to make sure the
max_entry_ttl
getter takes care of the boundary offset: stellar/rs-soroban-sdk#1269, so that user can't trigger the error using it.
Thank you @jayz22 for addressing this issue and reply to us. The changes look good. I shall let our team and clients know about this update.
What version are you using?
20.1.0
What did you do?
Formal Auditting for Client Code https://github.com/stellar/rs-soroban-env/blob/36d33cb6c986c9a8a9200b7eb04cf02e2c3f0ef4/soroban-env-host/src/storage.rs#L382
When call to the
extend_ttl()
function in host/storage, when the function parameterextend_to
=li.max_entry_ttl
(li.max_entry_ttl
=host.with_ledger_info(|li| li.max_entry_ttl)
) and parameterkey
matchesContractData(LedgerKeyContractData {_, _, StorageType::Temporal, })
, the call toextend_ttl
will always return an error.This is because of the following condition checking where,
new_live_until
=li_sequece_number
+ extend_tohost.max_live_until_ledger()
=li_sequece_number
+ li.max_entry_ttl - 1 will always go to theelse
branch. https://github.com/stellar/rs-soroban-env/blob/36d33cb6c986c9a8a9200b7eb04cf02e2c3f0ef4/soroban-env-host/src/storage.rs#L436-L446What did you expect to see?
Though it is rare for a contract instance to set its temporal stroage to the exisiting max livable ledger sequence, it is still possible. Maybe it is reasonable to calculate the
new_live_until
in the same way as themax_live_live_until_ledger
.