Client: repair gas cost estimation

This commit is contained in:
Benjamin Canou 2018-06-17 02:01:34 +02:00
parent 2976353636
commit 79ab86b076

View File

@ -206,15 +206,15 @@ let may_patch_limits
let may_need_patching_single let may_need_patching_single
: type kind. kind contents -> kind contents option = function : type kind. kind contents -> kind contents option = function
| Manager_operation c | Manager_operation c
when c.gas_limit < Z.zero || gas_limit < c.gas_limit when c.gas_limit < Z.zero || gas_limit <= c.gas_limit
|| c.storage_limit < Z.zero || storage_limit < c.storage_limit -> || c.storage_limit < Z.zero || storage_limit <= c.storage_limit ->
let gas_limit = let gas_limit =
if c.gas_limit < Z.zero || gas_limit < c.gas_limit then if c.gas_limit < Z.zero || gas_limit <= c.gas_limit then
gas_limit gas_limit
else else
c.gas_limit in c.gas_limit in
let storage_limit = let storage_limit =
if c.storage_limit < Z.zero || storage_limit < c.storage_limit then if c.storage_limit < Z.zero || storage_limit <= c.storage_limit then
storage_limit storage_limit
else else
c.storage_limit in c.storage_limit in
@ -241,7 +241,7 @@ let may_patch_limits
type kind. kind contents * kind contents_result -> kind contents tzresult Lwt.t = function type kind. kind contents * kind contents_result -> kind contents tzresult Lwt.t = function
| Manager_operation c, (Manager_operation_result _ as result) -> | Manager_operation c, (Manager_operation_result _ as result) ->
begin begin
if c.gas_limit < Z.zero || gas_limit < c.gas_limit then if c.gas_limit < Z.zero || gas_limit <= c.gas_limit then
Lwt.return (estimated_gas_single result) >>=? fun gas -> Lwt.return (estimated_gas_single result) >>=? fun gas ->
begin begin
if Z.equal gas Z.zero then if Z.equal gas Z.zero then
@ -256,7 +256,7 @@ let may_patch_limits
else return c.gas_limit else return c.gas_limit
end >>=? fun gas_limit -> end >>=? fun gas_limit ->
begin begin
if c.storage_limit < Z.zero || storage_limit < c.storage_limit then if c.storage_limit < Z.zero || storage_limit <= c.storage_limit then
Lwt.return (estimated_storage_single result) >>=? fun storage -> Lwt.return (estimated_storage_single result) >>=? fun storage ->
begin begin
if Z.equal storage Z.zero then if Z.equal storage Z.zero then