Alpha: check hard storage limit in precheck
This commit is contained in:
parent
6efb4eb6b4
commit
13fb40a4c9
@ -902,6 +902,8 @@ module Fees : sig
|
||||
type error += Operation_quota_exceeded (* `Temporary *)
|
||||
type error += Storage_limit_too_high (* `Permanent *)
|
||||
|
||||
val check_storage_limit: context -> storage_limit:Z.t -> unit tzresult
|
||||
|
||||
end
|
||||
|
||||
module Operation : sig
|
||||
|
@ -482,8 +482,9 @@ let apply_internal_manager_operations ctxt mode ~payer ops =
|
||||
let precheck_manager_contents
|
||||
(type kind) ctxt raw_operation (op : kind Kind.manager contents)
|
||||
: context tzresult Lwt.t =
|
||||
let Manager_operation { source ; fee ; counter ; operation ; gas_limit } = op in
|
||||
let Manager_operation { source ; fee ; counter ; operation ; gas_limit ; storage_limit } = op in
|
||||
Lwt.return (Gas.check_limit ctxt gas_limit) >>=? fun () ->
|
||||
Lwt.return (Fees.check_storage_limit ctxt storage_limit) >>=? fun () ->
|
||||
Contract.must_be_allocated ctxt source >>=? fun () ->
|
||||
Contract.check_counter_increment ctxt source counter >>=? fun () ->
|
||||
begin
|
||||
|
@ -74,13 +74,14 @@ let burn_fees_for_storage c ~storage_limit ~payer =
|
||||
Contract_storage.spend_from_script c payer to_burn) >>=? fun c ->
|
||||
return c
|
||||
|
||||
let with_fees_for_storage c ~storage_limit ~payer f =
|
||||
begin if Compare.Z.(storage_limit > (Raw_context.constants c).hard_storage_limit_per_operation)
|
||||
let check_storage_limit c ~storage_limit =
|
||||
if Compare.Z.(storage_limit > (Raw_context.constants c).hard_storage_limit_per_operation)
|
||||
|| Compare.Z.(storage_limit < Z.zero)then
|
||||
fail Storage_limit_too_high
|
||||
error Storage_limit_too_high
|
||||
else
|
||||
return ()
|
||||
end >>=? fun () ->
|
||||
ok ()
|
||||
|
||||
let with_fees_for_storage c ~storage_limit ~payer f =
|
||||
Lwt.return (Raw_context.init_storage_space_to_pay c) >>=? fun c ->
|
||||
f c >>=? fun (c, ret) ->
|
||||
burn_fees_for_storage c ~storage_limit ~payer >>=? fun c ->
|
||||
|
@ -19,6 +19,9 @@ val record_paid_storage_space:
|
||||
Raw_context.t -> Contract_repr.t ->
|
||||
(Raw_context.t * Z.t * Z.t * Tez_repr.t) tzresult Lwt.t
|
||||
|
||||
val check_storage_limit:
|
||||
Raw_context.t -> storage_limit:Z.t -> unit tzresult
|
||||
|
||||
val with_fees_for_storage:
|
||||
Raw_context.t -> storage_limit:Z.t -> payer:Contract_repr.t ->
|
||||
(Raw_context.t -> (Raw_context.t * 'a) tzresult Lwt.t) ->
|
||||
|
Loading…
Reference in New Issue
Block a user