-
Notifications
You must be signed in to change notification settings - Fork 0
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
Feat/add findex redis v7 #20
Conversation
a5126b4
to
9f5de93
Compare
474cad4
to
cc4b02f
Compare
crate/cli/src/tests/datasets.rs
Outdated
} | ||
|
||
#[allow(clippy::indexing_slicing)] | ||
fn parse_entries(s: &str) -> CliResult<EncryptedEntries> { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Please confirm me that this is the right way to parse findex result. It works yes, but idk if my implementation is case specefic or would work on other datasets
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@tbrezot what's your opinion abt this function ?
5bb491c
to
d5bf147
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Many todos, unnecessary clones and "tooling" diffs that I would have preferred not to see here: keep functional changes separate to ease reviewing.
This first review will be followed by a more in-depth one when I have time.
crate/structs/Cargo.toml
Outdated
cosmian_crypto_core = { workspace = true, features = ["ser"] } | ||
cosmian_findex = { workspace = true } | ||
cosmian_findex_config = { path = "../config" } | ||
rand = "0.8.5" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is rand used for ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
tests
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
partial review only
pub(crate) struct FindexServer { | ||
pub(crate) params: ServerParams, | ||
pub(crate) db: Box<dyn DatabaseTraits + Sync + Send>, | ||
pub(crate) db: Redis<WORD_LENGTH>, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
INFO : I had to take this out because batch_read and guarded write are not compatible with Box<dyn ...>
pub(crate) db: Box<dyn DatabaseTraits + Sync + Send>,
I tried various fixes, didn't work. imo it's BR & GW that should be changed if we want to keep this as box.
Here is the error :
the trait `DatabaseTraits` cannot be made into an object
consider moving `batch_read` to another trait
consider moving `guarded_write` to another trait
only type `database::redis::instance::Redis<WORD_LENGTH>` implements the trait, consider using it directly insteadre
async fn create_index_id(&self, user_id: &str) -> FResult<Uuid> { | ||
let redis_key = user_id.as_bytes(); | ||
|
||
let mut con = self.client.get_connection()?; | ||
// let mut con = self.client.get_connection()?; | ||
let mut con: redis::aio::ConnectionManager = self.memory.manager.clone(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no more need to get the connection "out" of the ConnectionManager. The ConnectionManager implements ConnectionLike trait and can be used directly to execute Redis commands. It handles the connection management internally.
pipe.atomic() | ||
.query_async::<()>(&mut self.memory.manager.clone()) | ||
.await | ||
.map_err(FindexServerError::from)?; | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
writing let _:()
is a fix for this error :
error: this function depends on never type fallback being `()`
--> crate/server/src/database/redis/permissions.rs:66:5
|
66 | #[instrument(ret(Display), err, skip(self), level = "trace")]
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release!
= note: for more information, see issue #123748 <https://github.com/rust-lang/rust/issues/123748>
= help: specify the types explicitly
note: in edition 2024, the requirement `!: FromRedisValue` will fail
--> crate/server/src/database/redis/permissions.rs:79:18
|
79 | .query_async(&mut con_manager)
| ^^^^^^^^^^^
note: the lint level is defined here
--> crate/server/src/lib.rs:7:5
|
7 | future_incompatible,
| ^^^^^^^^^^^^^^^^^^^
= note: `#[deny(dependency_on_unit_never_type_fallback)]` implied by `#[deny(future_incompatible)]`
= note: this error originates in the attribute macro `instrument` (in Nightly builds, run with -Z macro-backtrace for more info)
d58688a
to
ece9476
Compare
crate/client/src/config.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
has to be removed
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cargo.toml
Outdated
@@ -63,3 +62,5 @@ url = "2.5.4" | |||
x509-parser = "0.16" | |||
zeroize = { version = "1.8", default-features = false } | |||
uuid = { version = "1.11", features = ["v4", "serde"] } | |||
cosmian_findex = { git = "https://github.com/Cosmian/findex", branch = "feat/update_for_findex_server" } | |||
cosmian_crypto_core = { version = "9.3.0", default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
is this dep required?
cosmian_crypto_core = { version = "9.3.0", default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, used here in particular crate/structs/src/findex_serialization.rs
ae704a7
to
558e721
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Partial response, the rest coming soon
So far looking good for tests except for the huge dataset
crate/cli/src/commands.rs
Outdated
@@ -88,14 +88,14 @@ impl CoreFindexActions { | |||
#[allow(clippy::future_not_send)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do not agree with this lint rule, at least in this context I don't feel it has meaning
The error :
error: passing a unit value to a function
--> crate/cli/src/commands.rs:91:39
|
91 | Self::Datasets(action) => Ok(println!("{}", action.run(findex_client).await?)),
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: for further information visit https://rust-lang.github.io/rust-clippy/master/index.html#unit_arg
= note: `#[deny(clippy::unit_arg)]` implied by `#[deny(clippy::complexity)]`
help: remove the semicolon from the last statement in the block
--> /home/cosmian/.rustup/toolchains/1.83.0-x86_64-unknown-linux-gnu/lib/rustlib/src/rust/library/std/src/macros.rs:143:9
|
143| $crate::io::_print($crate::format_args_nl!($($arg)*))
|
help: or move the expression in front of the call and replace it with the unit literal `()`
|
91 ~ Self::Datasets(action) => {
92 + {
93 + $crate::io::_print($crate::format_args_nl!($($arg)*));
94 + };
95 + Ok(println!("{}", action.run(findex_client).await?))
96 ~ },
The fix clippy wants to see :
Self::Datasets(action) => {
let result = action.run(findex_client).await?;
println!("{}", result);
Ok(result)
}
Repeating this multiple times, huge boilerplate, etc ...
If you agree with disabling this, mark this as resolved
crate/cli/src/tests/findex/tests.rs
Outdated
findex_parameters: FindexParameters { | ||
key: "11223344556677889900AABBCCDDEEFF".to_owned(), | ||
label: "My Findex label".to_owned(), | ||
key: "11223344556677889900AABBCCDDEEFF11223344556677889900AABBCCDDEEFF".to_owned(), |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's not the same (for now) but it's supposed to be the same
crate/client/src/rest_client.rs
Outdated
}) | ||
} | ||
/// Instantiate a Findex REST client with a specific index. See below. Do not expose this. | ||
fn new_memory(&self, index_id: Uuid) -> FindexRestClient { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
in findex terminology i'd call this a ... new memory. I mean this is how findex sees it, despite what it actually is. Hence the name
crate/client/src/rest_client.rs
Outdated
} | ||
} | ||
/// Instantiate a Findex REST client with a specific index. | ||
/// Batch read and guarded write operations are defined in the findex crate and thus their signatures are not editable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this should not have been a doc comment but rather some review comment
Here is the full text :
/// Instantiate a Findex REST client with a specific index.
/// Batch read and guarded write operations are defined in the findex crate and thus their signatures are not editable
/// Ideal way to access the Some(index_id) is by having it as a field in the FindexRestClient struct
/// In the cli crate, first instantiate a base FindexRestClient and that will be used to instantiate a findex instance with a specific index
/// each time a call for Findex is needed
What I meant is that "ideally" we should have been able to pass the index_id but since the signature isn't editable, I documented my work around
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Part 2/2 done, I will still try to optimize
crate/client/src/rest_client.rs
Outdated
let index_id = self.index_id.clone().expect( | ||
"Unexpected error : this function should never be called while from base instance", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To call this, instantiate_findex
SHOULD be called
Read the instantiate_findex function
It calls the private new_memory function, which in turn always takes an index_id.
If index_id is underfined, a panic happens because by design it should be defined - and hence I unwrapped
crate/client/src/rest_client.rs
Outdated
let index_id = self.index_id.clone().expect( | ||
"Unexpected error : this function should never be called while from base instance", | ||
); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No more clones btw. Mark as solved if ok
trace!("CSV line: {record:?}"); | ||
} | ||
|
||
// Return the resulting HashMap |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Let me know if it's better with the comments i deleted
crate/client/src/config.rs
Outdated
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cargo.toml
Outdated
@@ -63,3 +62,5 @@ url = "2.5.4" | |||
x509-parser = "0.16" | |||
zeroize = { version = "1.8", default-features = false } | |||
uuid = { version = "1.11", features = ["v4", "serde"] } | |||
cosmian_findex = { git = "https://github.com/Cosmian/findex", branch = "feat/update_for_findex_server" } | |||
cosmian_crypto_core = { version = "9.3.0", default-features = false } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yes, used here in particular crate/structs/src/findex_serialization.rs
49bbfe6
to
1f4a61a
Compare
8463d5c
to
b39f3e0
Compare
fab9379
to
686e46e
Compare
9991b9b
to
75e514c
Compare
086c230
to
406216a
Compare
ea3a1f5
to
8236ed7
Compare
test: a ccr test chore: clippy fix: redis red hat issues fix: stop clearing DB fix: stop clearing DB 2 fix: MAC OS problems fix: revoke test
8236ed7
to
eb1f175
Compare
trace!("{error_prefix} Invalid discriminant flag. Expected 0 or 1, found None"); | ||
return Err(FindexServerError::InvalidRequest( | ||
INVALID_REQUEST.to_owned(), | ||
)); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
trace!("{error_prefix} Invalid discriminant flag. Expected 0 or 1, found None"); | |
return Err(FindexServerError::InvalidRequest( | |
INVALID_REQUEST.to_owned(), | |
)); | |
return Err(FindexServerError::InvalidRequest(format!( | |
"{error_prefix} Invalid discriminant flag. Expected 0 or 1, found None" | |
))); |
transaction_async
function redis-rs/redis-rs#1485crate/structs
. This will be optimized later on : Deserializer, Serializer #29