Alpha: receipts account for the paid storage space diff and storage space
This commit is contained in:
parent
503e3c5679
commit
d00cbaf081
@ -124,8 +124,8 @@ let estimated_storage_single
|
||||
: kind Kind.manager contents_result) =
|
||||
let storage_size_diff (type kind) (result : kind manager_operation_result) =
|
||||
match result with
|
||||
| Applied (Transaction_result { storage_size_diff }) -> Ok storage_size_diff
|
||||
| Applied (Origination_result { storage_size_diff }) -> Ok storage_size_diff
|
||||
| Applied (Transaction_result { paid_storage_size_diff }) -> Ok paid_storage_size_diff
|
||||
| Applied (Origination_result { paid_storage_size_diff }) -> Ok paid_storage_size_diff
|
||||
| Applied Reveal_result -> Ok Z.zero
|
||||
| Applied Delegation_result -> Ok Z.zero
|
||||
| Skipped _ -> assert false
|
||||
|
@ -157,7 +157,8 @@ let pp_manager_operation_contents_and_result ppf
|
||||
"This delegation was successfully applied"
|
||||
| Applied (Transaction_result { balance_updates ; consumed_gas ;
|
||||
storage ;
|
||||
originated_contracts ; storage_size_diff }) ->
|
||||
originated_contracts ;
|
||||
storage_size ; paid_storage_size_diff }) ->
|
||||
Format.fprintf ppf
|
||||
"This transaction was successfully applied" ;
|
||||
begin match originated_contracts with
|
||||
@ -172,10 +173,15 @@ 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 <> Z.zero then
|
||||
begin if storage_size <> Z.zero then
|
||||
Format.fprintf ppf
|
||||
"@,Storage size difference: %s bytes"
|
||||
(Z.to_string storage_size_diff)
|
||||
"@,Storage size: %s bytes"
|
||||
(Z.to_string storage_size)
|
||||
end ;
|
||||
begin if paid_storage_size_diff <> Z.zero then
|
||||
Format.fprintf ppf
|
||||
"@,Paid storage size diff: %s bytes"
|
||||
(Z.to_string paid_storage_size_diff)
|
||||
end ;
|
||||
Format.fprintf ppf
|
||||
"@,Consumed gas: %s"
|
||||
@ -188,7 +194,8 @@ let pp_manager_operation_contents_and_result ppf
|
||||
pp_balance_updates balance_updates
|
||||
end
|
||||
| Applied (Origination_result { balance_updates ; consumed_gas ;
|
||||
originated_contracts ; storage_size_diff }) ->
|
||||
originated_contracts ;
|
||||
storage_size ; paid_storage_size_diff }) ->
|
||||
Format.fprintf ppf
|
||||
"This origination was successfully applied" ;
|
||||
begin match originated_contracts with
|
||||
@ -197,10 +204,15 @@ 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 <> Z.zero then
|
||||
begin if storage_size <> Z.zero then
|
||||
Format.fprintf ppf
|
||||
"@,Storage size used: %s bytes"
|
||||
(Z.to_string storage_size_diff)
|
||||
"@,Storage size: %s bytes"
|
||||
(Z.to_string storage_size)
|
||||
end ;
|
||||
begin if paid_storage_size_diff <> Z.zero then
|
||||
Format.fprintf ppf
|
||||
"@,Paid storage size diff: %s bytes"
|
||||
(Z.to_string paid_storage_size_diff)
|
||||
end ;
|
||||
Format.fprintf ppf
|
||||
"@,Consumed gas: %s"
|
||||
|
@ -900,7 +900,7 @@ module Fees : sig
|
||||
context -> payer:Contract.t -> (context * Tez.t) tzresult Lwt.t
|
||||
|
||||
val record_paid_storage_space:
|
||||
context -> Contract.t -> (context * Z.t * Tez.t) tzresult Lwt.t
|
||||
context -> Contract.t -> (context * Z.t * Z.t * Tez.t) tzresult Lwt.t
|
||||
|
||||
val with_fees_for_storage:
|
||||
context -> payer:Contract.t ->
|
||||
|
@ -379,7 +379,9 @@ let apply_manager_operation_content :
|
||||
Contract destination, Credited amount ] ;
|
||||
originated_contracts = [] ;
|
||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||
storage_size_diff = Z.zero } in
|
||||
storage_size = Z.zero ;
|
||||
paid_storage_size_diff = Z.zero ;
|
||||
} in
|
||||
return (ctxt, result, [])
|
||||
| Some script ->
|
||||
begin match parameters with
|
||||
@ -395,11 +397,10 @@ let apply_manager_operation_content :
|
||||
ctxt mode
|
||||
~source ~payer ~self:(destination, script) ~amount ~parameter
|
||||
>>=? fun { ctxt ; storage ; big_map_diff ; operations } ->
|
||||
Contract.used_storage_space ctxt destination >>=? fun old_size ->
|
||||
Contract.update_script_storage
|
||||
ctxt destination storage big_map_diff >>=? fun ctxt ->
|
||||
Fees.record_paid_storage_space
|
||||
ctxt destination >>=? fun (ctxt, new_size, fees) ->
|
||||
ctxt destination >>=? fun (ctxt, new_size, paid_storage_size_diff, fees) ->
|
||||
Contract.originated_from_current_nonce
|
||||
~since: before_operation
|
||||
~until: ctxt >>=? fun originated_contracts ->
|
||||
@ -413,7 +414,8 @@ let apply_manager_operation_content :
|
||||
Contract destination, Credited amount ] ;
|
||||
originated_contracts ;
|
||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||
storage_size_diff = Z.sub new_size old_size } in
|
||||
storage_size = new_size ;
|
||||
paid_storage_size_diff } in
|
||||
return (ctxt, result, operations)
|
||||
end
|
||||
| Origination { manager ; delegate ; script ; preorigination ;
|
||||
@ -441,7 +443,7 @@ let apply_manager_operation_content :
|
||||
?script
|
||||
~spendable ~delegatable >>=? fun ctxt ->
|
||||
Fees.origination_burn ctxt ~payer >>=? fun (ctxt, orignation_burn) ->
|
||||
Fees.record_paid_storage_space ctxt contract >>=? fun (ctxt, size, fees) ->
|
||||
Fees.record_paid_storage_space ctxt contract >>=? fun (ctxt, size, paid_storage_size_diff, fees) ->
|
||||
Lwt.return Tez.(orignation_burn +? fees) >>=? fun all_fees ->
|
||||
let result =
|
||||
Origination_result
|
||||
@ -452,7 +454,8 @@ let apply_manager_operation_content :
|
||||
Contract contract, Credited credit ] ;
|
||||
originated_contracts = [ contract ] ;
|
||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||
storage_size_diff = size } in
|
||||
storage_size = size ;
|
||||
paid_storage_size_diff } in
|
||||
return (ctxt, result, [])
|
||||
| Delegation delegate ->
|
||||
set_delegate ctxt source delegate >>=? fun ctxt ->
|
||||
|
@ -112,13 +112,15 @@ type _ successful_manager_operation_result =
|
||||
balance_updates : balance_updates ;
|
||||
originated_contracts : Contract.t list ;
|
||||
consumed_gas : Z.t ;
|
||||
storage_size_diff : Z.t ;
|
||||
storage_size : Z.t ;
|
||||
paid_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 : Z.t ;
|
||||
storage_size : Z.t ;
|
||||
paid_storage_size_diff : Z.t ;
|
||||
} -> Kind.origination successful_manager_operation_result
|
||||
| Delegation_result : Kind.delegation successful_manager_operation_result
|
||||
|
||||
@ -209,12 +211,13 @@ module Manager_result = struct
|
||||
make
|
||||
~op_case: Operation.Encoding.Manager_operations.transaction_case
|
||||
~encoding:
|
||||
(obj5
|
||||
(obj6
|
||||
(opt "storage" Script.expr_encoding)
|
||||
(dft "balance_updates" balance_updates_encoding [])
|
||||
(dft "originated_contracts" (list Contract.encoding) [])
|
||||
(dft "consumed_gas" z Z.zero)
|
||||
(dft "storage_size_diff" z Z.zero))
|
||||
(dft "storage_size" z Z.zero)
|
||||
(dft "paid_storage_size_diff" z Z.zero))
|
||||
~iselect:
|
||||
(function
|
||||
| Internal_operation_result
|
||||
@ -231,27 +234,28 @@ module Manager_result = struct
|
||||
| Transaction_result
|
||||
{ storage ; balance_updates ;
|
||||
originated_contracts ; consumed_gas ;
|
||||
storage_size_diff } ->
|
||||
storage_size ; paid_storage_size_diff } ->
|
||||
(storage, balance_updates,
|
||||
originated_contracts, consumed_gas,
|
||||
storage_size_diff))
|
||||
storage_size, paid_storage_size_diff))
|
||||
~inj:
|
||||
(fun (storage, balance_updates,
|
||||
originated_contracts, consumed_gas,
|
||||
storage_size_diff) ->
|
||||
storage_size, paid_storage_size_diff) ->
|
||||
Transaction_result { storage ; balance_updates ;
|
||||
originated_contracts ; consumed_gas ;
|
||||
storage_size_diff })
|
||||
storage_size ; paid_storage_size_diff })
|
||||
|
||||
let origination_case =
|
||||
make
|
||||
~op_case: Operation.Encoding.Manager_operations.origination_case
|
||||
~encoding:
|
||||
(obj4
|
||||
(obj5
|
||||
(dft "balance_updates" balance_updates_encoding [])
|
||||
(dft "originated_contracts" (list Contract.encoding) [])
|
||||
(dft "consumed_gas" z Z.zero)
|
||||
(dft "storage_size_diff" z Z.zero))
|
||||
(dft "storage_size" z Z.zero)
|
||||
(dft "paid_storage_size_diff" z Z.zero))
|
||||
~iselect:
|
||||
(function
|
||||
| Internal_operation_result
|
||||
@ -267,19 +271,19 @@ module Manager_result = struct
|
||||
| Origination_result
|
||||
{ balance_updates ;
|
||||
originated_contracts ; consumed_gas ;
|
||||
storage_size_diff } ->
|
||||
storage_size ; paid_storage_size_diff } ->
|
||||
(balance_updates,
|
||||
originated_contracts, consumed_gas,
|
||||
storage_size_diff))
|
||||
storage_size, paid_storage_size_diff))
|
||||
~kind: Kind.Origination_manager_kind
|
||||
~inj:
|
||||
(fun (balance_updates,
|
||||
originated_contracts, consumed_gas,
|
||||
storage_size_diff) ->
|
||||
storage_size, paid_storage_size_diff) ->
|
||||
Origination_result
|
||||
{ balance_updates ;
|
||||
originated_contracts ; consumed_gas ;
|
||||
storage_size_diff })
|
||||
storage_size ; paid_storage_size_diff })
|
||||
|
||||
let delegation_case =
|
||||
make
|
||||
|
@ -90,13 +90,15 @@ and _ successful_manager_operation_result =
|
||||
balance_updates : balance_updates ;
|
||||
originated_contracts : Contract.t list ;
|
||||
consumed_gas : Z.t ;
|
||||
storage_size_diff : Z.t ;
|
||||
storage_size : Z.t ;
|
||||
paid_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 : Z.t ;
|
||||
storage_size : Z.t ;
|
||||
paid_storage_size_diff : Z.t ;
|
||||
} -> Kind.origination successful_manager_operation_result
|
||||
| Delegation_result : Kind.delegation successful_manager_operation_result
|
||||
|
||||
|
@ -32,7 +32,7 @@ let record_paid_storage_space c contract =
|
||||
Lwt.return (Raw_context.update_storage_space_to_pay c to_be_paid) >>=? fun c ->
|
||||
let cost_per_byte = Constants_storage.cost_per_byte c in
|
||||
Lwt.return (Tez_repr.(cost_per_byte *? (Z.to_int64 to_be_paid))) >>=? fun to_burn ->
|
||||
return (c, size, to_burn)
|
||||
return (c, size, to_be_paid, to_burn)
|
||||
|
||||
let burn_fees_for_storage c ~payer =
|
||||
let c, storage_space_to_pay = Raw_context.clear_storage_space_to_pay c in
|
||||
|
@ -15,7 +15,7 @@ val origination_burn:
|
||||
(** The returned Tez quantity is for logging purpose only *)
|
||||
val record_paid_storage_space:
|
||||
Raw_context.t -> Contract_repr.t ->
|
||||
(Raw_context.t * Z.t * Tez_repr.t) tzresult Lwt.t
|
||||
(Raw_context.t * Z.t * Z.t * Tez_repr.t) tzresult Lwt.t
|
||||
|
||||
val with_fees_for_storage:
|
||||
Raw_context.t -> payer:Contract_repr.t ->
|
||||
|
Loading…
Reference in New Issue
Block a user