From dfc30d3adcf4a258d7dad03a8a81b56181120469 Mon Sep 17 00:00:00 2001 From: eigmax Date: Mon, 19 Jan 2026 02:16:57 +0000 Subject: [PATCH 1/3] fix: tidy up all sql --- .../store/migrations/20250814113519_create_graph_table.sql | 2 ++ .../migrations/20250814113702_create_message_table.sql | 1 + .../migrations/20250814115805_create_instance_table.sql | 5 +++++ .../migrations/20251103122920_alter_messsage_table.sql | 3 --- .../20251128024953_alter_graph_and_instance_table.sql | 6 ------ .../migrations/20251212143606_alter_instance_table.sql.sql | 4 ---- ...l.sql => 20251215023559_create_operator_proof_table.sql} | 1 + ...sql => 20251215023612_create_watchtower_proof_table.sql} | 2 ++ ...ql => 20251215024440_create_long_running_task_table.sql} | 0 .../migrations/20251217081311_alert_instance_table.sql.sql | 3 --- .../migrations/20251218075349_alert_graph_table.sql.sql | 3 --- .../migrations/20251225062216_alert_instance_table.sql.sql | 3 --- ...e_table.sql.sql => 20260108112458_create_node_table.sql} | 0 ...20260109021138_create_bridge_out_global_stats_table.sql} | 0 .../migrations/20260109022807_alert_instance_table.sql.sql | 4 ---- .../20260113032823_alter_watchtower_proof_table.sql | 5 ----- .../20260117031151_alter_operator_proof_table.sql | 3 --- .../migrations/20260118060917_alter_operator_proof.sql | 6 ------ 18 files changed, 11 insertions(+), 40 deletions(-) delete mode 100644 crates/store/migrations/20251103122920_alter_messsage_table.sql delete mode 100644 crates/store/migrations/20251128024953_alter_graph_and_instance_table.sql delete mode 100644 crates/store/migrations/20251212143606_alter_instance_table.sql.sql rename crates/store/migrations/{20251215023559_create_operator_proof_table.sql.sql => 20251215023559_create_operator_proof_table.sql} (94%) rename crates/store/migrations/{20251215023612_create_watchtower_proof_table.sql.sql => 20251215023612_create_watchtower_proof_table.sql} (90%) rename crates/store/migrations/{20251215024440_create_long_running_task_table.sql.sql => 20251215024440_create_long_running_task_table.sql} (100%) delete mode 100644 crates/store/migrations/20251217081311_alert_instance_table.sql.sql delete mode 100644 crates/store/migrations/20251218075349_alert_graph_table.sql.sql delete mode 100644 crates/store/migrations/20251225062216_alert_instance_table.sql.sql rename crates/store/migrations/{20260108112458_create_node_table.sql.sql => 20260108112458_create_node_table.sql} (100%) rename crates/store/migrations/{20260109021138_create_bridge_out_global_stats_table.sql.sql => 20260109021138_create_bridge_out_global_stats_table.sql} (100%) delete mode 100644 crates/store/migrations/20260109022807_alert_instance_table.sql.sql delete mode 100644 crates/store/migrations/20260113032823_alter_watchtower_proof_table.sql delete mode 100644 crates/store/migrations/20260117031151_alter_operator_proof_table.sql delete mode 100644 crates/store/migrations/20260118060917_alter_operator_proof.sql diff --git a/crates/store/migrations/20250814113519_create_graph_table.sql b/crates/store/migrations/20250814113519_create_graph_table.sql index 0de9d5a1..94000307 100644 --- a/crates/store/migrations/20250814113519_create_graph_table.sql +++ b/crates/store/migrations/20250814113519_create_graph_table.sql @@ -33,6 +33,8 @@ CREATE TABLE graph `init_withdraw_tx_hash` TEXT, `bridge_out_start_at` BIGINT NOT NULL DEFAULT 0, `zkm_version` TEXT NOT NULL DEFAULT '', + `status_updated_at` BIGINT NOT NULL DEFAULT 0, + `proceed_withdraw_height` BIGINT NOT NULL DEFAULT 0, `created_at` BIGINT NOT NULL DEFAULT 0, `updated_at` BIGINT NOT NULL DEFAULT 0, PRIMARY KEY (`graph_id`) diff --git a/crates/store/migrations/20250814113702_create_message_table.sql b/crates/store/migrations/20250814113702_create_message_table.sql index 5907a31e..6c7de81e 100644 --- a/crates/store/migrations/20250814113702_create_message_table.sql +++ b/crates/store/migrations/20250814113702_create_message_table.sql @@ -11,6 +11,7 @@ CREATE TABLE message `state` TEXT NOT NULL DEFAULT 'pending', `lock_time_until` BIGINT NOT NULL DEFAULT 0, `weight` BIGINT NOT NULL DEFAULT 0, + `message_version` BIGINT NOT NULL DEFAULT 0, `created_at` BIGINT NOT NULL DEFAULT 0, `updated_at` BIGINT NOT NULL DEFAULT 0, PRIMARY KEY (`message_id`) diff --git a/crates/store/migrations/20250814115805_create_instance_table.sql b/crates/store/migrations/20250814115805_create_instance_table.sql index 2005341f..f283a98e 100644 --- a/crates/store/migrations/20250814115805_create_instance_table.sql +++ b/crates/store/migrations/20250814115805_create_instance_table.sql @@ -23,6 +23,11 @@ CREATE TABLE instance `pegin_data_tx_hash` TEXT NOT NULL DEFAULT '', `btc_height` BIGINT UNSIGNED NOT NULL DEFAULT 0, `parameters` TEXT, + `escrow_hash` TEXT, + `bridge_out_amount` TEXT NOT NULL DEFAULT '0', + `bridge_out_lock_time` BIGINT NOT NULL DEFAULT 0, + `post_pegin_txhash` TEXT, + `status_updated_at` BIGINT NOT NULL DEFAULT 0, `created_at` BIGINT NOT NULL DEFAULT 0, `updated_at` BIGINT NOT NULL DEFAULT 0, PRIMARY KEY (`instance_id`) diff --git a/crates/store/migrations/20251103122920_alter_messsage_table.sql b/crates/store/migrations/20251103122920_alter_messsage_table.sql deleted file mode 100644 index 9d64e9d1..00000000 --- a/crates/store/migrations/20251103122920_alter_messsage_table.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add migration script here -ALTER TABLE `message` - ADD COLUMN `message_version` BIGINT NOT NULL DEFAULT 0; diff --git a/crates/store/migrations/20251128024953_alter_graph_and_instance_table.sql b/crates/store/migrations/20251128024953_alter_graph_and_instance_table.sql deleted file mode 100644 index 38640e7f..00000000 --- a/crates/store/migrations/20251128024953_alter_graph_and_instance_table.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Add migration script here -ALTER TABLE `instance` - ADD COLUMN `status_updated_at` BIGINT NOT NULL DEFAULT 0; - -ALTER TABLE `graph` - ADD COLUMN `status_updated_at` BIGINT NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/crates/store/migrations/20251212143606_alter_instance_table.sql.sql b/crates/store/migrations/20251212143606_alter_instance_table.sql.sql deleted file mode 100644 index 9a3ae9ac..00000000 --- a/crates/store/migrations/20251212143606_alter_instance_table.sql.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Add migration script here -ALTER TABLE `instance` - ADD COLUMN `escrow_hash` TXET; - diff --git a/crates/store/migrations/20251215023559_create_operator_proof_table.sql.sql b/crates/store/migrations/20251215023559_create_operator_proof_table.sql similarity index 94% rename from crates/store/migrations/20251215023559_create_operator_proof_table.sql.sql rename to crates/store/migrations/20251215023559_create_operator_proof_table.sql index 374f69c7..ae2c2d6c 100644 --- a/crates/store/migrations/20251215023559_create_operator_proof_table.sql.sql +++ b/crates/store/migrations/20251215023559_create_operator_proof_table.sql @@ -14,6 +14,7 @@ CREATE TABLE operator_proof `total_time_to_proof` BIGINT NOT NULL DEFAULT 0, `proving_time` BIGINT NOT NULL DEFAULT 0, `zkm_version` TEXT NOT NULL DEFAULT '', + `operator_committed_blockhash` TEXT NOT NULL, `extra` TEXT, `created_at` BIGINT NOT NULL DEFAULT 0, `updated_at` BIGINT NOT NULL DEFAULT 0 diff --git a/crates/store/migrations/20251215023612_create_watchtower_proof_table.sql.sql b/crates/store/migrations/20251215023612_create_watchtower_proof_table.sql similarity index 90% rename from crates/store/migrations/20251215023612_create_watchtower_proof_table.sql.sql rename to crates/store/migrations/20251215023612_create_watchtower_proof_table.sql index 15379ee3..02229977 100644 --- a/crates/store/migrations/20251215023612_create_watchtower_proof_table.sql.sql +++ b/crates/store/migrations/20251215023612_create_watchtower_proof_table.sql @@ -17,6 +17,8 @@ CREATE TABLE watchtower_proof `total_time_to_proof` BIGINT NOT NULL DEFAULT 0, `proving_time` BIGINT NOT NULL DEFAULT 0, `zkm_version` TEXT NOT NULL DEFAULT '', + `node_index` INTEGER NOT NULL DEFAULT 0, + `included` BOOLEAN NOT NULL DEFAULT 0, `extra` TEXT, `created_at` BIGINT NOT NULL DEFAULT 0, `updated_at` BIGINT NOT NULL DEFAULT 0 diff --git a/crates/store/migrations/20251215024440_create_long_running_task_table.sql.sql b/crates/store/migrations/20251215024440_create_long_running_task_table.sql similarity index 100% rename from crates/store/migrations/20251215024440_create_long_running_task_table.sql.sql rename to crates/store/migrations/20251215024440_create_long_running_task_table.sql diff --git a/crates/store/migrations/20251217081311_alert_instance_table.sql.sql b/crates/store/migrations/20251217081311_alert_instance_table.sql.sql deleted file mode 100644 index 49d8dcb7..00000000 --- a/crates/store/migrations/20251217081311_alert_instance_table.sql.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add migration script here -ALTER TABLE `instance` - ADD COLUMN `bridge_out_lock_time` BIGINT NOT NULL DEFAULT 0; diff --git a/crates/store/migrations/20251218075349_alert_graph_table.sql.sql b/crates/store/migrations/20251218075349_alert_graph_table.sql.sql deleted file mode 100644 index 13c106a0..00000000 --- a/crates/store/migrations/20251218075349_alert_graph_table.sql.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add migration script here -ALTER TABLE `graph` - ADD COLUMN `proceed_withdraw_height` BIGINT NOT NULL DEFAULT 0; diff --git a/crates/store/migrations/20251225062216_alert_instance_table.sql.sql b/crates/store/migrations/20251225062216_alert_instance_table.sql.sql deleted file mode 100644 index cc7be452..00000000 --- a/crates/store/migrations/20251225062216_alert_instance_table.sql.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add migration script here -ALTER TABLE `instance` - ADD COLUMN `post_pegin_txhash` TEXT; diff --git a/crates/store/migrations/20260108112458_create_node_table.sql.sql b/crates/store/migrations/20260108112458_create_node_table.sql similarity index 100% rename from crates/store/migrations/20260108112458_create_node_table.sql.sql rename to crates/store/migrations/20260108112458_create_node_table.sql diff --git a/crates/store/migrations/20260109021138_create_bridge_out_global_stats_table.sql.sql b/crates/store/migrations/20260109021138_create_bridge_out_global_stats_table.sql similarity index 100% rename from crates/store/migrations/20260109021138_create_bridge_out_global_stats_table.sql.sql rename to crates/store/migrations/20260109021138_create_bridge_out_global_stats_table.sql diff --git a/crates/store/migrations/20260109022807_alert_instance_table.sql.sql b/crates/store/migrations/20260109022807_alert_instance_table.sql.sql deleted file mode 100644 index 8d3518d7..00000000 --- a/crates/store/migrations/20260109022807_alert_instance_table.sql.sql +++ /dev/null @@ -1,4 +0,0 @@ --- Add migration script here -ALTER TABLE `instance` - ADD COLUMN `bridge_out_amount` TEXT NOT NULL DEFAULT '0'; - diff --git a/crates/store/migrations/20260113032823_alter_watchtower_proof_table.sql b/crates/store/migrations/20260113032823_alter_watchtower_proof_table.sql deleted file mode 100644 index 0c765f35..00000000 --- a/crates/store/migrations/20260113032823_alter_watchtower_proof_table.sql +++ /dev/null @@ -1,5 +0,0 @@ --- Add migration script here -ALTER TABLE `watchtower_proof` - ADD COLUMN `node_index` INTEGER NOT NULL DEFAULT 0; -ALTER TABLE `watchtower_proof` - ADD COLUMN `included` BOOLEAN NOT NULL DEFAULT 0; \ No newline at end of file diff --git a/crates/store/migrations/20260117031151_alter_operator_proof_table.sql b/crates/store/migrations/20260117031151_alter_operator_proof_table.sql deleted file mode 100644 index 057386d5..00000000 --- a/crates/store/migrations/20260117031151_alter_operator_proof_table.sql +++ /dev/null @@ -1,3 +0,0 @@ --- Add migration script here -ALTER TABLE `operator_proof` - ADD COLUMN `blockhash_commit_txid` TEXT NOT NULL DEFAULT 'dac7516877b069dac6d2b0430e8b23812392665ecbb0c36c78c8acd12ddc929e'; \ No newline at end of file diff --git a/crates/store/migrations/20260118060917_alter_operator_proof.sql b/crates/store/migrations/20260118060917_alter_operator_proof.sql deleted file mode 100644 index c13907b0..00000000 --- a/crates/store/migrations/20260118060917_alter_operator_proof.sql +++ /dev/null @@ -1,6 +0,0 @@ --- Add migration script here -ALTER TABLE `operator_proof` - DROP COLUMN `blockhash_commit_txid`; - -ALTER TABLE `operator_proof` - ADD COLUMN `operator_committed_blockhash` TEXT NOT NULL DEFAULT 'dac7516877b069dac6d2b0430e8b23812392665ecbb0c36c78c8acd12ddc929e'; \ No newline at end of file From 6c7ea55683193b9e876a70b77f3799700200fbf8 Mon Sep 17 00:00:00 2001 From: eigmax Date: Mon, 19 Jan 2026 02:52:04 +0000 Subject: [PATCH 2/3] fix: remove message broadcast --- circuits/README.md | 2 +- circuits/cron-header-chain-proof.sh | 3 +- circuits/header-chain-proof/host/src/lib.rs | 4 +- ...a8254775b43f385ae469b993cdb6f434e7abb.json | 50 ------------------- ...4113902_create_message_broadcast_table.sql | 12 ----- crates/store/src/localdb.rs | 19 +------ crates/store/src/schema.rs | 10 ---- 7 files changed, 8 insertions(+), 92 deletions(-) delete mode 100644 crates/store/.sqlx/query-6877caa490b888ce98dce6e3538a8254775b43f385ae469b993cdb6f434e7abb.json delete mode 100644 crates/store/migrations/20250814113902_create_message_broadcast_table.sql diff --git a/circuits/README.md b/circuits/README.md index de58d53e..adc60a8d 100644 --- a/circuits/README.md +++ b/circuits/README.md @@ -84,7 +84,7 @@ docker compose up -d # export BITCOIN_NETWOKR=regtest # testnet -# export BITCOIN_NETWOKR=testnet +# export BITCOIN_NETWOKR=testnet4 # export ESPLORA_URL=https://mempool.space/testnet/api diff --git a/circuits/cron-header-chain-proof.sh b/circuits/cron-header-chain-proof.sh index 1b2d0f53..24efd7df 100644 --- a/circuits/cron-header-chain-proof.sh +++ b/circuits/cron-header-chain-proof.sh @@ -12,7 +12,7 @@ batch=${2:-$_batch} function find_input_proof() { local start="$1" local input_file - input_file=$(find $DATA -maxdepth 1 -type f -name '*-*.bin' -printf '%f\n' | + input_file=$(find $DATA -maxdepth 1 -type f -regex '.*[0-9]+-[0-9]+\.bin$' -printf '%f\n' | awk -v sum="$start" -F '[-.]' '($1 + $2) == sum { print $0; exit }') if [ ! $input_file ]; then @@ -31,6 +31,7 @@ else fi echo "Start i=$start, batch=$batch" +exit while true; do echo "Running for i=$start" diff --git a/circuits/header-chain-proof/host/src/lib.rs b/circuits/header-chain-proof/host/src/lib.rs index 62f90752..e415969a 100644 --- a/circuits/header-chain-proof/host/src/lib.rs +++ b/circuits/header-chain-proof/host/src/lib.rs @@ -197,7 +197,9 @@ impl ProofBuilder for HeaderChainProofBuilder { let prev_receipt = if *init_input { None } else { - let public_inputs = fs::read(&format!("{}.public_inputs.bin", input_proof)).unwrap(); + let public_inputs = fs::read(&format!("{}.public_inputs.bin", input_proof)).expect( + &format!("Failed to read public inputs from {}.public_inputs.bin", input_proof), + ); Some(public_inputs) }; diff --git a/crates/store/.sqlx/query-6877caa490b888ce98dce6e3538a8254775b43f385ae469b993cdb6f434e7abb.json b/crates/store/.sqlx/query-6877caa490b888ce98dce6e3538a8254775b43f385ae469b993cdb6f434e7abb.json deleted file mode 100644 index a19d5ceb..00000000 --- a/crates/store/.sqlx/query-6877caa490b888ce98dce6e3538a8254775b43f385ae469b993cdb6f434e7abb.json +++ /dev/null @@ -1,50 +0,0 @@ -{ - "db_name": "SQLite", - "query": "SELECT graph_id AS \"graph_id:Uuid\", graph_status, msg_type, msg_times, created_at, updated_at\n FROM message_broadcast\n WHERE graph_status = ? ", - "describe": { - "columns": [ - { - "name": "graph_id:Uuid", - "ordinal": 0, - "type_info": "Text" - }, - { - "name": "graph_status", - "ordinal": 1, - "type_info": "Text" - }, - { - "name": "msg_type", - "ordinal": 2, - "type_info": "Text" - }, - { - "name": "msg_times", - "ordinal": 3, - "type_info": "Integer" - }, - { - "name": "created_at", - "ordinal": 4, - "type_info": "Integer" - }, - { - "name": "updated_at", - "ordinal": 5, - "type_info": "Integer" - } - ], - "parameters": { - "Right": 1 - }, - "nullable": [ - false, - false, - false, - false, - false, - false - ] - }, - "hash": "6877caa490b888ce98dce6e3538a8254775b43f385ae469b993cdb6f434e7abb" -} diff --git a/crates/store/migrations/20250814113902_create_message_broadcast_table.sql b/crates/store/migrations/20250814113902_create_message_broadcast_table.sql deleted file mode 100644 index f718feb7..00000000 --- a/crates/store/migrations/20250814113902_create_message_broadcast_table.sql +++ /dev/null @@ -1,12 +0,0 @@ --- Add migration script here -DROP TABLE IF EXISTS `message_broadcast`; -CREATE TABLE message_broadcast -( - `graph_id` TEXT NOT NULL, - `graph_status` TEXT NOT NuLL DEFAULT '', - `msg_type` TEXT NOT NULL DEFAULT '', - `msg_times` BIGINT NOT NULL DEFAULT 0, - `created_at` BIGINT NOT NULL DEFAULT 0, - `updated_at` BIGINT NOT NULL DEFAULT 0, - PRIMARY KEY (`graph_id`, `graph_status`, `msg_type`) -); \ No newline at end of file diff --git a/crates/store/src/localdb.rs b/crates/store/src/localdb.rs index 068e95d0..47addbbe 100644 --- a/crates/store/src/localdb.rs +++ b/crates/store/src/localdb.rs @@ -1,9 +1,8 @@ use crate::utils::{QueryBuilder, QueryParam, create_place_holders}; use crate::{ BridgeOutGlobalStats, GoatTxRecord, Graph, GraphBtcTxVoutMonitor, GraphRawData, Instance, - LongRunningTaskProof, Message, MessageBroadcast, Node, NodesOverview, OperatorProof, - PeginGraphProcessData, PeginInstanceProcessData, SerializableTxid, WatchContract, - WatchtowerProof, + LongRunningTaskProof, Message, Node, NodesOverview, OperatorProof, PeginGraphProcessData, + PeginInstanceProcessData, SerializableTxid, WatchContract, WatchtowerProof, }; use indexmap::IndexMap; @@ -2080,20 +2079,6 @@ impl<'a> StorageProcessor<'a> { } } - pub async fn find_message_broadcasts( - &mut self, - graph_status: &str, - ) -> anyhow::Result> { - let records = sqlx::query_as!( - MessageBroadcast, - "SELECT graph_id AS \"graph_id:Uuid\", graph_status, msg_type, msg_times, created_at, updated_at - FROM message_broadcast - WHERE graph_status = ? ", - graph_status - ).fetch_all(self.conn()).await?; - Ok(records) - } - pub async fn add_message_broadcast_times( &mut self, graph_id: &Uuid, diff --git a/crates/store/src/schema.rs b/crates/store/src/schema.rs index 66dfb50d..3a9542f9 100644 --- a/crates/store/src/schema.rs +++ b/crates/store/src/schema.rs @@ -521,16 +521,6 @@ pub enum MessageType { InstanceDiscarded, } -#[derive(Clone, FromRow, Debug, Serialize, Deserialize, Default)] -pub struct MessageBroadcast { - pub graph_id: Uuid, - pub graph_status: String, - pub msg_type: String, - pub msg_times: i64, - pub updated_at: i64, - pub created_at: i64, -} - #[derive(Clone, Debug, Serialize, Deserialize, Default, Display, EnumString)] pub enum WatchContractStatus { #[default] From 5ba6b4f414ed53ad29bd03caaf53be850d340a47 Mon Sep 17 00:00:00 2001 From: eigmax Date: Mon, 19 Jan 2026 02:53:26 +0000 Subject: [PATCH 3/3] fix: remove exit --- circuits/cron-header-chain-proof.sh | 1 - 1 file changed, 1 deletion(-) diff --git a/circuits/cron-header-chain-proof.sh b/circuits/cron-header-chain-proof.sh index 24efd7df..8bf4d092 100644 --- a/circuits/cron-header-chain-proof.sh +++ b/circuits/cron-header-chain-proof.sh @@ -31,7 +31,6 @@ else fi echo "Start i=$start, batch=$batch" -exit while true; do echo "Running for i=$start"