Alpha: change space_storage from int64 to Z.t
This commit is contained in:
parent
12b7a49f96
commit
8f5aecfc01
@ -172,8 +172,8 @@ let storage_limit_arg =
|
||||
of letting the client decide based on a simulation"
|
||||
(parameter (fun _ s ->
|
||||
try
|
||||
let v = Int64.of_string s in
|
||||
assert Compare.Int64.(v >= 0L) ;
|
||||
let v = Z.of_string s in
|
||||
assert Compare.Z.(v >= Z.zero) ;
|
||||
return v
|
||||
with _ -> failwith "invalid storage limit (must be a positive number of bytes)"))
|
||||
|
||||
|
@ -15,7 +15,7 @@ val tez_sym: string
|
||||
val init_arg: (string, Proto_alpha.full) Clic.arg
|
||||
val fee_arg: (Tez.t, Proto_alpha.full) Clic.arg
|
||||
val gas_limit_arg: (Z.t option, Proto_alpha.full) Clic.arg
|
||||
val storage_limit_arg: (Int64.t option, Proto_alpha.full) Clic.arg
|
||||
val storage_limit_arg: (Z.t option, Proto_alpha.full) Clic.arg
|
||||
val arg_arg: (string, Proto_alpha.full) Clic.arg
|
||||
val source_arg: (string option, Proto_alpha.full) Clic.arg
|
||||
|
||||
|
@ -59,7 +59,7 @@ let reveal cctxt
|
||||
let contents =
|
||||
Single
|
||||
(Manager_operation { source ; fee ; counter ;
|
||||
gas_limit = Z.zero ; storage_limit = 0L ;
|
||||
gas_limit = Z.zero ; storage_limit = Z.zero ;
|
||||
operation = Reveal src_pk }) in
|
||||
Injection.inject_operation cctxt ~chain ~block ?confirmations
|
||||
?branch ~src_sk contents >>=? fun (oph, op, result) ->
|
||||
@ -109,7 +109,7 @@ let delegate_contract cctxt
|
||||
let operation = Delegation delegate_opt in
|
||||
Injection.inject_manager_operation
|
||||
cctxt ~chain ~block ?confirmations
|
||||
?branch ~source ~fee ~gas_limit:Z.zero ~storage_limit:0L
|
||||
?branch ~source ~fee ~gas_limit:Z.zero ~storage_limit:Z.zero
|
||||
~src_pk ~src_sk operation >>=? fun res ->
|
||||
return res
|
||||
|
||||
|
@ -98,7 +98,7 @@ val originate_contract:
|
||||
?branch:int ->
|
||||
fee:Tez.t ->
|
||||
?gas_limit:Z.t ->
|
||||
?storage_limit:Int64.t ->
|
||||
?storage_limit:Z.t ->
|
||||
delegate:public_key_hash option ->
|
||||
?delegatable:bool ->
|
||||
?spendable:bool ->
|
||||
@ -125,7 +125,7 @@ val transfer :
|
||||
amount:Tez.t ->
|
||||
fee:Tez.t ->
|
||||
?gas_limit:Z.t ->
|
||||
?storage_limit:Int64.t ->
|
||||
?storage_limit:Z.t ->
|
||||
unit ->
|
||||
(Kind.transaction Kind.manager Injection.result * Contract.t list) tzresult Lwt.t
|
||||
|
||||
@ -162,4 +162,3 @@ val activate_account:
|
||||
activation_key ->
|
||||
string ->
|
||||
Kind.activate_account Injection.result tzresult Lwt.t
|
||||
|
||||
|
@ -106,15 +106,15 @@ let estimated_storage_single
|
||||
match result with
|
||||
| Applied (Transaction_result { storage_size_diff }) -> Ok storage_size_diff
|
||||
| Applied (Origination_result { storage_size_diff }) -> Ok storage_size_diff
|
||||
| Applied Reveal_result -> Ok Int64.zero
|
||||
| Applied Delegation_result -> Ok Int64.zero
|
||||
| Applied Reveal_result -> Ok Z.zero
|
||||
| Applied Delegation_result -> Ok Z.zero
|
||||
| Skipped _ -> assert false
|
||||
| Failed (_, errs) -> Alpha_environment.wrap_error (Error errs) in
|
||||
List.fold_left
|
||||
(fun acc (Internal_operation_result (_, r)) ->
|
||||
acc >>? fun acc ->
|
||||
storage_size_diff r >>? fun storage ->
|
||||
Ok (Int64.add acc storage))
|
||||
Ok (Z.add acc storage))
|
||||
(storage_size_diff operation_result) internal_operation_results
|
||||
|
||||
let estimated_storage res =
|
||||
@ -125,9 +125,9 @@ let estimated_storage res =
|
||||
| Cons_result (res, rest) ->
|
||||
estimated_storage_single res >>? fun storage1 ->
|
||||
estimated_storage rest >>? fun storage2 ->
|
||||
Ok (Int64.add storage1 storage2) in
|
||||
Ok (Z.add storage1 storage2) in
|
||||
estimated_storage res >>? fun diff ->
|
||||
Ok (max 0L diff)
|
||||
Ok (max Z.zero diff)
|
||||
|
||||
let originated_contracts_single
|
||||
(type kind)
|
||||
@ -207,14 +207,14 @@ let may_patch_limits
|
||||
: type kind. kind contents -> kind contents option = function
|
||||
| Manager_operation c
|
||||
when c.gas_limit < Z.zero || gas_limit < c.gas_limit
|
||||
|| c.storage_limit < 0L || storage_limit < c.storage_limit ->
|
||||
|| c.storage_limit < Z.zero || storage_limit < c.storage_limit ->
|
||||
let gas_limit =
|
||||
if c.gas_limit < Z.zero || gas_limit < c.gas_limit then
|
||||
gas_limit
|
||||
else
|
||||
c.gas_limit in
|
||||
let storage_limit =
|
||||
if c.storage_limit < 0L || storage_limit < c.storage_limit then
|
||||
if c.storage_limit < Z.zero || storage_limit < c.storage_limit then
|
||||
storage_limit
|
||||
else
|
||||
c.storage_limit in
|
||||
@ -256,17 +256,17 @@ let may_patch_limits
|
||||
else return c.gas_limit
|
||||
end >>=? fun gas_limit ->
|
||||
begin
|
||||
if c.storage_limit < 0L || 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 ->
|
||||
begin
|
||||
if Int64.equal storage 0L then
|
||||
if Z.equal storage Z.zero then
|
||||
cctxt#message "Estimated storage: no bytes added" >>= fun () ->
|
||||
return 0L
|
||||
return Z.zero
|
||||
else
|
||||
cctxt#message
|
||||
"Estimated storage: %Ld bytes added (will add 20 for safety)"
|
||||
storage >>= fun () ->
|
||||
return (Int64.add storage 20L)
|
||||
"Estimated storage: %s bytes added (will add 20 for safety)"
|
||||
(Z.to_string storage) >>= fun () ->
|
||||
return (Z.add storage (Z.of_int 20))
|
||||
end
|
||||
else return c.storage_limit
|
||||
end >>=? fun storage_limit ->
|
||||
@ -349,7 +349,7 @@ let inject_operation
|
||||
|
||||
let inject_manager_operation
|
||||
cctxt ~chain ~block ?branch ?confirmations
|
||||
~source ~src_pk ~src_sk ~fee ?(gas_limit = Z.minus_one) ?(storage_limit = -1L)
|
||||
~source ~src_pk ~src_sk ~fee ?(gas_limit = Z.minus_one) ?(storage_limit = (Z.of_int (-1)))
|
||||
(type kind) (operation : kind manager_operation)
|
||||
: (Operation_hash.t * kind Kind.manager contents * kind Kind.manager contents_result) tzresult Lwt.t =
|
||||
Alpha_services.Contract.counter
|
||||
@ -365,7 +365,7 @@ let inject_manager_operation
|
||||
let contents =
|
||||
Cons
|
||||
(Manager_operation { source ; fee = Tez.zero ; counter ;
|
||||
gas_limit = Z.zero ; storage_limit = 0L ;
|
||||
gas_limit = Z.zero ; storage_limit = Z.zero ;
|
||||
operation = Reveal src_pk },
|
||||
Single (Manager_operation { source ; fee ; counter = Z.succ counter ;
|
||||
gas_limit ; storage_limit ; operation })) in
|
||||
|
@ -50,7 +50,7 @@ val inject_manager_operation:
|
||||
src_sk:Client_keys.sk_uri ->
|
||||
fee:Tez.t ->
|
||||
?gas_limit:Z.t ->
|
||||
?storage_limit:int64 ->
|
||||
?storage_limit:Z.t ->
|
||||
'kind manager_operation ->
|
||||
'kind Kind.manager result tzresult Lwt.t
|
||||
|
||||
|
@ -172,10 +172,10 @@ let pp_manager_operation_contents_and_result ppf
|
||||
Format.fprintf ppf "@,@[<hv 2>Updated storage:@ %a@]"
|
||||
Michelson_v1_printer.print_expr expr
|
||||
end ;
|
||||
begin if storage_size_diff <> 0L then
|
||||
begin if storage_size_diff <> Z.zero then
|
||||
Format.fprintf ppf
|
||||
"@,Storage size difference: %Ld bytes"
|
||||
storage_size_diff
|
||||
"@,Storage size difference: %s bytes"
|
||||
(Z.to_string storage_size_diff)
|
||||
end ;
|
||||
Format.fprintf ppf
|
||||
"@,Consumed gas: %s"
|
||||
@ -197,10 +197,10 @@ let pp_manager_operation_contents_and_result ppf
|
||||
Format.fprintf ppf "@,@[<v 2>Originated contracts:@,%a@]"
|
||||
(Format.pp_print_list Contract.pp) contracts
|
||||
end ;
|
||||
begin if storage_size_diff <> 0L then
|
||||
begin if storage_size_diff <> Z.zero then
|
||||
Format.fprintf ppf
|
||||
"@,Storage size used: %Ld bytes"
|
||||
storage_size_diff
|
||||
"@,Storage size used: %s bytes"
|
||||
(Z.to_string storage_size_diff)
|
||||
end ;
|
||||
Format.fprintf ppf
|
||||
"@,Consumed gas: %s"
|
||||
@ -218,13 +218,13 @@ let pp_manager_operation_contents_and_result ppf
|
||||
Fee to the baker: %s%a@,\
|
||||
Expected counter: %s@,\
|
||||
Gas limit: %s@,\
|
||||
Storage limit: %Ld bytes"
|
||||
Storage limit: %s bytes"
|
||||
Contract.pp source
|
||||
Client_proto_args.tez_sym
|
||||
Tez.pp fee
|
||||
(Z.to_string counter)
|
||||
(Z.to_string gas_limit)
|
||||
storage_limit ;
|
||||
(Z.to_string storage_limit) ;
|
||||
begin match balance_updates with
|
||||
| [] -> ()
|
||||
| balance_updates ->
|
||||
|
@ -332,8 +332,8 @@ module Constants : sig
|
||||
block_reward: Tez.t ;
|
||||
endorsement_reward: Tez.t ;
|
||||
cost_per_byte: Tez.t ;
|
||||
hard_storage_limit_per_operation: Int64.t ;
|
||||
hard_storage_limit_per_block: Int64.t ;
|
||||
hard_storage_limit_per_operation: Z.t ;
|
||||
hard_storage_limit_per_block: Z.t ;
|
||||
}
|
||||
val parametric_encoding: parametric Data_encoding.t
|
||||
val parametric: context -> parametric
|
||||
@ -347,8 +347,8 @@ module Constants : sig
|
||||
val hard_gas_limit_per_operation: context -> Z.t
|
||||
val hard_gas_limit_per_block: context -> Z.t
|
||||
val cost_per_byte: context -> Tez.t
|
||||
val hard_storage_limit_per_operation: context -> Int64.t
|
||||
val hard_storage_limit_per_block: context -> Int64.t
|
||||
val hard_storage_limit_per_operation: context -> Z.t
|
||||
val hard_storage_limit_per_block: context -> Z.t
|
||||
val proof_of_work_threshold: context -> int64
|
||||
val dictator_pubkey: context -> Signature.Public_key.t
|
||||
val tokens_per_roll: context -> Tez.t
|
||||
@ -558,10 +558,10 @@ module Contract : sig
|
||||
type error += Operation_storage_quota_exceeded (* `Temporary *)
|
||||
type error += Storage_limit_too_high (* `Permanent *)
|
||||
|
||||
val set_storage_limit: context -> Int64.t -> context tzresult
|
||||
val set_storage_limit: context -> Z.t -> context tzresult
|
||||
val set_storage_unlimited: context -> context
|
||||
|
||||
val used_storage_space: context -> t -> Int64.t tzresult Lwt.t
|
||||
val used_storage_space: context -> t -> Z.t tzresult Lwt.t
|
||||
val paid_storage_space_fees: context -> t -> Tez.t tzresult Lwt.t
|
||||
val pay_for_storage_space: context -> t -> Tez.t -> context tzresult Lwt.t
|
||||
|
||||
@ -829,7 +829,7 @@ and _ contents =
|
||||
counter: counter ;
|
||||
operation: 'kind manager_operation ;
|
||||
gas_limit: Z.t;
|
||||
storage_limit: Int64.t;
|
||||
storage_limit: Z.t;
|
||||
} -> 'kind Kind.manager contents
|
||||
|
||||
and _ manager_operation =
|
||||
|
@ -359,7 +359,7 @@ let apply_manager_operation_content :
|
||||
Contract destination, Credited amount ] ;
|
||||
originated_contracts = [] ;
|
||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||
storage_size_diff = 0L } in
|
||||
storage_size_diff = Z.zero } in
|
||||
return (ctxt, result, [])
|
||||
| Some script ->
|
||||
begin match parameters with
|
||||
@ -393,7 +393,7 @@ let apply_manager_operation_content :
|
||||
Contract destination, Credited amount ] ;
|
||||
originated_contracts ;
|
||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||
storage_size_diff = Int64.sub new_size old_size } in
|
||||
storage_size_diff = Z.sub new_size old_size } in
|
||||
return (ctxt, result, operations)
|
||||
end
|
||||
| Origination { manager ; delegate ; script ; preorigination ;
|
||||
|
@ -112,13 +112,13 @@ type _ successful_manager_operation_result =
|
||||
balance_updates : balance_updates ;
|
||||
originated_contracts : Contract.t list ;
|
||||
consumed_gas : Z.t ;
|
||||
storage_size_diff : Int64.t ;
|
||||
storage_size_diff : Z.t ;
|
||||
} -> Kind.transaction successful_manager_operation_result
|
||||
| Origination_result :
|
||||
{ balance_updates : balance_updates ;
|
||||
originated_contracts : Contract.t list ;
|
||||
consumed_gas : Z.t ;
|
||||
storage_size_diff : Int64.t ;
|
||||
storage_size_diff : Z.t ;
|
||||
} -> Kind.origination successful_manager_operation_result
|
||||
| Delegation_result : Kind.delegation successful_manager_operation_result
|
||||
|
||||
@ -214,7 +214,7 @@ module Manager_result = struct
|
||||
(dft "balance_updates" balance_updates_encoding [])
|
||||
(dft "originated_contracts" (list Contract.encoding) [])
|
||||
(dft "consumed_gas" z Z.zero)
|
||||
(dft "storage_size_diff" int64 0L))
|
||||
(dft "storage_size_diff" z Z.zero))
|
||||
~iselect:
|
||||
(function
|
||||
| Internal_operation_result
|
||||
@ -251,7 +251,7 @@ module Manager_result = struct
|
||||
(dft "balance_updates" balance_updates_encoding [])
|
||||
(dft "originated_contracts" (list Contract.encoding) [])
|
||||
(dft "consumed_gas" z Z.zero)
|
||||
(dft "storage_size_diff" int64 0L))
|
||||
(dft "storage_size_diff" z Z.zero))
|
||||
~iselect:
|
||||
(function
|
||||
| Internal_operation_result
|
||||
|
@ -90,13 +90,13 @@ and _ successful_manager_operation_result =
|
||||
balance_updates : balance_updates ;
|
||||
originated_contracts : Contract.t list ;
|
||||
consumed_gas : Z.t ;
|
||||
storage_size_diff : Int64.t ;
|
||||
storage_size_diff : Z.t ;
|
||||
} -> Kind.transaction successful_manager_operation_result
|
||||
| Origination_result :
|
||||
{ balance_updates : balance_updates ;
|
||||
originated_contracts : Contract.t list ;
|
||||
consumed_gas : Z.t ;
|
||||
storage_size_diff : Int64.t ;
|
||||
storage_size_diff : Z.t ;
|
||||
} -> Kind.origination successful_manager_operation_result
|
||||
| Delegation_result : Kind.delegation successful_manager_operation_result
|
||||
|
||||
|
@ -71,8 +71,8 @@ type parametric = {
|
||||
block_reward: Tez_repr.t ;
|
||||
endorsement_reward: Tez_repr.t ;
|
||||
cost_per_byte: Tez_repr.t ;
|
||||
hard_storage_limit_per_operation: Int64.t ;
|
||||
hard_storage_limit_per_block: Int64.t ;
|
||||
hard_storage_limit_per_operation: Z.t ;
|
||||
hard_storage_limit_per_block: Z.t ;
|
||||
}
|
||||
|
||||
let default = {
|
||||
@ -104,8 +104,8 @@ let default = {
|
||||
endorsement_security_deposit = Tez_repr.(mul_exn one 64) ;
|
||||
block_reward = Tez_repr.(mul_exn one 16) ;
|
||||
endorsement_reward = Tez_repr.(mul_exn one 2) ;
|
||||
hard_storage_limit_per_operation = 60_000L ;
|
||||
hard_storage_limit_per_block = 1_000_000L ;
|
||||
hard_storage_limit_per_operation = Z.of_int 60_000 ;
|
||||
hard_storage_limit_per_block = Z.of_int 1_000_000 ;
|
||||
cost_per_byte = Tez_repr.of_mutez_exn 1_000L ;
|
||||
}
|
||||
|
||||
@ -207,8 +207,8 @@ let parametric_encoding =
|
||||
(obj4
|
||||
(req "endorsement_reward" Tez_repr.encoding)
|
||||
(req "cost_per_byte" Tez_repr.encoding)
|
||||
(req "hard_storage_limit_per_operation" int64)
|
||||
(req "hard_storage_limit_per_block" int64))))
|
||||
(req "hard_storage_limit_per_operation" z)
|
||||
(req "hard_storage_limit_per_block" z))))
|
||||
|
||||
type t = {
|
||||
fixed : fixed ;
|
||||
|
@ -189,17 +189,17 @@ let failwith msg = fail (Failure msg)
|
||||
type big_map_diff = (string * Script_repr.expr option) list
|
||||
|
||||
let update_script_big_map c contract = function
|
||||
| None -> return (c, 0L)
|
||||
| None -> return (c, Z.zero)
|
||||
| Some diff ->
|
||||
fold_left_s (fun (c, total) (key, value) ->
|
||||
match value with
|
||||
| None ->
|
||||
Storage.Contract.Big_map.remove (c, contract) key >>=? fun (c, freed) ->
|
||||
return (c, Int64.sub total (Int64.of_int freed))
|
||||
return (c, Z.sub total (Z.of_int freed))
|
||||
| Some v ->
|
||||
Storage.Contract.Big_map.init_set (c, contract) key v >>=? fun (c, size_diff) ->
|
||||
return (c, Int64.add total (Int64.of_int size_diff)))
|
||||
(c, 0L) diff
|
||||
return (c, Z.add total (Z.of_int size_diff)))
|
||||
(c, Z.zero) diff
|
||||
|
||||
let create_base c contract
|
||||
~balance ~manager ~delegate ?script ~spendable ~delegatable =
|
||||
@ -222,8 +222,8 @@ let create_base c contract
|
||||
Storage.Contract.Code.init c contract code >>=? fun (c, code_size) ->
|
||||
Storage.Contract.Storage.init c contract storage >>=? fun (c, storage_size) ->
|
||||
update_script_big_map c contract big_map_diff >>=? fun (c, big_map_size) ->
|
||||
let total_size = Int64.add (Int64.add (Int64.of_int code_size) (Int64.of_int storage_size)) big_map_size in
|
||||
assert Compare.Int64.(total_size >= 0L) ;
|
||||
let total_size = Z.add (Z.add (Z.of_int code_size) (Z.of_int storage_size)) big_map_size in
|
||||
assert Compare.Z.(total_size >= Z.zero) ;
|
||||
Storage.Contract.Used_storage_space.init c contract total_size >>=? fun c ->
|
||||
Storage.Contract.Paid_storage_space_fees.init c contract Tez_repr.zero
|
||||
| None ->
|
||||
@ -388,7 +388,7 @@ let update_script_storage c contract storage big_map_diff =
|
||||
update_script_big_map c contract big_map_diff >>=? fun (c, big_map_size_diff) ->
|
||||
Storage.Contract.Storage.set c contract storage >>=? fun (c, size_diff) ->
|
||||
Storage.Contract.Used_storage_space.get c contract >>=? fun previous_size ->
|
||||
let new_size = Int64.add previous_size (Int64.add big_map_size_diff (Int64.of_int size_diff)) in
|
||||
let new_size = Z.add previous_size (Z.add big_map_size_diff (Z.of_int size_diff)) in
|
||||
Storage.Contract.Used_storage_space.set c contract new_size
|
||||
|
||||
let spend_from_script c contract amount =
|
||||
@ -458,7 +458,7 @@ let init c =
|
||||
|
||||
let used_storage_space c contract =
|
||||
Storage.Contract.Used_storage_space.get_option c contract >>=? function
|
||||
| None -> return 0L
|
||||
| None -> return Z.zero
|
||||
| Some fees -> return fees
|
||||
|
||||
let paid_storage_space_fees c contract =
|
||||
|
@ -102,7 +102,7 @@ val originated_from_current_nonce :
|
||||
val init:
|
||||
Raw_context.t -> Raw_context.t tzresult Lwt.t
|
||||
|
||||
val used_storage_space: Raw_context.t -> Contract_repr.t -> Int64.t tzresult Lwt.t
|
||||
val used_storage_space: Raw_context.t -> Contract_repr.t -> Z.t tzresult Lwt.t
|
||||
val paid_storage_space_fees: Raw_context.t -> Contract_repr.t -> Tez_repr.t tzresult Lwt.t
|
||||
val pay_for_storage_space: Raw_context.t -> Contract_repr.t -> Tez_repr.t -> Raw_context.t tzresult Lwt.t
|
||||
|
||||
|
@ -28,7 +28,7 @@ let origination_burn c ~payer contract =
|
||||
Contract.spend_from_script c payer origination_burn >>=? fun c ->
|
||||
Contract.used_storage_space c contract >>=? fun size ->
|
||||
let cost_per_byte = Constants.cost_per_byte c in
|
||||
Lwt.return (Tez.(cost_per_byte *? size)) >>=? fun fees ->
|
||||
Lwt.return (Tez.(cost_per_byte *? (Z.to_int64 size))) >>=? fun fees ->
|
||||
trace Cannot_pay_storage_fee
|
||||
(Contract.spend_from_script c payer fees >>=? fun c ->
|
||||
Contract.pay_for_storage_space c contract fees) >>=? fun c ->
|
||||
@ -38,7 +38,7 @@ let update_script_storage c ~payer contract =
|
||||
Contract.paid_storage_space_fees c contract >>=? fun paid_fees ->
|
||||
Contract.used_storage_space c contract >>=? fun size ->
|
||||
let cost_per_byte = Constants.cost_per_byte c in
|
||||
Lwt.return (Tez.(cost_per_byte *? size)) >>=? fun fees ->
|
||||
Lwt.return (Tez.(cost_per_byte *? (Z.to_int64 size))) >>=? fun fees ->
|
||||
match Tez.(fees -? paid_fees) with
|
||||
| Error _ ->
|
||||
(* Previously paid fees are greater than required fees. *)
|
||||
|
@ -13,9 +13,8 @@ type error += Cannot_pay_storage_fee
|
||||
|
||||
val origination_burn:
|
||||
Alpha_context.t -> payer:Contract.t ->
|
||||
Contract.t -> (Alpha_context.t * Int64.t * Tez.t) tzresult Lwt.t
|
||||
Contract.t -> (Alpha_context.t * Z.t * Tez.t) tzresult Lwt.t
|
||||
|
||||
val update_script_storage:
|
||||
Alpha_context.t -> payer:Contract.t ->
|
||||
Contract.t -> (Alpha_context.t * Int64.t * Tez.t) tzresult Lwt.t
|
||||
|
||||
Contract.t -> (Alpha_context.t * Z.t * Tez.t) tzresult Lwt.t
|
||||
|
@ -278,7 +278,7 @@ module Forge = struct
|
||||
let reveal ctxt
|
||||
block ~branch ~source ~sourcePubKey ~counter ~fee () =
|
||||
operations ctxt block ~branch ~source ~sourcePubKey ~counter ~fee
|
||||
~gas_limit:Z.zero ~storage_limit:0L []
|
||||
~gas_limit:Z.zero ~storage_limit:Z.zero []
|
||||
|
||||
let transaction ctxt
|
||||
block ~branch ~source ?sourcePubKey ~counter
|
||||
@ -310,7 +310,7 @@ module Forge = struct
|
||||
let delegation ctxt
|
||||
block ~branch ~source ?sourcePubKey ~counter ~fee delegate =
|
||||
operations ctxt block ~branch ~source ?sourcePubKey ~counter ~fee
|
||||
~gas_limit:Z.zero ~storage_limit:0L
|
||||
~gas_limit:Z.zero ~storage_limit:Z.zero
|
||||
[Manager (Delegation delegate)]
|
||||
|
||||
end
|
||||
|
@ -67,7 +67,7 @@ module Forge : sig
|
||||
counter:counter ->
|
||||
fee:Tez.t ->
|
||||
gas_limit:Z.t ->
|
||||
storage_limit:Int64.t ->
|
||||
storage_limit:Z.t ->
|
||||
packed_manager_operation list -> MBytes.t shell_tzresult Lwt.t
|
||||
|
||||
val reveal:
|
||||
@ -89,7 +89,7 @@ module Forge : sig
|
||||
destination:Contract.t ->
|
||||
?parameters:Script.expr ->
|
||||
gas_limit:Z.t ->
|
||||
storage_limit:Int64.t ->
|
||||
storage_limit:Z.t ->
|
||||
fee:Tez.t ->
|
||||
unit -> MBytes.t shell_tzresult Lwt.t
|
||||
|
||||
@ -106,7 +106,7 @@ module Forge : sig
|
||||
?delegatePubKey: public_key_hash ->
|
||||
?script:Script.t ->
|
||||
gas_limit:Z.t ->
|
||||
storage_limit:Int64.t ->
|
||||
storage_limit:Z.t ->
|
||||
fee:Tez.t->
|
||||
unit -> MBytes.t shell_tzresult Lwt.t
|
||||
|
||||
|
@ -89,7 +89,7 @@ and _ contents =
|
||||
counter: counter ;
|
||||
operation: 'kind manager_operation ;
|
||||
gas_limit: Z.t;
|
||||
storage_limit: Int64.t;
|
||||
storage_limit: Z.t;
|
||||
} -> 'kind Kind.manager contents
|
||||
|
||||
and _ manager_operation =
|
||||
@ -474,7 +474,7 @@ module Encoding = struct
|
||||
(req "fee" Tez_repr.encoding)
|
||||
(req "counter" z)
|
||||
(req "gas_limit" z)
|
||||
(req "storage_limit" int64))
|
||||
(req "storage_limit" z))
|
||||
|
||||
let extract
|
||||
(type kind)
|
||||
|
@ -90,7 +90,7 @@ and _ contents =
|
||||
counter: counter ;
|
||||
operation: 'kind manager_operation ;
|
||||
gas_limit: Z.t;
|
||||
storage_limit: Int64.t;
|
||||
storage_limit: Z.t;
|
||||
} -> 'kind Kind.manager contents
|
||||
|
||||
and _ manager_operation =
|
||||
|
@ -100,10 +100,10 @@ let constants_encoding =
|
||||
opt Tez_repr.(=)
|
||||
default.cost_per_byte c.cost_per_byte
|
||||
and hard_storage_limit_per_operation =
|
||||
opt Compare.Int64.(=)
|
||||
opt Compare.Z.(=)
|
||||
default.hard_storage_limit_per_operation c.hard_storage_limit_per_operation
|
||||
and hard_storage_limit_per_block =
|
||||
opt Compare.Int64.(=)
|
||||
opt Compare.Z.(=)
|
||||
default.hard_storage_limit_per_block c.hard_storage_limit_per_block
|
||||
in
|
||||
(( preserved_cycles,
|
||||
@ -223,8 +223,8 @@ let constants_encoding =
|
||||
(obj4
|
||||
(opt "endorsement_reward" Tez_repr.encoding)
|
||||
(opt "cost_per_byte" Tez_repr.encoding)
|
||||
(opt "hard_storage_limit_per_operation" int64)
|
||||
(opt "hard_storage_limit_per_block" int64))))
|
||||
(opt "hard_storage_limit_per_operation" z)
|
||||
(opt "hard_storage_limit_per_block" z))))
|
||||
|
||||
let encoding =
|
||||
let open Data_encoding in
|
||||
|
@ -22,7 +22,7 @@ type t = {
|
||||
rewards: Tez_repr.t ;
|
||||
block_gas: Z.t ;
|
||||
operation_gas: Gas_limit_repr.t ;
|
||||
block_storage: Int64.t ;
|
||||
block_storage: Z.t ;
|
||||
operation_storage: Storage_limit_repr.t ;
|
||||
origination_nonce: Contract_repr.origination_nonce option ;
|
||||
internal_nonce: int ;
|
||||
@ -174,8 +174,8 @@ let () =
|
||||
(fun () -> Storage_limit_too_high)
|
||||
|
||||
let set_storage_limit ctxt remaining =
|
||||
if Compare.Int64.(remaining > ctxt.constants.hard_storage_limit_per_operation)
|
||||
|| Compare.Int64.(remaining < 0L)then
|
||||
if Compare.Z.(remaining > ctxt.constants.hard_storage_limit_per_operation)
|
||||
|| Compare.Z.(remaining < Z.zero)then
|
||||
error Storage_limit_too_high
|
||||
else
|
||||
ok { ctxt with operation_storage = Limited { remaining } }
|
||||
@ -509,7 +509,7 @@ module type T = sig
|
||||
|
||||
val consume_gas: context -> Gas_limit_repr.cost -> context tzresult
|
||||
|
||||
val record_bytes_stored: context -> Int64.t -> context tzresult
|
||||
val record_bytes_stored: context -> Z.t -> context tzresult
|
||||
|
||||
val description: context Storage_description.t
|
||||
|
||||
|
@ -88,7 +88,7 @@ val block_gas_level: t -> Z.t
|
||||
|
||||
type error += Storage_limit_too_high (* `Permanent *)
|
||||
|
||||
val set_storage_limit: t -> Int64.t -> t tzresult
|
||||
val set_storage_limit: t -> Z.t -> t tzresult
|
||||
val set_storage_unlimited: t -> t
|
||||
|
||||
type error += Undefined_operation_nonce (* `Permanent *)
|
||||
@ -184,7 +184,7 @@ module type T = sig
|
||||
|
||||
(** Internally used in {!Storage_functors} to consume storage from
|
||||
within a view. *)
|
||||
val record_bytes_stored: context -> Int64.t -> context tzresult
|
||||
val record_bytes_stored: context -> Z.t -> context tzresult
|
||||
|
||||
val description: context Storage_description.t
|
||||
|
||||
|
@ -24,11 +24,6 @@ module Z = struct
|
||||
let encoding = Data_encoding.z
|
||||
end
|
||||
|
||||
module Int64 = struct
|
||||
type t = Int64.t
|
||||
let encoding = Data_encoding.int64
|
||||
end
|
||||
|
||||
module Int_index = struct
|
||||
type t = int
|
||||
let path_length = 1
|
||||
@ -202,7 +197,7 @@ module Contract = struct
|
||||
module Used_storage_space =
|
||||
Indexed_context.Make_map
|
||||
(struct let name = ["used_bytes"] end)
|
||||
(Int64)
|
||||
(Z)
|
||||
|
||||
module Roll_list =
|
||||
Indexed_context.Make_map
|
||||
|
@ -176,7 +176,7 @@ module Contract : sig
|
||||
Includes code, global storage and big map elements. *)
|
||||
module Used_storage_space : Indexed_data_storage
|
||||
with type key = Contract_repr.t
|
||||
and type value = Int64.t
|
||||
and type value = Z.t
|
||||
and type t := Raw_context.t
|
||||
|
||||
(** Total fees burnt for storage space. *)
|
||||
|
@ -359,13 +359,13 @@ module Make_indexed_carbonated_data_storage
|
||||
consume_write_gas C.set s i v >>=? fun (s, bytes) ->
|
||||
C.set s (name i) bytes >>=? fun t ->
|
||||
let size_diff = MBytes.length bytes - prev_size in
|
||||
Lwt.return (C.record_bytes_stored t (Int64.of_int size_diff)) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Z.of_int size_diff)) >>=? fun t ->
|
||||
return (C.project t, size_diff)
|
||||
let init s i v =
|
||||
consume_write_gas C.init s i v >>=? fun (s, bytes) ->
|
||||
C.init s (name i) bytes >>=? fun t ->
|
||||
let size = MBytes.length bytes in
|
||||
Lwt.return (C.record_bytes_stored t (Int64.of_int size)) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Z.of_int size)) >>=? fun t ->
|
||||
return (C.project t, size)
|
||||
let init_set s i v =
|
||||
let init_set s i v = C.init_set s i v >>= return in
|
||||
@ -373,20 +373,20 @@ module Make_indexed_carbonated_data_storage
|
||||
consume_write_gas init_set s i v >>=? fun (s, bytes) ->
|
||||
init_set s (name i) bytes >>=? fun t ->
|
||||
let size_diff = MBytes.length bytes - prev_size in
|
||||
Lwt.return (C.record_bytes_stored t (Int64.of_int size_diff)) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Z.of_int size_diff)) >>=? fun t ->
|
||||
return (C.project t, size_diff)
|
||||
let remove s i =
|
||||
let remove s i = C.remove s i >>= return in
|
||||
existing_size s i >>=? fun prev_size ->
|
||||
consume_remove_gas remove s i >>=? fun s ->
|
||||
remove s (name i) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Int64.of_int ~-prev_size)) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Z.of_int ~-prev_size)) >>=? fun t ->
|
||||
return (C.project t, prev_size)
|
||||
let delete s i =
|
||||
existing_size s i >>=? fun prev_size ->
|
||||
consume_remove_gas C.delete s i >>=? fun s ->
|
||||
C.delete s (name i) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Int64.of_int ~-prev_size)) >>=? fun t ->
|
||||
Lwt.return (C.record_bytes_stored t (Z.of_int ~-prev_size)) >>=? fun t ->
|
||||
return (C.project t, prev_size)
|
||||
let set_option s i v =
|
||||
match v with
|
||||
@ -784,13 +784,13 @@ module Make_indexed_subcontext (C : Raw_context.T) (I : INDEX)
|
||||
consume_write_gas Raw_context.set (pack s i) v >>=? fun (c, bytes) ->
|
||||
Raw_context.set c data_name bytes >>=? fun c ->
|
||||
let size_diff = MBytes.length bytes - prev_size in
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Int64.of_int size_diff)) >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Z.of_int size_diff)) >>=? fun c ->
|
||||
return (Raw_context.project c, size_diff)
|
||||
let init s i v =
|
||||
consume_write_gas Raw_context.init (pack s i) v >>=? fun (c, bytes) ->
|
||||
Raw_context.init c data_name bytes >>=? fun c ->
|
||||
let size = MBytes.length bytes in
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Int64.of_int size)) >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Z.of_int size)) >>=? fun c ->
|
||||
return (Raw_context.project c, size)
|
||||
let init_set s i v =
|
||||
let init_set c k v = Raw_context.init_set c k v >>= return in
|
||||
@ -798,20 +798,20 @@ module Make_indexed_subcontext (C : Raw_context.T) (I : INDEX)
|
||||
consume_write_gas init_set (pack s i) v >>=? fun (c, bytes) ->
|
||||
init_set c data_name bytes >>=? fun c ->
|
||||
let size_diff = MBytes.length bytes - prev_size in
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Int64.of_int size_diff)) >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Z.of_int size_diff)) >>=? fun c ->
|
||||
return (Raw_context.project c, size_diff)
|
||||
let remove s i =
|
||||
let remove c k = Raw_context.remove c k >>= return in
|
||||
existing_size (pack s i) >>=? fun prev_size ->
|
||||
consume_remove_gas remove (pack s i) >>=? fun c ->
|
||||
remove c data_name >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Int64.of_int ~-prev_size)) >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Z.of_int ~-prev_size)) >>=? fun c ->
|
||||
return (Raw_context.project c, prev_size)
|
||||
let delete s i =
|
||||
existing_size (pack s i) >>=? fun prev_size ->
|
||||
consume_remove_gas Raw_context.delete (pack s i) >>=? fun c ->
|
||||
Raw_context.delete c data_name >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Int64.of_int ~-prev_size)) >>=? fun c ->
|
||||
Lwt.return (Raw_context.record_bytes_stored c (Z.of_int ~-prev_size)) >>=? fun c ->
|
||||
return (Raw_context.project c, prev_size)
|
||||
let set_option s i v =
|
||||
match v with
|
||||
|
@ -9,7 +9,7 @@
|
||||
|
||||
type t =
|
||||
| Unaccounted
|
||||
| Limited of { remaining : Int64.t }
|
||||
| Limited of { remaining : Z.t }
|
||||
|
||||
type error += Block_quota_exceeded (* `Temporary *)
|
||||
type error += Operation_quota_exceeded (* `Temporary *)
|
||||
@ -41,11 +41,11 @@ let consume block_storage operation_storage ~bytes = match operation_storage wit
|
||||
| Unaccounted -> ok (block_storage, Unaccounted)
|
||||
| Limited { remaining } ->
|
||||
let remaining =
|
||||
Int64.sub remaining bytes in
|
||||
Z.sub remaining bytes in
|
||||
let block_remaining =
|
||||
Int64.sub block_storage bytes in
|
||||
if Compare.Int64.(remaining < 0L)
|
||||
Z.sub block_storage bytes in
|
||||
if Compare.Z.(remaining < Z.zero)
|
||||
then error Operation_quota_exceeded
|
||||
else if Compare.Int64.(block_remaining < 0L)
|
||||
else if Compare.Z.(block_remaining < Z.zero)
|
||||
then error Block_quota_exceeded
|
||||
else ok (block_remaining, Limited { remaining })
|
||||
|
@ -9,9 +9,9 @@
|
||||
|
||||
type t =
|
||||
| Unaccounted
|
||||
| Limited of { remaining : Int64.t }
|
||||
| Limited of { remaining : Z.t }
|
||||
|
||||
type error += Block_quota_exceeded (* `Temporary *)
|
||||
type error += Operation_quota_exceeded (* `Temporary *)
|
||||
|
||||
val consume : Int64.t -> t -> bytes:Int64.t -> (Int64.t * t) tzresult
|
||||
val consume : Z.t -> t -> bytes:Z.t -> (Z.t * t) tzresult
|
||||
|
@ -81,8 +81,8 @@ val genesis:
|
||||
?block_reward:Tez_repr.tez ->
|
||||
?endorsement_reward:Tez_repr.tez ->
|
||||
?cost_per_byte: Tez_repr.t ->
|
||||
?hard_storage_limit_per_operation: Int64.t ->
|
||||
?hard_storage_limit_per_block: Int64.t ->
|
||||
?hard_storage_limit_per_operation: Z.t ->
|
||||
?hard_storage_limit_per_block: Z.t ->
|
||||
?commitments:Commitment_repr.t list ->
|
||||
?security_deposit_ramp_up_cycles: int option ->
|
||||
?no_reward_cycles: int option ->
|
||||
|
@ -76,7 +76,7 @@ let manager_operation
|
||||
counter ;
|
||||
operation = Reveal public_key ;
|
||||
gas_limit = Z.of_int 20 ;
|
||||
storage_limit = 0L ;
|
||||
storage_limit = Z.zero ;
|
||||
} in
|
||||
let op =
|
||||
Manager_operation {
|
||||
@ -104,7 +104,7 @@ let revelation ctxt public_key =
|
||||
counter ;
|
||||
operation = Reveal public_key ;
|
||||
gas_limit = Z.of_int 20 ;
|
||||
storage_limit = 0L ;
|
||||
storage_limit = Z.zero ;
|
||||
})) in
|
||||
return @@ sign account.sk ctxt sop
|
||||
|
||||
|
@ -23,7 +23,7 @@ val miss_signed_endorsement:
|
||||
val transaction:
|
||||
?fee:Tez.tez ->
|
||||
?gas_limit:Z.t ->
|
||||
?storage_limit:int64 ->
|
||||
?storage_limit:Z.t ->
|
||||
?parameters:Script.lazy_expr ->
|
||||
Context.t ->
|
||||
Contract.t ->
|
||||
@ -50,7 +50,7 @@ val origination:
|
||||
?credit:Tez.tez ->
|
||||
?fee:Tez.tez ->
|
||||
?gas_limit:Z.t ->
|
||||
?storage_limit:int64 ->
|
||||
?storage_limit:Z.t ->
|
||||
Context.t ->
|
||||
Contract.contract ->
|
||||
(Operation.packed * Contract.contract) tzresult Lwt.t
|
||||
|
Loading…
Reference in New Issue
Block a user