From 97a924409a401e3f14b82b21afdf802dd0e55286 Mon Sep 17 00:00:00 2001 From: Rabbit Date: Thu, 18 Jan 2024 13:04:56 +0800 Subject: [PATCH 1/2] fix: ckb mode --- app/models/ckb_sync/api.rb | 12 +++++++----- app/utils/ckb_utils.rb | 21 +-------------------- 2 files changed, 8 insertions(+), 25 deletions(-) diff --git a/app/models/ckb_sync/api.rb b/app/models/ckb_sync/api.rb index aae3a5cd67..d7a8443bc2 100644 --- a/app/models/ckb_sync/api.rb +++ b/app/models/ckb_sync/api.rb @@ -22,11 +22,13 @@ def chain_type end def mode - if chain_type == "ckb" - CKB::MODE::MAINNET - else - CKB::MODE::TESTNET - end + # if chain_type == "ckb" + # CKB::MODE::MAINNET + # else + # CKB::MODE::TESTNET + # end + + ENV["CKB_NET_MODE"] end def issuer_script_code_hash diff --git a/app/utils/ckb_utils.rb b/app/utils/ckb_utils.rb index 7ced1d6e70..f640e3ddc6 100644 --- a/app/utils/ckb_utils.rb +++ b/app/utils/ckb_utils.rb @@ -404,25 +404,6 @@ def self.decode_header_deps(raw_header_deps) # @param [String] output_data # @return [String] cell type def self.cell_type(type_script, output_data) - if type_script&.code_hash == CkbSync::Api.instance.xudt_code_hash && - ((ENV["CKB_NET_MODE"] == CKB::MODE::TESTNET && type_script&.hash_type == "type") || - (ENV["CKB_NET_MODE"] == CKB::MODE::MAINNET && type_script&.hash_type == "data1")) - str = Kredis.string type_script.compute_hash - unless str.value - if OmigaInscriptionInfo.exists?(udt_hash: type_script.compute_hash) - str.value ="omiga_inscription" - else - str.value = "xudt" - end - end - - return str.value - end - - if type_script&.code_hash == CkbSync::Api.instance.omiga_inscription_info_code_hash - return "omiga_inscription_info" - end - return "normal" unless ([ Settings.dao_code_hash, Settings.dao_type_hash, Settings.sudt_cell_type_hash, Settings.sudt1_cell_type_hash, CkbSync::Api.instance.issuer_script_code_hash, CkbSync::Api.instance.token_class_script_code_hash, @@ -436,7 +417,7 @@ def self.cell_type(type_script, output_data) CkbSync::Api.instance.spore_cluster_code_hash, *CkbSync::Api.instance.spore_cell_code_hashes, ].include?(type_script&.code_hash) && type_script&.hash_type == "data1" || - ENV["CKB_NET_MODE"] == CKB::MODE::MAINNET && [CkbSync::Api.instance.xudt_code_hash].include?(type_script&.code_hash) && type_script&.hash_type == "data1" + CkbSync::Api.instance.mode == CKB::MODE::MAINNET && [CkbSync::Api.instance.xudt_code_hash].include?(type_script&.code_hash) && type_script&.hash_type == "data1" case type_script&.code_hash when Settings.dao_code_hash, Settings.dao_type_hash From 44613e43eef7ae247b0b7b0babf447f9c1ed3bac Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Thu, 18 Jan 2024 14:16:24 +0800 Subject: [PATCH 2/2] chore: Non-web transaction's method should use OtherTransaction start Signed-off-by: Miles Zhang --- .../ckb_sync/new_node_data_processor.rb | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/app/models/ckb_sync/new_node_data_processor.rb b/app/models/ckb_sync/new_node_data_processor.rb index 14a48c6f29..35e024c3ae 100644 --- a/app/models/ckb_sync/new_node_data_processor.rb +++ b/app/models/ckb_sync/new_node_data_processor.rb @@ -107,27 +107,31 @@ def process_block(node_block, refresh_balance: true) local_block end + add_transaction_tracer :process_block, category: :task - add_method_tracer :build_udts!, "Custom/build_udt!" - add_method_tracer :process_ckb_txs, "Custom/process_ckb_txs" - add_method_tracer :build_cells_and_locks!, "Custom/build_cells_and_locks!" + add_method_tracer :build_udts!, "OtherTransaction/build_udt!" + add_method_tracer :process_ckb_txs, "OtherTransaction/process_ckb_txs" + add_method_tracer :build_cells_and_locks!, + "OtherTransaction/build_cells_and_locks!" add_method_tracer :update_ckb_txs_rel_and_fee, - "Custom/update_ckb_txs_rel_and_fee" - add_method_tracer :update_block_info!, "Custom/update_block_info!" + "OtherTransaction/update_ckb_txs_rel_and_fee" + add_method_tracer :update_block_info!, "OtherTransaction/update_block_info!" add_method_tracer :update_block_reward_info!, - "Custom/update_block_reward_info!" - add_method_tracer :update_mining_info, "Custom/update_mining_info" + "OtherTransaction/update_block_reward_info!" + add_method_tracer :update_mining_info, "OtherTransaction/update_mining_info" add_method_tracer :update_table_records_count, - "Custom/update_table_records_count" + "OtherTransaction/update_table_records_count" add_method_tracer :update_or_create_udt_accounts!, - "Custom/update_or_create_udt_accounts!" - add_method_tracer :update_udt_info, "Custom/update_udt_info" - add_method_tracer :process_dao_events!, "Custom/process_dao_events!" - add_method_tracer :update_addresses_info, "Custom/update_addresses_info" + "OtherTransaction/update_or_create_udt_accounts!" + add_method_tracer :update_udt_info, "OtherTransaction/update_udt_info" + add_method_tracer :process_dao_events!, + "OtherTransaction/process_dao_events!" + add_method_tracer :update_addresses_info, + "OtherTransaction/update_addresses_info" add_method_tracer :generate_statistics_data, - "Custom/generate_statistics_data" + "OtherTransaction/generate_statistics_data" add_method_tracer :generate_deployed_cells_and_referring_cells, - "Custom/generate_deployed_cells_and_referring_cells" + "OtherTransaction/generate_deployed_cells_and_referring_cells" def check_invalid_address(address) if (address.balance < 0) || (address.balance_occupied < 0)