Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysio.system.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <sysio/asset.hpp>
4#include <sysio/binary_extension.hpp>
5#include <sysio/privileged.hpp>
6#include <sysio/producer_schedule.hpp>
7#include <sysio/singleton.hpp>
8#include <sysio/system.hpp>
9#include <sysio/time.hpp>
10
13
14#include <deque>
15#include <optional>
16#include <string>
17#include <type_traits>
18
19#ifdef CHANNEL_RAM_AND_NAMEBID_FEES_TO_REX
20#undef CHANNEL_RAM_AND_NAMEBID_FEES_TO_REX
21#endif
22// CHANNEL_RAM_AND_NAMEBID_FEES_TO_REX macro determines whether ramfee and namebid proceeds are
23// channeled to REX pool. In order to stop these proceeds from being channeled, the macro must
24// be set to 0.
25#define CHANNEL_RAM_AND_NAMEBID_FEES_TO_REX 1
26
27namespace sysiosystem {
28
29 using sysio::asset;
30 using sysio::binary_extension;
32 using sysio::check;
33 using sysio::const_mem_fun;
35 using sysio::indexed_by;
36 using sysio::name;
37 using sysio::same_payer;
38 using sysio::symbol;
43
44 inline constexpr int64_t powerup_frac = 1'000'000'000'000'000ll; // 1.0 = 10^15
45
46 template<typename E, typename F>
47 static inline auto has_field( F flags, E field )
48 -> std::enable_if_t< std::is_integral_v<F> && std::is_unsigned_v<F> &&
49 std::is_enum_v<E> && std::is_same_v< F, std::underlying_type_t<E> >, bool>
50 {
51 return ( (flags & static_cast<F>(field)) != 0 );
52 }
53
54 template<typename E, typename F>
55 static inline auto set_field( F flags, E field, bool value = true )
56 -> std::enable_if_t< std::is_integral_v<F> && std::is_unsigned_v<F> &&
57 std::is_enum_v<E> && std::is_same_v< F, std::underlying_type_t<E> >, F >
58 {
59 if( value )
60 return ( flags | static_cast<F>(field) );
61 else
62 return ( flags & ~static_cast<F>(field) );
63 }
64
65 static constexpr uint32_t seconds_per_year = 52 * 7 * 24 * 3600;
66 static constexpr uint32_t seconds_per_day = 24 * 3600;
67 static constexpr uint32_t seconds_per_hour = 3600;
68 static constexpr int64_t useconds_per_year = int64_t(seconds_per_year) * 1000'000ll;
69 static constexpr int64_t useconds_per_day = int64_t(seconds_per_day) * 1000'000ll;
70 static constexpr int64_t useconds_per_hour = int64_t(seconds_per_hour) * 1000'000ll;
71 static constexpr uint32_t blocks_per_day = 2 * seconds_per_day; // half seconds per day
72
73 static constexpr int64_t min_activated_stake = 150'000'000'0000;
74 static constexpr int64_t ram_gift_bytes = 1400;
75 static constexpr int64_t min_pervote_daily_pay = 100'0000;
76 static constexpr uint32_t refund_delay_sec = 3 * seconds_per_day;
77
78 static constexpr int64_t inflation_precision = 100; // 2 decimals
79 static constexpr int64_t default_annual_rate = 500; // 5% annual rate
80 static constexpr int64_t pay_factor_precision = 10000;
81 static constexpr int64_t default_inflation_pay_factor = 50000; // producers pay share = 10000 / 50000 = 20% of the inflation
82 static constexpr int64_t default_votepay_factor = 40000; // per-block pay share = 10000 / 40000 = 25% of the producer pay
83
84#ifdef SYSTEM_BLOCKCHAIN_PARAMETERS
85 struct blockchain_parameters_v1 : sysio::blockchain_parameters
86 {
87 sysio::binary_extension<uint32_t> max_action_return_value_size;
88 SYSLIB_SERIALIZE_DERIVED( blockchain_parameters_v1, sysio::blockchain_parameters,
89 (max_action_return_value_size) )
90 };
91 using blockchain_parameters_t = blockchain_parameters_v1;
92#else
94#endif
95
110 // A name bid, which consists of:
111 // - a `newname` name that the bid is for
112 // - a `high_bidder` account name that is the one with the highest bid so far
113 // - the `high_bid` which is amount of highest bid
114 // - and `last_bid_time` which is the time of the highest bid
115 struct [[sysio::table, sysio::contract("sysio.system")]] name_bid {
118 int64_t high_bid = 0;
120
121 uint64_t primary_key()const { return newname.value; }
122 uint64_t by_high_bid()const { return static_cast<uint64_t>(-high_bid); }
123 };
124
125 // A bid refund, which is defined by:
126 // - the `bidder` account name owning the refund
127 // - the `amount` to be refunded
128 struct [[sysio::table, sysio::contract("sysio.system")]] bid_refund {
131
132 uint64_t primary_key()const { return bidder.value; }
133 };
134 typedef sysio::multi_index< "namebids"_n, name_bid,
135 indexed_by<"highbid"_n, const_mem_fun<name_bid, uint64_t, &name_bid::by_high_bid> >
137
138 typedef sysio::multi_index< "bidrefunds"_n, bid_refund > bid_refund_table;
139
140 // Defines new global state parameters.
141 struct [[sysio::table("global"), sysio::contract("sysio.system")]] sysio_global_state : sysio::blockchain_parameters {
142 uint64_t free_ram()const { return max_ram_size - total_ram_bytes_reserved; }
143
144 uint64_t max_ram_size = 64ll*1024 * 1024 * 1024;
145 uint64_t total_ram_bytes_reserved = 0;
146 int64_t total_ram_stake = 0;
147
150 int64_t pervote_bucket = 0;
151 int64_t perblock_bucket = 0;
152 uint32_t total_unpaid_blocks = 0;
153 int64_t total_activated_stake = 0;
155 uint16_t last_producer_schedule_size = 0;
156 double total_producer_vote_weight = 0;
158
159 // explicit serialization macro is not necessary, used here only to improve compilation time
160 SYSLIB_SERIALIZE_DERIVED( sysio_global_state, sysio::blockchain_parameters,
161 (max_ram_size)(total_ram_bytes_reserved)(total_ram_stake)
162 (last_producer_schedule_update)(last_pervote_bucket_fill)
163 (pervote_bucket)(perblock_bucket)(total_unpaid_blocks)(total_activated_stake)(thresh_activated_stake_time)
164 (last_producer_schedule_size)(total_producer_vote_weight)(last_name_close) )
165 };
166
167 // Defines new global state parameters added after version 1.0
168 struct [[sysio::table("global2"), sysio::contract("sysio.system")]] sysio_global_state2 {
170
171 uint16_t new_ram_per_block = 0;
174 double total_producer_votepay_share = 0;
175 uint8_t revision = 0;
176
177 SYSLIB_SERIALIZE( sysio_global_state2, (new_ram_per_block)(last_ram_increase)(last_block_num)
178 (total_producer_votepay_share)(revision) )
179 };
180
181 // Defines new global state parameters added after version 1.3.0
182 struct [[sysio::table("global3"), sysio::contract("sysio.system")]] sysio_global_state3 {
185 double total_vpay_share_change_rate = 0;
186
187 SYSLIB_SERIALIZE( sysio_global_state3, (last_vpay_state_update)(total_vpay_share_change_rate) )
188 };
189
190 // Defines new global state parameters to store inflation rate and distribution
191 struct [[sysio::table("global4"), sysio::contract("sysio.system")]] sysio_global_state4 {
196
197 SYSLIB_SERIALIZE( sysio_global_state4, (continuous_rate)(inflation_pay_factor)(votepay_factor) )
198 };
199
201 return sysio::block_signing_authority_v0{ .threshold = 1, .keys = {{producer_key, 1}} };
202 }
203
204 // Defines `producer_info` structure to be stored in `producer_info` table, added after version 1.0
205 struct [[sysio::table, sysio::contract("sysio.system")]] producer_info {
207 double total_votes = 0;
209 bool is_active = true;
210 std::string url;
211 uint32_t unpaid_blocks = 0;
213 uint16_t location = 0;
214 sysio::binary_extension<sysio::block_signing_authority> producer_authority; // added in version 1.9.0
215
216 uint64_t primary_key()const { return owner.value; }
217 double by_votes()const { return is_active ? -total_votes : total_votes; }
218 bool active()const { return is_active; }
219 void deactivate() { producer_key = public_key(); producer_authority.reset(); is_active = false; }
220
222 if( producer_authority.has_value() ) {
223 bool zero_threshold = std::visit( [](auto&& auth ) -> bool {
224 return (auth.threshold == 0);
225 }, *producer_authority );
226 // zero_threshold could be true despite the validation done in regproducer2 because the v1.9.0 sysio.system
227 // contract has a bug which may have modified the producer table such that the producer_authority field
228 // contains a default constructed sysio::block_signing_authority (which has a 0 threshold and so is invalid).
229 if( !zero_threshold ) return *producer_authority;
230 }
231 return convert_to_block_signing_authority( producer_key );
232 }
233
234 // The unregprod and claimrewards actions modify unrelated fields of the producers table and under the default
235 // serialization behavior they would increase the size of the serialized table if the producer_authority field
236 // was not already present. This is acceptable (though not necessarily desired) because those two actions require
237 // the authority of the producer who pays for the table rows.
238 // However, the rmvproducer action and the onblock transaction would also modify the producer table in a similar
239 // way and increasing its serialized size is not acceptable in that context.
240 // So, a custom serialization is defined to handle the binary_extension producer_authority
241 // field in the desired way. (Note: v1.9.0 did not have this custom serialization behavior.)
242
243 template<typename DataStream>
244 friend DataStream& operator << ( DataStream& ds, const producer_info& t ) {
245 ds << t.owner
246 << t.total_votes
247 << t.producer_key
248 << t.is_active
249 << t.url
250 << t.unpaid_blocks
251 << t.last_claim_time
252 << t.location;
253
254 if( !t.producer_authority.has_value() ) return ds;
255
256 return ds << t.producer_authority;
257 }
258
259 template<typename DataStream>
260 friend DataStream& operator >> ( DataStream& ds, producer_info& t ) {
261 return ds >> t.owner
262 >> t.total_votes
263 >> t.producer_key
264 >> t.is_active
265 >> t.url
266 >> t.unpaid_blocks
267 >> t.last_claim_time
268 >> t.location
270 }
271 };
272
273 // Defines new producer info structure to be stored in new producer info table, added after version 1.3.0
274 struct [[sysio::table, sysio::contract("sysio.system")]] producer_info2 {
276 double votepay_share = 0;
278
279 uint64_t primary_key()const { return owner.value; }
280
281 // explicit serialization macro is not necessary, used here only to improve compilation time
282 SYSLIB_SERIALIZE( producer_info2, (owner)(votepay_share)(last_votepay_share_update) )
283 };
284
285 // Voter info. Voter info stores information about the voter:
286 // - `owner` the voter
287 // - `proxy` the proxy set by the voter, if any
288 // - `producers` the producers approved by this voter if no proxy set
289 // - `staked` the amount staked
290 struct [[sysio::table, sysio::contract("sysio.system")]] voter_info {
293 std::vector<name> producers;
294 int64_t staked = 0;
295
296 // Every time a vote is cast we must first "undo" the last vote weight, before casting the
297 // new vote weight. Vote weight is calculated as:
298 // stated.amount * 2 ^ ( weeks_since_launch/weeks_per_year)
299 double last_vote_weight = 0;
300
301 // Total vote weight delegated to this voter.
302 double proxied_vote_weight= 0;
303 bool is_proxy = 0;
304
305
306 uint32_t flags1 = 0;
307 uint32_t reserved2 = 0;
309
310 uint64_t primary_key()const { return owner.value; }
311
312 enum class flags1_fields : uint32_t {
313 ram_managed = 1,
314 net_managed = 2,
315 cpu_managed = 4
316 };
317
318 // explicit serialization macro is not necessary, used here only to improve compilation time
319 SYSLIB_SERIALIZE( voter_info, (owner)(proxy)(producers)(staked)(last_vote_weight)(proxied_vote_weight)(is_proxy)(flags1)(reserved2)(reserved3) )
320 };
321
322
323 typedef sysio::multi_index< "voters"_n, voter_info > voters_table;
324
325
326 typedef sysio::multi_index< "producers"_n, producer_info,
327 indexed_by<"prototalvote"_n, const_mem_fun<producer_info, double, &producer_info::by_votes> >
329
330 typedef sysio::multi_index< "producers2"_n, producer_info2 > producers_table2;
331
332
333 typedef sysio::singleton< "global"_n, sysio_global_state > global_state_singleton;
334
335 typedef sysio::singleton< "global2"_n, sysio_global_state2 > global_state2_singleton;
336
337 typedef sysio::singleton< "global3"_n, sysio_global_state3 > global_state3_singleton;
338
339 typedef sysio::singleton< "global4"_n, sysio_global_state4 > global_state4_singleton;
340
341 struct [[sysio::table, sysio::contract("sysio.system")]] user_resources {
345 int64_t ram_bytes = 0;
346
347 bool is_empty()const { return net_weight.amount == 0 && cpu_weight.amount == 0 && ram_bytes == 0; }
348 uint64_t primary_key()const { return owner.value; }
349
350 // explicit serialization macro is not necessary, used here only to improve compilation time
351 SYSLIB_SERIALIZE( user_resources, (owner)(net_weight)(cpu_weight)(ram_bytes) )
352 };
353
354 // Every user 'from' has a scope/table that uses every recipient 'to' as the primary key.
355 struct [[sysio::table, sysio::contract("sysio.system")]] delegated_bandwidth {
360
361 bool is_empty()const { return net_weight.amount == 0 && cpu_weight.amount == 0; }
362 uint64_t primary_key()const { return to.value; }
363
364 // explicit serialization macro is not necessary, used here only to improve compilation time
365 SYSLIB_SERIALIZE( delegated_bandwidth, (from)(to)(net_weight)(cpu_weight) )
366
367 };
368
369 struct [[sysio::table, sysio::contract("sysio.system")]] refund_request {
374
375 bool is_empty()const { return net_amount.amount == 0 && cpu_amount.amount == 0; }
376 uint64_t primary_key()const { return owner.value; }
377
378 // explicit serialization macro is not necessary, used here only to improve compilation time
379 SYSLIB_SERIALIZE( refund_request, (owner)(request_time)(net_amount)(cpu_amount) )
380 };
381
382
383 typedef sysio::multi_index< "userres"_n, user_resources > user_resources_table;
384 typedef sysio::multi_index< "delband"_n, delegated_bandwidth > del_bandwidth_table;
385 typedef sysio::multi_index< "refunds"_n, refund_request > refunds_table;
386
387 // `rex_pool` structure underlying the rex pool table. A rex pool table entry is defined by:
388 // - `version` defaulted to zero,
389 // - `total_lent` total amount of CORE_SYMBOL in open rex_loans
390 // - `total_unlent` total amount of CORE_SYMBOL available to be lent (connector),
391 // - `total_rent` fees received in exchange for lent (connector),
392 // - `total_lendable` total amount of CORE_SYMBOL that have been lent (total_unlent + total_lent),
393 // - `total_rex` total number of REX shares allocated to contributors to total_lendable,
394 // - `namebid_proceeds` the amount of CORE_SYMBOL to be transferred from namebids to REX pool,
395 // - `loan_num` increments with each new loan
396 struct [[sysio::table,sysio::contract("sysio.system")]] rex_pool {
397 uint8_t version = 0;
404 uint64_t loan_num = 0;
405
406 uint64_t primary_key()const { return 0; }
407 };
408
409 typedef sysio::multi_index< "rexpool"_n, rex_pool > rex_pool_table;
410
411 // `rex_return_pool` structure underlying the rex return pool table. A rex return pool table entry is defined by:
412 // - `version` defaulted to zero,
413 // - `last_dist_time` the last time proceeds from renting, ram fees, and name bids were added to the rex pool,
414 // - `pending_bucket_time` timestamp of the pending 12-hour return bucket,
415 // - `oldest_bucket_time` cached timestamp of the oldest 12-hour return bucket,
416 // - `pending_bucket_proceeds` proceeds in the pending 12-hour return bucket,
417 // - `current_rate_of_increase` the current rate per dist_interval at which proceeds are added to the rex pool,
418 // - `proceeds` the maximum amount of proceeds that can be added to the rex pool at any given time
419 struct [[sysio::table,sysio::contract("sysio.system")]] rex_return_pool {
420 uint8_t version = 0;
422 time_point_sec pending_bucket_time = time_point_sec::maximum();
423 time_point_sec oldest_bucket_time = time_point_sec::min();
424 int64_t pending_bucket_proceeds = 0;
425 int64_t current_rate_of_increase = 0;
426 int64_t proceeds = 0;
427
428 static constexpr uint32_t total_intervals = 30 * 144; // 30 days
429 static constexpr uint32_t dist_interval = 10 * 60; // 10 minutes
430 static constexpr uint8_t hours_per_bucket = 12;
431 static_assert( total_intervals * dist_interval == 30 * seconds_per_day );
432
433 uint64_t primary_key()const { return 0; }
434 };
435
436 typedef sysio::multi_index< "rexretpool"_n, rex_return_pool > rex_return_pool_table;
437
444
445 // `rex_return_buckets` structure underlying the rex return buckets table. A rex return buckets table is defined by:
446 // - `version` defaulted to zero,
447 // - `return_buckets` buckets of proceeds accumulated in 12-hour intervals
448 struct [[sysio::table,sysio::contract("sysio.system")]] rex_return_buckets {
449 uint8_t version = 0;
450 std::vector<pair_time_point_sec_int64> return_buckets; // sorted by first field
451
452 uint64_t primary_key()const { return 0; }
453 };
454
455 typedef sysio::multi_index< "retbuckets"_n, rex_return_buckets > rex_return_buckets_table;
456
457 // `rex_fund` structure underlying the rex fund table. A rex fund table entry is defined by:
458 // - `version` defaulted to zero,
459 // - `owner` the owner of the rex fund,
460 // - `balance` the balance of the fund.
461 struct [[sysio::table,sysio::contract("sysio.system")]] rex_fund {
462 uint8_t version = 0;
465
466 uint64_t primary_key()const { return owner.value; }
467 };
468
469 typedef sysio::multi_index< "rexfund"_n, rex_fund > rex_fund_table;
470
471 // `rex_balance` structure underlying the rex balance table. A rex balance table entry is defined by:
472 // - `version` defaulted to zero,
473 // - `owner` the owner of the rex fund,
474 // - `vote_stake` the amount of CORE_SYMBOL currently included in owner's vote,
475 // - `rex_balance` the amount of REX owned by owner,
476 // - `matured_rex` matured REX available for selling
477 struct [[sysio::table,sysio::contract("sysio.system")]] rex_balance {
478 uint8_t version = 0;
482 int64_t matured_rex = 0;
483 std::vector<pair_time_point_sec_int64> rex_maturities;
484
485 uint64_t primary_key()const { return owner.value; }
486 };
487
488 typedef sysio::multi_index< "rexbal"_n, rex_balance > rex_balance_table;
489
490 // `rex_loan` structure underlying the `rex_cpu_loan_table` and `rex_net_loan_table`. A rex net/cpu loan table entry is defined by:
491 // - `version` defaulted to zero,
492 // - `from` account creating and paying for loan,
493 // - `receiver` account receiving rented resources,
494 // - `payment` SYS tokens paid for the loan,
495 // - `balance` is the amount of SYS tokens available to be used for loan auto-renewal,
496 // - `total_staked` total amount staked,
497 // - `loan_num` loan number/id,
498 // - `expiration` the expiration time when loan will be either closed or renewed
499 // If payment <= balance, the loan is renewed, and closed otherwise.
500 struct [[sysio::table,sysio::contract("sysio.system")]] rex_loan {
501 uint8_t version = 0;
509
510 uint64_t primary_key()const { return loan_num; }
511 uint64_t by_expr()const { return expiration.elapsed.count(); }
512 uint64_t by_owner()const { return from.value; }
513 };
514
515 typedef sysio::multi_index< "cpuloan"_n, rex_loan,
516 indexed_by<"byexpr"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_expr>>,
517 indexed_by<"byowner"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_owner>>
519
520 typedef sysio::multi_index< "netloan"_n, rex_loan,
521 indexed_by<"byexpr"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_expr>>,
522 indexed_by<"byowner"_n, const_mem_fun<rex_loan, uint64_t, &rex_loan::by_owner>>
524
525 struct [[sysio::table,sysio::contract("sysio.system")]] rex_order {
526 uint8_t version = 0;
532 bool is_open = true;
533
534 void close() { is_open = false; }
535 uint64_t primary_key()const { return owner.value; }
536 uint64_t by_time()const { return is_open ? order_time.elapsed.count() : std::numeric_limits<uint64_t>::max(); }
537 };
538
539 typedef sysio::multi_index< "rexqueue"_n, rex_order,
540 indexed_by<"bytime"_n, const_mem_fun<rex_order, uint64_t, &rex_order::by_time>>> rex_order_table;
541
547
549 std::optional<int64_t> current_weight_ratio; // Immediately set weight_ratio to this amount. 1x = 10^15. 0.01x = 10^13.
550 // Do not specify to preserve the existing setting or use the default;
551 // this avoids sudden price jumps. For new chains which don't need
552 // to gradually phase out staking and REX, 0.01x (10^13) is a good
553 // value for both current_weight_ratio and target_weight_ratio.
554 std::optional<int64_t> target_weight_ratio; // Linearly shrink weight_ratio to this amount. 1x = 10^15. 0.01x = 10^13.
555 // Do not specify to preserve the existing setting or use the default.
556 std::optional<int64_t> assumed_stake_weight; // Assumed stake weight for ratio calculations. Use the sum of total
557 // staked and total rented by REX at the time the power market
558 // is first activated. Do not specify to preserve the existing
559 // setting (no default exists); this avoids sudden price jumps.
560 // For new chains which don't need to phase out staking and REX,
561 // 10^12 is probably a good value.
562 std::optional<time_point_sec> target_timestamp; // Stop automatic weight_ratio shrinkage at this time. Once this
563 // time hits, weight_ratio will be target_weight_ratio. Ignored
564 // if current_weight_ratio == target_weight_ratio. Do not specify
565 // this to preserve the existing setting (no default exists).
566 std::optional<double> exponent; // Exponent of resource price curve. Must be >= 1. Do not specify
567 // to preserve the existing setting or use the default.
568 std::optional<uint32_t> decay_secs; // Number of seconds for the gap between adjusted resource
569 // utilization and instantaneous resource utilization to shrink
570 // by 63%. Do not specify to preserve the existing setting or
571 // use the default.
572 std::optional<asset> min_price; // Fee needed to reserve the entire resource market weight at the
573 // minimum price. For example, this could be set to 0.005% of
574 // total token supply. Do not specify to preserve the existing
575 // setting or use the default.
576 std::optional<asset> max_price; // Fee needed to reserve the entire resource market weight at the
577 // maximum price. For example, this could be set to 10% of total
578 // token supply. Do not specify to preserve the existing
579 // setting (no default exists).
580
583 };
584
586 powerup_config_resource net; // NET market configuration
587 powerup_config_resource cpu; // CPU market configuration
588 std::optional<uint32_t> powerup_days; // `powerup` `days` argument must match this. Do not specify to preserve the
589 // existing setting or use the default.
590 std::optional<asset> min_powerup_fee; // Fees below this amount are rejected. Do not specify to preserve the
591 // existing setting (no default exists).
592
593 SYSLIB_SERIALIZE( powerup_config, (net)(cpu)(powerup_days)(min_powerup_fee) )
594 };
595
597 static constexpr double default_exponent = 2.0; // Exponent of 2.0 means that the price to reserve a
598 // tiny amount of resources increases linearly
599 // with utilization.
600 static constexpr uint32_t default_decay_secs = 1 * seconds_per_day; // 1 day; if 100% of bandwidth resources are in a
601 // single loan, then, assuming no further powerup usage,
602 // 1 day after it expires the adjusted utilization
603 // will be at approximately 37% and after 3 days
604 // the adjusted utilization will be less than 5%.
605
607 int64_t weight = 0; // resource market weight. calculated; varies over time.
608 // 1 represents the same amount of resources as 1
609 // satoshi of SYS staked.
610 int64_t weight_ratio = 0; // resource market weight ratio:
611 // assumed_stake_weight / (assumed_stake_weight + weight).
612 // calculated; varies over time. 1x = 10^15. 0.01x = 10^13.
613 int64_t assumed_stake_weight = 0; // Assumed stake weight for ratio calculations.
614 int64_t initial_weight_ratio = powerup_frac; // Initial weight_ratio used for linear shrinkage.
615 int64_t target_weight_ratio = powerup_frac / 100; // Linearly shrink the weight_ratio to this amount.
616 time_point_sec initial_timestamp = {}; // When weight_ratio shrinkage started
617 time_point_sec target_timestamp = {}; // Stop automatic weight_ratio shrinkage at this time. Once this
618 // time hits, weight_ratio will be target_weight_ratio.
619 double exponent = default_exponent; // Exponent of resource price curve.
620 uint32_t decay_secs = default_decay_secs; // Number of seconds for the gap between adjusted resource
621 // utilization and instantaneous utilization to shrink by 63%.
622 asset min_price = {}; // Fee needed to reserve the entire resource market weight at
623 // the minimum price (defaults to 0).
624 asset max_price = {}; // Fee needed to reserve the entire resource market weight at
625 // the maximum price.
626 int64_t utilization = 0; // Instantaneous resource utilization. This is the current
627 // amount sold. utilization <= weight.
628 int64_t adjusted_utilization = 0; // Adjusted resource utilization. This is >= utilization and
629 // <= weight. It grows instantly but decays exponentially.
630 time_point_sec utilization_timestamp = {}; // When adjusted_utilization was last updated
631 };
632
633 struct [[sysio::table("powup.state"),sysio::contract("sysio.system")]] powerup_state {
634 static constexpr uint32_t default_powerup_days = 30; // 30 day resource powerup
635
636 uint8_t version = 0;
637 powerup_state_resource net = {}; // NET market state
638 powerup_state_resource cpu = {}; // CPU market state
639 uint32_t powerup_days = default_powerup_days; // `powerup` `days` argument must match this.
640 asset min_powerup_fee = {}; // fees below this amount are rejected
641
642 uint64_t primary_key()const { return 0; }
643 };
644
645 typedef sysio::singleton<"powup.state"_n, powerup_state> powerup_state_singleton;
646
647 struct [[sysio::table("powup.order"),sysio::contract("sysio.system")]] powerup_order {
648 uint8_t version = 0;
654
655 uint64_t primary_key()const { return id; }
656 uint64_t by_owner()const { return owner.value; }
657 uint64_t by_expires()const { return expires.utc_seconds; }
658 };
659
660 typedef sysio::multi_index< "powup.order"_n, powerup_order,
661 indexed_by<"byowner"_n, const_mem_fun<powerup_order, uint64_t, &powerup_order::by_owner>>,
662 indexed_by<"byexpires"_n, const_mem_fun<powerup_order, uint64_t, &powerup_order::by_expires>>
664
679 class [[sysio::contract("sysio.system")]] system_contract : public native {
680
681 private:
682 voters_table _voters;
683 producers_table _producers;
684 producers_table2 _producers2;
689 sysio_global_state _gstate;
690 sysio_global_state2 _gstate2;
691 sysio_global_state3 _gstate3;
692 sysio_global_state4 _gstate4;
693 rammarket _rammarket;
694 rex_pool_table _rexpool;
695 rex_return_pool_table _rexretpool;
696 rex_return_buckets_table _rexretbuckets;
697 rex_fund_table _rexfunds;
698 rex_balance_table _rexbalance;
699 rex_order_table _rexorders;
700
701 public:
702 static constexpr sysio::name active_permission{"active"_n};
703 static constexpr sysio::name token_account{"sysio.token"_n};
704 static constexpr sysio::name ram_account{"sysio.ram"_n};
705 static constexpr sysio::name ramfee_account{"sysio.ramfee"_n};
706 static constexpr sysio::name stake_account{"sysio.stake"_n};
707 static constexpr sysio::name bpay_account{"sysio.bpay"_n};
708 static constexpr sysio::name vpay_account{"sysio.vpay"_n};
709 static constexpr sysio::name names_account{"sysio.names"_n};
710 static constexpr sysio::name saving_account{"sysio.saving"_n};
711 static constexpr sysio::name rex_account{"sysio.rex"_n};
712 static constexpr sysio::name reserve_account{"sysio.reserv"_n}; // cspell:disable-line
713 static constexpr sysio::name null_account{"sysio.null"_n};
714 static constexpr symbol ramcore_symbol = symbol(symbol_code("RAMCORE"), 4);
715 static constexpr symbol ram_symbol = symbol(symbol_code("RAM"), 0);
716 static constexpr symbol rex_symbol = symbol(symbol_code("REX"), 4);
717
720
721 // Returns the core symbol by system account name
722 // @param system_account - the system account to get the core symbol for.
723 static symbol get_core_symbol( name system_account = "sysio"_n ) {
724 rammarket rm(system_account, system_account.value);
725 const static auto sym = get_core_symbol( rm );
726 return sym;
727 }
728
729 // Actions:
741 [[sysio::action]]
742 void init( unsigned_int version, const symbol& core );
743
753 [[sysio::action]]
754 void onblock( ignore<block_header> header );
755
764 [[sysio::action]]
765 void setalimits( const name& account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight );
766
773 [[sysio::action]]
774 void setacctram( const name& account, const std::optional<int64_t>& ram_bytes );
775
782 [[sysio::action]]
783 void setacctnet( const name& account, const std::optional<int64_t>& net_weight );
784
791 [[sysio::action]]
792 void setacctcpu( const name& account, const std::optional<int64_t>& cpu_weight );
793
794
800 [[sysio::action]]
801 void activate( const sysio::checksum256& feature_digest );
802
803 // functions defined in delegate_bandwidth.cpp
804
818 [[sysio::action]]
819 void delegatebw( const name& from, const name& receiver,
820 const asset& stake_net_quantity, const asset& stake_cpu_quantity, bool transfer );
821
826 [[sysio::action]]
827 void setrex( const asset& balance );
828
840 [[sysio::action]]
841 void deposit( const name& owner, const asset& amount );
842
850 [[sysio::action]]
851 void withdraw( const name& owner, const asset& amount );
852
869 [[sysio::action]]
870 void buyrex( const name& from, const asset& amount );
871
888 [[sysio::action]]
889 void unstaketorex( const name& owner, const name& receiver, const asset& from_net, const asset& from_cpu );
890
901 [[sysio::action]]
902 void sellrex( const name& from, const asset& rex );
903
911 [[sysio::action]]
912 void cnclrexorder( const name& owner );
913
931 [[sysio::action]]
932 void rentcpu( const name& from, const name& receiver, const asset& loan_payment, const asset& loan_fund );
933
951 [[sysio::action]]
952 void rentnet( const name& from, const name& receiver, const asset& loan_payment, const asset& loan_fund );
953
962 [[sysio::action]]
963 void fundcpuloan( const name& from, uint64_t loan_num, const asset& payment );
964
973 [[sysio::action]]
974 void fundnetloan( const name& from, uint64_t loan_num, const asset& payment );
975
983 [[sysio::action]]
984 void defcpuloan( const name& from, uint64_t loan_num, const asset& amount );
985
993 [[sysio::action]]
994 void defnetloan( const name& from, uint64_t loan_num, const asset& amount );
995
1001 [[sysio::action]]
1002 void updaterex( const name& owner );
1003
1011 [[sysio::action]]
1012 void rexexec( const name& user, uint16_t max );
1013
1020 [[sysio::action]]
1021 void consolidate( const name& owner );
1022
1032 [[sysio::action]]
1033 void mvtosavings( const name& owner, const asset& rex );
1034
1042 [[sysio::action]]
1043 void mvfrsavings( const name& owner, const asset& rex );
1044
1056 [[sysio::action]]
1057 void closerex( const name& owner );
1058
1086 [[sysio::action]]
1087 void undelegatebw( const name& from, const name& receiver,
1088 const asset& unstake_net_quantity, const asset& unstake_cpu_quantity );
1089
1099 [[sysio::action]]
1100 void buyram( const name& payer, const name& receiver, const asset& quant );
1101
1110 [[sysio::action]]
1111 void buyrambytes( const name& payer, const name& receiver, uint32_t bytes );
1112
1120 [[sysio::action]]
1121 void sellram( const name& account, int64_t bytes );
1122
1129 [[sysio::action]]
1130 void refund( const name& owner );
1131
1132 // functions defined in voting.cpp
1133
1147 [[sysio::action]]
1148 void regproducer( const name& producer, const public_key& producer_key, const std::string& url, uint16_t location );
1149
1163 [[sysio::action]]
1164 void regproducer2( const name& producer, const sysio::block_signing_authority& producer_authority, const std::string& url, uint16_t location );
1165
1172 [[sysio::action]]
1173 void unregprod( const name& producer );
1174
1179 [[sysio::action]]
1180 void setram( uint64_t max_ram_size );
1181
1189 [[sysio::action]]
1190 void setramrate( uint16_t bytes_per_block );
1191
1215 [[sysio::action]]
1216 void voteproducer( const name& voter, const name& proxy, const std::vector<name>& producers );
1217
1228 [[sysio::action]]
1229 void voteupdate( const name& voter_name );
1230
1244 [[sysio::action]]
1245 void regproxy( const name& proxy, bool isproxy );
1246
1252 [[sysio::action]]
1253 void setparams( const blockchain_parameters_t& params );
1254
1255#ifdef SYSTEM_CONFIGURABLE_WASM_LIMITS
1261 [[sysio::action]]
1262 void wasmcfg( const name& settings );
1263#endif
1264
1269 [[sysio::action]]
1270 void claimrewards( const name& owner );
1271
1277 [[sysio::action]]
1278 void setpriv( const name& account, uint8_t is_priv );
1279
1284 [[sysio::action]]
1285 void rmvproducer( const name& producer );
1286
1294 [[sysio::action]]
1295 void updtrevision( uint8_t revision );
1296
1313 [[sysio::action]]
1314 void bidname( const name& bidder, const name& newname, const asset& bid );
1315
1322 [[sysio::action]]
1323 void bidrefund( const name& bidder, const name& newname );
1324
1341 [[sysio::action]]
1342 void setinflation( int64_t annual_rate, int64_t inflation_pay_factor, int64_t votepay_factor );
1343
1348 [[sysio::action]]
1349 void cfgpowerup( powerup_config& args );
1350
1357 [[sysio::action]]
1358 void powerupexec( const name& user, uint16_t max );
1359
1371 [[sysio::action]]
1372 void powerup( const name& payer, const name& receiver, uint32_t days, int64_t net_frac, int64_t cpu_frac, const asset& max_payment );
1373
1389 [[sysio::action]]
1390 void limitauthchg( const name& account, const std::vector<name>& allow_perms, const std::vector<name>& disallow_perms );
1391
1395 [[sysio::on_notify("auth.msg::onlinkauth")]]
1396 void onlinkauth(const name &user, const name &permission, const sysio::public_key &pub_key);
1397
1398 using init_action = sysio::action_wrapper<"init"_n, &system_contract::init>;
1399 using setacctram_action = sysio::action_wrapper<"setacctram"_n, &system_contract::setacctram>;
1400 using setacctnet_action = sysio::action_wrapper<"setacctnet"_n, &system_contract::setacctnet>;
1401 using setacctcpu_action = sysio::action_wrapper<"setacctcpu"_n, &system_contract::setacctcpu>;
1402 using activate_action = sysio::action_wrapper<"activate"_n, &system_contract::activate>;
1403 using delegatebw_action = sysio::action_wrapper<"delegatebw"_n, &system_contract::delegatebw>;
1404 using deposit_action = sysio::action_wrapper<"deposit"_n, &system_contract::deposit>;
1405 using withdraw_action = sysio::action_wrapper<"withdraw"_n, &system_contract::withdraw>;
1406 using buyrex_action = sysio::action_wrapper<"buyrex"_n, &system_contract::buyrex>;
1407 using unstaketorex_action = sysio::action_wrapper<"unstaketorex"_n, &system_contract::unstaketorex>;
1408 using sellrex_action = sysio::action_wrapper<"sellrex"_n, &system_contract::sellrex>;
1409 using cnclrexorder_action = sysio::action_wrapper<"cnclrexorder"_n, &system_contract::cnclrexorder>;
1410 using rentcpu_action = sysio::action_wrapper<"rentcpu"_n, &system_contract::rentcpu>;
1411 using rentnet_action = sysio::action_wrapper<"rentnet"_n, &system_contract::rentnet>;
1412 using fundcpuloan_action = sysio::action_wrapper<"fundcpuloan"_n, &system_contract::fundcpuloan>;
1413 using fundnetloan_action = sysio::action_wrapper<"fundnetloan"_n, &system_contract::fundnetloan>;
1414 using defcpuloan_action = sysio::action_wrapper<"defcpuloan"_n, &system_contract::defcpuloan>;
1415 using defnetloan_action = sysio::action_wrapper<"defnetloan"_n, &system_contract::defnetloan>;
1416 using updaterex_action = sysio::action_wrapper<"updaterex"_n, &system_contract::updaterex>;
1417 using rexexec_action = sysio::action_wrapper<"rexexec"_n, &system_contract::rexexec>;
1418 using setrex_action = sysio::action_wrapper<"setrex"_n, &system_contract::setrex>;
1419 using mvtosavings_action = sysio::action_wrapper<"mvtosavings"_n, &system_contract::mvtosavings>;
1420 using mvfrsavings_action = sysio::action_wrapper<"mvfrsavings"_n, &system_contract::mvfrsavings>;
1421 using consolidate_action = sysio::action_wrapper<"consolidate"_n, &system_contract::consolidate>;
1422 using closerex_action = sysio::action_wrapper<"closerex"_n, &system_contract::closerex>;
1423 using undelegatebw_action = sysio::action_wrapper<"undelegatebw"_n, &system_contract::undelegatebw>;
1424 using buyram_action = sysio::action_wrapper<"buyram"_n, &system_contract::buyram>;
1425 using buyrambytes_action = sysio::action_wrapper<"buyrambytes"_n, &system_contract::buyrambytes>;
1426 using sellram_action = sysio::action_wrapper<"sellram"_n, &system_contract::sellram>;
1427 using refund_action = sysio::action_wrapper<"refund"_n, &system_contract::refund>;
1428 using regproducer_action = sysio::action_wrapper<"regproducer"_n, &system_contract::regproducer>;
1429 using regproducer2_action = sysio::action_wrapper<"regproducer2"_n, &system_contract::regproducer2>;
1430 using unregprod_action = sysio::action_wrapper<"unregprod"_n, &system_contract::unregprod>;
1431 using setram_action = sysio::action_wrapper<"setram"_n, &system_contract::setram>;
1432 using setramrate_action = sysio::action_wrapper<"setramrate"_n, &system_contract::setramrate>;
1433 using voteproducer_action = sysio::action_wrapper<"voteproducer"_n, &system_contract::voteproducer>;
1434 using voteupdate_action = sysio::action_wrapper<"voteupdate"_n, &system_contract::voteupdate>;
1435 using regproxy_action = sysio::action_wrapper<"regproxy"_n, &system_contract::regproxy>;
1436 using claimrewards_action = sysio::action_wrapper<"claimrewards"_n, &system_contract::claimrewards>;
1437 using rmvproducer_action = sysio::action_wrapper<"rmvproducer"_n, &system_contract::rmvproducer>;
1438 using updtrevision_action = sysio::action_wrapper<"updtrevision"_n, &system_contract::updtrevision>;
1439 using bidname_action = sysio::action_wrapper<"bidname"_n, &system_contract::bidname>;
1440 using bidrefund_action = sysio::action_wrapper<"bidrefund"_n, &system_contract::bidrefund>;
1441 using setpriv_action = sysio::action_wrapper<"setpriv"_n, &system_contract::setpriv>;
1442 using setalimits_action = sysio::action_wrapper<"setalimits"_n, &system_contract::setalimits>;
1443 using setparams_action = sysio::action_wrapper<"setparams"_n, &system_contract::setparams>;
1444 using setinflation_action = sysio::action_wrapper<"setinflation"_n, &system_contract::setinflation>;
1445 using cfgpowerup_action = sysio::action_wrapper<"cfgpowerup"_n, &system_contract::cfgpowerup>;
1446 using powerupexec_action = sysio::action_wrapper<"powerupexec"_n, &system_contract::powerupexec>;
1447 using powerup_action = sysio::action_wrapper<"powerup"_n, &system_contract::powerup>;
1448
1449 private:
1450 // Implementation details:
1451
1452 static symbol get_core_symbol( const rammarket& rm ) {
1453 auto itr = rm.find(ramcore_symbol.raw());
1454 check(itr != rm.end(), "system contract must first be initialized");
1455 return itr->quote.balance.symbol;
1456 }
1457
1458 //defined in sysio.system.cpp
1459 static sysio_global_state get_default_parameters();
1460 static sysio_global_state4 get_default_inflation_parameters();
1461 symbol core_symbol()const;
1462 void update_ram_supply();
1463
1464 // defined in rex.cpp
1465 void runrex( uint16_t max );
1466 void update_rex_pool();
1467 void update_resource_limits( const name& from, const name& receiver, int64_t delta_net, int64_t delta_cpu );
1468 void check_voting_requirement( const name& owner,
1469 const char* error_msg = "must vote for at least 21 producers or for a proxy before buying REX" )const;
1470 rex_order_outcome fill_rex_order( const rex_balance_table::const_iterator& bitr, const asset& rex );
1471 asset update_rex_account( const name& owner, const asset& proceeds, const asset& unstake_quant, bool force_vote_update = false );
1472 void channel_to_rex( const name& from, const asset& amount, bool required = false );
1473 void channel_namebid_to_rex( const int64_t highest_bid );
1474 template <typename T>
1475 int64_t rent_rex( T& table, const name& from, const name& receiver, const asset& loan_payment, const asset& loan_fund );
1476 template <typename T>
1477 void fund_rex_loan( T& table, const name& from, uint64_t loan_num, const asset& payment );
1478 template <typename T>
1479 void defund_rex_loan( T& table, const name& from, uint64_t loan_num, const asset& amount );
1480 void transfer_from_fund( const name& owner, const asset& amount );
1481 void transfer_to_fund( const name& owner, const asset& amount );
1482 bool rex_loans_available()const;
1483 bool rex_system_initialized()const { return _rexpool.begin() != _rexpool.end(); }
1484 bool rex_available()const { return rex_system_initialized() && _rexpool.begin()->total_rex.amount > 0; }
1485 static time_point_sec get_rex_maturity();
1486 asset add_to_rex_balance( const name& owner, const asset& payment, const asset& rex_received );
1487 asset add_to_rex_pool( const asset& payment );
1488 void add_to_rex_return_pool( const asset& fee );
1489 void process_rex_maturities( const rex_balance_table::const_iterator& bitr );
1490 void consolidate_rex_balance( const rex_balance_table::const_iterator& bitr,
1491 const asset& rex_in_sell_order );
1492 int64_t read_rex_savings( const rex_balance_table::const_iterator& bitr );
1493 void put_rex_savings( const rex_balance_table::const_iterator& bitr, int64_t rex );
1494 void update_rex_stake( const name& voter );
1495
1496 void add_loan_to_rex_pool( const asset& payment, int64_t rented_tokens, bool new_loan );
1497 void remove_loan_from_rex_pool( const rex_loan& loan );
1498 template <typename Index, typename Iterator>
1499 int64_t update_renewed_loan( Index& idx, const Iterator& itr, int64_t rented_tokens );
1500
1501 // defined in delegate_bandwidth.cpp
1502 void changebw( name from, const name& receiver,
1503 const asset& stake_net_quantity, const asset& stake_cpu_quantity, bool transfer );
1504 void update_voting_power( const name& voter, const asset& total_update );
1505
1506 // defined in voting.cpp
1507 void register_producer( const name& producer, const sysio::block_signing_authority& producer_authority, const std::string& url, uint16_t location );
1508 void update_elected_producers( const block_timestamp& timestamp );
1509 void update_votes( const name& voter, const name& proxy, const std::vector<name>& producers, bool voting );
1510 void propagate_weight_change( const voter_info& voter );
1511 double update_producer_votepay_share( const producers_table2::const_iterator& prod_itr,
1512 const time_point& ct,
1513 double shares_rate, bool reset_to_zero = false );
1514 double update_total_votepay_share( const time_point& ct,
1515 double additional_shares_delta = 0.0, double shares_rate_delta = 0.0 );
1516
1517 template <auto system_contract::*...Ptrs>
1518 class registration {
1519 public:
1520 template <auto system_contract::*P, auto system_contract::*...Ps>
1521 struct for_each {
1522 template <typename... Args>
1523 static constexpr void call( system_contract* this_contract, Args&&... args )
1524 {
1525 std::invoke( P, this_contract, args... );
1526 for_each<Ps...>::call( this_contract, std::forward<Args>(args)... );
1527 }
1528 };
1529 template <auto system_contract::*P>
1530 struct for_each<P> {
1531 template <typename... Args>
1532 static constexpr void call( system_contract* this_contract, Args&&... args )
1533 {
1534 std::invoke( P, this_contract, std::forward<Args>(args)... );
1535 }
1536 };
1537
1538 template <typename... Args>
1539 constexpr void operator() ( Args&&... args )
1540 {
1541 for_each<Ptrs...>::call( this_contract, std::forward<Args>(args)... );
1542 }
1543
1544 system_contract* this_contract;
1545 };
1546
1547 registration<&system_contract::update_rex_stake> vote_stake_updater{ this };
1548
1549 // defined in power.cpp
1550 void adjust_resources(name payer, name account, symbol core_symbol, int64_t net_delta, int64_t cpu_delta, bool must_not_be_managed = false);
1551 void process_powerup_queue(
1552 time_point_sec now, symbol core_symbol, powerup_state& state,
1553 powerup_order_table& orders, uint32_t max_items, int64_t& net_delta_available,
1554 int64_t& cpu_delta_available);
1555
1556 // defined in block_info.cpp
1557 void add_to_blockinfo_table(const sysio::checksum256& previous_block_id, const sysio::block_timestamp timestamp) const;
1558 };
1559
1560}
std::string name
contains only the public point of an elliptic curve key.
constexpr int64_t count() const
Definition time.hpp:26
sysio::action_wrapper<"rexexec"_n, &system_contract::rexexec > rexexec_action
sysio::action_wrapper<"activate"_n, &system_contract::activate > activate_action
sysio::action_wrapper<"setacctnet"_n, &system_contract::setacctnet > setacctnet_action
sysio::action_wrapper<"unregprod"_n, &system_contract::unregprod > unregprod_action
sysio::action_wrapper<"undelegatebw"_n, &system_contract::undelegatebw > undelegatebw_action
sysio::action_wrapper<"setram"_n, &system_contract::setram > setram_action
sysio::action_wrapper<"claimrewards"_n, &system_contract::claimrewards > claimrewards_action
sysio::action_wrapper<"setinflation"_n, &system_contract::setinflation > setinflation_action
sysio::action_wrapper<"closerex"_n, &system_contract::closerex > closerex_action
sysio::action_wrapper<"setacctcpu"_n, &system_contract::setacctcpu > setacctcpu_action
sysio::action_wrapper<"defcpuloan"_n, &system_contract::defcpuloan > defcpuloan_action
sysio::action_wrapper<"withdraw"_n, &system_contract::withdraw > withdraw_action
sysio::action_wrapper<"powerup"_n, &system_contract::powerup > powerup_action
sysio::action_wrapper<"deposit"_n, &system_contract::deposit > deposit_action
sysio::action_wrapper<"regproducer2"_n, &system_contract::regproducer2 > regproducer2_action
sysio::action_wrapper<"fundcpuloan"_n, &system_contract::fundcpuloan > fundcpuloan_action
sysio::action_wrapper<"init"_n, &system_contract::init > init_action
sysio::action_wrapper<"updaterex"_n, &system_contract::updaterex > updaterex_action
static symbol get_core_symbol(name system_account="sysio"_n)
sysio::action_wrapper<"voteproducer"_n, &system_contract::voteproducer > voteproducer_action
sysio::action_wrapper<"mvfrsavings"_n, &system_contract::mvfrsavings > mvfrsavings_action
sysio::action_wrapper<"mvtosavings"_n, &system_contract::mvtosavings > mvtosavings_action
sysio::action_wrapper<"refund"_n, &system_contract::refund > refund_action
sysio::action_wrapper<"updtrevision"_n, &system_contract::updtrevision > updtrevision_action
sysio::action_wrapper<"setrex"_n, &system_contract::setrex > setrex_action
sysio::action_wrapper<"regproxy"_n, &system_contract::regproxy > regproxy_action
sysio::action_wrapper<"setacctram"_n, &system_contract::setacctram > setacctram_action
sysio::action_wrapper<"bidname"_n, &system_contract::bidname > bidname_action
sysio::action_wrapper<"unstaketorex"_n, &system_contract::unstaketorex > unstaketorex_action
sysio::action_wrapper<"sellram"_n, &system_contract::sellram > sellram_action
sysio::action_wrapper<"setparams"_n, &system_contract::setparams > setparams_action
sysio::action_wrapper<"cnclrexorder"_n, &system_contract::cnclrexorder > cnclrexorder_action
sysio::action_wrapper<"bidrefund"_n, &system_contract::bidrefund > bidrefund_action
sysio::action_wrapper<"buyram"_n, &system_contract::buyram > buyram_action
sysio::action_wrapper<"cfgpowerup"_n, &system_contract::cfgpowerup > cfgpowerup_action
sysio::action_wrapper<"rentcpu"_n, &system_contract::rentcpu > rentcpu_action
sysio::action_wrapper<"buyrambytes"_n, &system_contract::buyrambytes > buyrambytes_action
sysio::action_wrapper<"setramrate"_n, &system_contract::setramrate > setramrate_action
sysio::action_wrapper<"delegatebw"_n, &system_contract::delegatebw > delegatebw_action
sysio::action_wrapper<"consolidate"_n, &system_contract::consolidate > consolidate_action
sysio::action_wrapper<"rentnet"_n, &system_contract::rentnet > rentnet_action
sysio::action_wrapper<"setpriv"_n, &system_contract::setpriv > setpriv_action
sysio::action_wrapper<"rmvproducer"_n, &system_contract::rmvproducer > rmvproducer_action
sysio::action_wrapper<"defnetloan"_n, &system_contract::defnetloan > defnetloan_action
sysio::action_wrapper<"setalimits"_n, &system_contract::setalimits > setalimits_action
sysio::action_wrapper<"regproducer"_n, &system_contract::regproducer > regproducer_action
sysio::action_wrapper<"fundnetloan"_n, &system_contract::fundnetloan > fundnetloan_action
sysio::action_wrapper<"powerupexec"_n, &system_contract::powerupexec > powerupexec_action
sysio::action_wrapper<"voteupdate"_n, &system_contract::voteupdate > voteupdate_action
sysio::action_wrapper<"sellrex"_n, &system_contract::sellrex > sellrex_action
sysio::action_wrapper<"buyrex"_n, &system_contract::buyrex > buyrex_action
uint64_t id
Definition code_cache.cpp:0
DataStream & operator<<(DataStream &ds, const float64_t &v)
DataStream & operator>>(DataStream &ds, float64_t &v)
#define P
Definition dtoa.c:437
ehm field
void init()
Definition lib_test.cpp:3
std::variant< block_signing_authority_v0 > block_signing_authority
sysio::multi_index< "retbuckets"_n, rex_return_buckets > rex_return_buckets_table
constexpr int64_t powerup_frac
sysio::multi_index< "rammarket"_n, exchange_state > rammarket
sysio::multi_index< "rexpool"_n, rex_pool > rex_pool_table
sysio::multi_index< "delband"_n, delegated_bandwidth > del_bandwidth_table
sysio::multi_index< "refunds"_n, refund_request > refunds_table
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
sysio::blockchain_parameters blockchain_parameters_t
sysio::multi_index< "rexretpool"_n, rex_return_pool > rex_return_pool_table
sysio::singleton<"powup.state"_n, powerup_state > powerup_state_singleton
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
sysio::singleton< "global"_n, sysio_global_state > global_state_singleton
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
sysio::singleton< "global4"_n, sysio_global_state4 > global_state4_singleton
sysio::multi_index< "rexbal"_n, rex_balance > rex_balance_table
sysio::multi_index< "rexfund"_n, rex_fund > rex_fund_table
sysio::singleton< "global2"_n, sysio_global_state2 > global_state2_singleton
sysio::multi_index< "producers"_n, producer_info, indexed_by<"prototalvote"_n, const_mem_fun< producer_info, double, &producer_info::by_votes > > > producers_table
sysio::multi_index< "voters"_n, voter_info > voters_table
sysio::singleton< "global3"_n, sysio_global_state3 > global_state3_singleton
sysio::block_signing_authority convert_to_block_signing_authority(const sysio::public_key &producer_key)
sysio::multi_index< "bidrefunds"_n, bid_refund > bid_refund_table
sysio::multi_index< "producers2"_n, producer_info2 > producers_table2
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
sysio::multi_index< "userres"_n, user_resources > user_resources_table
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
#define value
Definition pkcs11.h:157
#define T(meth, val, expected)
string url
Definition main.cpp:166
schedule config_dir_name data_dir_name p2p_port http_port file_size name name keys peers producers(dont_start)) FC_REFLECT(testnet_def
unsigned short uint16_t
Definition stdint.h:125
signed __int64 int64_t
Definition stdint.h:135
unsigned int uint32_t
Definition stdint.h:126
unsigned char uint8_t
Definition stdint.h:124
unsigned __int64 uint64_t
Definition stdint.h:136
Immutable except for fc::from_variant.
Definition name.hpp:43
uint64_t primary_key() const
uint64_t by_high_bid() const
uint64_t primary_key() const
SYSLIB_SERIALIZE(pair_time_point_sec_int64,(first)(second))
std::optional< int64_t > assumed_stake_weight
std::optional< time_point_sec > target_timestamp
std::optional< int64_t > target_weight_ratio
std::optional< int64_t > current_weight_ratio
std::optional< uint32_t > decay_secs
powerup_config_resource cpu
powerup_config_resource net
std::optional< asset > min_powerup_fee
std::optional< uint32_t > powerup_days
static constexpr uint32_t default_decay_secs
static constexpr double default_exponent
sysio::binary_extension< sysio::block_signing_authority > producer_authority
sysio::public_key producer_key
bool is_active
a packed public key object
sysio::block_signing_authority get_producer_authority() const
uint64_t primary_key() const
REX daily maturity buckets.
std::vector< pair_time_point_sec_int64 > rex_maturities
uint64_t primary_key() const
sysio::time_point expiration
uint64_t primary_key() const
uint64_t by_expr() const
uint64_t by_owner() const
uint64_t by_time() const
sysio::time_point order_time
uint64_t primary_key() const
uint64_t primary_key() const
std::vector< pair_time_point_sec_int64 > return_buckets
block_timestamp last_producer_schedule_update
block_timestamp last_name_close
the sum of all producer votes
static constexpr void call(system_contract *this_contract, Args &&... args)
static constexpr void call(system_contract *this_contract, Args &&... args)
std::vector< name > producers
the proxy set by the voter, if any
uint64_t primary_key() const
account_query_db::get_accounts_by_authorizers_params params
char * s
pInfo flags