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

storage: split runtime events related accounts into a separate table #809

Draft
wants to merge 3 commits into
base: main
Choose a base branch
from

Conversation

ptrus
Copy link
Member

@ptrus ptrus commented Nov 30, 2024

Fixes: #804 #786

This splits runtime_events.related_accounts into a separate table, because otherwise we are unable to support efficient queries for event related accounts ordered by round. Some more context in #804

Additionally, we need to introduce an event index (solves #786) because otherwise the new table cannot reference the existing runtime_events table, which currently has no primary key, so rows cannot be referenced uniquely.

@ptrus ptrus added the blocked Unable to proceed label Nov 30, 2024
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch 6 times, most recently from c1d59fc to 4c81c25 Compare November 30, 2024 10:19
}
}
return nil
return currIdx, nil
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This doesn't work ok with events that are currently not tracked and would be tracked in future. E.g. adding a handler for new event types would change the resulting indexes on reindex.

The index should probably be made out of 2 values (index within GetEventsRaw, and then the index within the "DecodedEvents").

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we skip events?

Copy link
Collaborator

@pro-wh pro-wh Dec 3, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

come to think of it, how do oasis-core and oasis-sdk architecturally represent events? I think they're put into a map[event_type]slice_of_events kind of structure per block or tx

Copy link
Member Author

@ptrus ptrus Dec 4, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

do we skip events?

Yeah for example rofl events are currently skipped (added in #812)

come to think of it, how do oasis-core and oasis-sdk architecturally represent events? I think they're put into a map[event_type]slice_of_events kind of structure per block or tx

Yeah that's how it is done in oasis-sdk. So maybe going with (event_type, index) pair would be the best to represent this in the db as well. (where index is the index within the events of the same type).

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

that sounds ok. I hope using a text column in the key is not too expensive

Copy link
Member Author

@ptrus ptrus Jan 28, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I went with the per block unique event indexes number (regardless of type) since that was the most straightforward. This is also internal to the DB field, so the problem i mentioned above (in case we skip events) doesn't really matter.

@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch 3 times, most recently from a73a23e to be7cc48 Compare December 23, 2024 13:59
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch 9 times, most recently from 0afd708 to 69a761f Compare January 28, 2025 13:08
@@ -344,7 +342,7 @@ func ExtractRound(blockHeader nodeapi.RuntimeBlockHeader, txrs []nodeapi.Runtime
}
// Set the 'Success' field to 'Pending' for deposits. This is because the outcome of the Deposit tx is only known in the next block.
blockTransactionData.Success = nil

blockTransactionData.RelatedAccountAddresses[to] = struct{}{}
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

oh I see. so here for example there's additional logic used in arriving at the "to" address that we want to apply before adding the "to" address to the related accounts

although we lucked out here because the signers are elsewhere added to the related accounts set

@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch from 69a761f to 5d7e7d6 Compare January 31, 2025 07:39
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch 2 times, most recently from a4b2c12 to 07b9678 Compare January 31, 2025 08:29
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch from 07b9678 to 5ca8e62 Compare January 31, 2025 12:18
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch 2 times, most recently from 5025423 to 139e84e Compare January 31, 2025 19:42
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch from 139e84e to 03f1332 Compare January 31, 2025 19:58
@ptrus ptrus removed the blocked Unable to proceed label Feb 1, 2025
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.

Querying transfers for a specific token doesn't use an index
2 participants