Skip to content

Commit

Permalink
Remove obsolete InvalidConsensus.Worker
Browse files Browse the repository at this point in the history
This worker only handled one of invalid consensus cases, i.e. when a parent
block lost consensus, but the child one didn't.
Even then it worked only when all blocks are reliably and sequentially
imported (certainly not our case), and only once on indexer launch.

Now this particular case is covered by previous commit, and we don't need
this worker at all.
  • Loading branch information
goodsoft committed Mar 29, 2019
1 parent 32bae02 commit f15eff7
Show file tree
Hide file tree
Showing 6 changed files with 1 addition and 272 deletions.
18 changes: 0 additions & 18 deletions apps/explorer/lib/explorer/chain.ex
Original file line number Diff line number Diff line change
Expand Up @@ -2638,24 +2638,6 @@ defmodule Explorer.Chain do
@spec data() :: Dataloader.Ecto.t()
def data, do: DataloaderEcto.new(Repo)

@doc """
Returns a list of block numbers with invalid consensus.
"""
@spec list_block_numbers_with_invalid_consensus :: [integer()]
def list_block_numbers_with_invalid_consensus do
query =
from(
block in Block,
join: parent in Block,
on: parent.hash == block.parent_hash,
where: block.consensus == true,
where: parent.consensus == false,
select: parent.number
)

Repo.all(query, timeout: :infinity)
end

def list_decompiled_contracts(limit, offset) do
query =
from(
Expand Down
21 changes: 0 additions & 21 deletions apps/explorer/test/explorer/chain_test.exs
Original file line number Diff line number Diff line change
Expand Up @@ -3667,27 +3667,6 @@ defmodule Explorer.ChainTest do
end
end

describe "list_block_numbers_with_invalid_consensus/0" do
test "returns a list of block numbers with invalid consensus" do
block1 = insert(:block)
block2_with_invalid_consensus = insert(:block, parent_hash: block1.hash, consensus: false)
_block2 = insert(:block, parent_hash: block1.hash, number: block2_with_invalid_consensus.number)
block3 = insert(:block, parent_hash: block2_with_invalid_consensus.hash)
block4 = insert(:block, parent_hash: block3.hash)
block5 = insert(:block, parent_hash: block4.hash)
block6_without_consensus = insert(:block, parent_hash: block5.hash, consensus: false)
block6 = insert(:block, parent_hash: block5.hash, number: block6_without_consensus.number)
block7 = insert(:block, parent_hash: block6.hash)
block8_with_invalid_consensus = insert(:block, parent_hash: block7.hash, consensus: false)
_block8 = insert(:block, parent_hash: block7.hash, number: block8_with_invalid_consensus.number)
block9 = insert(:block, parent_hash: block8_with_invalid_consensus.hash)
_block10 = insert(:block, parent_hash: block9.hash)

assert Chain.list_block_numbers_with_invalid_consensus() ==
[block2_with_invalid_consensus.number, block8_with_invalid_consensus.number]
end
end

describe "block_combined_rewards/1" do
test "sums the block_rewards values" do
block = insert(:block)
Expand Down
45 changes: 0 additions & 45 deletions apps/indexer/lib/indexer/block/invalid_consensus/supervisor.ex

This file was deleted.

99 changes: 0 additions & 99 deletions apps/indexer/lib/indexer/block/invalid_consensus/worker.ex

This file was deleted.

3 changes: 1 addition & 2 deletions apps/indexer/lib/indexer/block/supervisor.ex
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ defmodule Indexer.Block.Supervisor do
"""

alias Indexer.Block
alias Indexer.Block.{Catchup, InvalidConsensus, Realtime, Reward, Uncle}
alias Indexer.Block.{Catchup, Realtime, Reward, Uncle}
alias Indexer.Temporary.{AddressesWithoutCode, FailedCreatedAddresses}

use Supervisor
Expand Down Expand Up @@ -50,7 +50,6 @@ defmodule Indexer.Block.Supervisor do
%{block_fetcher: block_fetcher, block_interval: block_interval, memory_monitor: memory_monitor},
[name: Catchup.Supervisor]
]},
{InvalidConsensus.Supervisor, [[], [name: InvalidConsensus.Supervisor]]},
{Realtime.Supervisor,
[
%{block_fetcher: realtime_block_fetcher, subscribe_named_arguments: realtime_subscribe_named_arguments},
Expand Down
87 changes: 0 additions & 87 deletions apps/indexer/test/indexer/block/invalid_consensus/worker_test.exs

This file was deleted.

0 comments on commit f15eff7

Please sign in to comment.