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

Solution_id is integer #3071

Merged
merged 3 commits into from
Oct 18, 2024
Merged

Solution_id is integer #3071

merged 3 commits into from
Oct 18, 2024

Conversation

sunce86
Copy link
Contributor

@sunce86 sunce86 commented Oct 18, 2024

Description

Related to #3064

This PR enables driver to send either string or integer for solution_id.

This PR marks the start of transition period. Once the PR is merged, external solvers will be asked to:

  1. Start sending solution_id as integer in /solve response.
  2. Implement receiving either string or integer for solution_id on /reveal and on /settle.

Once done, backend will have a follow up where we will definitely switch to using integers in all three endpoints and #3064 will be fixed.

How to test

Manually checked that both versions are properly serialized/deserialized.

@sunce86 sunce86 self-assigned this Oct 18, 2024
@sunce86 sunce86 requested a review from a team as a code owner October 18, 2024 08:55
Copy link
Contributor

@squadgazzz squadgazzz left a comment

Choose a reason for hiding this comment

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

LGTM

Copy link
Contributor

@m-lord-renkse m-lord-renkse left a comment

Choose a reason for hiding this comment

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

Nice change!!

where
D: serde::Deserializer<'de>,
{
struct SolutionIdVisitor;
Copy link
Contributor

Choose a reason for hiding this comment

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

Alternatively this can also be implemented using a helper enum. Might be a bit more self explanatory.

fn deserialize_solution_id<'de, D>(deserializer: D) -> Result<u64, D::Error>
where
    D: serde::Deserializer<'de>,
{
    #[serde_as]
    #[derive(Deserialize, Debug)]
    #[serde(untagged)]
    enum StringOrInt {
        String(#[serde_as(as = "DisplayFromStr")] u64),
        Int(u64)
    }

    let result = match StringOrInt::deserialize(deserializer)? {
        StringOrInt::String(id) => id,
        StringOrInt::Int(id) => id
    };

    Ok(result)
}

Copy link
Contributor Author

Choose a reason for hiding this comment

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

This one is nice as well. But I guess it's ok keeping the current version since it will be removed in one week from now.

@sunce86 sunce86 merged commit 3690ba5 into main Oct 18, 2024
11 checks passed
@sunce86 sunce86 deleted the solution_id_is_integer branch October 18, 2024 13:13
@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants