-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Co-authored-by: jfldde <168934971+jfldde@users.noreply.github.com>
- Loading branch information
Showing
14 changed files
with
322 additions
and
24 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
crates/batch-prover/src/db_migrations/remove_unused_common_tables.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::sync::Arc; | ||
|
||
use sov_db::ledger_db::migrations::{LedgerMigration, MigrationName, MigrationVersion}; | ||
use sov_db::ledger_db::LedgerDB; | ||
use sov_db::schema::tables::{BATCH_PROVER_LEDGER_TABLES, LEDGER_TABLES}; | ||
|
||
/// Table removal migration | ||
/// tables BatchByNumber and SlotByNumber are removed | ||
pub(crate) struct RemoveUnusedTables {} | ||
|
||
impl LedgerMigration for RemoveUnusedTables { | ||
fn identifier(&self) -> (MigrationName, MigrationVersion) { | ||
("RemoveUnusedTables".to_owned(), 3) | ||
} | ||
|
||
fn execute( | ||
&self, | ||
ledger_db: Arc<LedgerDB>, | ||
tables_to_drop: &mut Vec<String>, | ||
) -> anyhow::Result<()> { | ||
// Get difference of LEDGER_TABLES and SEQUENCER_LEDGER_TABLES and drop them | ||
let mut diff = LEDGER_TABLES.to_vec(); | ||
diff.retain(|x| !BATCH_PROVER_LEDGER_TABLES.contains(x)); | ||
let diff_tables = diff.iter().map(|x| x.to_string()).collect::<Vec<_>>(); | ||
for table in diff_tables { | ||
// Check if table exists in the database | ||
if ledger_db.get_cf_handle(&table).is_ok() { | ||
tables_to_drop.push(table); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
crates/fullnode/src/db_migrations/remove_unused_common_tables.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::sync::Arc; | ||
|
||
use sov_db::ledger_db::migrations::{LedgerMigration, MigrationName, MigrationVersion}; | ||
use sov_db::ledger_db::LedgerDB; | ||
use sov_db::schema::tables::{FULL_NODE_LEDGER_TABLES, LEDGER_TABLES}; | ||
|
||
/// Table removal migration | ||
/// tables BatchByNumber and SlotByNumber are removed | ||
pub(crate) struct RemoveUnusedTables {} | ||
|
||
impl LedgerMigration for RemoveUnusedTables { | ||
fn identifier(&self) -> (MigrationName, MigrationVersion) { | ||
("RemoveUnusedTables".to_owned(), 3) | ||
} | ||
|
||
fn execute( | ||
&self, | ||
ledger_db: Arc<LedgerDB>, | ||
tables_to_drop: &mut Vec<String>, | ||
) -> anyhow::Result<()> { | ||
// Get difference of LEDGER_TABLES and SEQUENCER_LEDGER_TABLES and drop them | ||
let mut diff = LEDGER_TABLES.to_vec(); | ||
diff.retain(|x| !FULL_NODE_LEDGER_TABLES.contains(x)); | ||
let diff_tables = diff.iter().map(|x| x.to_string()).collect::<Vec<_>>(); | ||
for table in diff_tables { | ||
// Check if table exists in the database | ||
if ledger_db.get_cf_handle(&table).is_ok() { | ||
tables_to_drop.push(table); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
crates/light-client-prover/src/db_migrations/remove_unused_common_tables.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::sync::Arc; | ||
|
||
use sov_db::ledger_db::migrations::{LedgerMigration, MigrationName, MigrationVersion}; | ||
use sov_db::ledger_db::LedgerDB; | ||
use sov_db::schema::tables::{LEDGER_TABLES, LIGHT_CLIENT_PROVER_LEDGER_TABLES}; | ||
|
||
/// Table removal migration | ||
/// tables BatchByNumber and SlotByNumber are removed | ||
pub(crate) struct RemoveUnusedTables {} | ||
|
||
impl LedgerMigration for RemoveUnusedTables { | ||
fn identifier(&self) -> (MigrationName, MigrationVersion) { | ||
("RemoveUnusedTables".to_owned(), 3) | ||
} | ||
|
||
fn execute( | ||
&self, | ||
ledger_db: Arc<LedgerDB>, | ||
tables_to_drop: &mut Vec<String>, | ||
) -> anyhow::Result<()> { | ||
// Get difference of LEDGER_TABLES and SEQUENCER_LEDGER_TABLES and drop them | ||
let mut diff = LEDGER_TABLES.to_vec(); | ||
diff.retain(|x| !LIGHT_CLIENT_PROVER_LEDGER_TABLES.contains(x)); | ||
let diff_tables = diff.iter().map(|x| x.to_string()).collect::<Vec<_>>(); | ||
for table in diff_tables { | ||
// Check if table exists in the database | ||
if ledger_db.get_cf_handle(&table).is_ok() { | ||
tables_to_drop.push(table); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
crates/sequencer/src/db_migrations/remove_unused_common_tables.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
use std::sync::Arc; | ||
|
||
use sov_db::ledger_db::migrations::{LedgerMigration, MigrationName, MigrationVersion}; | ||
use sov_db::ledger_db::LedgerDB; | ||
use sov_db::schema::tables::{LEDGER_TABLES, SEQUENCER_LEDGER_TABLES}; | ||
|
||
/// Table removal migration | ||
/// tables BatchByNumber and SlotByNumber are removed | ||
pub(crate) struct RemoveUnusedTables {} | ||
|
||
impl LedgerMigration for RemoveUnusedTables { | ||
fn identifier(&self) -> (MigrationName, MigrationVersion) { | ||
("RemoveUnusedTables".to_owned(), 3) | ||
} | ||
|
||
fn execute( | ||
&self, | ||
ledger_db: Arc<LedgerDB>, | ||
tables_to_drop: &mut Vec<String>, | ||
) -> anyhow::Result<()> { | ||
// Get difference of LEDGER_TABLES and SEQUENCER_LEDGER_TABLES and drop them | ||
let mut diff = LEDGER_TABLES.to_vec(); | ||
diff.retain(|x| !SEQUENCER_LEDGER_TABLES.contains(x)); | ||
let diff_tables = diff.iter().map(|x| x.to_string()).collect::<Vec<_>>(); | ||
for table in diff_tables { | ||
// Check if table exists in the database | ||
if ledger_db.get_cf_handle(&table).is_ok() { | ||
tables_to_drop.push(table); | ||
} | ||
} | ||
Ok(()) | ||
} | ||
} |
Oops, something went wrong.