Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysiosystem Namespace Reference

Namespaces

namespace  block_info
 

Classes

struct  abi_hash
 
struct  authority
 
struct  bid_refund
 
struct  block_header
 
struct  delegated_bandwidth
 
struct  exchange_state
 
struct  key_weight
 
struct  limit_auth_change
 
struct  name_bid
 
class  native
 
struct  pair_time_point_sec_int64
 
struct  permission_level_weight
 
struct  powerup_config
 
struct  powerup_config_resource
 
struct  powerup_order
 
struct  powerup_state
 
struct  powerup_state_resource
 
struct  producer_info
 
struct  producer_info2
 
struct  refund_request
 
struct  rex_balance
 
struct  rex_fund
 
struct  rex_loan
 
struct  rex_order
 
struct  rex_order_outcome
 
struct  rex_pool
 
struct  rex_return_buckets
 
struct  rex_return_pool
 
struct  sysio_global_state
 
struct  sysio_global_state2
 
struct  sysio_global_state3
 
struct  sysio_global_state4
 
class  system_contract
 
struct  user_resources
 
struct  voter_info
 
struct  wait_weight
 

Typedefs

typedef sysio::multi_index< "rammarket"_n, exchange_staterammarket
 
typedef sysio::multi_index<"limitauthchg"_n, limit_auth_changelimit_auth_change_table
 
using blockchain_parameters_t = sysio::blockchain_parameters
 
typedef sysio::multi_index< "namebids"_n, name_bid, indexed_by<"highbid"_n, const_mem_fun< name_bid, uint64_t, &name_bid::by_high_bid > > > name_bid_table
 
typedef sysio::multi_index< "bidrefunds"_n, bid_refundbid_refund_table
 
typedef sysio::multi_index< "voters"_n, voter_infovoters_table
 
typedef sysio::multi_index< "producers"_n, producer_info, indexed_by<"prototalvote"_n, const_mem_fun< producer_info, double, &producer_info::by_votes > > > producers_table
 
typedef sysio::multi_index< "producers2"_n, producer_info2producers_table2
 
typedef sysio::singleton< "global"_n, sysio_global_stateglobal_state_singleton
 
typedef sysio::singleton< "global2"_n, sysio_global_state2global_state2_singleton
 
typedef sysio::singleton< "global3"_n, sysio_global_state3global_state3_singleton
 
typedef sysio::singleton< "global4"_n, sysio_global_state4global_state4_singleton
 
typedef sysio::multi_index< "userres"_n, user_resourcesuser_resources_table
 
typedef sysio::multi_index< "delband"_n, delegated_bandwidthdel_bandwidth_table
 
typedef sysio::multi_index< "refunds"_n, refund_requestrefunds_table
 
typedef sysio::multi_index< "rexpool"_n, rex_poolrex_pool_table
 
typedef sysio::multi_index< "rexretpool"_n, rex_return_poolrex_return_pool_table
 
typedef sysio::multi_index< "retbuckets"_n, rex_return_bucketsrex_return_buckets_table
 
typedef sysio::multi_index< "rexfund"_n, rex_fundrex_fund_table
 
typedef sysio::multi_index< "rexbal"_n, rex_balancerex_balance_table
 
typedef sysio::multi_index< "cpuloan"_n, rex_loan, indexed_by<"byexpr"_n, const_mem_fun< rex_loan, uint64_t, &rex_loan::by_expr > >, indexed_by<"byowner"_n, const_mem_fun< rex_loan, uint64_t, &rex_loan::by_owner > > > rex_cpu_loan_table
 
typedef sysio::multi_index< "netloan"_n, rex_loan, indexed_by<"byexpr"_n, const_mem_fun< rex_loan, uint64_t, &rex_loan::by_expr > >, indexed_by<"byowner"_n, const_mem_fun< rex_loan, uint64_t, &rex_loan::by_owner > > > rex_net_loan_table
 
typedef sysio::multi_index< "rexqueue"_n, rex_order, indexed_by<"bytime"_n, const_mem_fun< rex_order, uint64_t, &rex_order::by_time > > > rex_order_table
 
typedef sysio::singleton<"powup.state"_n, powerup_statepowerup_state_singleton
 
typedef sysio::multi_index< "powup.order"_n, powerup_order, indexed_by<"byowner"_n, const_mem_fun< powerup_order, uint64_t, &powerup_order::by_owner > >, indexed_by<"byexpires"_n, const_mem_fun< powerup_order, uint64_t, &powerup_order::by_expires > > > powerup_order_table
 

Functions

void check_auth_change (name contract, name account, const binary_extension< name > &authorized_by)
 
sysio::block_signing_authority convert_to_block_signing_authority (const sysio::public_key &producer_key)
 
void validate_b1_vesting (int64_t stake)
 
void update_weight (time_point_sec now, powerup_state_resource &res, int64_t &delta_available)
 
void update_utilization (time_point_sec now, powerup_state_resource &res)
 
int64_t calc_powerup_fee (const powerup_state_resource &state, int64_t utilization_increase)
 
double get_continuous_rate (int64_t annual_rate)
 
double stake2vote (int64_t staked)
 

Variables

constexpr int64_t powerup_frac = 1'000'000'000'000'000ll
 

Typedef Documentation

◆ bid_refund_table

typedef sysio::multi_index< "bidrefunds"_n, bid_refund > sysiosystem::bid_refund_table

Definition at line 138 of file sysio.system.hpp.

◆ blockchain_parameters_t

using sysiosystem::blockchain_parameters_t = sysio::blockchain_parameters

Definition at line 93 of file sysio.system.hpp.

◆ del_bandwidth_table

typedef sysio::multi_index< "delband"_n, delegated_bandwidth > sysiosystem::del_bandwidth_table

Definition at line 384 of file sysio.system.hpp.

◆ global_state2_singleton

typedef sysio::singleton< "global2"_n, sysio_global_state2 > sysiosystem::global_state2_singleton

Definition at line 335 of file sysio.system.hpp.

◆ global_state3_singleton

typedef sysio::singleton< "global3"_n, sysio_global_state3 > sysiosystem::global_state3_singleton

Definition at line 337 of file sysio.system.hpp.

◆ global_state4_singleton

typedef sysio::singleton< "global4"_n, sysio_global_state4 > sysiosystem::global_state4_singleton

Definition at line 339 of file sysio.system.hpp.

◆ global_state_singleton

typedef sysio::singleton< "global"_n, sysio_global_state > sysiosystem::global_state_singleton

Definition at line 333 of file sysio.system.hpp.

◆ limit_auth_change_table

typedef sysio::multi_index<"limitauthchg"_n, limit_auth_change> sysiosystem::limit_auth_change_table

Definition at line 19 of file limit_auth_changes.hpp.

◆ name_bid_table

typedef sysio::multi_index< "namebids"_n, name_bid, indexed_by<"highbid"_n, const_mem_fun<name_bid, uint64_t, &name_bid::by_high_bid> > > sysiosystem::name_bid_table

Definition at line 136 of file sysio.system.hpp.

◆ powerup_order_table

typedef sysio::multi_index< "powup.order"_n, powerup_order, indexed_by<"byowner"_n, const_mem_fun<powerup_order, uint64_t, &powerup_order::by_owner> >, indexed_by<"byexpires"_n, const_mem_fun<powerup_order, uint64_t, &powerup_order::by_expires> > > sysiosystem::powerup_order_table

Definition at line 663 of file sysio.system.hpp.

◆ powerup_state_singleton

typedef sysio::singleton<"powup.state"_n, powerup_state> sysiosystem::powerup_state_singleton

Definition at line 645 of file sysio.system.hpp.

◆ producers_table

typedef sysio::multi_index< "producers"_n, producer_info, indexed_by<"prototalvote"_n, const_mem_fun<producer_info, double, &producer_info::by_votes> > > sysiosystem::producers_table

Definition at line 328 of file sysio.system.hpp.

◆ producers_table2

typedef sysio::multi_index< "producers2"_n, producer_info2 > sysiosystem::producers_table2

Definition at line 330 of file sysio.system.hpp.

◆ rammarket

typedef sysio::multi_index< "rammarket"_n, exchange_state > sysiosystem::rammarket

Definition at line 47 of file exchange_state.hpp.

◆ refunds_table

typedef sysio::multi_index< "refunds"_n, refund_request > sysiosystem::refunds_table

Definition at line 385 of file sysio.system.hpp.

◆ rex_balance_table

typedef sysio::multi_index< "rexbal"_n, rex_balance > sysiosystem::rex_balance_table

Definition at line 488 of file sysio.system.hpp.

◆ rex_cpu_loan_table

typedef sysio::multi_index< "cpuloan"_n, rex_loan, indexed_by<"byexpr"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_expr> >, indexed_by<"byowner"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_owner> > > sysiosystem::rex_cpu_loan_table

Definition at line 518 of file sysio.system.hpp.

◆ rex_fund_table

typedef sysio::multi_index< "rexfund"_n, rex_fund > sysiosystem::rex_fund_table

Definition at line 469 of file sysio.system.hpp.

◆ rex_net_loan_table

typedef sysio::multi_index< "netloan"_n, rex_loan, indexed_by<"byexpr"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_expr> >, indexed_by<"byowner"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_owner> > > sysiosystem::rex_net_loan_table

Definition at line 523 of file sysio.system.hpp.

◆ rex_order_table

typedef sysio::multi_index< "rexqueue"_n, rex_order, indexed_by<"bytime"_n, const_mem_fun<rex_order, uint64_t, &rex_order::by_time> > > sysiosystem::rex_order_table

Definition at line 540 of file sysio.system.hpp.

◆ rex_pool_table

typedef sysio::multi_index< "rexpool"_n, rex_pool > sysiosystem::rex_pool_table

Definition at line 409 of file sysio.system.hpp.

◆ rex_return_buckets_table

typedef sysio::multi_index< "retbuckets"_n, rex_return_buckets > sysiosystem::rex_return_buckets_table

Definition at line 455 of file sysio.system.hpp.

◆ rex_return_pool_table

typedef sysio::multi_index< "rexretpool"_n, rex_return_pool > sysiosystem::rex_return_pool_table

Definition at line 436 of file sysio.system.hpp.

◆ user_resources_table

typedef sysio::multi_index< "userres"_n, user_resources > sysiosystem::user_resources_table

Definition at line 383 of file sysio.system.hpp.

◆ voters_table

typedef sysio::multi_index< "voters"_n, voter_info > sysiosystem::voters_table

Definition at line 323 of file sysio.system.hpp.

Function Documentation

◆ calc_powerup_fee()

int64_t sysiosystem::calc_powerup_fee ( const powerup_state_resource & state,
int64_t utilization_increase )
Precondition
0 <= state.min_price.amount <= state.max_price.amount
0 < state.max_price.amount
1.0 <= state.exponent
0 <= state.utilization <= state.adjusted_utilization <= state.weight
0 <= utilization_increase <= (state.weight - state.utilization)

Definition at line 262 of file powerup.cpp.

262 {
263 if( utilization_increase <= 0 ) return 0;
264
265 // Let p(u) = price as a function of the utilization fraction u which is defined for u in [0.0, 1.0].
266 // Let f(u) = integral of the price function p(x) from x = 0.0 to x = u, again defined for u in [0.0, 1.0].
267
268 // In particular we choose f(u) = min_price * u + ((max_price - min_price) / exponent) * (u ^ exponent).
269 // And so p(u) = min_price + (max_price - min_price) * (u ^ (exponent - 1.0)).
270
271 // Returns f(double(end_utilization)/state.weight) - f(double(start_utilization)/state.weight) which is equivalent to
272 // the integral of p(x) from x = double(start_utilization)/state.weight to x = double(end_utilization)/state.weight.
273 // @pre 0 <= start_utilization <= end_utilization <= state.weight
274 auto price_integral_delta = [&state](int64_t start_utilization, int64_t end_utilization) -> double {
275 double coefficient = (state.max_price.amount - state.min_price.amount) / state.exponent;
276 double start_u = double(start_utilization) / state.weight;
277 double end_u = double(end_utilization) / state.weight;
278 return state.min_price.amount * end_u - state.min_price.amount * start_u +
279 coefficient * std::pow(end_u, state.exponent) - coefficient * std::pow(start_u, state.exponent);
280 };
281
282 // Returns p(double(utilization)/state.weight).
283 // @pre 0 <= utilization <= state.weight
284 auto price_function = [&state](int64_t utilization) -> double {
285 double price = state.min_price.amount;
286 // state.exponent >= 1.0, therefore the exponent passed into std::pow is >= 0.0.
287 // Since the exponent passed into std::pow could be 0.0 and simultaneously so could double(utilization)/state.weight,
288 // the safest thing to do is handle that as a special case explicitly rather than relying on std::pow to return 1.0
289 // instead of triggering a domain error.
290 double new_exponent = state.exponent - 1.0;
291 if (new_exponent <= 0.0) {
292 return state.max_price.amount;
293 } else {
294 price += (state.max_price.amount - state.min_price.amount) * std::pow(double(utilization) / state.weight, new_exponent);
295 }
296
297 return price;
298 };
299
300 double fee = 0.0;
301 int64_t start_utilization = state.utilization;
302 int64_t end_utilization = start_utilization + utilization_increase;
303
304 if (start_utilization < state.adjusted_utilization) {
305 fee += price_function(state.adjusted_utilization) *
306 std::min(utilization_increase, state.adjusted_utilization - start_utilization) / state.weight;
307 start_utilization = state.adjusted_utilization;
308 }
309
310 if (start_utilization < end_utilization) {
311 fee += price_integral_delta(start_utilization, end_utilization);
312 }
313
314 return std::ceil(fee);
315}
signed __int64 int64_t
Definition stdint.h:135
Here is the caller graph for this function:

◆ check_auth_change()

void sysiosystem::check_auth_change ( name contract,
name account,
const binary_extension< name > & authorized_by )

Definition at line 37 of file limit_auth_changes.cpp.

37 {
38 name by(authorized_by.has_value() ? authorized_by.value().value : 0);
39 if(by.value)
40 sysio::require_auth({account, by});
41 limit_auth_change_table table(contract, contract.value);
42 auto it = table.find(account.value);
43 if(it == table.end())
44 return;
45 sysio::check(by.value, "authorized_by is required for this account");
46 if(!it->allow_perms.empty())
47 sysio::check(
48 std::find(it->allow_perms.begin(), it->allow_perms.end(), by) != it->allow_perms.end(),
49 "authorized_by does not appear in allow_perms");
50 else
51 sysio::check(
52 std::find(it->disallow_perms.begin(), it->disallow_perms.end(), by) == it->disallow_perms.end(),
53 "authorized_by appears in disallow_perms");
54 }
Immutable except for fc::from_variant.
Definition name.hpp:43
Here is the caller graph for this function:

◆ convert_to_block_signing_authority()

sysio::block_signing_authority sysiosystem::convert_to_block_signing_authority ( const sysio::public_key & producer_key)
inline

Definition at line 200 of file sysio.system.hpp.

200 {
201 return sysio::block_signing_authority_v0{ .threshold = 1, .keys = {{producer_key, 1}} };
202 }
Here is the caller graph for this function:

◆ get_continuous_rate()

double sysiosystem::get_continuous_rate ( int64_t annual_rate)

Definition at line 14 of file sysio.system.cpp.

14 {
15 return std::log1p(double(annual_rate)/double(100*inflation_precision));
16 }
Here is the caller graph for this function:

◆ stake2vote()

double sysiosystem::stake2vote ( int64_t staked)

TODO subtract 2080 brings the large numbers closer to this decade

Definition at line 145 of file voting.cpp.

145 {
147 double weight = int64_t( (current_time_point().sec_since_epoch() - (block_timestamp::block_timestamp_epoch / 1000)) / (seconds_per_day * 7) ) / double( 52 );
148 return double(staked) * std::pow( 2, weight );
149 }

◆ update_utilization()

void sysiosystem::update_utilization ( time_point_sec now,
powerup_state_resource & res )
Precondition
now >= res.utilization_timestamp
Postcondition
res.utilization <= new res.adjusted_utilization
if res.utilization < old res.adjusted_utilization, then new res.adjusted_utilization <= old res.adjusted_utilization
if res.utilization >= old res.adjusted_utilization, then new res.adjusted_utilization == res.utilization

Definition at line 105 of file powerup.cpp.

105 {
106 if (now <= res.utilization_timestamp) return;
107
108 if (res.utilization >= res.adjusted_utilization) {
110 } else {
112 int64_t delta = diff * std::exp(-double(now.utc_seconds - res.utilization_timestamp.utc_seconds) / double(res.decay_secs));
113 delta = std::clamp( delta, 0ll, diff);
114 res.adjusted_utilization = res.utilization + delta;
115 }
116 res.utilization_timestamp = now;
117}
void diff(const std::string &a, const std::string &b)
Definition jmp.cpp:18
Here is the call graph for this function:
Here is the caller graph for this function:

◆ update_weight()

void sysiosystem::update_weight ( time_point_sec now,
powerup_state_resource & res,
int64_t & delta_available )

Definition at line 91 of file powerup.cpp.

91 {
92 if (now >= res.target_timestamp) {
94 } else {
96 int128_t(res.target_weight_ratio - res.initial_weight_ratio) *
97 (now.utc_seconds - res.initial_timestamp.utc_seconds) /
98 (res.target_timestamp.utc_seconds - res.initial_timestamp.utc_seconds);
99 }
100 int64_t new_weight = res.assumed_stake_weight * int128_t(powerup_frac) / res.weight_ratio - res.assumed_stake_weight;
101 delta_available += new_weight - res.weight;
102 res.weight = new_weight;
103}
__int128 int128_t
Definition types.hpp:241
Here is the caller graph for this function:

◆ validate_b1_vesting()

void sysiosystem::validate_b1_vesting ( int64_t stake)

Friday, June 1, 2018 12:00:00 AM UTC

Tuesday, December 7, 2021 11:59:00 PM UTC

Definition at line 161 of file delegate_bandwidth.cpp.

161 {
162 const int64_t base_time = 1527811200;
163 const int64_t current_time = 1638921540;
164 const int64_t max_claimable = 100'000'000'0000ll;
165 const int64_t claimable = int64_t(max_claimable * double(current_time - base_time) / (10*seconds_per_year) );
166
167 check( max_claimable - claimable <= stake, "b1 can only claim their tokens over 10 years" );
168 }

Variable Documentation

◆ powerup_frac

int64_t sysiosystem::powerup_frac = 1'000'000'000'000'000ll
inlineconstexpr

Definition at line 44 of file sysio.system.hpp.