Alpha: count origination burn towards storage limit
This commit is contained in:
parent
94378f9809
commit
9afdd9b167
@ -302,7 +302,7 @@ let genesis
|
|||||||
?(tokens_per_roll = Constants_repr.default.tokens_per_roll)
|
?(tokens_per_roll = Constants_repr.default.tokens_per_roll)
|
||||||
?(michelson_maximum_type_size = Constants_repr.default.michelson_maximum_type_size)
|
?(michelson_maximum_type_size = Constants_repr.default.michelson_maximum_type_size)
|
||||||
?(seed_nonce_revelation_tip = Constants_repr.default.seed_nonce_revelation_tip)
|
?(seed_nonce_revelation_tip = Constants_repr.default.seed_nonce_revelation_tip)
|
||||||
?(origination_burn = Constants_repr.default.origination_burn)
|
?(origination_size = Constants_repr.default.origination_size)
|
||||||
?(block_security_deposit = Constants_repr.default.block_security_deposit)
|
?(block_security_deposit = Constants_repr.default.block_security_deposit)
|
||||||
?(endorsement_security_deposit = Constants_repr.default.endorsement_security_deposit)
|
?(endorsement_security_deposit = Constants_repr.default.endorsement_security_deposit)
|
||||||
?(block_reward = Constants_repr.default.block_reward)
|
?(block_reward = Constants_repr.default.block_reward)
|
||||||
@ -324,7 +324,7 @@ let genesis
|
|||||||
tokens_per_roll ;
|
tokens_per_roll ;
|
||||||
michelson_maximum_type_size ;
|
michelson_maximum_type_size ;
|
||||||
seed_nonce_revelation_tip ;
|
seed_nonce_revelation_tip ;
|
||||||
origination_burn ;
|
origination_size ;
|
||||||
block_security_deposit ;
|
block_security_deposit ;
|
||||||
endorsement_security_deposit ;
|
endorsement_security_deposit ;
|
||||||
block_reward ;
|
block_reward ;
|
||||||
|
@ -110,7 +110,7 @@ val genesis:
|
|||||||
?tokens_per_roll:Tez_repr.tez ->
|
?tokens_per_roll:Tez_repr.tez ->
|
||||||
?michelson_maximum_type_size:int ->
|
?michelson_maximum_type_size:int ->
|
||||||
?seed_nonce_revelation_tip:Tez_repr.tez ->
|
?seed_nonce_revelation_tip:Tez_repr.tez ->
|
||||||
?origination_burn:Tez_repr.tez ->
|
?origination_size:int ->
|
||||||
?block_security_deposit:Tez_repr.tez ->
|
?block_security_deposit:Tez_repr.tez ->
|
||||||
?endorsement_security_deposit:Tez_repr.tez ->
|
?endorsement_security_deposit:Tez_repr.tez ->
|
||||||
?block_reward:Tez_repr.tez ->
|
?block_reward:Tez_repr.tez ->
|
||||||
|
@ -141,13 +141,19 @@ let rec estimated_gas :
|
|||||||
|
|
||||||
let estimated_storage_single
|
let estimated_storage_single
|
||||||
(type kind)
|
(type kind)
|
||||||
|
origination_size
|
||||||
(Manager_operation_result { operation_result ;
|
(Manager_operation_result { operation_result ;
|
||||||
internal_operation_results }
|
internal_operation_results }
|
||||||
: kind Kind.manager contents_result) =
|
: kind Kind.manager contents_result) =
|
||||||
let storage_size_diff (type kind) (result : kind manager_operation_result) =
|
let storage_size_diff (type kind) (result : kind manager_operation_result) =
|
||||||
match result with
|
match result with
|
||||||
| Applied (Transaction_result { paid_storage_size_diff }) -> Ok paid_storage_size_diff
|
| Applied (Transaction_result { paid_storage_size_diff ; allocated_destination_contract }) ->
|
||||||
| Applied (Origination_result { paid_storage_size_diff }) -> Ok paid_storage_size_diff
|
if allocated_destination_contract then
|
||||||
|
Ok (Z.add paid_storage_size_diff origination_size)
|
||||||
|
else
|
||||||
|
Ok paid_storage_size_diff
|
||||||
|
| Applied (Origination_result { paid_storage_size_diff }) ->
|
||||||
|
Ok (Z.add paid_storage_size_diff origination_size)
|
||||||
| Applied Reveal_result -> Ok Z.zero
|
| Applied Reveal_result -> Ok Z.zero
|
||||||
| Applied Delegation_result -> Ok Z.zero
|
| Applied Delegation_result -> Ok Z.zero
|
||||||
| Skipped _ -> assert false
|
| Skipped _ -> assert false
|
||||||
@ -161,13 +167,13 @@ let estimated_storage_single
|
|||||||
Ok (Z.add acc storage))
|
Ok (Z.add acc storage))
|
||||||
(storage_size_diff operation_result) internal_operation_results
|
(storage_size_diff operation_result) internal_operation_results
|
||||||
|
|
||||||
let estimated_storage res =
|
let estimated_storage origination_size res =
|
||||||
let rec estimated_storage :
|
let rec estimated_storage :
|
||||||
type kind. kind Kind.manager contents_result_list -> _ =
|
type kind. kind Kind.manager contents_result_list -> _ =
|
||||||
function
|
function
|
||||||
| Single_result res -> estimated_storage_single res
|
| Single_result res -> estimated_storage_single origination_size res
|
||||||
| Cons_result (res, rest) ->
|
| Cons_result (res, rest) ->
|
||||||
estimated_storage_single res >>? fun storage1 ->
|
estimated_storage_single origination_size res >>? fun storage1 ->
|
||||||
estimated_storage rest >>? fun storage2 ->
|
estimated_storage rest >>? fun storage2 ->
|
||||||
Ok (Z.add storage1 storage2) in
|
Ok (Z.add storage1 storage2) in
|
||||||
estimated_storage res >>? fun diff ->
|
estimated_storage res >>? fun diff ->
|
||||||
@ -254,6 +260,7 @@ let may_patch_limits
|
|||||||
(chain, block) >>=? fun { parametric = {
|
(chain, block) >>=? fun { parametric = {
|
||||||
hard_gas_limit_per_operation = gas_limit ;
|
hard_gas_limit_per_operation = gas_limit ;
|
||||||
hard_storage_limit_per_operation = storage_limit ;
|
hard_storage_limit_per_operation = storage_limit ;
|
||||||
|
origination_size ;
|
||||||
} } ->
|
} } ->
|
||||||
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
|
||||||
@ -309,7 +316,7 @@ let may_patch_limits
|
|||||||
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 (Z.of_int origination_size) result) >>=? fun storage ->
|
||||||
begin
|
begin
|
||||||
if Z.equal storage Z.zero then
|
if Z.equal storage Z.zero then
|
||||||
cctxt#message "Estimated storage: no bytes added" >>= fun () ->
|
cctxt#message "Estimated storage: no bytes added" >>= fun () ->
|
||||||
|
@ -372,7 +372,7 @@ module Constants : sig
|
|||||||
tokens_per_roll: Tez.t ;
|
tokens_per_roll: Tez.t ;
|
||||||
michelson_maximum_type_size: int;
|
michelson_maximum_type_size: int;
|
||||||
seed_nonce_revelation_tip: Tez.t ;
|
seed_nonce_revelation_tip: Tez.t ;
|
||||||
origination_burn: Tez.t ;
|
origination_size: int ;
|
||||||
block_security_deposit: Tez.t ;
|
block_security_deposit: Tez.t ;
|
||||||
endorsement_security_deposit: Tez.t ;
|
endorsement_security_deposit: Tez.t ;
|
||||||
block_reward: Tez.t ;
|
block_reward: Tez.t ;
|
||||||
@ -399,7 +399,7 @@ module Constants : sig
|
|||||||
val block_reward: context -> Tez.t
|
val block_reward: context -> Tez.t
|
||||||
val endorsement_reward: context -> Tez.t
|
val endorsement_reward: context -> Tez.t
|
||||||
val seed_nonce_revelation_tip: context -> Tez.t
|
val seed_nonce_revelation_tip: context -> Tez.t
|
||||||
val origination_burn: context -> Tez.t
|
val origination_size: context -> int
|
||||||
val block_security_deposit: context -> Tez.t
|
val block_security_deposit: context -> Tez.t
|
||||||
val endorsement_security_deposit: context -> Tez.t
|
val endorsement_security_deposit: context -> Tez.t
|
||||||
|
|
||||||
@ -950,7 +950,7 @@ val manager_kind: 'kind manager_operation -> 'kind Kind.manager
|
|||||||
module Fees : sig
|
module Fees : sig
|
||||||
|
|
||||||
val origination_burn:
|
val origination_burn:
|
||||||
context -> payer:Contract.t -> (context * Tez.t) tzresult Lwt.t
|
context -> (context * Tez.t) tzresult Lwt.t
|
||||||
|
|
||||||
val record_paid_storage_space:
|
val record_paid_storage_space:
|
||||||
context -> Contract.t -> (context * Z.t * Z.t * Tez.t) tzresult Lwt.t
|
context -> Contract.t -> (context * Z.t * Z.t * Tez.t) tzresult Lwt.t
|
||||||
|
@ -374,14 +374,14 @@ let apply_manager_operation_content :
|
|||||||
| Transaction { amount ; parameters ; destination } -> begin
|
| Transaction { amount ; parameters ; destination } -> begin
|
||||||
spend ctxt source amount >>=? fun ctxt ->
|
spend ctxt source amount >>=? fun ctxt ->
|
||||||
begin match Contract.is_implicit destination with
|
begin match Contract.is_implicit destination with
|
||||||
| None -> return (ctxt, [])
|
| None -> return (ctxt, [], false)
|
||||||
| Some _ ->
|
| Some _ ->
|
||||||
Contract.allocated ctxt destination >>=? function
|
Contract.allocated ctxt destination >>=? function
|
||||||
| true -> return (ctxt, [])
|
| true -> return (ctxt, [], false)
|
||||||
| false ->
|
| false ->
|
||||||
Fees.origination_burn ctxt ~payer >>=? fun (ctxt, orignation_burn) ->
|
Fees.origination_burn ctxt >>=? fun (ctxt, origination_burn) ->
|
||||||
return (ctxt, [ Delegate.Contract payer, Delegate.Debited orignation_burn ])
|
return (ctxt, [ Delegate.Contract payer, Delegate.Debited origination_burn ], true)
|
||||||
end >>=? fun (ctxt, maybe_burn_balance_update) ->
|
end >>=? fun (ctxt, maybe_burn_balance_update, allocated_destination_contract) ->
|
||||||
Contract.credit ctxt destination amount >>=? fun ctxt ->
|
Contract.credit ctxt destination amount >>=? fun ctxt ->
|
||||||
Contract.get_script ctxt destination >>=? fun (ctxt, script) ->
|
Contract.get_script ctxt destination >>=? fun (ctxt, script) ->
|
||||||
match script with
|
match script with
|
||||||
@ -414,6 +414,7 @@ let apply_manager_operation_content :
|
|||||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||||
storage_size = Z.zero ;
|
storage_size = Z.zero ;
|
||||||
paid_storage_size_diff = Z.zero ;
|
paid_storage_size_diff = Z.zero ;
|
||||||
|
allocated_destination_contract ;
|
||||||
} in
|
} in
|
||||||
return (ctxt, result, [])
|
return (ctxt, result, [])
|
||||||
| Some script ->
|
| Some script ->
|
||||||
@ -451,7 +452,8 @@ let apply_manager_operation_content :
|
|||||||
originated_contracts ;
|
originated_contracts ;
|
||||||
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
consumed_gas = Gas.consumed ~since:before_operation ~until:ctxt ;
|
||||||
storage_size = new_size ;
|
storage_size = new_size ;
|
||||||
paid_storage_size_diff } in
|
paid_storage_size_diff ;
|
||||||
|
allocated_destination_contract } in
|
||||||
return (ctxt, result, operations)
|
return (ctxt, result, operations)
|
||||||
end
|
end
|
||||||
| Origination { manager ; delegate ; script ; preorigination ;
|
| Origination { manager ; delegate ; script ; preorigination ;
|
||||||
@ -482,14 +484,14 @@ let apply_manager_operation_content :
|
|||||||
~manager ~delegate ~balance:credit
|
~manager ~delegate ~balance:credit
|
||||||
?script
|
?script
|
||||||
~spendable ~delegatable >>=? fun ctxt ->
|
~spendable ~delegatable >>=? fun ctxt ->
|
||||||
Fees.origination_burn ctxt ~payer >>=? fun (ctxt, orignation_burn) ->
|
Fees.origination_burn ctxt >>=? fun (ctxt, origination_burn) ->
|
||||||
Fees.record_paid_storage_space ctxt contract >>=? fun (ctxt, size, paid_storage_size_diff, 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 =
|
let result =
|
||||||
Origination_result
|
Origination_result
|
||||||
{ balance_updates =
|
{ balance_updates =
|
||||||
Delegate.cleanup_balance_updates
|
Delegate.cleanup_balance_updates
|
||||||
[ Contract payer, Debited all_fees ;
|
[ Contract payer, Debited fees ;
|
||||||
|
Contract payer, Debited origination_burn ;
|
||||||
Contract source, Debited credit ;
|
Contract source, Debited credit ;
|
||||||
Contract contract, Credited credit ] ;
|
Contract contract, Credited credit ] ;
|
||||||
originated_contracts = [ contract ] ;
|
originated_contracts = [ contract ] ;
|
||||||
|
@ -51,6 +51,7 @@ type _ successful_manager_operation_result =
|
|||||||
consumed_gas : Z.t ;
|
consumed_gas : Z.t ;
|
||||||
storage_size : Z.t ;
|
storage_size : Z.t ;
|
||||||
paid_storage_size_diff : Z.t ;
|
paid_storage_size_diff : Z.t ;
|
||||||
|
allocated_destination_contract : bool ;
|
||||||
} -> Kind.transaction successful_manager_operation_result
|
} -> Kind.transaction successful_manager_operation_result
|
||||||
| Origination_result :
|
| Origination_result :
|
||||||
{ balance_updates : Delegate.balance_updates ;
|
{ balance_updates : Delegate.balance_updates ;
|
||||||
@ -164,14 +165,15 @@ module Manager_result = struct
|
|||||||
make
|
make
|
||||||
~op_case: Operation.Encoding.Manager_operations.transaction_case
|
~op_case: Operation.Encoding.Manager_operations.transaction_case
|
||||||
~encoding:
|
~encoding:
|
||||||
(obj7
|
(obj8
|
||||||
(opt "storage" Script.expr_encoding)
|
(opt "storage" Script.expr_encoding)
|
||||||
(opt "big_map_diff" Contract.big_map_diff_encoding)
|
(opt "big_map_diff" Contract.big_map_diff_encoding)
|
||||||
(dft "balance_updates" Delegate.balance_updates_encoding [])
|
(dft "balance_updates" Delegate.balance_updates_encoding [])
|
||||||
(dft "originated_contracts" (list Contract.encoding) [])
|
(dft "originated_contracts" (list Contract.encoding) [])
|
||||||
(dft "consumed_gas" z Z.zero)
|
(dft "consumed_gas" z Z.zero)
|
||||||
(dft "storage_size" z Z.zero)
|
(dft "storage_size" z Z.zero)
|
||||||
(dft "paid_storage_size_diff" z Z.zero))
|
(dft "paid_storage_size_diff" z Z.zero)
|
||||||
|
(dft "allocated_destination_contract" bool false))
|
||||||
~iselect:
|
~iselect:
|
||||||
(function
|
(function
|
||||||
| Internal_operation_result
|
| Internal_operation_result
|
||||||
@ -188,17 +190,21 @@ module Manager_result = struct
|
|||||||
| Transaction_result
|
| Transaction_result
|
||||||
{ storage ; big_map_diff ; balance_updates ;
|
{ storage ; big_map_diff ; balance_updates ;
|
||||||
originated_contracts ; consumed_gas ;
|
originated_contracts ; consumed_gas ;
|
||||||
storage_size ; paid_storage_size_diff } ->
|
storage_size ; paid_storage_size_diff ;
|
||||||
|
allocated_destination_contract } ->
|
||||||
(storage, big_map_diff, balance_updates,
|
(storage, big_map_diff, balance_updates,
|
||||||
originated_contracts, consumed_gas,
|
originated_contracts, consumed_gas,
|
||||||
storage_size, paid_storage_size_diff))
|
storage_size, paid_storage_size_diff,
|
||||||
|
allocated_destination_contract))
|
||||||
~inj:
|
~inj:
|
||||||
(fun (storage, big_map_diff, balance_updates,
|
(fun (storage, big_map_diff, balance_updates,
|
||||||
originated_contracts, consumed_gas,
|
originated_contracts, consumed_gas,
|
||||||
storage_size, paid_storage_size_diff) ->
|
storage_size, paid_storage_size_diff,
|
||||||
|
allocated_destination_contract) ->
|
||||||
Transaction_result { storage ; big_map_diff ; balance_updates ;
|
Transaction_result { storage ; big_map_diff ; balance_updates ;
|
||||||
originated_contracts ; consumed_gas ;
|
originated_contracts ; consumed_gas ;
|
||||||
storage_size ; paid_storage_size_diff })
|
storage_size ; paid_storage_size_diff ;
|
||||||
|
allocated_destination_contract })
|
||||||
|
|
||||||
let origination_case =
|
let origination_case =
|
||||||
make
|
make
|
||||||
|
@ -95,6 +95,7 @@ and _ successful_manager_operation_result =
|
|||||||
consumed_gas : Z.t ;
|
consumed_gas : Z.t ;
|
||||||
storage_size : Z.t ;
|
storage_size : Z.t ;
|
||||||
paid_storage_size_diff : Z.t ;
|
paid_storage_size_diff : Z.t ;
|
||||||
|
allocated_destination_contract : bool ;
|
||||||
} -> Kind.transaction successful_manager_operation_result
|
} -> Kind.transaction successful_manager_operation_result
|
||||||
| Origination_result :
|
| Origination_result :
|
||||||
{ balance_updates : Delegate.balance_updates ;
|
{ balance_updates : Delegate.balance_updates ;
|
||||||
|
@ -87,7 +87,7 @@ type parametric = {
|
|||||||
tokens_per_roll: Tez_repr.t ;
|
tokens_per_roll: Tez_repr.t ;
|
||||||
michelson_maximum_type_size: int;
|
michelson_maximum_type_size: int;
|
||||||
seed_nonce_revelation_tip: Tez_repr.t ;
|
seed_nonce_revelation_tip: Tez_repr.t ;
|
||||||
origination_burn: Tez_repr.t ;
|
origination_size: int ;
|
||||||
block_security_deposit: Tez_repr.t ;
|
block_security_deposit: Tez_repr.t ;
|
||||||
endorsement_security_deposit: Tez_repr.t ;
|
endorsement_security_deposit: Tez_repr.t ;
|
||||||
block_reward: Tez_repr.t ;
|
block_reward: Tez_repr.t ;
|
||||||
@ -117,7 +117,7 @@ let default = {
|
|||||||
| Ok c -> c
|
| Ok c -> c
|
||||||
| Error _ -> assert false
|
| Error _ -> assert false
|
||||||
end ;
|
end ;
|
||||||
origination_burn = Tez_repr.of_mutez_exn 257_000L ;
|
origination_size = 257 ;
|
||||||
block_security_deposit = Tez_repr.(mul_exn one 512) ;
|
block_security_deposit = Tez_repr.(mul_exn one 512) ;
|
||||||
endorsement_security_deposit = Tez_repr.(mul_exn one 64) ;
|
endorsement_security_deposit = Tez_repr.(mul_exn one 64) ;
|
||||||
block_reward = Tez_repr.(mul_exn one 16) ;
|
block_reward = Tez_repr.(mul_exn one 16) ;
|
||||||
@ -145,7 +145,7 @@ let parametric_encoding =
|
|||||||
c.tokens_per_roll,
|
c.tokens_per_roll,
|
||||||
c.michelson_maximum_type_size,
|
c.michelson_maximum_type_size,
|
||||||
c.seed_nonce_revelation_tip,
|
c.seed_nonce_revelation_tip,
|
||||||
c.origination_burn,
|
c.origination_size,
|
||||||
c.block_security_deposit,
|
c.block_security_deposit,
|
||||||
c.endorsement_security_deposit,
|
c.endorsement_security_deposit,
|
||||||
c.block_reward),
|
c.block_reward),
|
||||||
@ -165,7 +165,7 @@ let parametric_encoding =
|
|||||||
tokens_per_roll,
|
tokens_per_roll,
|
||||||
michelson_maximum_type_size,
|
michelson_maximum_type_size,
|
||||||
seed_nonce_revelation_tip,
|
seed_nonce_revelation_tip,
|
||||||
origination_burn,
|
origination_size,
|
||||||
block_security_deposit,
|
block_security_deposit,
|
||||||
endorsement_security_deposit,
|
endorsement_security_deposit,
|
||||||
block_reward),
|
block_reward),
|
||||||
@ -185,7 +185,7 @@ let parametric_encoding =
|
|||||||
tokens_per_roll ;
|
tokens_per_roll ;
|
||||||
michelson_maximum_type_size ;
|
michelson_maximum_type_size ;
|
||||||
seed_nonce_revelation_tip ;
|
seed_nonce_revelation_tip ;
|
||||||
origination_burn ;
|
origination_size ;
|
||||||
block_security_deposit ;
|
block_security_deposit ;
|
||||||
endorsement_security_deposit ;
|
endorsement_security_deposit ;
|
||||||
block_reward ;
|
block_reward ;
|
||||||
@ -210,7 +210,7 @@ let parametric_encoding =
|
|||||||
(req "tokens_per_roll" Tez_repr.encoding)
|
(req "tokens_per_roll" Tez_repr.encoding)
|
||||||
(req "michelson_maximum_type_size" uint16)
|
(req "michelson_maximum_type_size" uint16)
|
||||||
(req "seed_nonce_revelation_tip" Tez_repr.encoding)
|
(req "seed_nonce_revelation_tip" Tez_repr.encoding)
|
||||||
(req "origination_burn" Tez_repr.encoding)
|
(req "origination_size" int31)
|
||||||
(req "block_security_deposit" Tez_repr.encoding)
|
(req "block_security_deposit" Tez_repr.encoding)
|
||||||
(req "endorsement_security_deposit" Tez_repr.encoding)
|
(req "endorsement_security_deposit" Tez_repr.encoding)
|
||||||
(req "block_reward" Tez_repr.encoding))
|
(req "block_reward" Tez_repr.encoding))
|
||||||
|
@ -68,9 +68,9 @@ let michelson_maximum_type_size c =
|
|||||||
let seed_nonce_revelation_tip c =
|
let seed_nonce_revelation_tip c =
|
||||||
let constants = Raw_context.constants c in
|
let constants = Raw_context.constants c in
|
||||||
constants.seed_nonce_revelation_tip
|
constants.seed_nonce_revelation_tip
|
||||||
let origination_burn c =
|
let origination_size c =
|
||||||
let constants = Raw_context.constants c in
|
let constants = Raw_context.constants c in
|
||||||
constants.origination_burn
|
constants.origination_size
|
||||||
let block_security_deposit c =
|
let block_security_deposit c =
|
||||||
let constants = Raw_context.constants c in
|
let constants = Raw_context.constants c in
|
||||||
constants.block_security_deposit
|
constants.block_security_deposit
|
||||||
|
@ -58,10 +58,14 @@ let () =
|
|||||||
(function Storage_limit_too_high -> Some () | _ -> None)
|
(function Storage_limit_too_high -> Some () | _ -> None)
|
||||||
(fun () -> Storage_limit_too_high)
|
(fun () -> Storage_limit_too_high)
|
||||||
|
|
||||||
let origination_burn c ~payer =
|
let origination_burn c =
|
||||||
let origination_burn = Constants_storage.origination_burn c in
|
let origination_size = Constants_storage.origination_size c in
|
||||||
Contract_storage.spend_from_script c payer origination_burn >>=? fun c ->
|
let cost_per_byte = Constants_storage.cost_per_byte c in
|
||||||
return (c, origination_burn)
|
(* the origination burn, measured in bytes *)
|
||||||
|
Lwt.return
|
||||||
|
Tez_repr.(cost_per_byte *? (Int64.of_int origination_size)) >>=? fun to_be_paid ->
|
||||||
|
return (Raw_context.update_allocated_contracts_count c,
|
||||||
|
to_be_paid)
|
||||||
|
|
||||||
let record_paid_storage_space c contract =
|
let record_paid_storage_space c contract =
|
||||||
Contract_storage.used_storage_space c contract >>=? fun size ->
|
Contract_storage.used_storage_space c contract >>=? fun size ->
|
||||||
@ -72,13 +76,19 @@ let record_paid_storage_space c contract =
|
|||||||
return (c, size, to_be_paid, to_burn)
|
return (c, size, to_be_paid, to_burn)
|
||||||
|
|
||||||
let burn_storage_fees c ~storage_limit ~payer =
|
let burn_storage_fees c ~storage_limit ~payer =
|
||||||
let c, storage_space_to_pay = Raw_context.clear_storage_space_to_pay c in
|
let origination_size = Constants_storage.origination_size c in
|
||||||
let remaining = Z.sub storage_limit storage_space_to_pay in
|
let c, storage_space_to_pay, allocated_contracts =
|
||||||
|
Raw_context.clear_storage_space_to_pay c in
|
||||||
|
let storage_space_for_allocated_contracts =
|
||||||
|
Z.mul (Z.of_int allocated_contracts) (Z.of_int origination_size) in
|
||||||
|
let consumed =
|
||||||
|
Z.add storage_space_to_pay storage_space_for_allocated_contracts in
|
||||||
|
let remaining = Z.sub storage_limit consumed in
|
||||||
if Compare.Z.(remaining < Z.zero) then
|
if Compare.Z.(remaining < Z.zero) then
|
||||||
fail Operation_quota_exceeded
|
fail Operation_quota_exceeded
|
||||||
else
|
else
|
||||||
let cost_per_byte = Constants_storage.cost_per_byte c in
|
let cost_per_byte = Constants_storage.cost_per_byte c in
|
||||||
Lwt.return (Tez_repr.(cost_per_byte *? (Z.to_int64 storage_space_to_pay))) >>=? fun to_burn ->
|
Lwt.return (Tez_repr.(cost_per_byte *? (Z.to_int64 consumed))) >>=? fun to_burn ->
|
||||||
(* Burning the fees... *)
|
(* Burning the fees... *)
|
||||||
if Tez_repr.(to_burn = Tez_repr.zero) then
|
if Tez_repr.(to_burn = Tez_repr.zero) then
|
||||||
(* If the payer was was deleted by transfering all its balance, and no space was used,
|
(* If the payer was was deleted by transfering all its balance, and no space was used,
|
||||||
|
@ -27,8 +27,9 @@ type error += Cannot_pay_storage_fee (* `Temporary *)
|
|||||||
type error += Operation_quota_exceeded (* `Temporary *)
|
type error += Operation_quota_exceeded (* `Temporary *)
|
||||||
type error += Storage_limit_too_high (* `Permanent *)
|
type error += Storage_limit_too_high (* `Permanent *)
|
||||||
|
|
||||||
|
(** Does not burn, only adds the burn to storage space to be paid *)
|
||||||
val origination_burn:
|
val origination_burn:
|
||||||
Raw_context.t -> payer:Contract_repr.t -> (Raw_context.t * Tez_repr.t) tzresult Lwt.t
|
Raw_context.t -> (Raw_context.t * Tez_repr.t) tzresult Lwt.t
|
||||||
|
|
||||||
(** The returned Tez quantity is for logging purpose only *)
|
(** The returned Tez quantity is for logging purpose only *)
|
||||||
val record_paid_storage_space:
|
val record_paid_storage_space:
|
||||||
|
@ -135,9 +135,9 @@ let constants_encoding =
|
|||||||
and seed_nonce_revelation_tip =
|
and seed_nonce_revelation_tip =
|
||||||
opt Tez_repr.(=)
|
opt Tez_repr.(=)
|
||||||
default.seed_nonce_revelation_tip c.seed_nonce_revelation_tip
|
default.seed_nonce_revelation_tip c.seed_nonce_revelation_tip
|
||||||
and origination_burn =
|
and origination_size =
|
||||||
opt Tez_repr.(=)
|
opt Compare.Int.(=)
|
||||||
default.origination_burn c.origination_burn
|
default.origination_size c.origination_size
|
||||||
and block_security_deposit =
|
and block_security_deposit =
|
||||||
opt Tez_repr.(=)
|
opt Tez_repr.(=)
|
||||||
default.block_security_deposit c.block_security_deposit
|
default.block_security_deposit c.block_security_deposit
|
||||||
@ -170,7 +170,7 @@ let constants_encoding =
|
|||||||
tokens_per_roll,
|
tokens_per_roll,
|
||||||
michelson_maximum_type_size,
|
michelson_maximum_type_size,
|
||||||
seed_nonce_revelation_tip,
|
seed_nonce_revelation_tip,
|
||||||
origination_burn,
|
origination_size,
|
||||||
block_security_deposit,
|
block_security_deposit,
|
||||||
endorsement_security_deposit,
|
endorsement_security_deposit,
|
||||||
block_reward),
|
block_reward),
|
||||||
@ -190,7 +190,7 @@ let constants_encoding =
|
|||||||
tokens_per_roll,
|
tokens_per_roll,
|
||||||
michelson_maximum_type_size,
|
michelson_maximum_type_size,
|
||||||
seed_nonce_revelation_tip,
|
seed_nonce_revelation_tip,
|
||||||
origination_burn,
|
origination_size,
|
||||||
block_security_deposit,
|
block_security_deposit,
|
||||||
endorsement_security_deposit,
|
endorsement_security_deposit,
|
||||||
block_reward),
|
block_reward),
|
||||||
@ -226,8 +226,8 @@ let constants_encoding =
|
|||||||
unopt default.michelson_maximum_type_size michelson_maximum_type_size ;
|
unopt default.michelson_maximum_type_size michelson_maximum_type_size ;
|
||||||
seed_nonce_revelation_tip =
|
seed_nonce_revelation_tip =
|
||||||
unopt default.seed_nonce_revelation_tip seed_nonce_revelation_tip ;
|
unopt default.seed_nonce_revelation_tip seed_nonce_revelation_tip ;
|
||||||
origination_burn =
|
origination_size =
|
||||||
unopt default.origination_burn origination_burn ;
|
unopt default.origination_size origination_size ;
|
||||||
block_security_deposit =
|
block_security_deposit =
|
||||||
unopt default.block_security_deposit block_security_deposit ;
|
unopt default.block_security_deposit block_security_deposit ;
|
||||||
endorsement_security_deposit =
|
endorsement_security_deposit =
|
||||||
@ -258,7 +258,7 @@ let constants_encoding =
|
|||||||
(opt "tokens_per_roll" Tez_repr.encoding)
|
(opt "tokens_per_roll" Tez_repr.encoding)
|
||||||
(opt "michelson_maximum_type_size" uint16)
|
(opt "michelson_maximum_type_size" uint16)
|
||||||
(opt "seed_nonce_revelation_tip" Tez_repr.encoding)
|
(opt "seed_nonce_revelation_tip" Tez_repr.encoding)
|
||||||
(opt "origination_burn" Tez_repr.encoding)
|
(opt "origination_size" int31)
|
||||||
(opt "block_security_deposit" Tez_repr.encoding)
|
(opt "block_security_deposit" Tez_repr.encoding)
|
||||||
(opt "endorsement_security_deposit" Tez_repr.encoding)
|
(opt "endorsement_security_deposit" Tez_repr.encoding)
|
||||||
(opt "block_reward" Tez_repr.encoding))
|
(opt "block_reward" Tez_repr.encoding))
|
||||||
|
@ -40,6 +40,7 @@ type t = {
|
|||||||
block_gas: Z.t ;
|
block_gas: Z.t ;
|
||||||
operation_gas: Gas_limit_repr.t ;
|
operation_gas: Gas_limit_repr.t ;
|
||||||
storage_space_to_pay: Z.t option ;
|
storage_space_to_pay: Z.t option ;
|
||||||
|
allocated_contracts: int option ;
|
||||||
origination_nonce: Contract_repr.origination_nonce option ;
|
origination_nonce: Contract_repr.origination_nonce option ;
|
||||||
internal_nonce: int ;
|
internal_nonce: int ;
|
||||||
internal_nonces_used: Int_set.t ;
|
internal_nonces_used: Int_set.t ;
|
||||||
@ -203,7 +204,7 @@ let init_storage_space_to_pay ctxt =
|
|||||||
| Some _ ->
|
| Some _ ->
|
||||||
assert false
|
assert false
|
||||||
| None ->
|
| None ->
|
||||||
{ ctxt with storage_space_to_pay = Some Z.zero }
|
{ ctxt with storage_space_to_pay = Some Z.zero ; allocated_contracts = Some 0 }
|
||||||
|
|
||||||
let update_storage_space_to_pay ctxt n =
|
let update_storage_space_to_pay ctxt n =
|
||||||
match ctxt.storage_space_to_pay with
|
match ctxt.storage_space_to_pay with
|
||||||
@ -212,12 +213,22 @@ let update_storage_space_to_pay ctxt n =
|
|||||||
| Some storage_space_to_pay ->
|
| Some storage_space_to_pay ->
|
||||||
{ ctxt with storage_space_to_pay = Some (Z.add n storage_space_to_pay) }
|
{ ctxt with storage_space_to_pay = Some (Z.add n storage_space_to_pay) }
|
||||||
|
|
||||||
let clear_storage_space_to_pay ctxt =
|
let update_allocated_contracts_count ctxt =
|
||||||
match ctxt.storage_space_to_pay with
|
match ctxt.allocated_contracts with
|
||||||
| None ->
|
| None ->
|
||||||
assert false
|
assert false
|
||||||
| Some storage_space_to_pay ->
|
| Some allocated_contracts ->
|
||||||
{ ctxt with storage_space_to_pay = None }, storage_space_to_pay
|
{ ctxt with allocated_contracts = Some (succ allocated_contracts) }
|
||||||
|
|
||||||
|
let clear_storage_space_to_pay ctxt =
|
||||||
|
match ctxt.storage_space_to_pay, ctxt.allocated_contracts with
|
||||||
|
| None, _ | _, None ->
|
||||||
|
assert false
|
||||||
|
| Some storage_space_to_pay, Some allocated_contracts ->
|
||||||
|
{ ctxt with storage_space_to_pay = None ;
|
||||||
|
allocated_contracts = None},
|
||||||
|
storage_space_to_pay,
|
||||||
|
allocated_contracts
|
||||||
|
|
||||||
type storage_error =
|
type storage_error =
|
||||||
| Incompatible_protocol_version of string
|
| Incompatible_protocol_version of string
|
||||||
@ -442,6 +453,7 @@ let prepare ~level ~timestamp ~fitness ctxt =
|
|||||||
deposits = Signature.Public_key_hash.Map.empty ;
|
deposits = Signature.Public_key_hash.Map.empty ;
|
||||||
operation_gas = Unaccounted ;
|
operation_gas = Unaccounted ;
|
||||||
storage_space_to_pay = None ;
|
storage_space_to_pay = None ;
|
||||||
|
allocated_contracts = None ;
|
||||||
block_gas = constants.Constants_repr.hard_gas_limit_per_block ;
|
block_gas = constants.Constants_repr.hard_gas_limit_per_block ;
|
||||||
origination_nonce = None ;
|
origination_nonce = None ;
|
||||||
internal_nonce = 0 ;
|
internal_nonce = 0 ;
|
||||||
@ -502,6 +514,7 @@ let register_resolvers enc resolve =
|
|||||||
fitness = 0L ;
|
fitness = 0L ;
|
||||||
allowed_endorsements = Signature.Public_key_hash.Map.empty ;
|
allowed_endorsements = Signature.Public_key_hash.Map.empty ;
|
||||||
storage_space_to_pay = None ;
|
storage_space_to_pay = None ;
|
||||||
|
allocated_contracts = None ;
|
||||||
fees = Tez_repr.zero ;
|
fees = Tez_repr.zero ;
|
||||||
rewards = Tez_repr.zero ;
|
rewards = Tez_repr.zero ;
|
||||||
deposits = Signature.Public_key_hash.Map.empty ;
|
deposits = Signature.Public_key_hash.Map.empty ;
|
||||||
|
@ -119,7 +119,8 @@ val block_gas_level: t -> Z.t
|
|||||||
|
|
||||||
val init_storage_space_to_pay: t -> t
|
val init_storage_space_to_pay: t -> t
|
||||||
val update_storage_space_to_pay: t -> Z.t -> t
|
val update_storage_space_to_pay: t -> Z.t -> t
|
||||||
val clear_storage_space_to_pay: t -> t * Z.t
|
val update_allocated_contracts_count: t -> t
|
||||||
|
val clear_storage_space_to_pay: t -> t * Z.t * int
|
||||||
|
|
||||||
type error += Undefined_operation_nonce (* `Permanent *)
|
type error += Undefined_operation_nonce (* `Permanent *)
|
||||||
|
|
||||||
|
@ -70,7 +70,7 @@ let multiple_origination_and_delegation () =
|
|||||||
Context.init 2 >>=? fun (blk, contracts) ->
|
Context.init 2 >>=? fun (blk, contracts) ->
|
||||||
let c1 = List.nth contracts 0 in
|
let c1 = List.nth contracts 0 in
|
||||||
let n = 10 in
|
let n = 10 in
|
||||||
Context.get_constants (B blk) >>=? fun { parametric = { origination_burn } } ->
|
Context.get_constants (B blk) >>=? fun { parametric = { origination_size ; cost_per_byte } } ->
|
||||||
Context.Contract.pkh c1 >>=? fun delegate_pkh ->
|
Context.Contract.pkh c1 >>=? fun delegate_pkh ->
|
||||||
|
|
||||||
let new_accounts = List.map (fun _ -> Account.new_account ()) (1 -- n) in
|
let new_accounts = List.map (fun _ -> Account.new_account ()) (1 -- n) in
|
||||||
@ -111,6 +111,7 @@ let multiple_origination_and_delegation () =
|
|||||||
) tickets in
|
) tickets in
|
||||||
|
|
||||||
(* Previous balance - (Credit (n * 10tz) + Origination cost (n tz)) *)
|
(* Previous balance - (Credit (n * 10tz) + Origination cost (n tz)) *)
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
Tez.(origination_burn *? (Int64.of_int n)) >>?= fun origination_total_cost ->
|
Tez.(origination_burn *? (Int64.of_int n)) >>?= fun origination_total_cost ->
|
||||||
Tez.((Tez.of_int (10 * n)) +? origination_total_cost) >>?= fun total_cost ->
|
Tez.((Tez.of_int (10 * n)) +? origination_total_cost) >>?= fun total_cost ->
|
||||||
Assert.balance_was_debited ~loc:__LOC__
|
Assert.balance_was_debited ~loc:__LOC__
|
||||||
|
@ -150,7 +150,8 @@ let delegate_to_bootstrap_by_origination ~fee () =
|
|||||||
Context.Contract.balance (I i) bootstrap >>=? fun balance ->
|
Context.Contract.balance (I i) bootstrap >>=? fun balance ->
|
||||||
(* originate a contract with bootstrap's manager as delegate *)
|
(* originate a contract with bootstrap's manager as delegate *)
|
||||||
Op.origination ~fee ~credit:Tez.zero ~delegate:manager.pkh (I i) bootstrap >>=? fun (op, orig_contract) ->
|
Op.origination ~fee ~credit:Tez.zero ~delegate:manager.pkh (I i) bootstrap >>=? fun (op, orig_contract) ->
|
||||||
Context.get_constants (I i) >>=? fun { parametric = { origination_burn ; _ }} -> (* 0.257tz *)
|
Context.get_constants (I i) >>=? fun { parametric = { origination_size ; cost_per_byte ; _ }} -> (* 0.257tz *)
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
Lwt.return (Tez.(+?) fee origination_burn) >>=? fun total_fee ->
|
Lwt.return (Tez.(+?) fee origination_burn) >>=? fun total_fee ->
|
||||||
if fee > balance then
|
if fee > balance then
|
||||||
begin
|
begin
|
||||||
@ -258,7 +259,7 @@ let tests_bootstrap_contracts = [
|
|||||||
Test.tztest "bootstrap keys are already registered as delegate keys (max fee)" `Quick (bootstrap_manager_already_registered_delegate ~fee:Tez.max_tez) ;
|
Test.tztest "bootstrap keys are already registered as delegate keys (max fee)" `Quick (bootstrap_manager_already_registered_delegate ~fee:Tez.max_tez) ;
|
||||||
Test.tztest "bootstrap manager can be delegate (init origination, small fee)" `Quick (delegate_to_bootstrap_by_origination ~fee:Tez.one_mutez) ;
|
Test.tztest "bootstrap manager can be delegate (init origination, small fee)" `Quick (delegate_to_bootstrap_by_origination ~fee:Tez.one_mutez) ;
|
||||||
(* balance enough for fee but not for fee + origination burn *)
|
(* balance enough for fee but not for fee + origination burn *)
|
||||||
Test.tztest "bootstrap manager can be delegate (init origination, edge case)" `Quick (delegate_to_bootstrap_by_origination ~fee:(Tez.of_mutez_exn 3_999_999_750_000L)) ;
|
Test.tztest "bootstrap manager can be delegate (init origination, edge case)" `Quick (delegate_to_bootstrap_by_origination ~fee:(Tez.of_mutez_exn 3_999_999_743_000L)) ;
|
||||||
(* fee bigger than bootstrap's initial balance*)
|
(* fee bigger than bootstrap's initial balance*)
|
||||||
Test.tztest "bootstrap manager can be delegate (init origination, large fee)" `Quick (delegate_to_bootstrap_by_origination ~fee:(Tez.of_int 10_000_000)) ;
|
Test.tztest "bootstrap manager can be delegate (init origination, large fee)" `Quick (delegate_to_bootstrap_by_origination ~fee:(Tez.of_int 10_000_000)) ;
|
||||||
Test.tztest "bootstrap manager can be delegate (init delegation, small fee)" `Quick (delegate_to_bootstrap_by_delegation ~fee:Tez.one_mutez) ;
|
Test.tztest "bootstrap manager can be delegate (init delegation, small fee)" `Quick (delegate_to_bootstrap_by_delegation ~fee:Tez.one_mutez) ;
|
||||||
@ -337,7 +338,8 @@ let unregistered_delegate_key_init_origination ~fee () =
|
|||||||
let unregistered_pkh = Account.(unregistered_account.pkh) in
|
let unregistered_pkh = Account.(unregistered_account.pkh) in
|
||||||
(* origination with delegate argument *)
|
(* origination with delegate argument *)
|
||||||
Op.origination ~fee ~delegate:unregistered_pkh (I i) bootstrap >>=? fun (op, orig_contract) ->
|
Op.origination ~fee ~delegate:unregistered_pkh (I i) bootstrap >>=? fun (op, orig_contract) ->
|
||||||
Context.get_constants (I i) >>=? fun { parametric = { origination_burn ; _ }} ->
|
Context.get_constants (I i) >>=? fun { parametric = { origination_size ; cost_per_byte ; _ }} ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
Lwt.return (Tez.(+?) fee origination_burn) >>=? fun _total_fee -> (* FIXME unused variable *)
|
Lwt.return (Tez.(+?) fee origination_burn) >>=? fun _total_fee -> (* FIXME unused variable *)
|
||||||
Context.Contract.balance (I i) bootstrap >>=? fun balance ->
|
Context.Contract.balance (I i) bootstrap >>=? fun balance ->
|
||||||
if fee > balance then
|
if fee > balance then
|
||||||
@ -1062,7 +1064,8 @@ let registered_self_delegate_key_init_origination () =
|
|||||||
Op.delegation (I i) contract (Some pkh) >>=? fun op ->
|
Op.delegation (I i) contract (Some pkh) >>=? fun op ->
|
||||||
Incremental.add_operation i op >>=? fun i ->
|
Incremental.add_operation i op >>=? fun i ->
|
||||||
Context.Contract.balance (I i) contract >>=? fun balance ->
|
Context.Contract.balance (I i) contract >>=? fun balance ->
|
||||||
Context.get_constants (I i) >>=? fun { parametric = { origination_burn ; _ }} ->
|
Context.get_constants (I i) >>=? fun { parametric = { origination_size ; cost_per_byte ; _ }} ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
(* origination with delegate argument *)
|
(* origination with delegate argument *)
|
||||||
Op.origination ~delegate:pkh ~credit:Tez.one (I i) contract >>=? fun (op, orig_contract) ->
|
Op.origination ~delegate:pkh ~credit:Tez.one (I i) contract >>=? fun (op, orig_contract) ->
|
||||||
Tez.(origination_burn +? Tez.one) >>?= fun total_cost ->
|
Tez.(origination_burn +? Tez.one) >>?= fun total_cost ->
|
||||||
|
@ -245,7 +245,7 @@ let genesis
|
|||||||
?(tokens_per_roll = Constants_repr.default.tokens_per_roll)
|
?(tokens_per_roll = Constants_repr.default.tokens_per_roll)
|
||||||
?(michelson_maximum_type_size = Constants_repr.default.michelson_maximum_type_size)
|
?(michelson_maximum_type_size = Constants_repr.default.michelson_maximum_type_size)
|
||||||
?(seed_nonce_revelation_tip = Constants_repr.default.seed_nonce_revelation_tip)
|
?(seed_nonce_revelation_tip = Constants_repr.default.seed_nonce_revelation_tip)
|
||||||
?(origination_burn = Constants_repr.default.origination_burn)
|
?(origination_size = Constants_repr.default.origination_size)
|
||||||
?(block_security_deposit = Constants_repr.default.block_security_deposit)
|
?(block_security_deposit = Constants_repr.default.block_security_deposit)
|
||||||
?(endorsement_security_deposit = Constants_repr.default.endorsement_security_deposit)
|
?(endorsement_security_deposit = Constants_repr.default.endorsement_security_deposit)
|
||||||
?(block_reward = Constants_repr.default.block_reward)
|
?(block_reward = Constants_repr.default.block_reward)
|
||||||
@ -288,7 +288,7 @@ let genesis
|
|||||||
tokens_per_roll ;
|
tokens_per_roll ;
|
||||||
michelson_maximum_type_size ;
|
michelson_maximum_type_size ;
|
||||||
seed_nonce_revelation_tip ;
|
seed_nonce_revelation_tip ;
|
||||||
origination_burn ;
|
origination_size ;
|
||||||
block_security_deposit ;
|
block_security_deposit ;
|
||||||
endorsement_security_deposit ;
|
endorsement_security_deposit ;
|
||||||
block_reward ;
|
block_reward ;
|
||||||
|
@ -103,7 +103,7 @@ val genesis:
|
|||||||
?tokens_per_roll:Tez_repr.tez ->
|
?tokens_per_roll:Tez_repr.tez ->
|
||||||
?michelson_maximum_type_size:int ->
|
?michelson_maximum_type_size:int ->
|
||||||
?seed_nonce_revelation_tip:Tez_repr.tez ->
|
?seed_nonce_revelation_tip:Tez_repr.tez ->
|
||||||
?origination_burn:Tez_repr.tez ->
|
?origination_size:int ->
|
||||||
?block_security_deposit:Tez_repr.tez ->
|
?block_security_deposit:Tez_repr.tez ->
|
||||||
?endorsement_security_deposit:Tez_repr.tez ->
|
?endorsement_security_deposit:Tez_repr.tez ->
|
||||||
?block_reward:Tez_repr.tez ->
|
?block_reward:Tez_repr.tez ->
|
||||||
|
@ -30,6 +30,6 @@ let tztest name speed f =
|
|||||||
| Ok () -> Lwt.return_unit
|
| Ok () -> Lwt.return_unit
|
||||||
| Error err ->
|
| Error err ->
|
||||||
Tezos_stdlib_unix.Logging_unix.close () >>= fun () ->
|
Tezos_stdlib_unix.Logging_unix.close () >>= fun () ->
|
||||||
Format.printf "WWW %a@." pp_print_error err ;
|
Format.printf "@.%a@." pp_print_error err ;
|
||||||
Lwt.fail Alcotest.Test_error
|
Lwt.fail Alcotest.Test_error
|
||||||
end
|
end
|
||||||
|
@ -43,8 +43,10 @@ let register_origination ?(fee=Tez.zero) ?(credit=Tez.zero) ?spendable ?delegata
|
|||||||
>>=? fun (operation, originated) ->
|
>>=? fun (operation, originated) ->
|
||||||
Block.bake ~operation b >>=? fun b ->
|
Block.bake ~operation b >>=? fun b ->
|
||||||
(* fee + credit + block security deposit were debited from source *)
|
(* fee + credit + block security deposit were debited from source *)
|
||||||
Context.get_constants (B b) >>=? fun {parametric = {origination_burn ;
|
Context.get_constants (B b) >>=? fun {parametric = { origination_size ;
|
||||||
block_security_deposit}} ->
|
cost_per_byte ;
|
||||||
|
block_security_deposit }} ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
Lwt.return (
|
Lwt.return (
|
||||||
Tez.(+?) credit block_security_deposit >>?
|
Tez.(+?) credit block_security_deposit >>?
|
||||||
Tez.(+?) fee >>?
|
Tez.(+?) fee >>?
|
||||||
@ -78,10 +80,12 @@ let test_origination_balances ~loc ?(fee=Tez.zero) ?(credit=Tez.zero)
|
|||||||
tests.*)
|
tests.*)
|
||||||
Context.get_constants (B b) >>=? fun
|
Context.get_constants (B b) >>=? fun
|
||||||
{ parametric =
|
{ parametric =
|
||||||
{ origination_burn ;
|
{ origination_size ;
|
||||||
|
cost_per_byte ;
|
||||||
block_security_deposit
|
block_security_deposit
|
||||||
}
|
}
|
||||||
} ->
|
} ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
Lwt.return (
|
Lwt.return (
|
||||||
Tez.(+?) credit block_security_deposit >>?
|
Tez.(+?) credit block_security_deposit >>?
|
||||||
Tez.(+?) fee >>?
|
Tez.(+?) fee >>?
|
||||||
@ -259,7 +263,9 @@ let register_origination_inc ~credit () =
|
|||||||
Context.init 1 >>=? fun (b, contracts) ->
|
Context.init 1 >>=? fun (b, contracts) ->
|
||||||
let source_contract = List.hd contracts in
|
let source_contract = List.hd contracts in
|
||||||
Incremental.begin_construction b >>=? fun inc ->
|
Incremental.begin_construction b >>=? fun inc ->
|
||||||
Op.origination (I inc) ~credit source_contract >>=? fun (operation, new_contract) ->
|
Op.origination (I inc)
|
||||||
|
~storage_limit:(Z.of_int Constants_repr.default.origination_size)
|
||||||
|
~credit source_contract >>=? fun (operation, new_contract) ->
|
||||||
Incremental.add_operation inc operation >>=? fun inc ->
|
Incremental.add_operation inc operation >>=? fun inc ->
|
||||||
return (inc, source_contract, new_contract)
|
return (inc, source_contract, new_contract)
|
||||||
|
|
||||||
@ -274,10 +280,11 @@ let origination_contract_from_origination_contract_not_enough_fund fee () =
|
|||||||
(* contract's balance is not enough to afford origination burn *)
|
(* contract's balance is not enough to afford origination burn *)
|
||||||
Op.origination ~fee (I inc) ~credit:amount contract >>=? fun (operation, orig_contract) ->
|
Op.origination ~fee (I inc) ~credit:amount contract >>=? fun (operation, orig_contract) ->
|
||||||
let expect_failure = function
|
let expect_failure = function
|
||||||
| Alpha_environment.Ecoproto_error (Contract_storage.Balance_too_low _) :: _ ->
|
| Alpha_environment.Ecoproto_error (Alpha_context.Fees.Cannot_pay_storage_fee) :: _ ->
|
||||||
return_unit
|
return_unit
|
||||||
| _ ->
|
| e ->
|
||||||
failwith "The contract has not enough funds, it fails!"
|
failwith "The contract has not enough funds, it fails! %a"
|
||||||
|
Error_monad.pp_print_error e
|
||||||
in
|
in
|
||||||
Incremental.add_operation ~expect_failure inc operation >>=? fun inc ->
|
Incremental.add_operation ~expect_failure inc operation >>=? fun inc ->
|
||||||
Context.Contract.balance (I inc) contract >>=? fun balance_aft ->
|
Context.Contract.balance (I inc) contract >>=? fun balance_aft ->
|
||||||
|
@ -25,6 +25,8 @@
|
|||||||
|
|
||||||
open Proto_alpha
|
open Proto_alpha
|
||||||
open Alpha_context
|
open Alpha_context
|
||||||
|
open Test_tez
|
||||||
|
open Test_utils
|
||||||
|
|
||||||
let account_pair = function
|
let account_pair = function
|
||||||
| [a1; a2] -> (a1, a2)
|
| [a1; a2] -> (a1, a2)
|
||||||
@ -153,7 +155,8 @@ let deactivation_then_empty_then_self_delegation () =
|
|||||||
Context.Contract.balance (B b) deactivated_contract >>=? fun balance ->
|
Context.Contract.balance (B b) deactivated_contract >>=? fun balance ->
|
||||||
let sink_account = Account.new_account () in
|
let sink_account = Account.new_account () in
|
||||||
let sink_contract = Contract.implicit_contract sink_account.pkh in
|
let sink_contract = Contract.implicit_contract sink_account.pkh in
|
||||||
Context.get_constants (B b) >>=? fun { parametric = { origination_burn } } ->
|
Context.get_constants (B b) >>=? fun { parametric = { origination_size ; cost_per_byte } } ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
let amount = match Tez.(balance -? origination_burn) with Ok r -> r | Error _ -> assert false in
|
let amount = match Tez.(balance -? origination_burn) with Ok r -> r | Error _ -> assert false in
|
||||||
Op.transaction (B b) deactivated_contract sink_contract amount >>=? fun empty_contract ->
|
Op.transaction (B b) deactivated_contract sink_contract amount >>=? fun empty_contract ->
|
||||||
Block.bake ~policy:(By_account m2.pkh) ~operation:empty_contract b >>=? fun b ->
|
Block.bake ~policy:(By_account m2.pkh) ~operation:empty_contract b >>=? fun b ->
|
||||||
@ -173,7 +176,8 @@ let deactivation_then_empty_then_self_delegation_then_recredit () =
|
|||||||
(* empty the contract *)
|
(* empty the contract *)
|
||||||
let sink_account = Account.new_account () in
|
let sink_account = Account.new_account () in
|
||||||
let sink_contract = Contract.implicit_contract sink_account.pkh in
|
let sink_contract = Contract.implicit_contract sink_account.pkh in
|
||||||
Context.get_constants (B b) >>=? fun { parametric = { origination_burn } } ->
|
Context.get_constants (B b) >>=? fun { parametric = { origination_size ; cost_per_byte } } ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
let amount = match Tez.(balance -? origination_burn) with Ok r -> r | Error _ -> assert false in
|
let amount = match Tez.(balance -? origination_burn) with Ok r -> r | Error _ -> assert false in
|
||||||
Op.transaction (B b) deactivated_contract sink_contract amount >>=? fun empty_contract ->
|
Op.transaction (B b) deactivated_contract sink_contract amount >>=? fun empty_contract ->
|
||||||
Block.bake ~policy:(By_account m2.pkh) ~operation:empty_contract b >>=? fun b ->
|
Block.bake ~policy:(By_account m2.pkh) ~operation:empty_contract b >>=? fun b ->
|
||||||
|
@ -53,7 +53,8 @@ let transfer_and_check_balances ?(with_burn = false) ~loc b ?(fee=Tez.zero) ?exp
|
|||||||
Context.Contract.balance (I b) dst >>=? fun bal_dst ->
|
Context.Contract.balance (I b) dst >>=? fun bal_dst ->
|
||||||
Op.transaction (I b) ~fee src dst amount >>=? fun op ->
|
Op.transaction (I b) ~fee src dst amount >>=? fun op ->
|
||||||
Incremental.add_operation ?expect_failure b op >>=? fun b ->
|
Incremental.add_operation ?expect_failure b op >>=? fun b ->
|
||||||
Context.get_constants (I b) >>=? fun { parametric = { origination_burn } } ->
|
Context.get_constants (I b) >>=? fun { parametric = { origination_size ; cost_per_byte } } ->
|
||||||
|
Tez.(cost_per_byte *? Int64.of_int origination_size) >>?= fun origination_burn ->
|
||||||
let amount_fee_maybe_burn =
|
let amount_fee_maybe_burn =
|
||||||
if with_burn then
|
if with_burn then
|
||||||
match Tez.(amount_fee +? origination_burn) with
|
match Tez.(amount_fee +? origination_burn) with
|
||||||
|
Loading…
Reference in New Issue
Block a user