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

Merged
merged 7 commits into from
Oct 23, 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
5 changes: 0 additions & 5 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,6 @@ gem "digest-crc"
# Backgroud Jobs

gem "sidekiq"
# fixed sidekiq7 bug.
gem "sidekiq-statistic", github: "dougmrqs/sidekiq-statistic", branch: "fix-problem-with-sidekiq-7"
gem "sidekiq-unique-jobs"
gem "sidekiq-status"
gem "sidekiq-failures"
gem "rufus-scheduler"
# bulk insertion of data into database using ActiveRecord
gem "activerecord-import"
Expand Down
51 changes: 11 additions & 40 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,12 +1,3 @@
GIT
remote: https://github.com/dougmrqs/sidekiq-statistic.git
revision: 590a190fcc8020b4fa05f400d51f6980514f25dd
branch: fix-problem-with-sidekiq-7
specs:
sidekiq-statistic (1.5.1)
sidekiq (>= 5.0)
tilt (~> 2.0)

GIT
remote: https://github.com/nervosnetwork/ckb-sdk-ruby.git
revision: 1790c72fb886bda3e30936a73bc3d1cbcee6c91f
Expand Down Expand Up @@ -100,13 +91,13 @@ GEM
console (~> 1.10)
io-event (~> 1.1)
timers (~> 4.1)
async-http (0.59.5)
async-http (0.60.1)
async (>= 1.25)
async-io (>= 1.28)
async-pool (>= 0.2)
protocol-http (~> 0.23)
protocol-http1 (~> 0.14.0)
protocol-http2 (~> 0.14.0)
protocol-http (~> 0.24.0)
protocol-http1 (~> 0.15.0)
protocol-http2 (~> 0.15.0)
traces (>= 0.8.0)
async-io (1.34.1)
async
Expand All @@ -124,21 +115,16 @@ GEM
bigdecimal (3.1.4)
bootsnap (1.13.0)
msgpack (~> 1.2)
brpoplpush-redis_script (0.1.3)
concurrent-ruby (~> 1.0, >= 1.0.5)
redis (>= 1.0, < 6)
builder (3.2.4)
byebug (11.1.3)
chronic_duration (0.10.6)
numerizer (~> 0.1.1)
codecov (0.6.0)
simplecov (>= 0.15, < 0.22)
coderay (1.1.3)
concurrent-ruby (1.2.2)
config (4.1.0)
deep_merge (~> 1.2, >= 1.2.1)
dry-validation (~> 1.0, >= 1.0.0)
connection_pool (2.4.0)
connection_pool (2.4.1)
console (1.16.2)
fiber-local
crack (0.4.5)
Expand Down Expand Up @@ -302,7 +288,6 @@ GEM
racc (~> 1.4)
nokogiri (1.14.3-x86_64-linux)
racc (~> 1.4)
numerizer (0.1.1)
pagy (5.10.1)
activesupport
parallel (1.22.1)
Expand All @@ -311,10 +296,10 @@ GEM
pg (1.4.5)
pkg-config (1.5.2)
protocol-hpack (1.4.2)
protocol-http (0.24.0)
protocol-http1 (0.14.6)
protocol-http (0.24.7)
protocol-http1 (0.15.1)
protocol-http (~> 0.22)
protocol-http2 (0.14.2)
protocol-http2 (0.15.1)
protocol-hpack (~> 1.4)
protocol-http (~> 0.18)
protocol-rack (0.2.4)
Expand All @@ -336,7 +321,7 @@ GEM
nio4r (~> 2.0)
raabro (1.4.0)
racc (1.6.2)
rack (2.2.6.4)
rack (2.2.8)
rack-attack (6.6.1)
rack (>= 1.0, < 3)
rack-cache (1.13.0)
Expand Down Expand Up @@ -428,21 +413,11 @@ GEM
shoulda-context (2.0.0)
shoulda-matchers (5.2.0)
activesupport (>= 5.2.0)
sidekiq (7.0.8)
sidekiq (7.1.6)
concurrent-ruby (< 2)
connection_pool (>= 2.3.0)
rack (>= 2.2.4)
redis-client (>= 0.11.0)
sidekiq-failures (1.0.4)
sidekiq (>= 4.0.0)
sidekiq-status (2.1.3)
chronic_duration
sidekiq (>= 5.0)
sidekiq-unique-jobs (7.1.27)
brpoplpush-redis_script (> 0.1.1, <= 2.0.0)
concurrent-ruby (~> 1.0, >= 1.0.5)
sidekiq (>= 5.0, < 8.0)
thor (>= 0.20, < 3.0)
redis-client (>= 0.14.0)
simplecov (0.21.2)
docile (~> 1.1)
simplecov-html (~> 0.11)
Expand Down Expand Up @@ -556,10 +531,6 @@ DEPENDENCIES
shoulda-context
shoulda-matchers
sidekiq
sidekiq-failures
sidekiq-statistic!
sidekiq-status
sidekiq-unique-jobs
simplecov
solargraph
spring
Expand Down
14 changes: 5 additions & 9 deletions app/workers/contract_statistic_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,12 @@ class ContractStatisticWorker

def perform
Contract.find_each do |contract|
referring_cells = contract.referring_cell_outputs&.live
deployed_cells = contract.deployed_cell_outputs&.live
transactions = contract.cell_dependencies

contract.update(
ckb_transactions_count: transactions.count,
deployed_cells_count: deployed_cells&.count.to_i,
referring_cells_count: referring_cells&.count.to_i,
total_deployed_cells_capacity: deployed_cells&.sum(:capacity),
total_referring_cells_capacity: referring_cells&.sum(:capacity)
ckb_transactions_count: contract.cell_dependencies.count,
deployed_cells_count: contract.deployed_cell_outputs&.live&.size,
referring_cells_count: contract.referring_cell_outputs&.live&.size,
total_deployed_cells_capacity: contract.deployed_cell_outputs&.live&.sum(:capacity),
total_referring_cells_capacity: contract.referring_cell_outputs&.live&.sum(:capacity)
)
end
end
Expand Down
10 changes: 4 additions & 6 deletions config/initializers/sidekiq.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,10 +10,6 @@
config.redis = { url: redis_url, driver: :ruby, password: redis_password }
# config.redis = { url: redis_url, driver: :hiredis, password: redis_password }

config.death_handlers << ->(job, _ex) do
SidekiqUniqueJobs::Digests.del(digest: job["unique_digest"]) if job["unique_digest"]
end

if defined?(ActiveRecord::Base)
config = Rails.application.config.database_configuration[Rails.env]
config["reaping_frequency"] = ENV["DB_REAP_FREQ"] || 10
Expand All @@ -33,7 +29,9 @@
# - See https://thisdata.com/blog/timing-attacks-against-string-comparison/
# - Use & (do not use &&) so that it doesn't short circuit.
# - Use digests to stop length information leaking (see also ActiveSupport::SecurityUtils.variable_size_secure_compare)
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_USERNAME"])) &
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password), ::Digest::SHA256.hexdigest(ENV["SIDEKIQ_PASSWORD"]))
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(username),
::Digest::SHA256.hexdigest(ENV["SIDEKIQ_USERNAME"])) &
ActiveSupport::SecurityUtils.secure_compare(::Digest::SHA256.hexdigest(password),
::Digest::SHA256.hexdigest(ENV["SIDEKIQ_PASSWORD"]))
end
end
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
require "sidekiq/web"
require "sidekiq_unique_jobs/web"

Sidekiq::Web.use ActionDispatch::Cookies
Sidekiq::Web.use ActionDispatch::Session::CookieStore
Expand Down
Loading