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

feat: tx and receipt compression utils for no-std config #11112

Merged

Conversation

nadtech-hub
Copy link
Contributor

@nadtech-hub nadtech-hub commented Sep 22, 2024

Tx and receipt compression utils for no-std environment.

@nadtech-hub nadtech-hub changed the title compression utils to work without std feature PR for issue #10871 Sep 22, 2024
Copy link
Member

@onbjerg onbjerg left a comment

Choose a reason for hiding this comment

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

please also update the pr title to be more descriptive of the change, as it will show up in the changelog

@@ -38,6 +39,38 @@ thread_local! {
));
}

/// Tx compressor creator
Copy link
Member

Choose a reason for hiding this comment

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

please update these comments to be in the same style as the rest of the codebase, i.e. "Creates a [Compressor] for transactions" or something like that

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Done

@nadtech-hub nadtech-hub changed the title feature PR for issue #10871 Tx and receipt compression utils for not-std config Sep 22, 2024
@nadtech-hub nadtech-hub changed the title Tx and receipt compression utils for not-std config Tx and receipt compression utils for no-std config Sep 22, 2024
Copy link
Collaborator

@mattsse mattsse left a comment

Choose a reason for hiding this comment

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

ptal @joshieDo

Comment on lines 1 to 2
#[cfg(feature = "std")]
use std::thread_local;
Copy link
Collaborator

Choose a reason for hiding this comment

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

please use full paths instead of feature gating imports

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Remove macro above import?

Copy link
Collaborator

Choose a reason for hiding this comment

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

you can use std::thread_local! directly

Copy link
Contributor Author

Choose a reason for hiding this comment

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

make sense

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done

@nadtech-hub nadtech-hub changed the title Tx and receipt compression utils for no-std config feat: tx and receipt compression utils for no-std config Sep 23, 2024
@joshieDo
Copy link
Collaborator

joshieDo commented Sep 23, 2024

Functionality wise looks fine, but i'm not entirely sure of the overhead of doing this for each tx/receipt.

Maybe for no-std we disable compression (in the future)? That would make no-zstd incapable of reading std databases though. (but not vice-versa)

let mut compressor = compressor.borrow_mut();
let mut tmp = Vec::with_capacity(256);
let mut tmp = Vec::with_capacity(256);
if cfg!(feature = "std") {
Copy link
Collaborator

Choose a reason for hiding this comment

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

Can we use cfg_if here?

Copy link
Contributor Author

@nadtech-hub nadtech-hub Sep 24, 2024

Choose a reason for hiding this comment

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

I've viewed that crate. I can't foresee more than 2 if-else branches in this place, therefore this crate doesn't seem much useful

@@ -38,6 +38,35 @@ thread_local! {
));
}

/// Fn creates as many tx compressors per thread as times its called. It is meant to be used in no-std config
Copy link
Collaborator

@joshieDo joshieDo Sep 24, 2024

Choose a reason for hiding this comment

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

Suggested change
/// Fn creates as many tx compressors per thread as times its called. It is meant to be used in no-std config
/// Creates a [`Compressor`] for transactions.

Copy link
Collaborator

Choose a reason for hiding this comment

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

And for the others

Copy link
Contributor Author

Choose a reason for hiding this comment

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

changed

@joshieDo joshieDo added A-db Related to the database A-dependencies Pull requests or issues that are about dependencies labels Sep 24, 2024
@nadtech-hub
Copy link
Contributor Author

nadtech-hub commented Sep 24, 2024

lint / fmt script fails on my machine as well as in pipeline. @joshieDo could you help me with this?
image

@joshieDo
Copy link
Collaborator

if you run either make fmt or cargo +nightly fmt it should fix it

@nadtech-hub
Copy link
Contributor Author

if you run either make fmt or cargo +nightly fmt it should fix it

@joshieDo
All cheks passed. I guess it can be merged now

@joshieDo joshieDo added this pull request to the merge queue Sep 26, 2024
@joshieDo joshieDo removed this pull request from the merge queue due to a manual request Sep 26, 2024
@joshieDo joshieDo added this pull request to the merge queue Sep 26, 2024
Merged via the queue into paradigmxyz:main with commit 6d0159e Sep 26, 2024
36 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-db Related to the database A-dependencies Pull requests or issues that are about dependencies
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants