From 801ad179c3ad0223163f232beb1c9cfa77252ec5 Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 2 Oct 2024 14:28:16 +0500 Subject: [PATCH 1/2] validate chain config from db --- sequencer/src/catchup.rs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/sequencer/src/catchup.rs b/sequencer/src/catchup.rs index 888d0d2be7..2d6df9d18b 100644 --- a/sequencer/src/catchup.rs +++ b/sequencer/src/catchup.rs @@ -276,7 +276,17 @@ where &self, commitment: Commitment, ) -> anyhow::Result { - self.db.get_chain_config(commitment).await + let cf = self.db.get_chain_config(commitment).await?; + + if cf.commit() != commitment { + bail!( + "Invalid chain config: expected {:?}, got {:?}", + commitment, + cf.commit() + ) + } + + Ok(cf) } fn backoff(&self) -> &BackoffParams { From 4690af82e8251166f5b6cbc29976ca5269d7051a Mon Sep 17 00:00:00 2001 From: Abdul Basit Date: Wed, 2 Oct 2024 20:47:34 +0500 Subject: [PATCH 2/2] replace with panic --- sequencer/src/catchup.rs | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/sequencer/src/catchup.rs b/sequencer/src/catchup.rs index 2d6df9d18b..6b595baefb 100644 --- a/sequencer/src/catchup.rs +++ b/sequencer/src/catchup.rs @@ -279,8 +279,9 @@ where let cf = self.db.get_chain_config(commitment).await?; if cf.commit() != commitment { - bail!( - "Invalid chain config: expected {:?}, got {:?}", + panic!( + "Critical error: Mismatched chain config detected. Expected chain config: {:?}, but got: {:?}. + This may indicate a compromised database", commitment, cf.commit() )