Module Evm_node_lib_dev.Evm_store

The EVM node’s store is built around and SQLite database.

include module type of Octez_sqlite.Sqlite
type t

A handler to the database.

type conn

A direct connection to the database, allowing to interact with it.

type perm =
  1. | Read_only of {
    1. pool_size : int;
    }
  2. | Read_write

Permission mode for database access.

Note that SQLite uses file-level locking for write operations. When using Read_write mode, write operations will acquire an exclusive lock on the database file, preventing other processes from writing to it simultaneously. In this case the pool size is always 1. In Read_only mode, multiple processes can read concurrently.

Initialization and backup

val close : t -> unit Lwt.t
val vacuum : conn:conn -> output_db_file:string -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t

Rebuild the database in output_db_file using the VACUUM sqlite command. This function is useful to backup the database.

val vacuum_self : conn:conn -> unit Tezos_error_monad.Error_monad.tzresult Lwt.t

Vacuums the database itself after removing lot of data VACUUM sqlite command.

Database connections

use db k executes k with a fresh connection to db.

with_transaction conn k wraps the accesses to the database from conn made in the continuation k within a SQL transaction. If k fails, the transaction is rollbacked. Otherwise, the transaction is committed.

val assert_in_transaction : conn -> unit

assert_in_transaction conn raises an exception if a transaction has not been started with conn.

  • raises Assert_failure

Database low level queries

module Request : sig ... end

Module for creating SQL requests with metadata for tracing and debugging. This is a wrapper around Caqti's request system with additional metadata.

module Db : sig ... end

Caqti convenience functions wrapped in the Tezos error monad. See Caqti_connection_sig.Convenience.

val with_connection : conn -> (Db.conn -> 'a) -> 'a

with_connection conn k allows to wraps atomic low level accesses to the database from conn. with_connection can be used in the continuation of with_transaction.

val init : ?max_conn_reuse_count:int -> data_dir:string -> perm:perm -> unit -> t Tezos_base.TzPervasives.tzresult Lwt.t

init ?max_conn_reuse_count ~data_dir ~perm () returns a handler to the EVM node store located under data_dir. If no store is located in data_dir, an empty store is created. Also returns if the store was created (true) or was already existing (false).

If perm is Read_only, then SQL requests requiring write access will fail. With Read_write, they will succeed as expected.

val sqlite_file_name : string

name of the sqlite file

module Schemas : sig ... end
module Blueprints : sig ... end
module Context_hashes : sig ... end
type pending_kernel_upgrade = {
  1. kernel_upgrade : Evm_node_lib_dev_encoding.Evm_events.Upgrade.t;
  2. injected_before : Evm_node_lib_dev_encoding.Ethereum_types.quantity;
}
type pending_sequencer_upgrade = {
  1. sequencer_upgrade : Evm_node_lib_dev_encoding.Evm_events.Sequencer_upgrade.t;
  2. injected_before : Evm_node_lib_dev_encoding.Ethereum_types.quantity;
}
module Kernel_upgrades : sig ... end
module Sequencer_upgrades : sig ... end
module Delayed_transactions : sig ... end
module Blocks : sig ... end
module Block_storage_mode : sig ... end
module Transactions : sig ... end
module Irmin_chunks : sig ... end
module Pending_confirmations : sig ... end
module L1_l2_levels_relationships : sig ... end
module L1_l2_finalized_levels : sig ... end
type metadata = {
  1. smart_rollup_address : Octez_smart_rollup.Address.t;
  2. history_mode : Evm_node_config.Configuration.history_mode;
}
module Metadata : sig ... end

reset_after conn ~l2_level clear the table that has information related to l2 level after l2_level

reset_before conn ~l2_level clear the table that has information related to l2 level before l2_level, if history_mode is set to Full keep block-related information and clear the rest