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

New database tables for auction and solver competition #2980

Merged
merged 46 commits into from
Oct 17, 2024
Merged
Changes from 7 commits
Commits
Show all changes
46 commits
Select commit Hold shift + click to select a range
10a1bc1
Redesign settlement_scores table
sunce86 Sep 12, 2024
97aa50e
new table for storing proposed solutions
sunce86 Sep 16, 2024
8c82c6a
split into two tables
sunce86 Sep 17, 2024
9608b4b
cr fixes
sunce86 Sep 18, 2024
70152f4
don't force solution_id to be unique globally
sunce86 Sep 18, 2024
b387a16
fix index
sunce86 Sep 18, 2024
9a39a0f
remove obsolete index
sunce86 Sep 18, 2024
10197dc
removed deadline from solutions
sunce86 Sep 18, 2024
b7d8b81
move orders to separate table
sunce86 Sep 26, 2024
eb29854
rename latest_auction
sunce86 Sep 26, 2024
85c2c25
fix proposed jit orders
sunce86 Sep 26, 2024
ff2a816
Merge branch 'main' into auction-winners-table
sunce86 Sep 30, 2024
c3dcc38
rename latest_auction
sunce86 Sep 30, 2024
25034d7
consolidate auctions table
sunce86 Sep 30, 2024
2375340
Merge branch 'main' into auction-winners-table
sunce86 Oct 1, 2024
9895072
merge
sunce86 Oct 1, 2024
8f6042d
one time migration of auction
sunce86 Oct 2, 2024
83bcee1
Merge branch 'main' into auction-winners-table
sunce86 Oct 7, 2024
54ee105
revert merge conflit
sunce86 Oct 7, 2024
3b37da4
save/fetch solutions
sunce86 Oct 8, 2024
c1948b4
read/save proposed solutions
sunce86 Oct 8, 2024
c573566
Merge branch 'main' into auction-winners-table
sunce86 Oct 8, 2024
ee81863
save score afterall
sunce86 Oct 8, 2024
511dd47
fix db bugs
sunce86 Oct 8, 2024
2f165b6
fix db test
sunce86 Oct 8, 2024
92cc314
follow up
sunce86 Oct 8, 2024
5e9b5f3
remove renaming
sunce86 Oct 8, 2024
84aace6
fix post_processing
sunce86 Oct 8, 2024
26fd3d8
added comment for external prices
sunce86 Oct 8, 2024
44d384f
resolve uniqueness of solution id
sunce86 Oct 8, 2024
1b7b37d
winner merged with Participant
sunce86 Oct 8, 2024
442d568
Fix failing test
sunce86 Oct 8, 2024
f3e304f
remove migration code
sunce86 Oct 9, 2024
def2583
resolve future conflicts
sunce86 Oct 9, 2024
e5729ff
add docs
sunce86 Oct 9, 2024
0e9f679
improve saving of solutions
sunce86 Oct 9, 2024
86e8c5d
fix test
sunce86 Oct 9, 2024
b2dbe4d
Merge branch 'main' into auction-winners-table
sunce86 Oct 10, 2024
4b90f8e
merge
sunce86 Oct 10, 2024
7e6c362
small move
sunce86 Oct 10, 2024
fb31a15
local struct for fetching
sunce86 Oct 10, 2024
a4f4d9c
cr fixes
sunce86 Oct 11, 2024
0cc9f39
cr fixes from ilya
sunce86 Oct 14, 2024
8fb30ec
Split into functions
sunce86 Oct 14, 2024
166da4d
Merge branch 'main' into auction-winners-table
sunce86 Oct 14, 2024
3870108
Merge branch 'main' into auction-winners-table
sunce86 Oct 17, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
56 changes: 56 additions & 0 deletions database/sql/V072__auction_solution_orders.sql
Copy link
Contributor

Choose a reason for hiding this comment

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

A bit more context on what the migration is trying to achieve would be nice.

Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
-- Rename current `auctions` table to `auction` since it always contains only the latest auction
ALTER TABLE auctions RENAME TO auction;

CREATE TABLE auctions (
auction_id bigint PRIMARY KEY,
-- The block number at which the auction was created
block bigint NOT NULL,
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
-- The block number until which all winning solutions from a competition should be settled on-chain
deadline bigint NOT NULL
);

-- Table to store all proposed solutions for an auction, received from solvers during competition time.
-- A single auction can have multiple solutions, and each solution can contain multiple order executions.
-- This design allows for multiple solutions from a single solver
CREATE TABLE proposed_solutions (
auction_id bigint NOT NULL,
-- The block number until which the solutions should be settled
-- Not NULL for winning orders
deadline bigint,
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
-- solver submission address
solver bytea NOT NULL,
-- Has to be unique accross auctions (hash of the (auction_id + solver + solutionId received from solver)?)
solution_id numeric NOT NULL,
-- Whether the solution is one of the winning solutions of the auction
is_winner boolean NOT NULL,
Comment on lines +29 to +30
Copy link
Contributor

Choose a reason for hiding this comment

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

Isn't this field something that can be derived in the code from the data? I'm not sure this should be persisted.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Already discussed here:

#2980 (comment)


PRIMARY (auction_id, solution_id)
);

-- For performant filtering of solutions by auction_id and JOINs on auction_id
CREATE INDEX idx_auction_id ON proposed_solutions(auction_id);

-- Table to store all order executions of a solution
CREATE TABLE proposed_solution_executions (
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
auction_id bigint NOT NULL,
solution_id numeric NOT NULL,
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
order_uid bytea NOT NULL,
sell_token bytea NOT NULL,
buy_token bytea NOT NULL,
limit_sell numeric(78,0) NOT NULL,
limit_buy numeric(78,0) NOT NULL,
side OrderKind NOT NULL,
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
-- Uniform clearing price of the sell token
sell_token_price numeric(78,0) NOT NULL,
-- Uniform clearing price of the buy token
buy_token_price numeric(78,0) NOT NULL,
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
-- The effective amount that left the user's wallet including all fees.
executed_sell numeric(78,0) NOT NULL,
-- The effective amount the user received after all fees.
executed_buy numeric(78,0) NOT NULL,

PRIMARY (auction_id, solution_id, order_uid)
);

-- For performant JOINs on auction_id
CREATE INDEX idx_auction_id_solution_id_on_execution ON proposed_solution_executions(auction_id, solution_id);
sunce86 marked this conversation as resolved.
Show resolved Hide resolved
Loading