diff --git a/Gemfile b/Gemfile index c7fb91f7d..a013be501 100644 --- a/Gemfile +++ b/Gemfile @@ -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" diff --git a/Gemfile.lock b/Gemfile.lock index 41846dd95..2f9df335a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -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 @@ -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 @@ -124,13 +115,8 @@ 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) @@ -138,7 +124,7 @@ GEM 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) @@ -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) @@ -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) @@ -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) @@ -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) @@ -556,10 +531,6 @@ DEPENDENCIES shoulda-context shoulda-matchers sidekiq - sidekiq-failures - sidekiq-statistic! - sidekiq-status - sidekiq-unique-jobs simplecov solargraph spring diff --git a/app/workers/contract_statistic_worker.rb b/app/workers/contract_statistic_worker.rb index 558132c41..1324ee825 100644 --- a/app/workers/contract_statistic_worker.rb +++ b/app/workers/contract_statistic_worker.rb @@ -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 diff --git a/config/initializers/sidekiq.rb b/config/initializers/sidekiq.rb index c80f04713..b150e334c 100644 --- a/config/initializers/sidekiq.rb +++ b/config/initializers/sidekiq.rb @@ -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 @@ -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 diff --git a/config/routes.rb b/config/routes.rb index ca2ae99cf..fe4a1de51 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,4 @@ require "sidekiq/web" -require "sidekiq_unique_jobs/web" Sidekiq::Web.use ActionDispatch::Cookies Sidekiq::Web.use ActionDispatch::Session::CookieStore