diff --git a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs index bbdbd529f69..f44f26dc3fb 100644 --- a/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs +++ b/base_layer/core/src/chain_storage/lmdb_db/lmdb_db.rs @@ -2618,7 +2618,7 @@ fn run_migrations(db: &LMDBDatabase) -> Result<(), ChainStorageError> { Ok(()) } -// TODO: remove +// TODO: this is a temporary fix, remove mod tari_script_execution_stack_bug_migration { use serde::{Deserialize, Serialize}; use tari_common_types::types::{ComSignature, PublicKey}; @@ -2632,6 +2632,15 @@ mod tari_script_execution_stack_bug_migration { }; pub fn migrate(db: &LMDBDatabase) -> Result<(), ChainStorageError> { + { + let txn = db.write_transaction()?; + // Only perform migration if necessary + if fetch_metadata(&txn, &db.metadata_db)?.height_of_longest_chain() == 0 || + lmdb_len(&txn, &db.inputs_db)? == 0 + { + return Ok(()); + } + } unsafe { LMDBStore::resize(&db.env, &LMDBConfig::new(0, 1024 * 1024 * 1024, 0))?; }