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

Merged
merged 20 commits into from
Dec 6, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
66aafa6
Issue 797 (#2302)
rabbitz Dec 2, 2024
632b596
Merge pull request #2303 from nervosnetwork/develop
rabbitz Dec 2, 2024
82dd84f
Refactor contract (#2306)
zmcNotafraid Dec 4, 2024
07ae328
Merge pull request #2307 from nervosnetwork/develop
zmcNotafraid Dec 4, 2024
495503b
chore(deps): bump rails-html-sanitizer from 1.6.0 to 1.6.1 (#2305)
dependabot[bot] Dec 5, 2024
6c9ce5c
Feat/fiber (#2301)
rabbitz Dec 5, 2024
167bdf2
Merge pull request #2309 from nervosnetwork/develop
rabbitz Dec 5, 2024
33927e0
fix: keep unique analyze job (#2310)
zmcNotafraid Dec 5, 2024
eb83b55
Merge pull request #2311 from nervosnetwork/develop
zmcNotafraid Dec 5, 2024
691a89f
feat: speed up AnalyzeContractFromCellDependencyWorker (#2312)
zmcNotafraid Dec 5, 2024
82b9504
Merge pull request #2313 from nervosnetwork/develop
zmcNotafraid Dec 5, 2024
abe5b8d
feat: use sidekiq-unique-jobs (#2314)
zmcNotafraid Dec 5, 2024
3587de0
Merge pull request #2315 from nervosnetwork/develop
zmcNotafraid Dec 5, 2024
6180b8c
chore: adjust tests (#2317)
rabbitz Dec 6, 2024
597fad9
Merge pull request #2318 from nervosnetwork/develop
rabbitz Dec 6, 2024
6d7ea52
feat: remove deprecated code (#2308)
zmcNotafraid Dec 6, 2024
a6c7f86
feat: use task to analyze contract from start block (#2319)
zmcNotafraid Dec 6, 2024
9513941
Merge pull request #2320 from nervosnetwork/develop
zmcNotafraid Dec 6, 2024
aaf9f3d
fix: analyze_contract task (#2321)
zmcNotafraid Dec 6, 2024
804e3e5
Merge pull request #2322 from nervosnetwork/develop
zmcNotafraid Dec 6, 2024
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
9 changes: 8 additions & 1 deletion app/models/daily_statistic.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ class DailyStatistic < ApplicationRecord
transactions_count addresses_count total_dao_deposit live_cells_count dead_cells_count avg_hash_rate avg_difficulty uncle_rate
total_depositors_count address_balance_distribution total_tx_fee occupied_capacity daily_dao_deposit daily_dao_depositors_count
circulation_ratio daily_dao_withdraw nodes_count circulating_supply burnt locked_capacity treasury_amount mining_reward
deposit_compensation liquidity created_at_unixtimestamp ckb_hodl_wave holder_count
deposit_compensation liquidity created_at_unixtimestamp ckb_hodl_wave holder_count knowledge_size
).freeze
MILLISECONDS_IN_DAY = BigDecimal(24 * 60 * 60 * 1000)
GENESIS_TIMESTAMP = 1573852190812
Expand Down Expand Up @@ -239,6 +239,12 @@ def liquidity
tip_parse_dao.c_i - MarketData::BURN_QUOTA - treasury_amount.to_i
end

define_logic :knowledge_size do
tip_dao = current_tip_block.dao
tip_parse_dao = CkbUtils.parse_dao(tip_dao)
tip_parse_dao.u_i - MarketData::BURN_QUOTA * 0.6
end

define_logic :circulating_supply do
MarketData.new(indicator: "circulating_supply", tip_block_number: current_tip_block.number,
unit: "shannon").call
Expand Down Expand Up @@ -568,6 +574,7 @@ def aggron_first_day?
# locked_capacity :decimal(30, )
# ckb_hodl_wave :jsonb
# holder_count :integer
# knowledge_size :decimal(30, )
#
# Indexes
#
Expand Down
4 changes: 4 additions & 0 deletions app/serializers/daily_statistic_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -134,4 +134,8 @@ class DailyStatisticSerializer
} do |object|
object.holder_count.to_s
end

attribute :knowledge_size, if: Proc.new { |_record, params|
params.present? && params[:indicator].include?("knowledge_size")
}
end
2 changes: 1 addition & 1 deletion app/services/charts/daily_statistic_generator.rb
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ def updated_attrs
}
others = %i{
block_timestamp transactions_count addresses_count daily_dao_withdraw
average_deposit_time mining_reward
average_deposit_time mining_reward knowledge_size
treasury_amount estimated_apc live_cells_count dead_cells_count avg_hash_rate
avg_difficulty uncle_rate address_balance_distribution
total_tx_fee occupied_capacity daily_dao_deposit total_supply block_time_distribution
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
class AddKnowledgeSizeToDailyStatistics < ActiveRecord::Migration[7.0]
def change
add_column :daily_statistics, :knowledge_size, :decimal, precision: 30
end
end
7 changes: 5 additions & 2 deletions db/structure.sql
Original file line number Diff line number Diff line change
Expand Up @@ -1512,7 +1512,8 @@ CREATE TABLE public.daily_statistics (
nodes_count integer,
locked_capacity numeric(30,0),
ckb_hodl_wave jsonb,
holder_count integer
holder_count integer,
knowledge_size numeric(30,0)
);


Expand Down Expand Up @@ -5945,4 +5946,6 @@ INSERT INTO "schema_migrations" (version) VALUES
('20240823071323'),
('20240823071420'),
('20240902025657'),
('20240904043807');
('20240904043807'),
('20241202072604');

8 changes: 8 additions & 0 deletions test/services/charts/daily_statistic_generator_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -444,6 +444,14 @@ class DailyStatisticGeneratorTest < ActiveSupport::TestCase
assert_equal total_supply_temp, total_supply
end

test "it should get knowledge_size" do
tip_dao = @current_tip_block.dao
tip_parse_dao = CkbUtils.parse_dao(tip_dao)
knowledge_size_temp = tip_parse_dao.u_i - MarketData::BURN_QUOTA * 0.6
knowledge_size = Charts::DailyStatisticGenerator.new(@datetime).call.knowledge_size
assert_equal knowledge_size_temp, knowledge_size
end

test "it should get epoch_length_distribution" do
max_n = 1700
ranges = (700..max_n).step(100).map { |n| [n, n + 100] }
Expand Down
Loading