From 2bc3bf607638e388f510146b127f6b526a7793fe Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Wed, 31 Jul 2024 10:09:43 +0200 Subject: [PATCH 1/2] fix: replace impl From<&Path> with an ad-hoc method --- crates/blockifier/src/versioned_constants.rs | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/crates/blockifier/src/versioned_constants.rs b/crates/blockifier/src/versioned_constants.rs index a975ab0e98..93cf08b0d5 100644 --- a/crates/blockifier/src/versioned_constants.rs +++ b/crates/blockifier/src/versioned_constants.rs @@ -251,12 +251,8 @@ impl VersionedConstants { }; Self { validate_max_n_steps, max_recursion_depth, ..base_overrides } } -} - -impl TryFrom<&Path> for VersionedConstants { - type Error = VersionedConstantsError; - fn try_from(path: &Path) -> Result { + pub fn new_from_path_to_json_file(path: &Path) -> Result { Ok(serde_json::from_reader(std::fs::File::open(path)?)?) } } From 58ae35c1480f404aeae06ce15db761dc67b0dde2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Timoth=C3=A9e=20Delabrouille?= Date: Tue, 20 Aug 2024 02:09:39 +0200 Subject: [PATCH 2/2] replace try_from uses --- crates/papyrus_execution/src/lib.rs | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/crates/papyrus_execution/src/lib.rs b/crates/papyrus_execution/src/lib.rs index 46536125d4..b8f565d37d 100644 --- a/crates/papyrus_execution/src/lib.rs +++ b/crates/papyrus_execution/src/lib.rs @@ -99,12 +99,16 @@ const INITIAL_GAS_COST: u64 = 10000000000; pub type ExecutionResult = Result; static VERSIONED_CONSTANTS_13_0: Lazy = Lazy::new(|| { - VersionedConstants::try_from(Path::new("./resources/versioned_constants_13_0.json")) - .expect("Versioned constants JSON file is malformed") + VersionedConstants::new_from_path_to_json_file(Path::new( + "./resources/versioned_constants_13_0.json", + )) + .expect("Versioned constants JSON file is malformed") }); static VERSIONED_CONSTANTS_13_1: Lazy = Lazy::new(|| { - VersionedConstants::try_from(Path::new("./resources/versioned_constants_13_1.json")) - .expect("Versioned constants JSON file is malformed") + VersionedConstants::new_from_path_to_json_file(Path::new( + "./resources/versioned_constants_13_1.json", + )) + .expect("Versioned constants JSON file is malformed") }); #[derive(Copy, Clone, Serialize, Deserialize, Debug, PartialEq)]