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

Convert coordinator/substrate/db to use create_db macro #436

Merged
merged 7 commits into from
Dec 8, 2023

Conversation

davidjohnbell
Copy link
Contributor

Description

This is a continuation of pr #408. SubstrateDb was split into BlockDb, EventDb, SessionDb, and BatchDb, some helper methods to convert to/from the expected type were removed as they're covered by the macro.

Considerations

  • Helper function handled was renamed to is_unhandled. Calling code was largely in the form if !SubstrateDb::handled(...) { ... }, removing the negation and changing the name helps align the code with the intent.
  • handle_event could be refactored into a simple set method, I noticed that the calling code often performs the necessary checks however I didn't feel comfortable making this change due to some async statements that could break the previous assertions.

Copy link
Member

@kayabaNerve kayabaNerve left a comment

Choose a reason for hiding this comment

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

All LGTM, minus a few minor nits :)

LatestCosignedBlock: () -> u64,
CosignTransactions: (network: NetworkId) -> Vec<(Session, u64, [u8; 32])>,
BlockDb: () -> u64,
EventDb: (id: &[u8], index: u32) -> [u8; 0],
Copy link
Member

Choose a reason for hiding this comment

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

-> ()

coordinator/src/substrate/db.rs Outdated Show resolved Hide resolved
@@ -568,25 +568,25 @@ async fn handle_new_blocks<D: Db, Pro: Processors>(
)
.await?;
*next_block += 1;
db.set_next_block(*next_block);
let mut txn = db.txn(); // TODO: this line belongs to a removed method, remove SubstrateDb
Copy link
Member

Choose a reason for hiding this comment

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

This TODO doesn't seem still needed.

Copy link
Contributor Author

@davidjohnbell davidjohnbell Nov 18, 2023

Choose a reason for hiding this comment

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

I was thinking about making it a helper but decided against it. I’ll investigate tonight. But I think you’re correct, the comment is old and can be removed if you have a moment.

@kayabaNerve kayabaNerve force-pushed the create-db-substrate-v2 branch from 4dbacf9 to 7e74785 Compare November 20, 2023 08:16
@kayabaNerve kayabaNerve force-pushed the create-db-substrate-v2 branch from 91fe3b9 to 4b1a2b4 Compare December 7, 2023 14:51
These may be rebase artifacts.
@kayabaNerve
Copy link
Member

👍 Will merge once CI passes. Thanks :)

@kayabaNerve kayabaNerve merged commit 16b22dd into serai-dex:develop Dec 8, 2023
9 checks passed
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.

2 participants