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

Executed total fee token #2966

Merged
merged 21 commits into from
Dec 24, 2024
Merged

Executed total fee token #2966

merged 21 commits into from
Dec 24, 2024

Conversation

sunce86
Copy link
Contributor

@sunce86 sunce86 commented Sep 10, 2024

Description

Implements (1) and (2) from #2963.
Also, renames surplus_fee to executed_fee in database.

Changes

  • Added new field order_execution.executed_fee_token to database
  • Populated this field with order sell token, otherwise default value is 0x0
  • Token is exposed over API the same way as executed_fee.

Note: all places where sell token needs to be substituted with surplus token are marked with TODO surplus token and this will be tackled as part of (3) from #2963.

How to test

Existing e2e tests. Observed values during the tests.

@sunce86 sunce86 self-assigned this Sep 10, 2024
@sunce86 sunce86 requested a review from a team as a code owner September 10, 2024 14:05
Copy link

github-actions bot commented Sep 10, 2024

Reminder: Please update the DB Readme.


Caused by:

@sunce86 sunce86 changed the title Executed surplus fee token Executed total fee token Sep 11, 2024
crates/orderbook/openapi.yml Outdated Show resolved Hide resolved
crates/database/src/order_execution.rs Outdated Show resolved Hide resolved
crates/database/src/order_execution.rs Outdated Show resolved Hide resolved
database/README.md Outdated Show resolved Hide resolved
crates/orderbook/openapi.yml Outdated Show resolved Hide resolved
&total_fee,
&executed_protocol_fees,
Asset {
token: ByteArray(order_fee.total.token.0 .0),
Copy link
Contributor

@m-lord-renkse m-lord-renkse Sep 12, 2024

Choose a reason for hiding this comment

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

Maybe worth having From<TokenAddress> for ByteArray as it appears in more occurrences 🤔

database/sql/V072__total_fee_token.sql Outdated Show resolved Hide resolved
ADD COLUMN total_fee_token bytea NOT NULL DEFAULT '\x0000000000000000000000000000000000000000';

-- Now populate existing rows with the sell token taken from the 'orders' table, or if it doesn't exist, try from 'jit_orders'.
UPDATE order_execution oe
Copy link
Contributor

Choose a reason for hiding this comment

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

Did you test that this query does not leave any surplus_token uninitialized?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Here are test results on mainnet prod db:

Number of rows in order_execution: 1466450
Number of rows being updated: 1460019

So, there are ~6k entries in order_execution that can't be found in orders or jit_orders (but all missing orders are older than 2 months).
My assumptions is that those are some jit orders from before we started saving them in the library. Example:
https://api.cow.fi/mainnet/api/v1/solver_competition/by_tx_hash/0x59ddfcab4910ad48b3550658f0c46c8892f114e6791dbc032c05a42c1e858b63

Note how the order https://explorer.cow.fi/search/0x0088e45fff8487b9d4c5edcf2ad6580cdfc3a689c3c3022d7282aebf6446a8a99bd702e05b9c97e4a4a3e47df1e0fe7a0c26d2f166ff4487 can't be found in the explorer.
So, for these, I am not too worried if their token is not populated since those can't be found in explorer anyway.

Copy link

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the stale label Sep 27, 2024
@sunce86 sunce86 removed the stale label Sep 27, 2024
Copy link

github-actions bot commented Oct 5, 2024

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the stale label Oct 5, 2024
@sunce86 sunce86 reopened this Oct 31, 2024
@github-actions github-actions bot removed the stale label Nov 1, 2024
Copy link

github-actions bot commented Nov 9, 2024

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the stale label Nov 9, 2024
@github-actions github-actions bot closed this Nov 16, 2024
@sunce86 sunce86 reopened this Nov 28, 2024
@github-actions github-actions bot removed the stale label Nov 29, 2024
Copy link

github-actions bot commented Dec 6, 2024

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the stale label Dec 6, 2024
@fleupold fleupold removed the stale label Dec 6, 2024
Copy link

This pull request has been marked as stale because it has been inactive a while. Please update this pull request or it will be automatically closed.

@github-actions github-actions bot added the Stale label Dec 14, 2024
@sunce86 sunce86 removed the Stale label Dec 14, 2024
Copy link

Reminder: Please update the DB Readme and comment whether migrations are reversible (include rollback scripts if applicable).


Caused by:

Copy link

Reminder: Please consider backward compatibility when modifying the API specification.
If breaking changes are unavoidable, ensure:

  • You explicitly pointed out breaking changes.
  • You communicate the changes to affected teams.
  • You provide proper versioning and migration mechanisms.

Caused by:

Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

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

LGTM

@sunce86 sunce86 enabled auto-merge (squash) December 24, 2024 15:56
@sunce86 sunce86 merged commit 37300c4 into main Dec 24, 2024
11 checks passed
@sunce86 sunce86 deleted the executed-surplus-fee-token branch December 24, 2024 16:01
@github-actions github-actions bot locked and limited conversation to collaborators Dec 24, 2024
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.

5 participants