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

Remove SpentMessages table #1829

Closed

Conversation

Dentosal
Copy link
Member

@Dentosal Dentosal commented Apr 16, 2024

Work towards #1790

Depends on #1811

Removes SpentMessages table.

Checklist

  • Breaking changes are clearly marked as such in the PR description and changelog
  • New behavior is reflected in tests

Before requesting review

  • I have reviewed the code myself
  • I have created follow-up issues caused by this PR and linked them here

Before merging

  • Retarget to master

@Dentosal Dentosal self-assigned this Apr 16, 2024
@Voxelot
Copy link
Member

Voxelot commented Apr 16, 2024

are we removing spent messages due to the extra hassle of regenesis migration? We had that table to provide extra redundancy protection against double spending messages in case of any relayer hiccups. Are we just going to rely on the relayer offchain tables to track included events now? I guess this should be ok, since we pass the events through the executor now instead of letting the relayer directly update the onchain tables.

@xgreenx
Copy link
Collaborator

xgreenx commented Apr 16, 2024

are we removing spent messages due to the extra hassle of regenesis migration? We had that table to provide extra redundancy protection against double spending messages in case of any relayer hiccups. Are we just going to rely on the relayer offchain tables to track included events now?

We added the SpentMessages table for extra redundancy protection against double spending messages because we had two places that can be written into the Messages table. In the past, the relayer inserted new messages into the Messages table, and the executor removed messages from the Messages table.

However, with a new flow, the relayer writes all events into the EventsHistory table, and the executor writes and removes messages from the Messages table while increasing the da height.

The new flow provides the same protection by default because relayer hiccups/pruning no longer affect the Messages table.

/// The possible states a Message can be in
pub enum MessageState {
/// Message is still unspent
pub enum MessageStatus {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Ohh, I forgot that it affects the GraphQL API endpoint. Hmm, we need to find a way to still support this endpoint because the bridge relies on it.

Maybe we need to move this table to off-chain database instead.

Copy link
Member Author

Choose a reason for hiding this comment

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

Hmmm in that case I'm probably just going to redo the whole PR.

Comment on lines 147 to 148
tx.storage::<ProcessedTransactions>()
.insert(&transaction.key, &())?;
Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmm, this migration even shouldn't exist because we have OldTransactions for that. I think we forgot to remove it during #1811.

Hmm, it seems we need to migrate the ProcessedTransactions table instead of fetching it from OldTransactions because we can't rely on off-chain data during migration. Off-chain data migration is optional and only for nodes that want to support GraphQL API

Copy link
Member Author

Choose a reason for hiding this comment

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

#1811 is not merged yet, so we can still include that there. I'm going to remove this for now, we can do that in a separate PR if not in #1811. Removed in 435d1c6.

@Dentosal Dentosal changed the title Remove SpentMessages table; populate ProcessedTransactions on regenesis Remove SpentMessages table Apr 17, 2024
@xgreenx xgreenx closed this Apr 17, 2024
@xgreenx xgreenx deleted the dento/regenesis-spent-msgs branch April 17, 2024 12:59
xgreenx added a commit that referenced this pull request Apr 18, 2024
Re-implementation of the #1829
Work towards #1790

The change migrates the `ProcessedTransactions` table as part of the
on-chain snapshot. Since it is used to validate blocks, the root of all
processed transactions must be part of the `Genesis` structure along
with messages, coins, and contracts.

The changes also moved `SpentMessages` from the on-chain database to the
off-chain database since now it is only used for the GraphQL API.

### Before requesting review
- [x] I have reviewed the code myself

---------

Co-authored-by: Hannes Karppila <hannes.karppila@gmail.com>
crypto523 pushed a commit to crypto523/fuel-core that referenced this pull request Oct 7, 2024
Re-implementation of the FuelLabs/fuel-core#1829
Work towards FuelLabs/fuel-core#1790

The change migrates the `ProcessedTransactions` table as part of the
on-chain snapshot. Since it is used to validate blocks, the root of all
processed transactions must be part of the `Genesis` structure along
with messages, coins, and contracts.

The changes also moved `SpentMessages` from the on-chain database to the
off-chain database since now it is only used for the GraphQL API.

### Before requesting review
- [x] I have reviewed the code myself

---------

Co-authored-by: Hannes Karppila <hannes.karppila@gmail.com>
sui319 added a commit to sui319/fuel-core that referenced this pull request Feb 17, 2025
Re-implementation of the FuelLabs/fuel-core#1829
Work towards FuelLabs/fuel-core#1790

The change migrates the `ProcessedTransactions` table as part of the
on-chain snapshot. Since it is used to validate blocks, the root of all
processed transactions must be part of the `Genesis` structure along
with messages, coins, and contracts.

The changes also moved `SpentMessages` from the on-chain database to the
off-chain database since now it is only used for the GraphQL API.

### Before requesting review
- [x] I have reviewed the code myself

---------

Co-authored-by: Hannes Karppila <hannes.karppila@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants