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

Read write post interactions in db #1482

Merged
merged 14 commits into from
May 10, 2023
Merged

Conversation

MartinquaXD
Copy link
Contributor

@MartinquaXD MartinquaXD commented May 8, 2023

Fixes #1481

Adds DB migration to allow differentiating pre- and post-interactions.
Adjust some DB functions to work with pre- and post-interactions.
Reads post_interactions from DB and puts them into OrderMetadata and propagates it to some other places
Note that we now only have the required helper functions to store interactions in the DB but there is still no code path that actually calls that code for post-interactions.

Test Plan

Adjusted existing tests for slightly changed DB helper functions
Copied test for verifying roundtrip of pre-interactions for post-interactions

@MartinquaXD MartinquaXD requested a review from a team as a code owner May 8, 2023 13:54
@sunce86
Copy link
Contributor

sunce86 commented May 9, 2023

Would it make sense to merge this PR to a feature branch instead of main? The reason being that db migration PRs should be carefully merged to main and only once we are sure we are done with the feature and no further changes will be needed.

@MartinquaXD
Copy link
Contributor Author

Would it make sense to merge this PR to a feature branch instead of main?

Seems like a reasonable request. Will leave the PR unmerged for now so others can voice an opinion as well. 👌

@cowfee
Copy link
Contributor

cowfee commented May 9, 2023

OTOH merging into a feature branch can make the code more stale over time and more difficult to merge later. I'd be OK with merging to main TBH but I'm also OK with using a feature branch.

Copy link
Contributor

@cowfee cowfee left a comment

Choose a reason for hiding this comment

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

This breaks driver tests. I know they're not running in CI which is a problem, I'll add them next thing. But in the meantime please run and fix them manually.

crates/database/src/orders.rs Outdated Show resolved Hide resolved
Comment on lines 411 to 413
pub pre_interactions: Vec<(Address, BigDecimal, Vec<u8>)>,
pub post_interactions: Vec<(Address, BigDecimal, Vec<u8>)>,
pub ethflow_data: Option<(Option<TransactionHash>, i64)>,
Copy link
Contributor

Choose a reason for hiding this comment

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

I know this isn't on you, but it would be really nice to get rid of these tuples and either name these fields or give strong types to the tuple elements. It's hard to tell at a glance what the BigDecimal and i64 are for. And since this is a public signature being able to deduce as much as possible at a glance is important.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Unless I misunderstood the comment on the big SQL query this unfortunate type is due to limitations in sqlx. I created a type alias and attached the related comments to it for now.

Copy link
Contributor

Choose a reason for hiding this comment

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

I think you should be able to use a struct with derive(sqlx::FromRow) right? (May be wrong though).

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This currently doesn't work and there is an open issue about it.

crates/driver/src/domain/competition/order/mod.rs Outdated Show resolved Hide resolved
crates/driver/src/domain/competition/order/mod.rs Outdated Show resolved Hide resolved
crates/driver/src/domain/quote.rs Outdated Show resolved Hide resolved
@nlordell
Copy link
Contributor

Would it make sense to merge this PR to a feature branch instead of main?

Personally, I'm not a huge fan of feature branches. I would rather have a feature flag that can be turned on and off at runtime and merge directly into main. In terms of DB migration, I think we can always "undo" DB changes with additional migrations if needed (not to mention that the DB format for this feature seems relatively well specified and unlikely to change - famous last words and all...)

@MartinquaXD MartinquaXD enabled auto-merge (squash) May 10, 2023 17:32
@MartinquaXD MartinquaXD merged commit ccd7edf into main May 10, 2023
3 of 4 checks passed
@MartinquaXD MartinquaXD deleted the read-write-post-interactions-in-db branch May 10, 2023 17:48
@github-actions github-actions bot locked and limited conversation to collaborators May 10, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Read/Write post interactions in the DB
5 participants