From 5e21b361ef5974bf87aaa9e99309d373ddf4713f Mon Sep 17 00:00:00 2001 From: tbro Date: Thu, 19 Dec 2024 09:13:18 -0300 Subject: [PATCH] Do a checked_sub instead. I put the integer being subtracted from in the error to distinguish from rust panic message. --- sequencer/src/api/sql.rs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sequencer/src/api/sql.rs b/sequencer/src/api/sql.rs index c265f8974..359a3e260 100644 --- a/sequencer/src/api/sql.rs +++ b/sequencer/src/api/sql.rs @@ -208,7 +208,9 @@ async fn load_frontier( ) -> anyhow::Result { tx.get_path( Snapshot::::Index(height), - height - 1, + height + .checked_sub(1) + .ok_or(anyhow::anyhow!("Subtract with overflow ({height})!"))?, ) .await .context(format!("fetching frontier at height {height}"))