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

Insert Settlement & Mark Processed #276

Merged
merged 7 commits into from
May 11, 2023
Merged

Insert Settlement & Mark Processed #276

merged 7 commits into from
May 11, 2023

Conversation

bh2smith
Copy link
Contributor

@bh2smith bh2smith commented May 11, 2023

Part of #177

Doing a TODO to mark data as process when simulation is inserted. This happens in both cases of the pipeline (when there is an is not a simulation to go with it).

Test Plan

Every component is tested individually. Could also add a test fot insertSettlementAndMarkProcessed although it just runs both, tested methods, together.

@bh2smith bh2smith mentioned this pull request May 11, 2023
40 tasks
@bh2smith bh2smith requested review from fedgiac and a team May 11, 2023 08:07
@bh2smith bh2smith added the easy label May 11, 2023
@bh2smith bh2smith requested review from alfetopito and tukantje May 11, 2023 09:48
Copy link
Contributor

@gentrexha gentrexha left a comment

Choose a reason for hiding this comment

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

LGTM.

Left some comments and very nitpicky suggestion.

Comment on lines +30 to +33
await db.query(sql`TRUNCATE TABLE settlements;`);
await db.query(sql`TRUNCATE TABLE internalized_imbalances;`);
await db.query(sql`TRUNCATE TABLE settlement_simulations;`);
await db.query(sql`TRUNCATE TABLE tx_receipts;`);
Copy link
Contributor

Choose a reason for hiding this comment

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

Very nit: Can be wrapped in a for loop for each table.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Nope -- sorry not gonna do this now:

Feel free to try it out if you'd like

https://github.com/cowprotocol/solver-rewards/actions/runs/4946979712/jobs/8845749193

Comment on lines -34 to +41
await db.query(sql`TRUNCATE TABLE settlements;`);
await db.query(sql`TRUNCATE TABLE internalized_imbalances;`);
await db.query(sql`TRUNCATE TABLE settlement_simulations;`);
await db.query(sql`TRUNCATE TABLE tx_receipts;`);
await truncateTables();
Copy link
Contributor

Choose a reason for hiding this comment

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

I like this! Good job on reducing duplicated code.

Comment on lines +244 to +248
test("markReceiptProcessed does nothing when hash doesn't exist", async () => {
await expect(
markReceiptProcessed(db, "0x01")
).resolves.not.toThrowError();
});
Copy link
Contributor

Choose a reason for hiding this comment

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

Out of curiosity: Should we ever be expecting to mark a receipt as processed when there isn't a hash for it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, in the scenario where we run the program manually to "backfill" the data from many months ago till now, we will be calling this program on records that were never part of the "tx_receipts" table.

@bh2smith bh2smith merged commit 9537a04 into slippage-v2 May 11, 2023
@bh2smith bh2smith deleted the mark-processed branch May 11, 2023 11:18
@github-actions github-actions bot locked and limited conversation to collaborators May 11, 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.

3 participants