Alpha: exclude signature from the minimal stamp of PoW.
We don't want the stamp to be cheaper for people with faster signing devices...
This commit is contained in:
parent
5672508b00
commit
e3bfe0d651
@ -11,5 +11,6 @@
|
||||
"blocks_per_roll_snapshot" : 4,
|
||||
"blocks_per_cycle" : 8,
|
||||
"preserved_cycles" : 2,
|
||||
"first_free_baking_slot" : 4
|
||||
"first_free_baking_slot" : 4,
|
||||
"proof_of_work_threshold": -1
|
||||
}
|
||||
|
@ -22,17 +22,19 @@ let generate_seed_nonce () =
|
||||
| Ok nonce -> nonce
|
||||
|
||||
let forge_block_header
|
||||
cctxt block delegate_sk shell priority seed_nonce_hash =
|
||||
(cctxt : #Proto_alpha.full) block delegate_sk shell priority seed_nonce_hash =
|
||||
Alpha_services.Constants.proof_of_work_threshold
|
||||
cctxt block >>=? fun stamp_threshold ->
|
||||
let rec loop () =
|
||||
let proof_of_work_nonce = generate_proof_of_work_nonce () in
|
||||
let unsigned_header =
|
||||
Alpha_context.Block_header.forge_unsigned
|
||||
shell { priority ; seed_nonce_hash ; proof_of_work_nonce } in
|
||||
Client_keys.append cctxt delegate_sk unsigned_header >>=? fun signed_header ->
|
||||
let block_hash = Block_hash.hash_bytes [signed_header] in
|
||||
if Baking.check_hash block_hash stamp_threshold then
|
||||
let protocol_data : Block_header.protocol_data =
|
||||
{ priority ; seed_nonce_hash ; proof_of_work_nonce } in
|
||||
let faked_header : Block_header.t =
|
||||
{ shell ; protocol_data ; signature = Signature.zero } in
|
||||
if Baking.check_header_hash faked_header stamp_threshold then
|
||||
let unsigned_header =
|
||||
Alpha_context.Block_header.forge_unsigned shell protocol_data in
|
||||
Client_keys.append cctxt delegate_sk unsigned_header >>=? fun signed_header ->
|
||||
return signed_header
|
||||
else
|
||||
loop () in
|
||||
|
@ -252,7 +252,13 @@ let check_hash hash stamp_threshold =
|
||||
Compare.Uint64.(word <= stamp_threshold)
|
||||
|
||||
let check_header_hash header stamp_threshold =
|
||||
let hash = Block_header.hash header in
|
||||
let hash =
|
||||
Block_header.hash_raw
|
||||
{ shell = header.Block_header.shell ;
|
||||
protocol_data =
|
||||
Data_encoding.Binary.to_bytes
|
||||
Block_header.protocol_data_encoding
|
||||
header.protocol_data } in
|
||||
check_hash hash stamp_threshold
|
||||
|
||||
let check_proof_of_work_stamp ctxt block =
|
||||
|
@ -103,7 +103,7 @@ val first_endorsement_slots:
|
||||
the given key *)
|
||||
val check_signature: Block_header.t -> public_key -> unit tzresult Lwt.t
|
||||
|
||||
val check_hash: Block_hash.t -> int64 -> bool
|
||||
val check_header_hash: Block_header.t -> int64 -> bool
|
||||
|
||||
(** verify if the proof of work stamp is valid *)
|
||||
val check_proof_of_work_stamp:
|
||||
|
Loading…
Reference in New Issue
Block a user