From df4fde0d5e9a5081e7a7e16461e63e2a4b8b794e Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:24:14 +0800 Subject: [PATCH 1/6] chore(deps): bump sidekiq from 7.0.8 to 7.1.3 (#1449) Bumps [sidekiq](https://github.com/sidekiq/sidekiq) from 7.0.8 to 7.1.3. - [Changelog](https://github.com/sidekiq/sidekiq/blob/main/Changes.md) - [Commits](https://github.com/sidekiq/sidekiq/compare/v7.0.8...v7.1.3) --- updated-dependencies: - dependency-name: sidekiq dependency-type: direct:production ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 41846dd95..258cb8f70 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -138,7 +138,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) @@ -336,7 +336,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,11 +428,11 @@ GEM shoulda-context (2.0.0) shoulda-matchers (5.2.0) activesupport (>= 5.2.0) - sidekiq (7.0.8) + sidekiq (7.1.3) concurrent-ruby (< 2) connection_pool (>= 2.3.0) rack (>= 2.2.4) - redis-client (>= 0.11.0) + redis-client (>= 0.14.0) sidekiq-failures (1.0.4) sidekiq (>= 4.0.0) sidekiq-status (2.1.3) From 335708b5608e31ab94afbde703574f5e634a00ee Mon Sep 17 00:00:00 2001 From: "dependabot[bot]" <49699333+dependabot[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 14:38:19 +0800 Subject: [PATCH 2/6] chore(deps): bump protocol-http1 from 0.14.6 to 0.15.1 (#1369) Bumps [protocol-http1](https://github.com/socketry/protocol-http1) from 0.14.6 to 0.15.1. - [Changelog](https://github.com/socketry/protocol-http1/blob/main/release.cert) - [Commits](https://github.com/socketry/protocol-http1/compare/v0.14.6...v0.15.1) --- updated-dependencies: - dependency-name: protocol-http1 dependency-type: indirect ... Signed-off-by: dependabot[bot] Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com> --- Gemfile.lock | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/Gemfile.lock b/Gemfile.lock index 258cb8f70..4a8f3fc5b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -100,13 +100,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 @@ -311,10 +311,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) From cc3fd7b1f3bd367bff87e71aea250e2a5a0e65a1 Mon Sep 17 00:00:00 2001 From: "github-actions[bot]" <41898282+github-actions[bot]@users.noreply.github.com> Date: Fri, 20 Oct 2023 16:10:36 +0800 Subject: [PATCH 3/6] Merge released refs/heads/master into develop (#1480) Co-authored-by: Miles Zhang From d061a1bc3022b373af3bbaa5b88843f618a33bdf Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Fri, 20 Oct 2023 18:25:14 +0800 Subject: [PATCH 4/6] refactor: inner join cell_outputs is slow, fix it (#1481) Signed-off-by: Miles Zhang --- app/workers/contract_statistic_worker.rb | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/app/workers/contract_statistic_worker.rb b/app/workers/contract_statistic_worker.rb index 558132c41..e4258f963 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&.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 From 2894e12d3f8a020b3bbfac50154cdee65f370fc4 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Fri, 20 Oct 2023 21:52:24 +0800 Subject: [PATCH 5/6] feat: filter contract's referring cells of live status (#1482) * feat: filter contract's referring cells of live status Signed-off-by: Miles Zhang * chore: these sidekiq relation gems were not compatible or not used Signed-off-by: Miles Zhang --------- Signed-off-by: Miles Zhang --- Gemfile | 5 ---- Gemfile.lock | 29 ------------------------ app/workers/contract_statistic_worker.rb | 2 +- config/initializers/sidekiq.rb | 10 ++++---- config/routes.rb | 1 - 5 files changed, 5 insertions(+), 42 deletions(-) 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 4a8f3fc5b..ad5060471 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 @@ -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) @@ -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) @@ -433,16 +418,6 @@ GEM connection_pool (>= 2.3.0) rack (>= 2.2.4) redis-client (>= 0.14.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) 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 e4258f963..1324ee825 100644 --- a/app/workers/contract_statistic_worker.rb +++ b/app/workers/contract_statistic_worker.rb @@ -7,7 +7,7 @@ def perform contract.update( ckb_transactions_count: contract.cell_dependencies.count, deployed_cells_count: contract.deployed_cell_outputs&.live&.size, - referring_cells_count: contract.referring_cell_outputs&.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) ) 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 From 75dd3f1c2cdc9b3f2763cebcb0eb78aefc9d66b9 Mon Sep 17 00:00:00 2001 From: Miles Zhang Date: Sun, 22 Oct 2023 16:46:19 +0800 Subject: [PATCH 6/6] chore: sidekiq 7.1.3 has bug (#1483) Signed-off-by: Miles Zhang --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index ad5060471..2f9df335a 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -413,7 +413,7 @@ GEM shoulda-context (2.0.0) shoulda-matchers (5.2.0) activesupport (>= 5.2.0) - sidekiq (7.1.3) + sidekiq (7.1.6) concurrent-ruby (< 2) connection_pool (>= 2.3.0) rack (>= 2.2.4)