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 1 commit 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.

Because of the event index change, we would need a reindex of the runtime events.

This is blocked on either:

  • doing a full reindex
  • introducing support for more complex migrations (e.g. custom go code, which would reindex just the runtime events table)

@ptrus ptrus added the blocked Unable to proceed label Nov 30, 2024
@ptrus ptrus force-pushed the ptrus/feature/events-related-accounts branch 5 times, most recently from ba2ff6d to c1d59fc Compare November 30, 2024 10:14
return "", err
}

relatedAddresses[addr] = struct{}{}
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.

what does these now

I see that these calls are replaced with the one that only notes the preimage in the tx, message, and event visitors

the tx related accounts are now populated by combining the related accounts from the tx's events. that might work. as long as it doesn't miss anything that only shows up in the tx

how do the events' related accounts get populated

}
}
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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked Unable to proceed
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