-
Notifications
You must be signed in to change notification settings - Fork 16
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
fix(api): consider expiration return addresses for ledger updates #1314
Conversation
@@ -142,13 +144,26 @@ pub enum Output { | |||
|
|||
impl Output { | |||
/// Returns the [`Address`] that is in control of the output. | |||
pub fn owning_address(&self) -> Option<&Address> { | |||
pub fn owning_address(&self, spent_timestamp: impl Into<Option<MilestoneTimestamp>>) -> Option<&Address> { |
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.
Maybe I am misunderstanding something but isn't it the case that when the output is still unspent, but the latest milestone timestamp > expiration timestamp, then the owning address should already be the return address?
with the current logic the owner of an unspent output would still be the address in the address_unlock_condition despite we're passed the expiration.
so maybe this should just be a MilestoneTimestamp
as the argument and if the output is already spent, then it would be the spent_timestamp
like currently, but when the output is still unspent then this should be the latest milestone timestamp, and the logic could remain the same.
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 problem is there's simply no good way for us to do this. We would have to update all unspent outputs every milestone, which is simply not performant. Spending proves definitively who the owner is, so we just update it then. Since this is only used in the explorer routes, this is fine. The only concern I have is with analytics, because we use it for active addresses, balance, and base token activity and those calculations may possibly be wrong now.
https://chronicle-migr.stardust-mainnet.iotaledger.net/api/ This server can be used for testing the mainnet API before we commit to a migration. |
This PR changes how the owning address is calculated for spent outputs. Rather than assume the address unlock condition for basic/NFT outputs, the spent timestamp is checked against the expiration unlock condition, if it exists. Therefore, in the case where the output was spent on or after the timestamp, we use the return address to index the output.
UPDATE: Rolled the changes for the balance endpoint in as well for simplicity. The endpoint now returns
availableBalance
instead ofsigLockedBalance
and the calculation has been adjusted to include outputs with timelock conditions that have become unlocked, as well as those with matching expiration return addresses that are expired.Linked Issues
Notes to Reviewer
As a reviewer, please pay particular attention to the following areas when reviewing this PR and tick the above boxes after you have completed the steps.
API Changes
INX Changes
Database Changes