-
Notifications
You must be signed in to change notification settings - Fork 75
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
all: add support for new state expiration ledger entries #913
Conversation
d9e0051
to
22f0dd5
Compare
22f0dd5
to
0e414da
Compare
To reviewers: Given the tight deadline for the testnet release, please let's not get picky with stuff which wouldn't be a problem in production. It's fine to note it as a comment and create separate tickets, but let's not block the PR. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As you've already identified yourself, querying both the ledgerEntry and it's corresponding ledgerExpirationEntry would be better done on the go side; I think that a good starting point for that would be adding an optional expiration ledger sequence to the LedgerKeyAndEntry
data structure.
Also - we could use some clarification from core whether the access to the expiration ledger entry is counted as an additional entry access or not. ( it might be a special case ).
I doubt it since the host doesn't track them and AFAIU otherwise integration tests wouldn't had worked. But this is a question for @sisuresh |
2200d2f
to
315b6b1
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that one thing that is missing is the deletion of EvictedTemporaryLedgerKeys.
These need to be deleted as soon as they become stale, since temporary entries could not be restored.
Yes, that's why I had created #914 |
I think that it shouldn't be a testnet blocker here, but we should add some type of validation when inserting the ledger entries into the database to ensure that we always have "pairs" of entry + expiration. |
This is Core's responsibility, I don't think we should be testing the metadata. Regardless, please create a separate ticket if you think this is important and let's get this merged. |
Accessing the |
} => match executable { | ||
ContractExecutable::Token => { | ||
// TODO/FIXME: I don't think it will work for token contracts, since we don't store them in the state? | ||
let res = soroban_spec::read::parse_raw(&token::StellarAssetSpec::spec_xdr()); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The spec doesn't come from the state, just the entry that points to the token contract so this does work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, I know the spec is obtained separately. What I meant is that, AFAIU, we don't store ContractInstance
entries for token contracts since the user provides no wasm.
Maybe I am wrong, though, if that's the case, can you point me where that happens?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A non Wasm contract instance still needs to store the fact that it's a token.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A non Wasm contract instance still needs to store the fact that it's a token.
Yes, but my point is that we only seem to update the state when a wasm file is provided, which doesn't for token contracts.
Thus, when invoking a token contract, the state won't have its ledger entries.
@2opremio I've created #916, which implements all the go-side code that would require to support retrieving the LedgerExpirationSeq while getting the ledger entries. I think that it would be best to fully merge your pr first before applying the other. |
I am not sure this makes sense unless we also hide the expiration ledger entries from the end user. Otherwise the expiration field is redundant. |
I wouldn't "hide" them explicitly, rather than allowing the user to explore remaining lifetime. |
I understand the motivation but What’s the point of allowing to query expiration entries if you are providing the expiration as part of the result? I would go one way or the other, otherwise it’s confusing. |
Intentionally merged with a few CLI TODOs:
|
.map(|c| c.encoded_key.len() as u32 + c.old_entry_size_bytes) | ||
.map( | ||
|c| { | ||
let mut size = c.encoded_key.len() as u32 + c.old_entry_size_bytes; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah I missed this - We no longer need to count the key. @2opremio should I open a follow up PR?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, I was aware. I will fix it later on (it's not critical for the tesnet release since it will only add some overhead in the resource estimation)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
But, if you want to open a PR, by all means! I was assuming you have enough on your plate already.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'll leave it then since it's not critical.
What
Add support for the new state expiration ledger entries,
This PR also changes
getLedgerEntries
method so that doesn't filter out expired ledger entries. It simply returns whatever is in the database.Why
Fixes #873
Known limitations
I left a few TODOs in the CLI, namely:
get_contract_spec_from_storage()
with respect to expirations since I don't think the storage book-keeps expiration ledger entries.@willemneal could you please take a look at the items above? Also, could you do some testing on the CLI once this is merged? Unfortunately, the XDR is out of sync with futurenet so you will have to use a local network.
We should probably start improving CLI testing considerably (particularly, integration tests against soroban-rpc). I wasn't comfortable fixing (2) since there were no tests covering it (AFICT).
Also, we should probably just get rid of the sandbox mode once and for all.