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

feat(analytics): consider expiring and locked outputs #1335

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

DaughterOfMars
Copy link
Collaborator

Description

This PR tracks expiring and locked outputs in the address balance analytics, so that when the milestone is eventually handled those amounts will properly be transferred or added to the appropriate address. Each output with an expiration or timelock will create a record in the maps.

However!! this has potentially serious performance implications, primarily due to the memory usage of these tracking structures, which have no bounds!.

Alternatives

Conceptually, the same process could be instead applied to the database using a tracking table, something like this:

#[derive(Serialize, Deserialize)]
struct Id {
  milestone_timestamp: MilestoneTimestamp,
  output_id: OutputId,
}

#[derive(Serialize, Deserialize)]
struct TrackingDocument {
  _id: Id,
  address: Address,
  expiration_return_address: Option<Address>,
  amount: TokenAmount,
}

The usage of this table would be much the same as the HashMaps in this PR, and we could instead pass in the records for the current milestone for each balance analytic call. Additionally, this would allow chronicle to update the owning address for records in OutputCollection and LedgerUpdateCollection per milestone, potentially dramatically improving the functionality and performance of the explorer endpoints.

Conclusion

Due to the performance concerns, I don't want to merge this PR as-is, but rather keep it as a proof-of-concept for now.

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.

1 participant