-
Notifications
You must be signed in to change notification settings - Fork 90
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
+648
−18
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 97aa50e
new table for storing proposed solutions
sunce86 8c82c6a
split into two tables
sunce86 9608b4b
cr fixes
sunce86 70152f4
don't force solution_id to be unique globally
sunce86 b387a16
fix index
sunce86 9a39a0f
remove obsolete index
sunce86 10197dc
removed deadline from solutions
sunce86 b7d8b81
move orders to separate table
sunce86 eb29854
rename latest_auction
sunce86 85c2c25
fix proposed jit orders
sunce86 ff2a816
Merge branch 'main' into auction-winners-table
sunce86 c3dcc38
rename latest_auction
sunce86 25034d7
consolidate auctions table
sunce86 2375340
Merge branch 'main' into auction-winners-table
sunce86 9895072
merge
sunce86 8f6042d
one time migration of auction
sunce86 83bcee1
Merge branch 'main' into auction-winners-table
sunce86 54ee105
revert merge conflit
sunce86 3b37da4
save/fetch solutions
sunce86 c1948b4
read/save proposed solutions
sunce86 c573566
Merge branch 'main' into auction-winners-table
sunce86 ee81863
save score afterall
sunce86 511dd47
fix db bugs
sunce86 2f165b6
fix db test
sunce86 92cc314
follow up
sunce86 5e9b5f3
remove renaming
sunce86 84aace6
fix post_processing
sunce86 26fd3d8
added comment for external prices
sunce86 44d384f
resolve uniqueness of solution id
sunce86 1b7b37d
winner merged with Participant
sunce86 442d568
Fix failing test
sunce86 f3e304f
remove migration code
sunce86 def2583
resolve future conflicts
sunce86 e5729ff
add docs
sunce86 0e9f679
improve saving of solutions
sunce86 86e8c5d
fix test
sunce86 b2dbe4d
Merge branch 'main' into auction-winners-table
sunce86 4b90f8e
merge
sunce86 7e6c362
small move
sunce86 fb31a15
local struct for fetching
sunce86 a4f4d9c
cr fixes
sunce86 0cc9f39
cr fixes from ilya
sunce86 8fb30ec
Split into functions
sunce86 166da4d
Merge branch 'main' into auction-winners-table
sunce86 3870108
Merge branch 'main' into auction-winners-table
sunce86 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Already discussed here: |
||
|
||
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
|
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
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.