Success response when injecting a transaction with outdated branch
/injection/operation
currently seems to accept an operation that is referencing an outdated branch in op.Operation.shell.branch
. After briefly scanning the code it seems that it currently only checks if the branch is known, but not whether it is outdated.
let inject_operation v ?chain_id op =
( match chain_id with
| None -> (
Distributed_db.read_block_header v.db op.Operation.shell.branch
>>= function
| None ->
failwith
"Unknown branch (%a), cannot inject the operation."
Block_hash.pp_short
op.shell.branch
| Some (chain_id, _bh) ->
Lwt.return (get v chain_id) )
| Some chain_id -> (
Lwt.return (get v chain_id)
>>=? fun nv ->
Distributed_db.Block_header.known
(Chain_validator.chain_db nv)
op.shell.branch
>>= function
| true ->
return nv
| false ->
failwith
"Unknown branch (%a), cannot inject the operation."
Block_hash.pp_short
op.shell.branch ) )
>>=? fun nv ->
let pv_opt = Chain_validator.prevalidator nv in
match pv_opt with
| Some pv ->
Prevalidator.inject_operation pv op
| None ->
failwith "Prevalidator is not running, cannot inject the operation."
The expected behaviour would be to return an error if the branch is outdated or unknown.
This issue was originally brought up on Tezos Stackexhange and if fixed should be reported back there.