Skip to content

Commit

Permalink
Merge pull request #1516 from nervosnetwork/testnet
Browse files Browse the repository at this point in the history
Deploy to mainnet
  • Loading branch information
zmcNotafraid authored Nov 27, 2023
2 parents f7a912f + a0797b6 commit b926c32
Show file tree
Hide file tree
Showing 6 changed files with 10 additions and 14 deletions.
2 changes: 1 addition & 1 deletion app/controllers/api/v2/scripts_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def get_script_content
deployed_cells = @contract.deployed_cell_outputs
if deployed_cells.present?
deployed_type_script = deployed_cells[0].type_script
if deployed_type_script.code_hash == Settings.type_id_code_hash
if deployed_type_script && deployed_type_script.code_hash == Settings.type_id_code_hash
type_id = deployed_type_script.script_hash
end
end
Expand Down
1 change: 1 addition & 0 deletions app/jobs/import_block_job.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
# No used
class ImportBlockJob < ApplicationJob
def perform(block_hash)
if block_hash.is_a?(Integer)
Expand Down
2 changes: 0 additions & 2 deletions app/jobs/revert_block_job.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ def perform(local_tip_block = nil)
end

ApplicationRecord.transaction do
CkbTransaction.tx_pending.
where(tx_hash: CkbUtils.hexes_to_bins(local_tip_block.ckb_transactions.pluck(:tx_hash))).update_all(tx_status: "pending")
benchmark :revert_dao_contract_related_operations, local_tip_block
benchmark :revert_mining_info, local_tip_block

Expand Down
11 changes: 7 additions & 4 deletions app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,8 @@ def process_block(node_block, refresh_balance: true)
@contained_udt_ids = contained_udt_ids = []
@contained_address_ids = contained_address_ids = []

process_ckb_txs(node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags, udt_address_ids)
process_ckb_txs(node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags,
udt_address_ids)
addrs_changes = Hash.new { |hash, key| hash[key] = {} }
input_capacities, output_capacities = build_cells_and_locks!(local_block, node_block, ckb_txs, inputs, outputs,
tags, udt_address_ids, dao_address_ids, contained_udt_ids, contained_address_ids, addrs_changes)
Expand Down Expand Up @@ -136,7 +137,10 @@ def generate_statistics_data(local_block)
GenerateStatisticsDataWorker.perform_async(local_block.id)
end

def process_ckb_txs(node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags, udt_address_ids)
def process_ckb_txs(
node_block, ckb_txs, contained_address_ids, contained_udt_ids, dao_address_ids, tags,
udt_address_ids
)
tx_index = 0
ckb_txs.each do |cbk_tx|
cbk_tx["tx_hash"][0] = "0"
Expand Down Expand Up @@ -1182,7 +1186,6 @@ def cell_input_attributes(input, ckb_transaction_id, local_block_id, prev_output

def build_ckb_transactions!(node_block, local_block, inputs, outputs, outputs_data)
cycles = CkbSync::Api.instance.get_block_cycles node_block.header.hash
txs = nil
ckb_transactions_attributes = []
tx_index = 0
hashes = []
Expand All @@ -1209,7 +1212,7 @@ def build_ckb_transactions!(node_block, local_block, inputs, outputs, outputs_da
# locate correct record according to tx_hash
binary_hashes = CkbUtils.hexes_to_bins(hashes)
pending_txs = CkbTransaction.where(tx_hash: binary_hashes, tx_status: :pending).pluck(:tx_hash, :created_at)
CkbTransaction.where(tx_hash: hashes).update_all tx_status: "committed"
CkbTransaction.where(tx_hash: binary_hashes).update_all tx_status: "committed"

txs = CkbTransaction.upsert_all(ckb_transactions_attributes, unique_by: [:tx_status, :tx_hash],
returning: %w(id tx_hash block_timestamp created_at))
Expand Down
2 changes: 1 addition & 1 deletion app/workers/clean_up_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ class CleanUpWorker

def perform
TokenCollection.remove_corrupted
CkbTransaction.tx_pending.where("created_at < ?", 2.weeks.ago).destroy_all
CkbTransaction.tx_pending.where("created_at < ?", 1.day.ago).destroy_all
CkbTransaction.tx_rejected.where("created_at < ?", 3.months.ago).destroy_all
end
end
6 changes: 0 additions & 6 deletions app/workers/pool_transaction_check_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,6 @@ def perform
includes(:cell_dependencies, cell_inputs: :previous_cell_output).
order(id: :asc).limit(150)
pending_transactions.each do |tx|
# FIXME: remove this code
if CkbTransaction.tx_committed.exists?(tx_hash: tx.tx_hash)
tx.destroy!
next
end

is_rejected = false
rejected_transaction = nil
# check if any input is used by other transactions
Expand Down

0 comments on commit b926c32

Please sign in to comment.