From a594a0d93d83b4d24db7ddbb007a4110f4dc41c4 Mon Sep 17 00:00:00 2001
From: Marcin Ickiewicz <mickiewicz@syncad.com>
Date: Wed, 15 Jan 2025 12:06:03 +0100
Subject: [PATCH] rename hafd.irreversibla _datat to hafd.hive_state

---
 src/hive_fork_manager/app_api.sql              | 10 +++++-----
 src/hive_fork_manager/app_api_impl.sql         |  4 ++--
 .../application_loop/stages_functions.sql      |  2 +-
 src/hive_fork_manager/authorization.sql        |  2 +-
 .../block_views_for_head_block.sql             | 16 ++++++++--------
 src/hive_fork_manager/hived_api.sql            | 18 +++++++++---------
 src/hive_fork_manager/hived_api_impl.sql       |  6 +++---
 src/hive_fork_manager/irreversible_blocks.sql  |  6 +++---
 src/sql_serializer/indexes_controler.cpp       |  4 ++--
 tests/benchmarks/droprestoreindexes.sh         |  2 +-
 .../app_api/account_operations_view_test.sql   |  2 +-
 .../app_api/accounts_view_test.sql             |  2 +-
 ...p_next_block_group_process_BFF_wrong_id.sql |  2 +-
 ...block_process_BFF_in_irreversible_range.sql |  2 +-
 .../app_next_block_process_BFF_wrong_id.sql    |  2 +-
 .../app_api/applied_hardforks_view_test.sql    |  2 +-
 .../app_api/blocks_view_test.sql               |  2 +-
 .../app_api/operations_view_test.sql           |  2 +-
 .../app_api/signatures_view_test.sql           |  2 +-
 .../app_api/transactions_view_test.sql         |  2 +-
 .../process_BFF_in_irreversible_range.sql      |  2 +-
 .../application_loop/process_BFF_wrong_id.sql  |  2 +-
 .../alice_access_to_head_block_views.sql       |  2 +-
 .../hived_api/connect_test.sql                 |  4 ++--
 .../connect_test_not_remove_reversible.sql     |  2 +-
 .../disable_indexes_reversible_test.sql        |  2 +-
 .../hived_api/disable_indexes_test.sql         |  8 ++++----
 .../hived_api/get_block_2_test.sql             |  2 +-
 .../hived_api/get_block_3_test.sql             |  2 +-
 .../hived_api/get_block_header_2_test.sql      |  2 +-
 .../get_block_header_negative_test.sql         |  2 +-
 .../hived_api/get_block_header_test.sql        |  2 +-
 .../hived_api/get_block_range_test.sql         |  2 +-
 .../hived_api/get_block_reversible_test.sql    |  2 +-
 .../hived_api/get_block_test.sql               |  2 +-
 .../hived_api/mark_irreversible_dirty_test.sql |  4 ++--
 .../mark_irreversible_not_dirty_test.sql       |  4 ++--
 ...emoving_inconsistent_irreversibele_data.sql |  2 +-
 .../hived_api/push_block_test.sql              |  2 +-
 ...emoving_inconsistent_irreversibele_data.sql |  2 +-
 .../set_irreversible_cleaning_events_test.sql  |  2 +-
 .../shared_lib/calculate_schema_hash.sql       |  2 +-
 .../haf-local-tools/haf_local_tools/tables.py  |  2 +-
 tests/integration/replay/application.sql       |  2 +-
 44 files changed, 75 insertions(+), 75 deletions(-)

diff --git a/src/hive_fork_manager/app_api.sql b/src/hive_fork_manager/app_api.sql
index 083a0c5aa..5341b8619 100644
--- a/src/hive_fork_manager/app_api.sql
+++ b/src/hive_fork_manager/app_api.sql
@@ -37,7 +37,7 @@ BEGIN
           _name
         , _schema
         , ( SELECT MAX( hf.id ) FROM hafd.fork hf ) -- current fork id
-        , COALESCE( ( SELECT hid.consistent_block FROM hafd.irreversible_data hid ), 0 ) -- head of irreversible block
+        , COALESCE( ( SELECT hid.consistent_block FROM hafd.hive_state hid ), 0 ) -- head of irreversible block
         , _is_forking
         , _is_attached
         , NULL
@@ -67,7 +67,7 @@ BEGIN
             _name
         , _schema
         , ( SELECT MAX( hf.id ) FROM hafd.fork hf ) -- current fork id
-        , COALESCE( ( SELECT hid.consistent_block FROM hafd.irreversible_data hid ), 0 ) -- head of irreversible block
+        , COALESCE( ( SELECT hid.consistent_block FROM hafd.hive_state hid ), 0 ) -- head of irreversible block
         , _is_forking
         , False
         , _stages
@@ -241,7 +241,7 @@ BEGIN
     WHERE hc.name = __lead_context;
 
     SELECT hir.consistent_block INTO __head_of_irreversible_block
-    FROM hafd.irreversible_data hir;
+    FROM hafd.hive_state hir;
 
     IF __current_block_num > __head_of_irreversible_block THEN
         RAISE EXCEPTION 'Cannot attach context % because the block num % is grater than top of irreversible block %'
@@ -477,7 +477,7 @@ $BODY$
 DECLARE
     __result hafd.contexts.irreversible_block%TYPE;
 BEGIN
-    SELECT COALESCE( consistent_block, 0 ) INTO __result FROM hafd.irreversible_data;
+    SELECT COALESCE( consistent_block, 0 ) INTO __result FROM hafd.hive_state;
     RETURN __result;
 END;
 $BODY$;
@@ -858,7 +858,7 @@ BEGIN
                      FROM UNNEST(_contexts) AS context_names(name)
                      LEFT JOIN hafd.contexts hc USING(name)
                      JOIN hafd.contexts_attachment hca ON hca.context_id = hc.id
-                     CROSS JOIN hafd.irreversible_data), FALSE);
+                     CROSS JOIN hafd.hive_state), FALSE);
 END;
 $BODY$
 ;
diff --git a/src/hive_fork_manager/app_api_impl.sql b/src/hive_fork_manager/app_api_impl.sql
index 9cf0ad877..cdb0643a0 100644
--- a/src/hive_fork_manager/app_api_impl.sql
+++ b/src/hive_fork_manager/app_api_impl.sql
@@ -69,7 +69,7 @@ BEGIN
          , hc.fork_id
     INTO __curent_events_id, __current_context_block_num, __current_context_irreversible_block, __current_fork_id
     FROM hafd.contexts hc WHERE hc.name = __lead_context;
-    SELECT consistent_block INTO __newest_irreversible_block_num FROM hafd.irreversible_data;
+    SELECT consistent_block INTO __newest_irreversible_block_num FROM hafd.hive_state;
 
     -- hived can at any moment commit new events
     -- because of read committed, we need to be ready such situations
@@ -207,7 +207,7 @@ BEGIN
     FROM hafd.contexts as hc
     WHERE hc.name = __lead_context;
 
-    SELECT consistent_block INTO __newest_irreversible_block_num FROM hafd.irreversible_data;
+    SELECT consistent_block INTO __newest_irreversible_block_num FROM hafd.hive_state;
 
     IF __current_block_num <= __irreversible_block_num
        AND  __newest_irreversible_block_num IS NOT NULL THEN
diff --git a/src/hive_fork_manager/application_loop/stages_functions.sql b/src/hive_fork_manager/application_loop/stages_functions.sql
index 3396fa222..5017f092e 100644
--- a/src/hive_fork_manager/application_loop/stages_functions.sql
+++ b/src/hive_fork_manager/application_loop/stages_functions.sql
@@ -45,7 +45,7 @@ DECLARE
     __lead_context_distance_to_irr_hb INTEGER;
 BEGIN
     SELECT
-        ( ( SELECT COALESCE( hid.consistent_block, 0 ) - ctx.current_block_num FROM hafd.irreversible_data hid ) ) INTO __lead_context_distance_to_irr_hb
+        ( ( SELECT COALESCE( hid.consistent_block, 0 ) - ctx.current_block_num FROM hafd.hive_state hid ) ) INTO __lead_context_distance_to_irr_hb
     FROM hafd.contexts ctx
     WHERE ctx.name = _contexts [ 1 ];
 
diff --git a/src/hive_fork_manager/authorization.sql b/src/hive_fork_manager/authorization.sql
index 11655d266..30d125e69 100644
--- a/src/hive_fork_manager/authorization.sql
+++ b/src/hive_fork_manager/authorization.sql
@@ -40,7 +40,7 @@ ALTER TABLE hafd.operations OWNER TO hived_group;
 ALTER TABLE hafd.transactions_multisig OWNER TO hived_group;
 ALTER TABLE hafd.accounts OWNER TO hived_group;
 ALTER TABLE hafd.account_operations OWNER TO hived_group;
-ALTER TABLE hafd.irreversible_data OWNER TO hived_group;
+ALTER TABLE hafd.hive_state OWNER TO hived_group;
 ALTER TABLE hafd.blocks_reversible OWNER TO hived_group;
 ALTER TABLE hafd.transactions_reversible OWNER TO hived_group;
 ALTER TABLE hafd.operations_reversible OWNER TO hived_group;
diff --git a/src/hive_fork_manager/block_views_for_head_block.sql b/src/hive_fork_manager/block_views_for_head_block.sql
index bce8bcb01..f6c9a4884 100644
--- a/src/hive_fork_manager/block_views_for_head_block.sql
+++ b/src/hive_fork_manager/block_views_for_head_block.sql
@@ -11,7 +11,7 @@ UNION ALL
 (
 WITH 
 consistent_block AS
-(SELECT COALESCE(hid.consistent_block, 0) AS consistent_block FROM hafd.irreversible_data hid LIMIT 1)
+(SELECT COALESCE(hid.consistent_block, 0) AS consistent_block FROM hafd.hive_state hid LIMIT 1)
 ,forks AS
 (
   SELECT hbr.num, max(hbr.fork_id) AS max_fork_id
@@ -52,7 +52,7 @@ FROM
         JOIN (
             SELECT hbr.num, MAX(hbr.fork_id) as max_fork_id
             FROM hafd.blocks_reversible hbr
-            WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.irreversible_data hid )
+            WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.hive_state hid )
             GROUP by hbr.num
         ) as forks ON forks.max_fork_id = har.fork_id AND forks.num = har.block_num
     ) reversible
@@ -120,7 +120,7 @@ FROM (
     (
          SELECT rb.num, MAX(rb.fork_id) AS max_fork_id
          FROM hafd.blocks_reversible rb
-         WHERE rb.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.irreversible_data hid )
+         WHERE rb.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.hive_state hid )
          GROUP BY rb.num
     ) visible_blks ON visible_blks.num = hbr.num AND visible_blks.max_fork_id = hbr.fork_id
 ) t
@@ -166,7 +166,7 @@ FROM
     JOIN (
         SELECT hbr.num, MAX(hbr.fork_id) as max_fork_id
         FROM hafd.blocks_reversible hbr
-        WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.irreversible_data hid )
+        WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.hive_state hid )
         GROUP by hbr.num
     ) as forks ON forks.max_fork_id = htr.fork_id AND forks.num = htr.block_num
     ) reversible
@@ -209,7 +209,7 @@ FROM
       (
         SELECT hbr.num, MAX(hbr.fork_id) as max_fork_id
         FROM hafd.blocks_reversible hbr
-        WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.irreversible_data hid )
+        WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.hive_state hid )
         GROUP by hbr.num
       ) visible_ops on visible_ops.num = hafd.operation_id_to_block_num(o.id) and visible_ops.max_fork_id = o.fork_id
       JOIN
@@ -252,7 +252,7 @@ FROM
       (
         SELECT hbr.num, MAX(hbr.fork_id) as max_fork_id
         FROM hafd.blocks_reversible hbr
-        WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.irreversible_data hid )
+        WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.hive_state hid )
         GROUP by hbr.num
       ) visible_ops on visible_ops.num = hafd.operation_id_to_block_num(o.id) and visible_ops.max_fork_id = o.fork_id
 ) t
@@ -283,7 +283,7 @@ FROM (
                 JOIN (
                     SELECT hbr.num, MAX(hbr.fork_id) as max_fork_id
                     FROM hafd.blocks_reversible hbr
-                    WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.irreversible_data hid )
+                    WHERE hbr.num > ( SELECT COALESCE( hid.consistent_block, 0 ) FROM hafd.hive_state hid )
                     GROUP by hbr.num
                 ) as forks ON forks.max_fork_id = htr.fork_id AND forks.num = htr.block_num
         ) as trr ON trr.trx_hash = htmr.trx_hash AND trr.max_fork_id = htmr.fork_id
@@ -301,7 +301,7 @@ UNION ALL
 (
 WITH 
 consistent_block AS
-(SELECT COALESCE(hid.consistent_block, 0) AS consistent_block FROM hafd.irreversible_data hid LIMIT 1)
+(SELECT COALESCE(hid.consistent_block, 0) AS consistent_block FROM hafd.hive_state hid LIMIT 1)
 ,forks AS
 (
   SELECT hbr.num, max(hbr.fork_id) AS max_fork_id
diff --git a/src/hive_fork_manager/hived_api.sql b/src/hive_fork_manager/hived_api.sql
index 339c4c74f..6186e494c 100644
--- a/src/hive_fork_manager/hived_api.sql
+++ b/src/hive_fork_manager/hived_api.sql
@@ -113,7 +113,7 @@ BEGIN
     -- application contexts will use the event to clear data in shadow tables
     INSERT INTO hafd.events_queue( event, block_num )
     VALUES( 'NEW_IRREVERSIBLE', _block_num );
-    UPDATE hafd.irreversible_data SET consistent_block = _block_num;
+    UPDATE hafd.hive_state SET consistent_block = _block_num;
 END;
 $BODY$
 ;
@@ -141,7 +141,7 @@ BEGIN
 
 
 
-    UPDATE hafd.irreversible_data SET consistent_block = _block_num;
+    UPDATE hafd.hive_state SET consistent_block = _block_num;
 END;
 $BODY$
 ;
@@ -153,7 +153,7 @@ CREATE OR REPLACE FUNCTION hive.set_irreversible_dirty()
 AS
 $BODY$
 BEGIN
-    UPDATE hafd.irreversible_data SET is_dirty = TRUE;
+    UPDATE hafd.hive_state SET is_dirty = TRUE;
 END;
 $BODY$
 ;
@@ -165,7 +165,7 @@ CREATE OR REPLACE FUNCTION hive.set_irreversible_not_dirty()
 AS
 $BODY$
 BEGIN
-    UPDATE hafd.irreversible_data SET is_dirty = FALSE;
+    UPDATE hafd.hive_state SET is_dirty = FALSE;
 END;
 $BODY$
 ;
@@ -179,7 +179,7 @@ $BODY$
 DECLARE
     __is_dirty BOOL := FALSE;
 BEGIN
-    SELECT is_dirty INTO __is_dirty FROM hafd.irreversible_data;
+    SELECT is_dirty INTO __is_dirty FROM hafd.hive_state;
     RETURN __is_dirty;
 END;
 $BODY$
@@ -212,7 +212,7 @@ CREATE OR REPLACE FUNCTION hive.disable_fk_of_irreversible()
 AS
 $BODY$
 BEGIN
-    PERFORM hive.save_and_drop_foreign_keys( 'hafd', 'irreversible_data' );
+    PERFORM hive.save_and_drop_foreign_keys( 'hafd', 'hive_state' );
     PERFORM hive.save_and_drop_foreign_keys( 'hafd', 'blocks' );
     PERFORM hive.save_and_drop_foreign_keys( 'hafd', 'transactions' );
     PERFORM hive.save_and_drop_foreign_keys( 'hafd', 'transactions_multisig' );
@@ -239,7 +239,7 @@ BEGIN
     PERFORM hive.restore_indexes( 'hafd.applied_hardforks' );
     PERFORM hive.restore_indexes( 'hafd.accounts' );
     PERFORM hive.restore_indexes( 'hafd.account_operations' );
-    PERFORM hive.restore_indexes( 'hafd.irreversible_data' );
+    PERFORM hive.restore_indexes( 'hafd.hive_state' );
 
     PERFORM hive.reanalyze_indexes_with_expressions();
 END;
@@ -259,7 +259,7 @@ BEGIN
     PERFORM hive.restore_foreign_keys( 'hafd.transactions_multisig' );
     PERFORM hive.restore_foreign_keys( 'hafd.operations' );
     PERFORM hive.restore_foreign_keys( 'hafd.applied_hardforks' );
-    PERFORM hive.restore_foreign_keys( 'hafd.irreversible_data' );
+    PERFORM hive.restore_foreign_keys( 'hafd.hive_state' );
     PERFORM hive.restore_foreign_keys( 'hafd.accounts' );
     PERFORM hive.restore_foreign_keys( 'hafd.account_operations' );
 
@@ -455,7 +455,7 @@ BEGIN
         RETURN;
     END IF;
 
-    INSERT INTO hafd.irreversible_data VALUES(1,NULL, FALSE) ON CONFLICT DO NOTHING;
+    INSERT INTO hafd.hive_state VALUES(1,NULL, FALSE) ON CONFLICT DO NOTHING;
     INSERT INTO hafd.events_queue VALUES( 0, 'NEW_IRREVERSIBLE', 0 ) ON CONFLICT DO NOTHING;
     INSERT INTO hafd.events_queue VALUES( hive.unreachable_event_id(), 'NEW_BLOCK', 2147483647 ) ON CONFLICT DO NOTHING;
     SELECT MAX(eq.id) + 1 FROM hafd.events_queue eq WHERE eq.id != hive.unreachable_event_id() INTO __events_id;
diff --git a/src/hive_fork_manager/hived_api_impl.sql b/src/hive_fork_manager/hived_api_impl.sql
index 456ade1d4..30c2466d4 100644
--- a/src/hive_fork_manager/hived_api_impl.sql
+++ b/src/hive_fork_manager/hived_api_impl.sql
@@ -312,7 +312,7 @@ DECLARE
     __upper_bound_events_id BIGINT := NULL;
     __max_block_num INTEGER := NULL;
 BEGIN
-    SELECT consistent_block INTO __max_block_num FROM hafd.irreversible_data;
+    SELECT consistent_block INTO __max_block_num FROM hafd.hive_state;
 
     -- find the upper bound of events possible to remove
     SELECT MIN(heq.id) INTO __upper_bound_events_id
@@ -590,7 +590,7 @@ DECLARE
     __consistent_block INTEGER := NULL;
     __is_dirty BOOL := TRUE;
 BEGIN
-    SELECT consistent_block, is_dirty INTO __consistent_block, __is_dirty FROM hafd.irreversible_data;
+    SELECT consistent_block, is_dirty INTO __consistent_block, __is_dirty FROM hafd.hive_state;
 
     IF ( __is_dirty = FALSE ) THEN
         RETURN;
@@ -613,7 +613,7 @@ BEGIN
 
     DELETE FROM hafd.blocks WHERE num > __consistent_block;
 
-    UPDATE hafd.irreversible_data SET is_dirty = FALSE;
+    UPDATE hafd.hive_state SET is_dirty = FALSE;
 END;
 $BODY$
 ;
diff --git a/src/hive_fork_manager/irreversible_blocks.sql b/src/hive_fork_manager/irreversible_blocks.sql
index 3ee2465c2..2ca57f788 100644
--- a/src/hive_fork_manager/irreversible_blocks.sql
+++ b/src/hive_fork_manager/irreversible_blocks.sql
@@ -39,7 +39,7 @@ CREATE TYPE hafd.sync_state AS ENUM (
 );
 
 
-CREATE TABLE IF NOT EXISTS hafd.irreversible_data (
+CREATE TABLE IF NOT EXISTS hafd.hive_state (
       id integer,
       consistent_block integer,
       is_dirty bool NOT NULL,
@@ -50,8 +50,8 @@ CREATE TABLE IF NOT EXISTS hafd.irreversible_data (
 -- We use ADD CONSTRAINT with ALTER TABLE followed by NOT VALID because the NOT VALID option isn't documented
 -- or supported within CREATE TABLE, and thus, seems not to work there.
 -- This applies to the following tables as well.
-ALTER TABLE hafd.irreversible_data ADD CONSTRAINT fk_1_hive_irreversible_data FOREIGN KEY (consistent_block) REFERENCES hafd.blocks (num) NOT VALID;
-SELECT pg_catalog.pg_extension_config_dump('hafd.irreversible_data', '');
+ALTER TABLE hafd.hive_state ADD CONSTRAINT fk_1_hive_irreversible_data FOREIGN KEY (consistent_block) REFERENCES hafd.blocks (num) NOT VALID;
+SELECT pg_catalog.pg_extension_config_dump('hafd.hive_state', '');
 
 CREATE TABLE IF NOT EXISTS hafd.transactions (
     block_num integer NOT NULL,
diff --git a/src/sql_serializer/indexes_controler.cpp b/src/sql_serializer/indexes_controler.cpp
index 95a5c95d4..359a6118c 100644
--- a/src/sql_serializer/indexes_controler.cpp
+++ b/src/sql_serializer/indexes_controler.cpp
@@ -80,7 +80,7 @@ indexes_controler::enable_indexes() {
   fc::time_point restore_indexes_start_time = fc::time_point::now();
 
   auto restore_blocks_idxs = start_commit_sql( true, "hive.restore_indexes( 'hafd.blocks' )", "enable indexes" );
-  auto restore_irreversible_idxs = start_commit_sql( true, "hive.restore_indexes( 'hafd.irreversible_data' )", "enable indexes" );
+  auto restore_irreversible_idxs = start_commit_sql( true, "hive.restore_indexes( 'hafd.hive_state' )", "enable indexes" );
   auto restore_transactions_idxs = start_commit_sql( true, "hive.restore_indexes( 'hafd.transactions' )", "enable indexes" );
   auto restore_transactions_sigs_idxs = start_commit_sql( true, "hive.restore_indexes( 'hafd.transactions_multisig' )", "enable indexes" );
   auto restore_operations_idxs = start_commit_sql( true, "hive.restore_indexes( 'hafd.operations' )", "enable indexes" );
@@ -122,7 +122,7 @@ indexes_controler::enable_constrains() {
   ilog("Restoring HAF constraints...");
   fc::time_point restore_constraints_start_time = fc::time_point::now();
 
-  auto restore_irreversible_fks = start_commit_sql( true, "hive.restore_foreign_keys( 'hafd.irreversible_data' )", "enable indexes" );
+  auto restore_irreversible_fks = start_commit_sql( true, "hive.restore_foreign_keys( 'hafd.hive_state' )", "enable indexes" );
   auto restore_transactions_fks = start_commit_sql( true, "hive.restore_foreign_keys( 'hafd.transactions' )", "enable indexes" );
   auto restore_transactions_sigs_fks = start_commit_sql( true, "hive.restore_foreign_keys( 'hafd.transactions_multisig' )", "enable indexes" );
   auto restore_operations_fks = start_commit_sql( true, "hive.restore_foreign_keys( 'hafd.operations' )", "enable indexes" );
diff --git a/tests/benchmarks/droprestoreindexes.sh b/tests/benchmarks/droprestoreindexes.sh
index 08c3e421b..c4a7621d4 100755
--- a/tests/benchmarks/droprestoreindexes.sh
+++ b/tests/benchmarks/droprestoreindexes.sh
@@ -14,7 +14,7 @@ psql "$POSTGRES_ACCESS" --command="${cmd}"
 #restore indexes
 cmd="select hive.restore_indexes( 'hafd.blocks' );"
 psql "$POSTGRES_ACCESS" --command="${cmd}" &
-cmd="select hive.restore_indexes( 'hafd.irreversible_data' );"
+cmd="select hive.restore_indexes( 'hafd.hive_state' );"
 psql "$POSTGRES_ACCESS" --command="${cmd}" &
 cmd="select hive.restore_indexes( 'hafd.transactions' );"
 psql "$POSTGRES_ACCESS" --command="${cmd}" &
diff --git a/tests/integration/functional/hive_fork_manager/app_api/account_operations_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/account_operations_view_test.sql
index a2a5585f1..78c15dc86 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/account_operations_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/account_operations_view_test.sql
@@ -118,7 +118,7 @@ BEGIN
          , ( 1100, 3, hafd.operation_id(10,1,0), 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 4;
+    UPDATE hafd.hive_state SET consistent_block = 4;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/app_api/accounts_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/accounts_view_test.sql
index 7299c004b..8863a1f6d 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/accounts_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/accounts_view_test.sql
@@ -59,7 +59,7 @@ BEGIN
          , ( 1100, 'alice103', 10, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/app_api/app_next_block_group_process_BFF_wrong_id.sql b/tests/integration/functional/hive_fork_manager/app_api/app_next_block_group_process_BFF_wrong_id.sql
index 2c58c7b6d..034c788da 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/app_next_block_group_process_BFF_wrong_id.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/app_next_block_group_process_BFF_wrong_id.sql
@@ -29,7 +29,7 @@ BEGIN
     VALUES (5, 'initminer', 1)
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 3;
+    UPDATE hafd.hive_state SET consistent_block = 3;
 
     CREATE SCHEMA A;
     PERFORM hive.app_create_context( _name =>  'context', _schema => 'a'  );
diff --git a/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_in_irreversible_range.sql b/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_in_irreversible_range.sql
index ef0cd914c..492c54cf0 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_in_irreversible_range.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_in_irreversible_range.sql
@@ -21,7 +21,7 @@ BEGIN
     VALUES (5, 'initminer', 1)
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 3;
+    UPDATE hafd.hive_state SET consistent_block = 3;
 
     CREATE SCHEMA A;
     PERFORM hive.app_create_context( _name =>  'context', _schema => 'a'  );
diff --git a/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_wrong_id.sql b/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_wrong_id.sql
index 18d3b7145..75ed8df3d 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_wrong_id.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/app_next_block_process_BFF_wrong_id.sql
@@ -29,7 +29,7 @@ BEGIN
     VALUES (5, 'initminer', 1)
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 3;
+    UPDATE hafd.hive_state SET consistent_block = 3;
 
     CREATE SCHEMA A;
     PERFORM hive.app_create_context( _name =>  'context', _schema => 'a'  );
diff --git a/tests/integration/functional/hive_fork_manager/app_api/applied_hardforks_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/applied_hardforks_view_test.sql
index 0c125bd1b..3fe81a55e 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/applied_hardforks_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/applied_hardforks_view_test.sql
@@ -98,7 +98,7 @@ VALUES
      , ( 10, 10, hafd.operation_id(10, 1, 0), 3 )
 ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/app_api/blocks_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/blocks_view_test.sql
index b42ef6575..5d2ff8ce9 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/blocks_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/blocks_view_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/app_api/operations_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/operations_view_test.sql
index 32ab95bec..3e5d1233f 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/operations_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/operations_view_test.sql
@@ -88,7 +88,7 @@ BEGIN
          , ( hafd.operation_id(10, 1, 0), 0, 0, '{"type":"system_warning_operation","value":{"message":"TEN OPERATION"}}' :: jsonb :: hafd.operation, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/app_api/signatures_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/signatures_view_test.sql
index cbd80b19a..c1592bc30 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/signatures_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/signatures_view_test.sql
@@ -87,7 +87,7 @@ BEGIN
      , ( '\xDEED1102', '\xBEEF13',  3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/app_api/transactions_view_test.sql b/tests/integration/functional/hive_fork_manager/app_api/transactions_view_test.sql
index 871b1f957..75ff4ad83 100644
--- a/tests/integration/functional/hive_fork_manager/app_api/transactions_view_test.sql
+++ b/tests/integration/functional/hive_fork_manager/app_api/transactions_view_test.sql
@@ -61,7 +61,7 @@ BEGIN
          , ( 10, 0::SMALLINT, '\xDEED11', 101, 100, '2016-06-22 19:10:30-07'::timestamp, '\xBEEF', 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_in_irreversible_range.sql b/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_in_irreversible_range.sql
index 5008058d8..a2ba7bdc1 100644
--- a/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_in_irreversible_range.sql
+++ b/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_in_irreversible_range.sql
@@ -22,7 +22,7 @@ BEGIN
     VALUES (5, 'initminer', 1)
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 3;
+    UPDATE hafd.hive_state SET consistent_block = 3;
 
     CREATE SCHEMA A;
     PERFORM hive.app_create_context( _name =>  'context', _schema => 'a', _stages => __context_stages  );
diff --git a/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_wrong_id.sql b/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_wrong_id.sql
index ca0fd40e6..a32bf604d 100644
--- a/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_wrong_id.sql
+++ b/tests/integration/functional/hive_fork_manager/application_loop/process_BFF_wrong_id.sql
@@ -30,7 +30,7 @@ BEGIN
     VALUES (5, 'initminer', 1)
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 3;
+    UPDATE hafd.hive_state SET consistent_block = 3;
 
     CREATE SCHEMA A;
     PERFORM hive.app_create_context( _name =>  'context', _schema => 'a', _stages => __context_stages  );
diff --git a/tests/integration/functional/hive_fork_manager/authorization/alice_access_to_head_block_views.sql b/tests/integration/functional/hive_fork_manager/authorization/alice_access_to_head_block_views.sql
index 7fd317ef5..2d8307a43 100644
--- a/tests/integration/functional/hive_fork_manager/authorization/alice_access_to_head_block_views.sql
+++ b/tests/integration/functional/hive_fork_manager/authorization/alice_access_to_head_block_views.sql
@@ -139,7 +139,7 @@ BEGIN
          , ( 11, 3, hafd.operation_id(10,1,0), 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 4;
+    UPDATE hafd.hive_state SET consistent_block = 4;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/connect_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/connect_test.sql
index c97327347..607c780a3 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/connect_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/connect_test.sql
@@ -55,7 +55,7 @@ BEGIN
     -- block 2 was not claimed, and it is possible not all information about it was dumped - maybe hived crashes
     PERFORM hive.end_massive_sync( 1 );
 
-    UPDATE hafd.irreversible_data SET is_dirty = TRUE;
+    UPDATE hafd.hive_state SET is_dirty = TRUE;
 END;
 $BODY$
 ;
@@ -106,7 +106,7 @@ BEGIN
     ASSERT( SELECT COUNT(*) FROM hafd.fork WHERE block_num = 1 ) = 1, 'No fork added after connection on 1 block';
     ASSERT( SELECT COUNT(*) FROM hafd.fork WHERE block_num = 2 ) = 0, 'Fork added after connection on 2 block';
 
-    ASSERT( SELECT is_dirty FROM hafd.irreversible_data ) = FALSE, 'Irreversible data are dirty';
+    ASSERT( SELECT is_dirty FROM hafd.hive_state ) = FALSE, 'Irreversible data are dirty';
 END
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/connect_test_not_remove_reversible.sql b/tests/integration/functional/hive_fork_manager/hived_api/connect_test_not_remove_reversible.sql
index e898f2cef..7a917bb5c 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/connect_test_not_remove_reversible.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/connect_test_not_remove_reversible.sql
@@ -55,7 +55,7 @@ BEGIN
     -- block 2 was not claimed, and it is possible not all information about it was dumped - maybe hived crashes
     PERFORM hive.end_massive_sync( 1 );
 
-    UPDATE hafd.irreversible_data SET is_dirty = TRUE;
+    UPDATE hafd.hive_state SET is_dirty = TRUE;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_reversible_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_reversible_test.sql
index b5e37b84d..a6ceac36f 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_reversible_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_reversible_test.sql
@@ -67,7 +67,7 @@ BEGIN
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'transactions_reversible') ), 'FK for hafd.transactions exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'operations_reversible') ), 'FK for hafd.operations exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'transactions_multisig_reversible') ), 'FK for hafd.transactions_multisig exists';
-    ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'irreversible_data_reversible') ), 'FK for hafd.irreversible_data exists';
+    ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'irreversible_data_reversible') ), 'FK for hafd.hive_state exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'accounts_reversible') ), 'FK for hafd.accounts exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'account_operations_reversible') ), 'FK for hafd.account_operations exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'applied_hardforks_reversible') ), 'FK for hafd.applied_hardforks exists';
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_test.sql
index 751edb684..f15025406 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/disable_indexes_test.sql
@@ -70,8 +70,8 @@ BEGIN
     ASSERT NOT ( SELECT is_any_index_for_table( 'hafd.transactions'::regclass::oid ) ) , 'Index hafd.transactions exists';
     ASSERT NOT ( SELECT is_any_index_for_table( 'hafd.operations'::regclass::oid ) ) , 'Index hafd.operations exists';
     ASSERT NOT ( SELECT is_any_index_for_table( 'hafd.transactions_multisig'::regclass::oid ) ) , 'Index hafd.transactions_multisig exists';
-    -- hafd.irreversible_data pk must exist because ON CONFLICT is used during restarting HAF node
-    ASSERT ( SELECT is_any_index_for_table( 'hafd.irreversible_data'::regclass::oid ) ) , 'Index hafd.irreversible_data does not exists';
+    -- hafd.hive_state pk must exist because ON CONFLICT is used during restarting HAF node
+    ASSERT ( SELECT is_any_index_for_table( 'hafd.hive_state'::regclass::oid ) ) , 'Index hafd.hive_state does not exists';
     ASSERT NOT ( SELECT is_any_index_for_table( 'hafd.accounts'::regclass::oid ) ) , 'Index hafd.accounts exists';
     ASSERT NOT ( SELECT is_any_index_for_table( 'hafd.account_operations'::regclass::oid ) ) , 'Index hafd.account_operations exists';
     ASSERT NOT ( SELECT is_any_index_for_table( 'hafd.applied_hardforks'::regclass::oid ) ) , 'Index hafd.applied_hardforks exists';
@@ -80,8 +80,8 @@ BEGIN
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'blocks') ), 'FK for hafd.blocks exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'transactions') ), 'FK for hafd.transactions exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'transactions_multisig') ), 'FK for hafd.transactions_multisig exists';
-    -- we need to disable hafd.irreversible_data fk because its dependency with hafd.blocks
-    ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'irreversible_data') ), 'FK for hafd.irreversible_data exists';
+    -- we need to disable hafd.hive_state fk because its dependency with hafd.blocks
+    ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'hive_state') ), 'FK for hafd.hive_state exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'accounts') ), 'FK for hafd.accounts exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'account_operations') ), 'FK for hafd.account_operations exists';
     ASSERT NOT ( SELECT is_any_fk_for_hive_table( 'applied_hardforks') ), 'FK for hafd.applied_hardforks exists';
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_2_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_2_test.sql
index aa47224a4..cd0ff7fdd 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_2_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_2_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_3_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_3_test.sql
index 29e7136fd..0d5e608b4 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_3_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_3_test.sql
@@ -79,7 +79,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_2_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_2_test.sql
index 8d5f0e9c5..31fef401e 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_2_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_2_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_negative_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_negative_test.sql
index 0409bd14b..d631128a4 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_negative_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_negative_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_test.sql
index c3b351c13..d491a4773 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_header_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_range_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_range_test.sql
index 05d6bfb46..89b216538 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_range_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_range_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_reversible_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_reversible_test.sql
index 43a9150b6..164f6c020 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_reversible_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_reversible_test.sql
@@ -41,7 +41,7 @@ BEGIN
         , ( 10, '\xBADD1A', '\xCAFE1A', '2016-06-22 19:10:32-07'::timestamp, 5, '\x4007', E'[]', '\x2157', 'STM65w', 1000, 1000, 1000000, 1000, 1000, 1000, 2000, 2000, 3 )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/get_block_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/get_block_test.sql
index 0c12f1185..815e743aa 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/get_block_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/get_block_test.sql
@@ -63,7 +63,7 @@ BEGIN
         , ( hafd.operation_id(5, 1, 2), 0, 2, '{"type":"system_warning_operation","value":{"message":"BLOCK FIVE OP"}}' :: jsonb :: hafd.operation )
     ;
 
-    UPDATE hafd.irreversible_data SET consistent_block = 5;
+    UPDATE hafd.hive_state SET consistent_block = 5;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_dirty_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_dirty_test.sql
index a51f935da..4c7bf68cf 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_dirty_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_dirty_test.sql
@@ -4,7 +4,7 @@ CREATE OR REPLACE PROCEDURE haf_admin_test_given()
 AS
 $BODY$
 BEGIN
-    UPDATE hafd.irreversible_data SET is_dirty = FALSE;
+    UPDATE hafd.hive_state SET is_dirty = FALSE;
 END;
 $BODY$
 ;
@@ -24,7 +24,7 @@ CREATE OR REPLACE PROCEDURE haf_admin_test_then()
 AS
 $BODY$
 BEGIN
-    ASSERT( SELECT is_dirty FROM hafd.irreversible_data ) = TRUE, 'Irreversible data are not dirty';
+    ASSERT( SELECT is_dirty FROM hafd.hive_state ) = TRUE, 'Irreversible data are not dirty';
     ASSERT( SELECT * FROM hive.is_irreversible_dirty() ) = TRUE, 'hive.is_irreversible_dirty returns FALSE';
 END
 $BODY$
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_not_dirty_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_not_dirty_test.sql
index 27012b859..7b4c439f7 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_not_dirty_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/mark_irreversible_not_dirty_test.sql
@@ -4,7 +4,7 @@ CREATE OR REPLACE PROCEDURE haf_admin_test_given()
 AS
 $BODY$
 BEGIN
-    UPDATE hafd.irreversible_data SET is_dirty = TRUE;
+    UPDATE hafd.hive_state SET is_dirty = TRUE;
 END;
 $BODY$
 ;
@@ -24,7 +24,7 @@ CREATE OR REPLACE PROCEDURE haf_admin_test_then()
 AS
 $BODY$
 BEGIN
-    ASSERT( SELECT is_dirty FROM hafd.irreversible_data ) = FALSE, 'Irreversible data are dirty';
+    ASSERT( SELECT is_dirty FROM hafd.hive_state ) = FALSE, 'Irreversible data are dirty';
     ASSERT( SELECT * FROM hive.is_irreversible_dirty() ) = FALSE, 'hive.is_irreversible_dirty returns TRUE';
 END
 $BODY$
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/not_removing_inconsistent_irreversibele_data.sql b/tests/integration/functional/hive_fork_manager/hived_api/not_removing_inconsistent_irreversibele_data.sql
index 0a6e43df4..e93200976 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/not_removing_inconsistent_irreversibele_data.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/not_removing_inconsistent_irreversibele_data.sql
@@ -61,7 +61,7 @@ BEGIN
     -- block 2 was not claimed, and it is possible not all information about it was dumped - maybe hived crashes
     PERFORM hive.end_massive_sync( 1 );
 
-    UPDATE hafd.irreversible_data SET is_dirty = FALSE;
+    UPDATE hafd.hive_state SET is_dirty = FALSE;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/push_block_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/push_block_test.sql
index a6596eda0..fc0c61c48 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/push_block_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/push_block_test.sql
@@ -180,7 +180,7 @@ BEGIN
     ) = 1, 'Wrong data of hardfork 2';
 
 
-    ASSERT( SELECT is_dirty FROM hafd.irreversible_data ) = FALSE, 'Irreversible data are dirty';
+    ASSERT( SELECT is_dirty FROM hafd.hive_state ) = FALSE, 'Irreversible data are dirty';
 END
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/removing_inconsistent_irreversibele_data.sql b/tests/integration/functional/hive_fork_manager/hived_api/removing_inconsistent_irreversibele_data.sql
index c77c15c3d..ef0d35a3b 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/removing_inconsistent_irreversibele_data.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/removing_inconsistent_irreversibele_data.sql
@@ -61,7 +61,7 @@ BEGIN
     -- block 2 was not claimed, and it is possible not all information about it was dumped - maybe hived crashes
     PERFORM hive.end_massive_sync( 1 );
 
-    UPDATE hafd.irreversible_data SET is_dirty = TRUE;
+    UPDATE hafd.hive_state SET is_dirty = TRUE;
 END;
 $BODY$
 ;
diff --git a/tests/integration/functional/hive_fork_manager/hived_api/set_irreversible_cleaning_events_test.sql b/tests/integration/functional/hive_fork_manager/hived_api/set_irreversible_cleaning_events_test.sql
index b9ef21db7..5d76a1f11 100644
--- a/tests/integration/functional/hive_fork_manager/hived_api/set_irreversible_cleaning_events_test.sql
+++ b/tests/integration/functional/hive_fork_manager/hived_api/set_irreversible_cleaning_events_test.sql
@@ -76,7 +76,7 @@ AS
 $BODY$
 BEGIN
     ASSERT ( SELECT COUNT(*) FROM hafd.events_queue ) = 4, 'Wrong number of events';
-    ASSERT ( SELECT hid.consistent_block FROM hafd.irreversible_data hid ) = 3 , 'Wrong consisten irreversible block';
+    ASSERT ( SELECT hid.consistent_block FROM hafd.hive_state hid ) = 3 , 'Wrong consisten irreversible block';
     ASSERT EXISTS ( SELECT * FROM hafd.events_queue WHERE event = 'NEW_BLOCK' AND block_num=4 ), 'No NEW_BLOCK event 4';
     ASSERT EXISTS ( SELECT * FROM hafd.events_queue WHERE event = 'NEW_IRREVERSIBLE' AND block_num=3 ), 'No NEW_IRREVERSIBLE event';
 END;
diff --git a/tests/integration/functional/hive_fork_manager/shared_lib/calculate_schema_hash.sql b/tests/integration/functional/hive_fork_manager/shared_lib/calculate_schema_hash.sql
index 3618692f9..d89d096ac 100644
--- a/tests/integration/functional/hive_fork_manager/shared_lib/calculate_schema_hash.sql
+++ b/tests/integration/functional/hive_fork_manager/shared_lib/calculate_schema_hash.sql
@@ -9,7 +9,7 @@ FOR _row in
   SELECT (ROW(f.table_name, f.table_schema_hash, f.columns_hash, f.constraints_hash, f.indexes_hash)::text) FROM hive_update.calculate_schema_hash() AS f
   EXCEPT SELECT unnest(ARRAY[
     '(blocks,6943f52d-ec57-ed27-b2e3-d8ba4b3288ca,4397b404-c56c-84e1-952e-a73d29745394,4c7b832d-5d52-83fe-fd2b-7e7a69416fae,2b354f61-618a-da7d-3380-3e12c45a3f30)',
-    '(irreversible_data,7ad8ef3d-9cef-5660-8b57-6766f0fcfc6e,da91100e-58d4-0d29-083d-d046f6c71e18,77ed7932-7dab-20e3-b506-4a2d3fccfe75,f40cac4c-2fae-a597-11c8-8cc0f329e18f)',
+    '(hive_state,5467a57d-00ca-a492-dc5e-3835c745f74c,da91100e-58d4-0d29-083d-d046f6c71e18,77ed7932-7dab-20e3-b506-4a2d3fccfe75,db0a6fb3-b072-2629-7a5d-0fa6487b43f5)',
     '(transactions,a2f346aa-6ef3-1a4b-20fd-8fc5cb11eeb7,d0d1231f-f437-abf1-1f9f-6ae1ed916af4,d1456ff1-2474-ca5b-3b82-be0086c298f0,7766bb78-548b-dc33-4ebe-e5523196b1fb)',
     '(transactions_multisig,a1cc4195-2d73-eb00-3012-8fbf46dac280,2fae1b96-5a99-7b17-5163-ae45a2b02518,70f65c01-a33c-608b-b0e8-bd29f92615c9,cc576d3f-5919-0a1f-f851-1c008877b33a)',
     '(operation_types,dd6c8768-2bc2-2b76-3246-292b108f744f,cf35886f-de4e-e064-b170-fd4186ea9148,0dc429a2-22b0-2d05-44d6-cc66d48082b6,08d2ba03-e127-e0ad-aaee-657b3aa27bae)',
diff --git a/tests/integration/haf-local-tools/haf_local_tools/tables.py b/tests/integration/haf-local-tools/haf_local_tools/tables.py
index 9e55d8c79..1c3453bb8 100644
--- a/tests/integration/haf-local-tools/haf_local_tools/tables.py
+++ b/tests/integration/haf-local-tools/haf_local_tools/tables.py
@@ -215,7 +215,7 @@ class EventsQueue(HiveDataBase):
 
 
 class IrreversibleData(HiveDataBase):
-    __tablename__ = "irreversible_data"
+    __tablename__ = "hive_state"
 
     id = Column(Integer, primary_key=True)
     consistent_block = Column(Integer)
diff --git a/tests/integration/replay/application.sql b/tests/integration/replay/application.sql
index 7f7a5ae83..cb6de028e 100644
--- a/tests/integration/replay/application.sql
+++ b/tests/integration/replay/application.sql
@@ -16,7 +16,7 @@ $$
 DECLARE
     __result INT := 1;
 BEGIN
-    SELECT consistent_block INTO __result FROM hafd.irreversible_data;
+    SELECT consistent_block INTO __result FROM hafd.hive_state;
     RETURN __result;
 END
 $$
-- 
GitLab