Baker/Nonces: fix reveal nonces
This commit is contained in:
parent
e966d2784e
commit
e02b166b84
@ -944,9 +944,7 @@ let filter_outdated_nonces
|
||||
cctxt ~chain ~block:head () >>=? fun { protocol_data = { level = current_level } } ->
|
||||
let current_cycle = Cycle.to_int32 current_level.Level.cycle in
|
||||
let is_older_than_5_cycles block_cycle =
|
||||
let delta = Int32.sub current_cycle block_cycle in
|
||||
delta > 5l
|
||||
in
|
||||
Int32.sub current_cycle (Cycle.to_int32 block_cycle) > 5l in
|
||||
cctxt#with_lock begin fun () ->
|
||||
Client_baking_nonces.load cctxt >>=? fun nonces ->
|
||||
Block_hash.Map.fold
|
||||
@ -954,8 +952,7 @@ let filter_outdated_nonces
|
||||
acc >>=? fun acc ->
|
||||
Alpha_block_services.metadata cctxt ~chain ~block:(`Hash (hash, 0)) () >>=?
|
||||
fun { protocol_data = { level = { Level.cycle } } } ->
|
||||
let i = Cycle.to_int32 cycle in
|
||||
if is_older_than_5_cycles i then
|
||||
if is_older_than_5_cycles cycle then
|
||||
return acc
|
||||
else
|
||||
return (Block_hash.Map.add hash nonce acc)
|
||||
|
@ -117,3 +117,9 @@ val get_unrevealed_nonces:
|
||||
?chain:Chain_services.chain ->
|
||||
Block_services.block ->
|
||||
(Block_hash.t * (Raw_level.t * Nonce.t)) list tzresult Lwt.t
|
||||
|
||||
val filter_outdated_nonces:
|
||||
#Proto_alpha.full ->
|
||||
?chain:Block_services.chain ->
|
||||
Shell_services.block ->
|
||||
unit tzresult Lwt.t
|
||||
|
@ -104,9 +104,8 @@ let get_predecessor_cycle (cctxt : #Client_context.printer) cycle =
|
||||
|
||||
let do_reveal cctxt block blocks =
|
||||
let nonces = List.map snd blocks in
|
||||
Client_baking_revelation.forge_seed_nonce_revelation cctxt
|
||||
block nonces >>=? fun () ->
|
||||
Client_baking_nonces.dels cctxt (List.map fst blocks) >>=? fun () ->
|
||||
Client_baking_revelation.forge_seed_nonce_revelation
|
||||
cctxt block nonces >>=? fun () ->
|
||||
return_unit
|
||||
|
||||
let reveal_block_nonces (cctxt : #Proto_alpha.full) block_hashes =
|
||||
@ -141,4 +140,6 @@ let reveal_block_nonces (cctxt : #Proto_alpha.full) block_hashes =
|
||||
let reveal_nonces cctxt () =
|
||||
Client_baking_forge.get_unrevealed_nonces
|
||||
cctxt cctxt#block >>=? fun nonces ->
|
||||
do_reveal cctxt cctxt#block nonces
|
||||
do_reveal cctxt cctxt#block nonces >>=? fun () ->
|
||||
Client_baking_forge.filter_outdated_nonces cctxt cctxt#block >>=? fun () ->
|
||||
return_unit
|
||||
|
Loading…
Reference in New Issue
Block a user