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

Storing call_data in quotes and order_quotes tables #3124

Merged
merged 83 commits into from
Dec 11, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
Show all changes
83 commits
Select commit Hold shift + click to select a range
f46b82d
Implementation
mstrug Nov 14, 2024
d9eb189
Added call_data to quotes table
mstrug Nov 15, 2024
2c0e92e
Updated order_quotes table
mstrug Nov 15, 2024
006a873
Added comments
mstrug Nov 15, 2024
7d2bb01
Added db migration
mstrug Nov 15, 2024
9947257
Fixed formatting
mstrug Nov 15, 2024
692d94e
Fixed sql query
mstrug Nov 15, 2024
6fb1ae7
Updated db querying for order with quote
mstrug Nov 15, 2024
a8f349f
Added test
mstrug Nov 15, 2024
eaf09d2
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Nov 15, 2024
67c20ff
Fixed formatting
mstrug Nov 15, 2024
e9026a4
Updated tests
mstrug Nov 15, 2024
6671767
Added verified column to quotes table
mstrug Nov 21, 2024
086e579
Added quotes_interactions table
mstrug Nov 23, 2024
bca89ac
Fixed tests compilation
mstrug Nov 23, 2024
7c6983c
Fixed formatting
mstrug Nov 23, 2024
a847647
Updated orders database tables
mstrug Nov 23, 2024
1868aae
Fixed sql
mstrug Nov 25, 2024
507f6ae
Update
mstrug Nov 25, 2024
aff0468
Added removing quote_interactions on quote remove
mstrug Nov 25, 2024
189222b
Added order_quotes_interactions table
mstrug Nov 26, 2024
7a0cdc3
Added filling order quote interaction table
mstrug Nov 26, 2024
ae1115a
Fixed clippy warning
mstrug Nov 26, 2024
33a4cc4
Fixed missing variant
mstrug Nov 26, 2024
c62ac2d
Returning quote interactions in QuoteStoring implementation
mstrug Nov 27, 2024
dc36269
Added waiting for db migrations before tests
mstrug Nov 27, 2024
888e576
Added db dependency to migrations docker container
mstrug Nov 27, 2024
ec9eae0
Temporarily disabled restarts on migration
mstrug Nov 27, 2024
0210d3c
Reverted yaml file changes
mstrug Nov 27, 2024
77fc406
Fixed migration script
mstrug Nov 27, 2024
69dd7fa
Fixed test
mstrug Nov 27, 2024
828ec19
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Nov 27, 2024
757029a
Updated new table names
mstrug Nov 28, 2024
085c530
Updated db readme & migration script
mstrug Nov 28, 2024
1e91d31
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Nov 28, 2024
0921924
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Nov 28, 2024
67cd65c
Code cleanup
mstrug Nov 28, 2024
39cade5
Updated tests
mstrug Nov 28, 2024
5239901
Added transaction for storing interactions
mstrug Nov 29, 2024
5aac1dc
Updated removing of expired quote interactions
mstrug Nov 29, 2024
23b2182
Removed updated on conflict from insert order quote interaction
mstrug Nov 29, 2024
f4f040c
Updated test
mstrug Nov 29, 2024
8848b73
Updated db readme
mstrug Nov 29, 2024
0afb9ad
Ensuring repeated db inserts uses transaction
mstrug Nov 29, 2024
2f610ae
Fixed tests
mstrug Nov 29, 2024
9979645
Optimized db queries using join
mstrug Nov 29, 2024
9a7f510
Added test
mstrug Dec 2, 2024
d8ff00b
Small refactorings
mstrug Dec 2, 2024
726376a
Function rename
mstrug Dec 2, 2024
1e23f0d
Using array_agg function for getting quote with interactions from db
mstrug Dec 2, 2024
f5cbc3e
Removed new error variant, fixed comment in sql script
mstrug Dec 2, 2024
59e39a2
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 2, 2024
ddaf4b2
Updated table descriptions
mstrug Dec 3, 2024
730050c
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 4, 2024
b08e7f9
New implementation
mstrug Dec 4, 2024
4872843
Fixed formatting and implementation
mstrug Dec 4, 2024
3ee496d
Updated database readme
mstrug Dec 4, 2024
e659b34
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 6, 2024
36ed84b
Updated tests
mstrug Dec 6, 2024
c25d4f9
Small updates
mstrug Dec 6, 2024
7aafd11
Updated HTTP error code
mstrug Dec 6, 2024
b059d2e
Added metadata field to QuoteData struct
mstrug Dec 6, 2024
171dadb
Added NOT NULL constraint for new columns to quotes table
mstrug Dec 6, 2024
4761f8a
Added sql migration V075 revert script
mstrug Dec 6, 2024
f9dbea3
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 6, 2024
b963d71
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 9, 2024
17d25e6
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 9, 2024
e252f0e
Added support for versioning into QuoteMetadata type
mstrug Dec 9, 2024
eaa203c
Small optimization
mstrug Dec 9, 2024
d5c5b21
Improved error handling
mstrug Dec 9, 2024
978e436
Added e2e test
mstrug Dec 10, 2024
331e70b
Changed constraints of columns in order_quotes table
mstrug Dec 10, 2024
11b74d3
Updated revert sql script
mstrug Dec 10, 2024
35f1542
Moved undo sql script to sql folder
mstrug Dec 10, 2024
c990aab
Moved interactions to separate struct in trade_finding and price_esti…
mstrug Dec 10, 2024
4a9f686
Updated json format for QuoteMetadata
mstrug Dec 10, 2024
14c4ec6
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 10, 2024
71bfe2b
Fixed unit test
mstrug Dec 10, 2024
c9ceaa4
Added support for empty json in quote metadata column
mstrug Dec 10, 2024
373f891
Fixed new e2e test
mstrug Dec 11, 2024
c61f4bc
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 11, 2024
ebd3e3b
Improved errors conversions
mstrug Dec 11, 2024
8baf668
Merge branch 'main' into feature/storing-call-data-in-quotes
mstrug Dec 11, 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
7 changes: 4 additions & 3 deletions crates/orderbook/src/database/orders.rs
Original file line number Diff line number Diff line change
Expand Up @@ -692,7 +692,7 @@ mod tests {
signature::{Signature, SigningScheme},
},
primitive_types::U256,
shared::order_quoting::{QuoteData, QuoteMetadata},
shared::order_quoting::{QuoteData, QuoteMetadataV1},
std::sync::atomic::{AtomicI64, Ordering},
};

Expand Down Expand Up @@ -1221,7 +1221,7 @@ mod tests {
buy_amount: U256::from(2),
data: QuoteData {
verified: true,
metadata: QuoteMetadata {
metadata: QuoteMetadataV1 {
interactions: vec![
InteractionData {
target: H160([1; 20]),
Expand All @@ -1234,7 +1234,8 @@ mod tests {
call_data: vec![2, 20],
},
],
},
}
.into(),
..Default::default()
},
..Default::default()
Expand Down
30 changes: 24 additions & 6 deletions crates/shared/src/order_quoting.rs
Original file line number Diff line number Diff line change
Expand Up @@ -445,9 +445,10 @@ impl OrderQuoter {
quote_kind,
solver: trade_estimate.solver,
verified: trade_estimate.verified,
metadata: QuoteMetadata {
metadata: QuoteMetadataV1 {
interactions: trade_estimate.interactions,
},
}
.into(),
};

Ok(quote)
Expand Down Expand Up @@ -636,10 +637,9 @@ pub fn quote_kind_from_signing_scheme(scheme: &QuoteSigningScheme) -> QuoteKind
}

/// Used to store in database any quote metadata.
#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct QuoteMetadata {
/// Data provided by the solver in response to /quote request.
pub interactions: Vec<InteractionData>,
#[derive(Clone, Debug, PartialEq, serde::Deserialize, serde::Serialize)]
pub enum QuoteMetadata {
mstrug marked this conversation as resolved.
Show resolved Hide resolved
V1(QuoteMetadataV1),
mstrug marked this conversation as resolved.
Show resolved Hide resolved
}

impl TryInto<serde_json::Value> for QuoteMetadata {
Expand All @@ -658,6 +658,24 @@ impl TryFrom<serde_json::Value> for QuoteMetadata {
}
}

impl Default for QuoteMetadata {
fn default() -> Self {
Self::V1(Default::default())
}
}

impl From<QuoteMetadataV1> for QuoteMetadata {
fn from(val: QuoteMetadataV1) -> Self {
QuoteMetadata::V1(val)
}
}

#[derive(Clone, Debug, Default, PartialEq, serde::Deserialize, serde::Serialize)]
pub struct QuoteMetadataV1 {
/// Data provided by the solver in response to /quote request.
pub interactions: Vec<InteractionData>,
}

#[cfg(test)]
mod tests {
use {
Expand Down