Skip to content

Commit

Permalink
final test for the day
Browse files Browse the repository at this point in the history
  • Loading branch information
rodrigo-o committed Oct 1, 2024
1 parent 26f41cb commit 61d92bf
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 8 deletions.
8 changes: 4 additions & 4 deletions lib/lambda_ethereum_consensus/fork_choice/fork_choice.ex
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do

Logger.info("[Fork choice] Adding new block", root: block_info.root, slot: slot)

%Store{finalized_checkpoint: _last_finalized_checkpoint} = store
%Store{finalized_checkpoint: last_finalized_checkpoint} = store

result =
:telemetry.span([:sync, :on_block], %{}, fn ->
Expand All @@ -61,7 +61,7 @@ defmodule LambdaEthereumConsensus.ForkChoice do
:telemetry.span([:fork_choice, :recompute_head], %{}, fn ->
{recompute_head(new_store), %{}}
end)
# |> prune_old_states(last_finalized_checkpoint.epoch)
|> prune_old_states(last_finalized_checkpoint.epoch)
|> tap(fn store ->
StoreDb.persist_store(store)
Logger.info("[Fork choice] Added new block", slot: slot, root: block_root)
Expand Down Expand Up @@ -104,10 +104,10 @@ defmodule LambdaEthereumConsensus.ForkChoice do

@spec on_tick(Store.t(), Types.uint64()) :: Store.t()
def on_tick(store, time) do
%Store{finalized_checkpoint: _last_finalized_checkpoint} = store
%Store{finalized_checkpoint: last_finalized_checkpoint} = store

Handlers.on_tick(store, time)
# |> prune_old_states(last_finalized_checkpoint.epoch)
|> prune_old_states(last_finalized_checkpoint.epoch)
|> tap(&StoreDb.persist_store/1)
end

Expand Down
2 changes: 1 addition & 1 deletion lib/lambda_ethereum_consensus/fork_choice/head.ex
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Head do
{true, Map.put(new_blocks, block_root, block)}

not Enum.empty?(children) ->
{false, new_blocks}
{false, blocks}

true ->
filter_leaf_block(store, block_root, block, blocks)
Expand Down
2 changes: 1 addition & 1 deletion lib/lambda_ethereum_consensus/fork_choice/simple_tree.ex
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ defmodule LambdaEthereumConsensus.ForkChoice.Simple.Tree do
def get_children!(tree, parent_id) do
case get_children(tree, parent_id) do
{:error, :not_found} -> raise "Parent #{Base.encode16(parent_id)} not found in tree"
{:ok, res} -> res
{:ok, res} -> res |> IO.inspect(label: "Children of #{Base.encode16(parent_id)}")
end
end

Expand Down
7 changes: 5 additions & 2 deletions lib/types/store.ex
Original file line number Diff line number Diff line change
Expand Up @@ -144,8 +144,11 @@ defmodule Types.Store do

@spec get_children(t(), Types.root()) :: [BeaconBlock.t()]
def get_children(%__MODULE__{tree_cache: tree}, parent_root) do
Tree.get_children!(tree, parent_root)
|> Enum.map(&{&1, Blocks.get_block!(&1)})
Tree.get_children(tree, parent_root)
|> case do
{:ok, children} -> Enum.map(children, &{&1, Blocks.get_block!(&1)})
{:error, :not_found} -> []
end
end

@spec store_block_info(t(), BlockInfo.t()) :: t()
Expand Down

0 comments on commit 61d92bf

Please sign in to comment.