Skip to content

feat: historical block re-execution #139

@kariy

Description

@kariy

Description:

PR #118 have introduced versioned database types for block related data; the block header and transactions. The reason why we only versioned these types (instead of all the types for all the database tables) is because:

  • other than the Headers and Transactions tables (and other block-specific tables), the values for the rest of the tables can actually be derived again from the re-execution the stored blocks.
  • if new fields are introduced to types like Receipt, we won't be able to have those fields on older Receipts. New fields may be added that that extend the capability of Katana and aren't tight to specific protocol changes (eg., l2 gas fields). These new fields/data can't be derived for older entries without performing a re-execution of their respective transactions.
  • versioning all the types would be a huge maintenance effort.

To complete the database migration feature we need to perform the re-execution of historical blocks. We should be able to take existing database and perform execution of all the blocks in the database.

Feature Request:

  • Create a new crate called migration inside of <crates/storage>. Put all the logics related to database migration in this crate.
  • Don't integrate with katana-node yet. We only want to create a standalone implementation that is easily testable and the output can be easily verified.
  • The migration implementation shouldn't rely on concrete database type (eg., DbEnv for libmdbx implementation) it should only use the database abstraction traits defined in <crates/storage/db/src/abstraction> to perform any database related operations.

References:

  • Versioned types can be found in <crates/storage/db/src/models/versioned>.
  • Use the katana-executor crate to perform transaction execution. The executor implementation can be found in <crates/executor/src/implementation/blockifier/mod.rs>. An example of how to use the executor can be found in <crates/executor/tests/executor.rs>.
  • Before we can execute the blocks, we need to convert the database types to an executable types. Executable types can be found in <crates/primitives/src/transaction.rs> and <crates/primitives/src/block.rs>.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions