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(reth-storage-errors): no_std support #10011

Merged
merged 11 commits into from
Aug 13, 2024

Conversation

martinezjorge
Copy link
Contributor

@martinezjorge martinezjorge commented Aug 2, 2024

Towards #9478

Adds no_std support to reth-storage-errors.

Stacking PRs no longer necessary as implementing source for errors wrapped in error enum variants fixed the issues that were breaking tests.

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.

cool

crates/storage/errors/src/db.rs Outdated Show resolved Hide resolved
@@ -15,8 +15,9 @@ alloy-rlp.workspace = true
reth-primitives.workspace = true
reth-fs-util.workspace = true

thiserror-no-std = { workspace = true, default-features = false }
thiserror-no-std = { workspace = true, default-features = false, optional = true}
Copy link
Collaborator

Choose a reason for hiding this comment

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

I believe we can actually remove this now

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

pub enum DatabaseError {
/// Failed to open the database.
#[error("failed to open the database: {0}")]
#[display(fmt="failed to open the database: {_0}")]
Copy link
Collaborator

Choose a reason for hiding this comment

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

fmt nit for every occurrence

Suggested change
#[display(fmt="failed to open the database: {_0}")]
#[display(fmt = "failed to open the database: {_0}")]

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

@martinezjorge
Copy link
Contributor Author

@mattsse I think this is good to go if you could please take a look when you get a chance

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.

last nit

/// Provider result type.
pub type ProviderResult<Ok> = Result<Ok, ProviderError>;

/// Bundled errors variants thrown by various providers.
#[derive(Clone, Debug, thiserror_no_std::Error, PartialEq, Eq)]
#[derive(Clone, Debug, Display, From, PartialEq, Eq)]
Copy link
Collaborator

Choose a reason for hiding this comment

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

I'd like to not use From here instead impl From for the few variants manually

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

Copy link
Member

Choose a reason for hiding this comment

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

what's the argument for this @mattsse ?

Copy link
Contributor

Choose a reason for hiding this comment

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

Same q

Copy link
Collaborator

Choose a reason for hiding this comment

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

don't like the opt-out attributes, these from impls should be opt-in

Comment on lines 101 to 112
impl fmt::Display for DatabaseWriteError {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
write!(
f,
"write operation {} failed for key \"{}\" in table {}: {}",
self.operation,
reth_primitives::hex::encode(&self.key),
self.table_name,
self.info
)
}
}
Copy link
Member

Choose a reason for hiding this comment

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

should be possible to derive this too, check out example https://docs.rs/derive_more/latest/derive_more/derive.Display.html#custom-trait-bounds

crates/storage/errors/src/writer.rs Outdated Show resolved Hide resolved
crates/storage/errors/src/db.rs Outdated Show resolved Hide resolved
crates/storage/errors/src/lib.rs Outdated Show resolved Hide resolved
crates/storage/errors/src/provider.rs Outdated Show resolved Hide resolved
crates/storage/errors/src/writer.rs Outdated Show resolved Hide resolved
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.

lgtm, pending @shekhirin and conflict

@shekhirin shekhirin added this pull request to the merge queue Aug 13, 2024
Merged via the queue into paradigmxyz:main with commit b52a65b Aug 13, 2024
35 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants