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

chore: Core crypto 2.0 migration [WPB-14635] #3141

Merged
merged 3 commits into from
Dec 6, 2024

Conversation

m-zagorski
Copy link
Contributor

@m-zagorski m-zagorski commented Dec 2, 2024

EpicWPB-14635 Upgrade to CoreCrypto 2.0

https://wearezeta.atlassian.net/browse/WPB-14635

What's new in this PR?

Solutions

Update core crypto to version 2.0.0. Migrate exception error codes mappings, add logger with default log level set to INFO


PR Post Submission Checklist for internal contributors (Optional)

  • Wire's Github Workflow has automatically linked the PR to a JIRA issue

PR Post Merge Checklist for internal contributors

  • If any soft of configuration variable was introduced by this PR, it has been added to the relevant documents and the CI jobs have been updated.

References
  1. https://sparkbox.com/foundry/semantic_commit_messages
  2. https://github.com/wireapp/.github#usage
  3. E.g. feat(conversation-list): Sort conversations by most emojis in the title #SQPIT-764.

@@ -36,12 +39,19 @@ actual suspend fun coreCryptoCentral(
key = databaseKey
)
coreCrypto.setCallbacks(Callbacks())
setLogger(CoreCryptoLoggerImpl(), CoreCryptoLogLevel.INFO)
Copy link
Contributor Author

Choose a reason for hiding this comment

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

would we want to have some other log level for debug builds?

Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can set to the lowest level (CoreCryptoLogLevel.Trace), and within the CoreCryptoLoggerImpl we can map to different kaliumLogger functions, which alreadys implement log-level filtering within it.

Copy link
Member

Choose a reason for hiding this comment

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

Warning ⚠️ this can have a negative performance impact since a lot of messages will go over the ffi boundary.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

@typfel should we then make it default to INFO ? or we should have it disabled for prod at all?

Copy link
Member

@typfel typfel Dec 4, 2024

Choose a reason for hiding this comment

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

We want it enabled in Prod at the INFO level which will not generate large amounts of logs.

Setting the level TRACE will potentially generate a lot of logs so it should not be enabled in Prod.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Reverted to INFO there

}

@Suppress("MagicNumber")
private fun mapProteusExceptionToRawIntErrorCode(proteusException: ProteusExceptionNative): Int {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Those mappers are here because we've to rely on the native ProteusException type directly, and we're not having the right dependency in the ProteusException

Copy link
Member

@typfel typfel Dec 4, 2024

Choose a reason for hiding this comment

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

Going forward I'd suggest aligning ProteusException with the ProteusExceptionNative. We want to go away from dealing Int numbers for error handling.

Doesn't have to be done right away but maybe create a TODO with a ticket?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Makes sense to have it in a different task, there is also some corecryptobox mappings to the ProteusException - but indeed would be nice to also clean it up

Copy link
Contributor

github-actions bot commented Dec 2, 2024

Test Results

3 339 tests  +5   3 232 ✅ +5   5m 32s ⏱️ +50s
  572 suites ±0     107 💤 ±0 
  572 files   ±0       0 ❌ ±0 

Results for commit b11ad65. ± Comparison against base commit 346034a.

♻️ This comment has been updated with latest results.

Copy link
Contributor

github-actions bot commented Dec 2, 2024

@codecov-commenter
Copy link

codecov-commenter commented Dec 2, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 54.19%. Comparing base (ee39af7) to head (b11ad65).
Report is 2 commits behind head on develop.

Additional details and impacted files
@@             Coverage Diff             @@
##           develop    #3141      +/-   ##
===========================================
+ Coverage    54.18%   54.19%   +0.01%     
===========================================
  Files         1251     1251              
  Lines        36403    36444      +41     
  Branches      3680     3689       +9     
===========================================
+ Hits         19725    19752      +27     
- Misses       15259    15268       +9     
- Partials      1419     1424       +5     
Files with missing lines Coverage Δ
...kalium/cryptography/exceptions/ProteusException.kt 51.02% <ø> (+1.02%) ⬆️

... and 8 files with indirect coverage changes


Continue to review full report in Codecov by Sentry.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update ee39af7...b11ad65. Read the comment docs.

@datadog-wireapp
Copy link

datadog-wireapp bot commented Dec 2, 2024

Datadog Report

Branch report: chore/core-crypto-2.0-migration
Commit report: 9da936c
Test service: kalium-jvm

✅ 0 Failed, 3232 Passed, 107 Skipped, 1m 8.07s Total Time

@@ -36,12 +39,19 @@ actual suspend fun coreCryptoCentral(
key = databaseKey
)
coreCrypto.setCallbacks(Callbacks())
setLogger(CoreCryptoLoggerImpl(), CoreCryptoLogLevel.INFO)
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we can set to the lowest level (CoreCryptoLogLevel.Trace), and within the CoreCryptoLoggerImpl we can map to different kaliumLogger functions, which alreadys implement log-level filtering within it.

Copy link

sonarqubecloud bot commented Dec 5, 2024

@m-zagorski m-zagorski added this pull request to the merge queue Dec 5, 2024
private class CoreCryptoLoggerImpl : CoreCryptoLogger {
override fun log(level: CoreCryptoLogLevel, message: String, context: String?) {
when (level) {
CoreCryptoLogLevel.TRACE -> kaliumLogger.v("$message. $context")
Copy link

@johnxnguyen johnxnguyen Dec 5, 2024

Choose a reason for hiding this comment

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

@m-zagorski is the message and the context concatenated together? Or do they get sent to datadog separately?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

the message will be concatenated - is that correct ? @johnxnguyen

@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Dec 5, 2024
@m-zagorski m-zagorski added this pull request to the merge queue Dec 6, 2024
Merged via the queue into develop with commit d2b92a0 Dec 6, 2024
23 checks passed
@m-zagorski m-zagorski deleted the chore/core-crypto-2.0-migration branch December 6, 2024 13:19
@echoes-hq echoes-hq bot added the echoes: product-roadmap Work aligned with the customer-announced roadmap, targeting a specific release date. label Dec 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
echoes: product-roadmap Work aligned with the customer-announced roadmap, targeting a specific release date. 👕 size: M type: chore 🧹
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants