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

Add chain package #1178

Merged
merged 7 commits into from
Apr 30, 2024
Merged

Add chain package #1178

merged 7 commits into from
Apr 30, 2024

Conversation

peterjan
Copy link
Member

@peterjan peterjan commented Apr 17, 2024

This PR adds a chain package that exposes two interfaces implemented by the store. These essentially expose a database transaction, allowing us to atomically apply consensus updates from the subscriber (eventually).

Note that the interface is missing wallet.UpdateTx (and so are the tests), that's because it's a bit of a catch-22. Adding that would require updating coreutils and that would in turn require an update to the current subscriber to make the tests pass. That's not worth the trouble since we are extracting that completely in a F/U.

@peterjan peterjan force-pushed the pj/chain-update-tx branch from db4aa61 to 0b42c54 Compare April 17, 2024 19:28
@peterjan peterjan changed the title Add ChainStore and ChainUpdateTx interfaces Add chain package Apr 17, 2024
@peterjan peterjan self-assigned this Apr 18, 2024
@peterjan peterjan marked this pull request as ready for review April 18, 2024 06:59
@peterjan peterjan requested a review from ChrisSchinnerl April 18, 2024 06:59
stores/chain.go Outdated Show resolved Hide resolved
stores/chain.go Show resolved Hide resolved
stores/chain.go Outdated Show resolved Hide resolved
stores/chain.go Outdated Show resolved Hide resolved
stores/chain.go Outdated Show resolved Hide resolved
stores/chain.go Show resolved Hide resolved
@peterjan
Copy link
Member Author

Failing on NDFs in the stores package. Opened #1185 to get rid of those.

@peterjan peterjan force-pushed the pj/chain-update-tx branch from b6cfce7 to 15c2659 Compare April 22, 2024 13:07
@peterjan peterjan force-pushed the pj/chain-update-tx branch from d06cb6a to de6679e Compare April 22, 2024 13:34
@peterjan
Copy link
Member Author

@n8maninger would you mind giving this a look? I think Chris def. wants you to have seen this too before we approve it.

Address: hash256(e.SiacoinOutput.Address),
MaturityHeight: e.MaturityHeight,
Height: index.Height,
BlockID: hash256(index.ID),
Copy link
Member

Choose a reason for hiding this comment

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

This is the same issue we have in walletd right? Where we lose the actual index of the output when performing a reorg.
Leaving this as a reminder to fix it once we have decided what to do with it. Soft deletion via a spent field is probably the best option after all.

Copy link
Member Author

@peterjan peterjan Apr 29, 2024

Choose a reason for hiding this comment

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

Yeah this impl. now mirrors walletd and I figured we'd change it once we decide on what to do in walletd. Soft deletion is an option but you'd have spent be a block_id I guess. Or a hash of both the id and the height or something. In walletd I'm proposing to just use the index of the block that's being applied instead of the one being reverted?

Copy link
Member

@n8maninger n8maninger Apr 29, 2024

Choose a reason for hiding this comment

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

We shouldn't mirror walletd for renterd or hostd. I don't believe Siacoin Elements need to be tied to a chain index for these apps. Orphans can't exist since neither app needs to "live" rescan. Delete the elements explicitly in UpdateTx.RevertIndex instead of deleting the index foreign key or cascade deleting.

Associating them with the block being applied creates the same issue if that block ever gets reverted. It is best not to associate them with a chain index at all.

Copy link
Member

@n8maninger n8maninger left a comment

Choose a reason for hiding this comment

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

I think you need to update coreutils -- wallet.SiacoinElement no longer exists. We removed the extra ChainIndex field

@peterjan
Copy link
Member Author

I think you need to update coreutils -- wallet.SiacoinElement no longer exists. We removed the extra ChainIndex field

This PR is just an attempt to make the diff smaller on #1098 that's been open since forever, but now this one has been open for weeks. This one's really just trying to shave off ~600 lines off of the diff. I'd like to merge this actually and just fix the way we handle reverts in a F/U. its-happening is only a feature branch and it's been a real pain keeping it up to date with dev.

@ChrisSchinnerl ChrisSchinnerl merged commit 6e011b0 into its-happening Apr 30, 2024
6 checks passed
@ChrisSchinnerl ChrisSchinnerl deleted the pj/chain-update-tx branch April 30, 2024 07:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

3 participants