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

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
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 @@ -125,8 +125,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
18 changes: 13 additions & 5 deletions crates/model/src/solver_competition.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ pub struct SolverSettlement {
#[serde_as(as = "BTreeMap<_, HexOrDecimalU256>")]
pub clearing_prices: BTreeMap<H160, U256>,
pub orders: Vec<Order>,
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.

}

#[serde_as]
Expand Down Expand Up @@ -167,6 +168,7 @@ mod tests {
"executedAmount": "14",
}
],
"isWinner": true,
},
],
});
Expand Down Expand Up @@ -208,6 +210,7 @@ mod tests {
executed_amount: 14.into(),
},
],
is_winner: true,
}],
},
};
Expand Down Expand Up @@ -273,7 +276,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32666943622",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": true,
},
{
"orders": [
Expand All @@ -294,7 +298,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32652483021",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -315,7 +320,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "100000",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "60721701581190944"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -336,7 +342,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32725026283",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
},
{
"orders": [
Expand All @@ -357,7 +364,8 @@ mod tests {
"clearingPrices": {
"0x9d409a0a012cfba9b15f6d4b36ac57a46966ab9a": "32752835446",
"0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48": "19827747502258423744093"
}
},
"isWinner": false,
}
],
"transactionHashes": ["0x044499c2a830890cb0a8ecf9aec6c5621e8310092a58d369cdef726254d3d108"],
Expand Down
3 changes: 3 additions & 0 deletions crates/orderbook/openapi.yml
Original file line number Diff line number Diff line change
Expand Up @@ -1504,6 +1504,9 @@ components:
description: Maps from solver name to object describing that solver's settlement.
items:
$ref: "#/components/schemas/SolverSettlement"
isWinner:
type: boolean
description: whether the solution is a winner or not
Copy link
Contributor

Choose a reason for hiding this comment

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

wrong place, should go under SolverSettlement

SolverSettlement:
type: object
properties:
Expand Down
Loading