Skip to content

Conversation

@imabdulbasit
Copy link
Contributor

@imabdulbasit imabdulbasit commented Nov 6, 2025

This PR implements SQLITE persistence for events. It includes migration for all the tables needed.
It saves the genesis l1 block, stores all the diffs and loads the finalized snapshot.

@imabdulbasit imabdulbasit changed the title implement persistence WIP: implement persistence Nov 6, 2025
@imabdulbasit imabdulbasit changed the title WIP: implement persistence Implements persistence for Events, and snapshot loading Nov 6, 2025
@imabdulbasit imabdulbasit marked this pull request as ready for review November 6, 2025 20:35
Copy link
Member

@jbearer jbearer left a comment

Choose a reason for hiding this comment

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

I have a few suggestions but I think the only blocker is the question about computing/storing the stake for the full node set

Comment on lines +391 to +401
// Mark all delegations to this node as exits
let result = sqlx::query(
"UPDATE delegation
SET unlocks_at = $1, withdrawal_amount = '0'
WHERE delegator = $2 AND node = $3",
)
.bind(withdrawal.available_time as i64)
.bind(withdrawal.delegator.to_string())
.bind(withdrawal.node.to_string())
.execute(&mut **tx)
.await?;
Copy link
Member

Choose a reason for hiding this comment

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

It's a bit unfortunate that by breaking up the diff into one event for each wallet, this becomes one UPDATE for each wallet when it could be a single statement with just WHERE node = $. This is an issue with the design, since we use the same event stream for updating our own database as for updating clients...but there is a separate client for each wallet, while there is only one database, so the database become a bottleneck.

It seems like maybe we should have storage handle a new type of update, WalletsDiff, which are events generated that affect the entire set of wallets, not just one at at time. Then we could have a diff like NodeExited(address) without specifying any particular delegator. But anyways, this can be left for future work.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

#21

@imabdulbasit imabdulbasit requested a review from jbearer November 10, 2025 15:04
Copy link
Member

@jbearer jbearer left a comment

Choose a reason for hiding this comment

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

Looks good. It looks like the CI failure is timing out while the demo is pulling Docker images. I hope this PR might fix it

@imabdulbasit imabdulbasit merged commit 219af97 into main Nov 10, 2025
10 of 11 checks passed
@imabdulbasit imabdulbasit deleted the ab/persistence branch November 10, 2025 19:50
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.

3 participants