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

Add is_winner to solver competition endpoints #3127

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions crates/autopilot/src/run_loop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -476,6 +476,7 @@ impl RunLoop {
.iter()
.map(|(token, price)| (token.0, price.get().into()))
.collect(),
is_winner: participant.is_winner(),
})
.collect(),
};
Expand Down
2 changes: 2 additions & 0 deletions crates/e2e/tests/e2e/solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -126,8 +126,10 @@ async fn solver_competition(web3: Web3) {

// Non winning candidate
assert!(competition.common.solutions[0].ranking == 2);
assert!(!competition.common.solutions[0].is_winner);
// Winning candidate
assert!(competition.common.solutions[1].ranking == 1);
assert!(competition.common.solutions[1].is_winner);
}

async fn fairness_check(web3: Web3) {
Expand Down
19 changes: 14 additions & 5 deletions crates/model/src/solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ pub struct SolverSettlement {
#[serde_as(as = "BTreeMap<_, HexOrDecimalU256>")]
pub clearing_prices: BTreeMap<H160, U256>,
pub orders: Vec<Order>,
#[serde(default)]
pub is_winner: bool,
Copy link
Contributor

Choose a reason for hiding this comment

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

I would add #[serde(default)] above the new field to make it explicit that is_winner might be missing for some entries and to make the deserialization more robust.

Copy link
Contributor

Choose a reason for hiding this comment

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

Why not just do the migration in this PR as well to have al the data correct in one go?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@MartinquaXD see my message below: #3127 (comment)

I would love to hear your opinion. I am open to do a migration in this PR, but I assume a SQL migration is off the table due to the json characteristics 🤔

}

#[serde_as]
Expand Down Expand Up @@ -165,6 +167,7 @@ mod tests {
"executedAmount": "14",
}
],
"isWinner": true,
},
],
});
Expand Down Expand Up @@ -206,6 +209,7 @@ mod tests {
executed_amount: 14.into(),
},
],
is_winner: true,
}],
},
};
Expand Down Expand Up @@ -271,7 +275,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32666943622",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": true,
},
{
"orders": [
Expand All @@ -292,7 +297,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32652483021",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -313,7 +319,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "100000",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "60721701581190944"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -334,7 +341,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32725026283",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -355,7 +363,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32752835446",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
}
],
"transactionHashes": ["0x044499c2a830890cb0a8ecf9aec6c5621e8310092a58d369cdef726254d3d108"],
Expand Down
5 changes: 4 additions & 1 deletion crates/orderbook/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -403,7 +403,7 @@ paths:
"200":
description: Version
content:
text/plain: {}
text/plain: { }
m-lord-renkse marked this conversation as resolved.
Show resolved Hide resolved
"/api/v1/app_data/{app_data_hash}":
get:
summary: Get the full `appData` from contract `appDataHash`.
Expand Down Expand Up @@ -1661,6 +1661,9 @@ components:
$ref: "#/components/schemas/UID"
executedAmount:
$ref: "#/components/schemas/BigUint"
isWinner:
type: boolean
description: whether the solution is a winner (received the right to get executed) or not
NativePriceResponse:
description: |
The estimated native price for the token
Expand Down
Loading