From 6a0bdfa377bd0032d7da9ec2533d04759485a9f0 Mon Sep 17 00:00:00 2001 From: Federico Gimenez Date: Thu, 7 Mar 2024 14:37:26 +0100 Subject: [PATCH 1/2] feat: add PrecompileError::Other --- crates/primitives/src/precompile.rs | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/crates/primitives/src/precompile.rs b/crates/primitives/src/precompile.rs index ee75d84c88..fd61e232c2 100644 --- a/crates/primitives/src/precompile.rs +++ b/crates/primitives/src/precompile.rs @@ -125,6 +125,8 @@ pub enum PrecompileError { BlobMismatchedVersion, /// The proof verification failed. BlobVerifyKzgProofFailed, + /// Catch-all variant for other errors. + Other(std::string::String), } #[cfg(feature = "std")] @@ -153,6 +155,9 @@ impl fmt::Display for PrecompileError { PrecompileError::BlobVerifyKzgProofFailed => { write!(f, "verifying blob kzg proof failed") } + PrecompileError::Other(why) => { + write!(f, "other precompile error: {why}") + } } } } From 65fd9cacb6d5af9cac9278f152409efab2debfbe Mon Sep 17 00:00:00 2001 From: Federico Gimenez Date: Thu, 7 Mar 2024 14:45:47 +0100 Subject: [PATCH 2/2] add PrecomileError::other --- crates/primitives/src/precompile.rs | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/crates/primitives/src/precompile.rs b/crates/primitives/src/precompile.rs index fd61e232c2..9ab05372f0 100644 --- a/crates/primitives/src/precompile.rs +++ b/crates/primitives/src/precompile.rs @@ -1,7 +1,7 @@ use crate::{Bytes, Env}; use core::fmt; use dyn_clone::DynClone; -use std::{boxed::Box, sync::Arc}; +use std::{boxed::Box, string::String, sync::Arc}; /// A precompile operation result. /// @@ -126,7 +126,13 @@ pub enum PrecompileError { /// The proof verification failed. BlobVerifyKzgProofFailed, /// Catch-all variant for other errors. - Other(std::string::String), + Other(String), +} + +impl PrecompileError { + pub fn other(err: impl Into) -> Self { + Self::Other(err.into()) + } } #[cfg(feature = "std")]