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

Ns/versionable unsupported #1691

Merged
merged 2 commits into from
Oct 22, 2024
Merged

Ns/versionable unsupported #1691

merged 2 commits into from
Oct 22, 2024

Conversation

nsarlin-zama
Copy link
Contributor

@nsarlin-zama nsarlin-zama commented Oct 16, 2024

closes: please link all relevant issues

PR content/description

Adds a trait and a type to mark deprecation of older versions of a type that are no longer supported.

Namely, there is a trait Deprecable that is used on a user facing type to tell that older versions of this type can be deprecated. This trait mainly defines some str associated constants that will be used to provide a friendlier error message to the user. In the example below, a user that tries to deserialize a deprecated version, would get the following error:

Deprecated MyStruct found in serialized data, minimal supported version is my_app v2

(In the context of tfhe-rs, this could be something like Deprecated ServerKey found in serialized data, minimal supported version is tfhe-rs v0.8)

The type Deprecated<MyStruct> should be used in the dispatch enum and replaces the deprecated versions. As it replaces them, it allows to remove all the code associated to defining, loading and upgrading them.

Since the remaining valid versions will still keep their place in the dispatch enum, any data that has not been explicitly deprecated will still be compatible.

Example:

use tfhe_versionable::deprecation::{Deprecable, Deprecated};
use tfhe_versionable::{Versionize, VersionsDispatch};
#[derive(Versionize)]
#[versionize(MyStructVersions)]
struct MyStruct;

impl Deprecable for MyStruct {
    const TYPE_NAME: &'static str = "MyStruct";
    const MIN_SUPPORTED_APP_VERSION: &'static str = "my_app v2";
}

#[derive(VersionsDispatch)]
#[allow(unused)]
pub enum MyStructVersions {
    V0(Deprecated<MyStruct>),
    V1(Deprecated<MyStruct>),
    V2(MyStruct),
}

We could also define a macro in tfhe-rs for the Deprecable trait implementation. (Something like deprecable!(ServerKey))

Check-list:

  • Tests for the changes have been added (for bug fixes / features)
  • Docs have been added / updated (for bug fixes / features)
  • Relevant issues are marked as resolved/closed, related issues are linked in the description
  • Check for breaking changes (including serialization changes) and add them to commit message following the conventional commit specification

@cla-bot cla-bot bot added the cla-signed label Oct 16, 2024
@nsarlin-zama nsarlin-zama force-pushed the ns/versionable_unsupported branch 3 times, most recently from 870a2c9 to edae72d Compare October 17, 2024 14:18
Copy link
Member

@IceTDrinker IceTDrinker left a comment

Choose a reason for hiding this comment

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

Looks good small things I saw

utils/tfhe-versionable/src/deprecation.rs Outdated Show resolved Hide resolved
utils/tfhe-versionable/src/deprecation.rs Show resolved Hide resolved
@nsarlin-zama nsarlin-zama force-pushed the ns/versionable_unsupported branch from edae72d to b92a3cd Compare October 21, 2024 11:51
@nsarlin-zama nsarlin-zama force-pushed the ns/versionable_unsupported branch from b92a3cd to d074107 Compare October 21, 2024 11:52
@nsarlin-zama nsarlin-zama merged commit 466a996 into main Oct 22, 2024
87 checks passed
@nsarlin-zama nsarlin-zama deleted the ns/versionable_unsupported branch October 22, 2024 09:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants