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

Don't ban nodes for block created in early catchup #13538

Merged
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
1 change: 1 addition & 0 deletions src/lib/transition_handler/dune
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@
kimchi_backend.pasta
kimchi_backend.pasta.basic
internal_tracing
transition_frontier_extensions
)
(instrumentation (backend bisect_ppx))
(preprocess (pps ppx_mina ppx_version ppx_jane)))
39 changes: 33 additions & 6 deletions src/lib/transition_handler/validator.ml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ open Pipe_lib.Strict_pipe
open Mina_base
open Mina_state
open Cache_lib
open Mina_block
open Network_peer

module type CONTEXT = sig
Expand Down Expand Up @@ -87,6 +86,7 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~time_controller
Writer.t ) ~unprocessed_transition_cache =
let open Context in
let module Lru = Core_extended_cache.Lru in
let outdated_root_cache = Lru.create ~destruct:None 1000 in
O1trace.background_thread "validate_blocks_against_frontier" (fun () ->
Reader.iter transition_reader
~f:(fun (`Block transition_env, `Valid_cb vc) ->
Expand Down Expand Up @@ -118,8 +118,9 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~time_controller
in
let transition_time =
Mina_block.header transition
|> Header.protocol_state |> Protocol_state.blockchain_state
|> Blockchain_state.timestamp |> Block_time.to_time_exn
|> Mina_block.Header.protocol_state
|> Protocol_state.blockchain_state |> Blockchain_state.timestamp
|> Block_time.to_time_exn
in
Perf_histograms.add_span
~name:"accepted_transition_remote_latency"
Expand All @@ -143,18 +144,44 @@ let run ~context:(module Context : CONTEXT) ~trust_system ~time_controller
[%log internal] "Failure"
~metadata:[ ("reason", `String "Disconnected") ] ;
Mina_metrics.(Counter.inc_one Rejected_blocks.worse_than_root) ;
let protocol_state =
Mina_block.Header.protocol_state (Mina_block.header transition)
in
[%log error]
~metadata:
[ ("state_hash", State_hash.to_yojson transition_hash)
; ("reason", `String "not selected over current root")
; ( "protocol_state"
, Header.protocol_state (Mina_block.header transition)
|> Protocol_state.value_to_yojson )
, Protocol_state.value_to_yojson protocol_state )
]
"Validation error: external transition with state hash \
$state_hash was rejected for reason $reason" ;
let is_in_root_history =
let open Transition_frontier.Extensions in
get_extension
(Transition_frontier.extensions frontier)
Root_history
|> Root_history.mem
in
let parent_hash =
Protocol_state.previous_state_hash protocol_state
in
let action =
if
is_in_root_history transition_hash
|| Option.is_some
(Lru.find outdated_root_cache transition_hash)
then Trust_system.Actions.Sent_old_gossip
else if
is_in_root_history parent_hash
|| Option.is_some (Lru.find outdated_root_cache parent_hash)
then (
Lru.add outdated_root_cache ~key:transition_hash ~data:() ;
Sent_useless_gossip )
else Disconnected_chain
in
Trust_system.record_envelope_sender trust_system logger sender
( Trust_system.Actions.Disconnected_chain
( action
, Some
( "received transition that was not connected to our chain \
from $sender"
Expand Down