Mina_base.Fee_excessFee excesses associated with transactions or transitions.
These are represented as a 'left' and 'right' excess, which describe the unresolved fee excesses in the fee tokens of the first (or leftmost) and last (or rightmost) transactions in the transition.
Assumptions: * Transactions are grouped by their fee token. * The 'fee transfer' transaction to dispense those fees is part of this group. * The fee excess for each token is 0 across the group. * No transactions with fees paid in another token are executed while the previous fee token's excess is non-zero.
By maintaining these assumptions, we can ensure that the un-settled fee excesses can be represented by excesses in (at most) 2 tokens. Consider, for example, any consecutive subsequence of the transactions
..txn@2ft@2txn@3txn@3ft@3txn@4ft@4txn@5txn@5ft@5txn@6ft@6..
where txn@i and ft@i are transactions and fee transfers respectively paid in token i. The only groups which may have non-zero fee excesses are those which contain the start and end of the subsequence.
The code below also defines a canonical representation where fewer than 2 tokens have non-zero excesses. See rebalance below for details and the implementation.
module Poly : sig ... endmodule Stable : sig ... endtype t = Stable.Latest.tval to_yojson : t -> Yojson.Safe.tval of_yojson : Yojson.Safe.t -> t Ppx_deriving_yojson_runtime.error_orval _ : Yojson.Safe.t -> t Ppx_deriving_yojson_runtime.error_orval hash_fold_t :
Ppx_hash_lib.Std.Hash.state ->
t ->
Ppx_hash_lib.Std.Hash.stateval hash : t -> Ppx_hash_lib.Std.Hash.hash_valueval t_of_sexp : Ppx_sexp_conv_lib.Sexp.t -> tval sexp_of_t : t -> Ppx_sexp_conv_lib.Sexp.ttype ('token, 'fee) poly = ( 'token, 'fee ) Poly.t = {fee_token_l : 'token; |
fee_excess_l : 'fee; |
fee_token_r : 'token; |
fee_excess_r : 'fee; |
}val hash_fold_poly :
'token 'fee. ( Ppx_hash_lib.Std.Hash.state ->
'token ->
Ppx_hash_lib.Std.Hash.state ) ->
( Ppx_hash_lib.Std.Hash.state -> 'fee -> Ppx_hash_lib.Std.Hash.state ) ->
Ppx_hash_lib.Std.Hash.state ->
( 'token, 'fee ) poly ->
Ppx_hash_lib.Std.Hash.stateval poly_of_sexp :
'token 'fee. ( Ppx_sexp_conv_lib.Sexp.t -> 'token ) ->
( Ppx_sexp_conv_lib.Sexp.t -> 'fee ) ->
Ppx_sexp_conv_lib.Sexp.t ->
( 'token, 'fee ) polyval sexp_of_poly :
'token 'fee. ( 'token -> Ppx_sexp_conv_lib.Sexp.t ) ->
( 'fee -> Ppx_sexp_conv_lib.Sexp.t ) ->
( 'token, 'fee ) poly ->
Ppx_sexp_conv_lib.Sexp.tval poly_to_yojson :
( 'a -> 'b ) ->
( 'c -> 'b ) ->
( 'a, 'c ) Poly.Stable.Latest.t ->
[> `List of [> `Assoc of (string * 'b) list ] list ]val poly_of_yojson :
( 'a -> ( 'b, string ) Core_kernel__Result.t ) ->
( 'a -> ( 'c, string ) Core_kernel__Result.t ) ->
[> `List of [> `Assoc of (string * 'a) list ] list ] ->
( ( 'b, 'c ) Poly.Stable.Latest.t, string ) Core_kernel__Result.ttype var = ( Token_id.Checked.t, Currency.Fee.Signed.var ) polyval typ : ( var, t ) Snark_params.Tick.Typ.tval to_input :
( Account_id.Digest.t, Currency.Fee.Signed.t ) poly ->
Snark_params.Tick.Field.t Random_oracle.Input.Chunked.tval to_input_checked :
( Token_id.Checked.t, Currency.Fee.Signed.var ) poly ->
( Pickles.Impls.Step.Field.t Random_oracle.Input.Chunked.t,
Backend.Tick.Field.t )
Snarky_backendless.Checked_runner.Simple.tval assert_equal_checked : var -> var -> unit Snark_params.Tick.Checked.tval eliminate_fee_excess :
(Mina_wire_types.Mina_base.Account_id.Digest.V1.t
* ( Currency.Fee.Stable.Latest.t, Sgn.t ) Currency.Signed_poly.t) ->
(Mina_wire_types.Mina_base.Account_id.Digest.V1.t * Currency.Fee.Signed.t) ->
(Mina_wire_types.Mina_base.Account_id.Digest.V1.t
* ( Currency.Fee.Stable.Latest.t, Sgn.t ) Currency.Signed_poly.t) ->
((Mina_wire_types.Mina_base.Account_id.Digest.V1.t * Currency.Fee.Signed.t)
* (Mina_wire_types.Mina_base.Account_id.Digest.V1.t
* ( Currency.Fee.Stable.Latest.t, Sgn.t ) Currency.Signed_poly.t))
Base__Or_error.tEliminate a fee excess, either by combining it with one to the left/right, or by checking that it is zero.
val eliminate_fee_excess_checked :
(Token_id.Checked.t * Backend.Tick.Field.t Snarky_backendless.Cvar.t) ->
(Token_id.Checked.t * Backend.Tick.Field.t Snarky_backendless.Cvar.t) ->
(Token_id.Checked.t * Backend.Tick.Field.t Snarky_backendless.Cvar.t) ->
((Token_id.Checked.t * Snark_params.Tick.Field.Var.t)
* (Token_id.Checked.t * Snark_params.Tick.Field.Var.t))
Snark_params.Tick.Checked.tval rebalance :
t ->
( Account_id.Digest.t, Currency.Fee.Signed.t ) poly Base__Or_error.tval rebalance_checked :
( Token_id.Checked.t, Backend.Tick.Field.t Snarky_backendless.Cvar.t ) poly ->
( ( Token_id.Checked.t, Snark_params.Tick.Field.Var.t ) poly,
Backend.Tick.Field.t )
Snarky_backendless.Checked_runner.Simple.tval combine :
( Mina_wire_types.Mina_base.Account_id.Digest.V1.t,
( Currency.Fee.Stable.Latest.t, Sgn.t ) Currency.Signed_poly.t )
poly ->
( Mina_wire_types.Mina_base.Account_id.Digest.V1.t,
( Currency.Fee.Stable.Latest.t, Sgn.t ) Currency.Signed_poly.t )
poly ->
( Account_id.Digest.t, Currency.Fee.Signed.t ) poly Base__Or_error.tCombine the fee excesses from two transitions.
val combine_checked :
( Token_id.Checked.t, Currency.Fee.Signed.var ) poly ->
( Token_id.Checked.t, Currency.Fee.Signed.var ) poly ->
( Token_id.Checked.t, Currency.Fee.Signed.var ) poly
Snark_params.Tick.Checked.tval empty : ( Account_id.Digest.t, Currency.Fee.Signed.t ) polyval is_empty :
( Mina_wire_types.Mina_base.Account_id.Digest.V1.t, Currency.Fee.Signed.t )
poly ->
boolval zero : ( Account_id.Digest.t, Currency.Fee.Signed.t ) polyval is_zero :
( Mina_wire_types.Mina_base.Account_id.Digest.V1.t, Currency.Fee.Signed.t )
poly ->
boolval of_single :
(Token_id.Stable.V2.t
* ( Currency.Fee.Stable.V1.t, Sgn.Stable.V1.t )
Currency.Signed_poly.Stable.V1.t) ->
( Account_id.Digest.t, Currency.Fee.Signed.t ) polyval of_one_or_two :
[< `One of Account_id.Digest.t * Currency.Fee.Signed.t
| `Two of
(Account_id.Digest.t * Currency.Fee.Signed.t)
* (Account_id.Digest.t * Currency.Fee.Signed.t) ] ->
( Account_id.Digest.t, Currency.Fee.Signed.t ) poly Base__Or_error.tval to_one_or_two :
t ->
[> `One of
Token_id.Stable.V2.t
* ( Currency.Fee.Stable.V1.t, Sgn.Stable.V1.t )
Currency.Signed_poly.Stable.V1.t
| `Two of
(Token_id.Stable.V2.t
* ( Currency.Fee.Stable.V1.t, Sgn.Stable.V1.t )
Currency.Signed_poly.Stable.V1.t)
* (Token_id.Stable.V2.t
* ( Currency.Fee.Stable.V1.t, Sgn.Stable.V1.t )
Currency.Signed_poly.Stable.V1.t) ]val gen :
( Account_id.Digest.t, Currency.Fee.Signed.t ) poly
Core_kernel__Quickcheck.Generator.t