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

feat: Refactor auction_transaction relation #2282

Closed
sunce86 opened this issue Jan 14, 2024 · 3 comments
Closed

feat: Refactor auction_transaction relation #2282

sunce86 opened this issue Jan 14, 2024 · 3 comments

Comments

@sunce86
Copy link
Contributor

sunce86 commented Jan 14, 2024

Problem

With colocation, auction_id is appended to transaction call_data always (and this will also be required and verified once solvers run their own driver), so it's not needed to keep the <from, nonce> pair anymore. This paIr was used pre-colocation so that we connect the auction to the transaction hash.

Currently, our database looks like this:

settlements table (initially partially populated by EventHandler (without <from, nonce>), and later OnSettlementEventHandler updates <from, nonce>):

  • block_number
  • log_index
  • transaction hash
  • Optional from
  • Optional nonce

auction_transaction table (populated by OnSettlementEventHandler):

  • auction_id
  • from
  • nonce

Proposal:

settlements table:

  • block_number
  • log_index
  • transaction hash
  • Option<auction_id>

Drop auction_transaction table.

EventHandler would insert settlement on each new event, while OnSettlementEventHandler would fetch all settlements without auction_id and populate that field and all depending data (settlement observations and order executions). This would make OnSettlementEventHandler completely reorg friendly since right now the auction_transaction table is not reorg friendly and does not contain column block_number which would allow entry deletion when EventHandler detects reorg.

Related to #2275

@MartinquaXD
Copy link
Contributor

Seems good to me. I don't see any obvious problems with this approach and always found that we had to join using from and nonce instead of auction_id clunky.

@fleupold
Copy link
Contributor

Sounds good to me! If we make a new version of the contract, we will likely make auction ID a mandatory part of the calldata anyways.

fleupold added a commit that referenced this issue Jan 26, 2024
# Description
Part of #2282 &
#2275

Exchanges `tx_from/tx_nonce` for `auction_id` which can be directly
encoded from the settlement transaction since we shipped colocation.
This allows us to remove an entire database table and a bunch of other
complicated code.

I'm not yet removing the old columns in case something goes bad with
this change.

# Changes
<!-- List of detailed changes (how the change is accomplished) -->

- [x] Removed `auction_transaction` table.
- [x] Redesigned `settlements` table to contain auction id

## How to test
1. db tests and e2e tests cover the new functionality.
2. Locally I've tested the db migration file like this:
- First comment out the V_58 migration file and apply old schema.
- Insert 10 settlements, of which first 5 have `auction_transaction`
record (except one settlement (block_number 3), to simulate the
existence of settlement from other environment staging/prod)
- Then, manually apply migration script V_58
- Observed the `settlements` table,`auction_id` were populated as
expected.

---------

Co-authored-by: Felix Leupold <[email protected]>
@sunce86
Copy link
Contributor Author

sunce86 commented Jan 31, 2024

Done with #2283

@sunce86 sunce86 closed this as completed Jan 31, 2024
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

No branches or pull requests

3 participants