Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Deploy to mainnet #1516

Merged
merged 4 commits into from
Nov 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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/utils/ckb_utils.rb
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def self.base_reward(block_number, epoch_number)
end

def self.epoch_reward_with_halving(epoch_number)
Settings.default_epoch_reward.to_i >> epoch_number / HALVING_EPOCH
Settings.default_epoch_reward.to_i >> epoch_number / HALVING_EPOCH
end

def self.primary_reward(block_number, block_economic_state)
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
Loading