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 #2388

Merged
merged 6 commits into from
Jan 5, 2025
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/models/bitcoin_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -34,5 +34,5 @@ def self.refresh
#
# Indexes
#
# index_bitcoin_statistics_on_timestamp (timestamp) UNIQUE
# index_bitcoin_statistics_on_timestamp (timestamp)
#
12 changes: 11 additions & 1 deletion app/models/ckb_sync/new_node_data_processor.rb
Original file line number Diff line number Diff line change
Expand Up @@ -355,7 +355,17 @@ def update_addresses_dao_info(addrs_deposit_info)
is_depositor: address_info[:is_depositor],
}
end
Address.upsert_all(addresses_deposit_attributes, record_timestamps: true) if addresses_deposit_attributes.present?
if addresses_deposit_attributes.present?
Address.upsert_all(
addresses_deposit_attributes,
record_timestamps: true,
on_duplicate: Arel.sql(
"dao_deposit = COALESCE(EXCLUDED.dao_deposit, addresses.dao_deposit), " \
"interest = COALESCE(EXCLUDED.interest, addresses.interest), " \
"is_depositor = COALESCE(EXCLUDED.is_depositor, addresses.is_depositor)",
),
)
end
end

def update_or_create_udt_accounts!(local_block)
Expand Down
33 changes: 16 additions & 17 deletions app/models/fiber_graph_channel.rb
Original file line number Diff line number Diff line change
Expand Up @@ -51,23 +51,22 @@ def funding_cell
#
# Table name: fiber_graph_channels
#
# id :bigint not null, primary key
# channel_outpoint :string
# funding_tx_block_number :bigint
# funding_tx_index :integer
# node1 :string
# node2 :string
# last_updated_timestamp :bigint
# created_timestamp :bigint
# node1_to_node2_fee_rate :decimal(30, ) default(0)
# node2_to_node1_fee_rate :decimal(30, ) default(0)
# capacity :decimal(64, 2) default(0.0)
# chain_hash :string
# created_at :datetime not null
# updated_at :datetime not null
# udt_id :bigint
# open_transaction_id :bigint
# closed_transaction_id :bigint
# id :bigint not null, primary key
# channel_outpoint :string
# node1 :string
# node2 :string
# created_timestamp :bigint
# capacity :decimal(64, 2) default(0.0)
# chain_hash :string
# created_at :datetime not null
# updated_at :datetime not null
# udt_id :bigint
# open_transaction_id :bigint
# closed_transaction_id :bigint
# last_updated_timestamp_of_node1 :bigint
# last_updated_timestamp_of_node2 :bigint
# fee_rate_of_node1 :decimal(30, ) default(0)
# fee_rate_of_node2 :decimal(30, ) default(0)
#
# Indexes
#
Expand Down
3 changes: 1 addition & 2 deletions app/services/charts/daily_statistic_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,8 @@ def call
daily_statistic = ::DailyStatistic.find_or_create_by!(created_at_unixtimestamp: to_be_counted_date.to_i)
daily_statistic.from_scratch = from_scratch
daily_statistic.reset!(updated_attrs)

daily_statistic
rescue Exception => e
rescue StandardError => e
Rails.logger.error "Error occurred during DailyStatisticGenerator error: #{e.message}"
end

Expand Down
9 changes: 4 additions & 5 deletions app/views/api/v2/fiber/graph_channels/index.jbuilder
Original file line number Diff line number Diff line change
@@ -1,12 +1,11 @@
json.data do
json.fiber_graph_channels @channels do |channel|
json.(channel, :channel_outpoint, :node1, :node2, :chain_hash, :open_transaction_info, :closed_transaction_info)
json.funding_tx_block_number channel.funding_tx_block_number.to_s
json.funding_tx_index channel.funding_tx_index.to_s
json.last_updated_timestamp channel.last_updated_timestamp.to_s
json.last_updated_timestamp_of_node1 channel.last_updated_timestamp_of_node1.to_s
json.last_updated_timestamp_of_node2 channel.last_updated_timestamp_of_node2.to_s
json.created_timestamp channel.created_timestamp.to_s
json.node1_to_node2_fee_rate channel.node1_to_node2_fee_rate.to_s
json.node2_to_node1_fee_rate channel.node2_to_node1_fee_rate.to_s
json.fee_rate_of_node1 channel.fee_rate_of_node1.to_s
json.fee_rate_of_node2 channel.fee_rate_of_node2.to_s
json.capacity channel.capacity.to_s
json.udt_cfg_info channel.udt_info
end
Expand Down
9 changes: 4 additions & 5 deletions app/views/api/v2/fiber/graph_nodes/show.jbuilder
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,11 @@ json.data do

json.fiber_graph_channels @graph_channels do |channel|
json.(channel, :channel_outpoint, :node1, :node2, :chain_hash, :open_transaction_info, :closed_transaction_info, :udt_info)
json.funding_tx_block_number channel.funding_tx_block_number.to_s
json.funding_tx_index channel.funding_tx_index.to_s
json.last_updated_timestamp channel.last_updated_timestamp.to_s
json.last_updated_timestamp_of_node1 channel.last_updated_timestamp_of_node1.to_s
json.last_updated_timestamp_of_node2 channel.last_updated_timestamp_of_node2.to_s
json.fee_rate_of_node1 channel.fee_rate_of_node1.to_s
json.fee_rate_of_node2 channel.fee_rate_of_node2.to_s
json.created_timestamp channel.created_timestamp.to_s
json.node1_to_node2_fee_rate channel.node1_to_node2_fee_rate.to_s
json.node2_to_node1_fee_rate channel.node2_to_node1_fee_rate.to_s
json.capacity channel.capacity.to_s
end
end
9 changes: 4 additions & 5 deletions app/workers/fiber_graph_detect_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,13 @@ def build_channel_attributes(channel)

{
channel_outpoint:,
funding_tx_block_number: channel["funding_tx_block_number"].to_i(16),
funding_tx_index: channel["funding_tx_index"].to_i(16),
node1: channel["node1"],
node2: channel["node2"],
last_updated_timestamp: channel["last_updated_timestamp"].to_i(16),
created_timestamp: channel["created_timestamp"],
node1_to_node2_fee_rate: channel["node1_to_node2_fee_rate"].to_i(16),
node2_to_node1_fee_rate: channel["node2_to_node1_fee_rate"].to_i(16),
last_updated_timestamp_of_node1: channel["last_updated_timestamp_of_node1"].to_i(16),
last_updated_timestamp_of_node2: channel["last_updated_timestamp_of_node2"].to_i(16),
fee_rate_of_node1: channel["fee_rate_of_node1"].to_i(16),
fee_rate_of_node2: channel["fee_rate_of_node2"].to_i(16),
capacity: channel["capacity"].to_i(16),
chain_hash: channel["chain_hash"],
open_transaction_id: open_transaction&.id,
Expand Down
14 changes: 14 additions & 0 deletions db/migrate/20250103072945_update_fiber_graph_channels.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
class UpdateFiberGraphChannels < ActiveRecord::Migration[7.0]
def change
remove_column :fiber_graph_channels, :funding_tx_block_number, :bigint
remove_column :fiber_graph_channels, :funding_tx_index, :integer
remove_column :fiber_graph_channels, :last_updated_timestamp, :bigint
remove_column :fiber_graph_channels, :node1_to_node2_fee_rate, :decimal, precision: 30, default: 0.0
remove_column :fiber_graph_channels, :node2_to_node1_fee_rate, :decimal, precision: 30, default: 0.0

add_column :fiber_graph_channels, :last_updated_timestamp_of_node1, :bigint
add_column :fiber_graph_channels, :last_updated_timestamp_of_node2, :bigint
add_column :fiber_graph_channels, :fee_rate_of_node1, :decimal, precision: 30, default: 0.0
add_column :fiber_graph_channels, :fee_rate_of_node2, :decimal, precision: 30, default: 0.0
end
end
16 changes: 8 additions & 8 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1755,21 +1755,20 @@ ALTER SEQUENCE public.fiber_channels_id_seq OWNED BY public.fiber_channels.id;
CREATE TABLE public.fiber_graph_channels (
id bigint NOT NULL,
channel_outpoint character varying,
funding_tx_block_number bigint,
funding_tx_index integer,
node1 character varying,
node2 character varying,
last_updated_timestamp bigint,
created_timestamp bigint,
node1_to_node2_fee_rate numeric(30,0) DEFAULT 0.0,
node2_to_node1_fee_rate numeric(30,0) DEFAULT 0.0,
capacity numeric(64,2) DEFAULT 0.0,
chain_hash character varying,
created_at timestamp(6) without time zone NOT NULL,
updated_at timestamp(6) without time zone NOT NULL,
udt_id bigint,
open_transaction_id bigint,
closed_transaction_id bigint
closed_transaction_id bigint,
last_updated_timestamp_of_node1 bigint,
last_updated_timestamp_of_node2 bigint,
fee_rate_of_node1 numeric(30,0) DEFAULT 0.0,
fee_rate_of_node2 numeric(30,0) DEFAULT 0.0
);


Expand Down Expand Up @@ -4747,7 +4746,7 @@ CREATE UNIQUE INDEX index_bitcoin_annotations_on_ckb_transaction_id ON public.bi
-- Name: index_bitcoin_statistics_on_timestamp; Type: INDEX; Schema: public; Owner: -
--

CREATE UNIQUE INDEX index_bitcoin_statistics_on_timestamp ON public.bitcoin_statistics USING btree ("timestamp");
CREATE INDEX index_bitcoin_statistics_on_timestamp ON public.bitcoin_statistics USING btree ("timestamp");


--
Expand Down Expand Up @@ -6317,6 +6316,7 @@ INSERT INTO "schema_migrations" (version) VALUES
('20241223023654'),
('20241223060331'),
('20241225045757'),
('20241231022644');
('20241231022644'),
('20250103072945');


Loading