Wire Sysio Wire Sysion 1.0.0
Loading...
Searching...
No Matches
sysiosystem::system_contract Class Reference

#include <sysio.system.hpp>

Inheritance diagram for sysiosystem::system_contract:
Collaboration diagram for sysiosystem::system_contract:

Public Types

using init_action = sysio::action_wrapper<"init"_n, &system_contract::init>
 
using setacctram_action = sysio::action_wrapper<"setacctram"_n, &system_contract::setacctram>
 
using setacctnet_action = sysio::action_wrapper<"setacctnet"_n, &system_contract::setacctnet>
 
using setacctcpu_action = sysio::action_wrapper<"setacctcpu"_n, &system_contract::setacctcpu>
 
using activate_action = sysio::action_wrapper<"activate"_n, &system_contract::activate>
 
using delegatebw_action = sysio::action_wrapper<"delegatebw"_n, &system_contract::delegatebw>
 
using deposit_action = sysio::action_wrapper<"deposit"_n, &system_contract::deposit>
 
using withdraw_action = sysio::action_wrapper<"withdraw"_n, &system_contract::withdraw>
 
using buyrex_action = sysio::action_wrapper<"buyrex"_n, &system_contract::buyrex>
 
using unstaketorex_action = sysio::action_wrapper<"unstaketorex"_n, &system_contract::unstaketorex>
 
using sellrex_action = sysio::action_wrapper<"sellrex"_n, &system_contract::sellrex>
 
using cnclrexorder_action = sysio::action_wrapper<"cnclrexorder"_n, &system_contract::cnclrexorder>
 
using rentcpu_action = sysio::action_wrapper<"rentcpu"_n, &system_contract::rentcpu>
 
using rentnet_action = sysio::action_wrapper<"rentnet"_n, &system_contract::rentnet>
 
using fundcpuloan_action = sysio::action_wrapper<"fundcpuloan"_n, &system_contract::fundcpuloan>
 
using fundnetloan_action = sysio::action_wrapper<"fundnetloan"_n, &system_contract::fundnetloan>
 
using defcpuloan_action = sysio::action_wrapper<"defcpuloan"_n, &system_contract::defcpuloan>
 
using defnetloan_action = sysio::action_wrapper<"defnetloan"_n, &system_contract::defnetloan>
 
using updaterex_action = sysio::action_wrapper<"updaterex"_n, &system_contract::updaterex>
 
using rexexec_action = sysio::action_wrapper<"rexexec"_n, &system_contract::rexexec>
 
using setrex_action = sysio::action_wrapper<"setrex"_n, &system_contract::setrex>
 
using mvtosavings_action = sysio::action_wrapper<"mvtosavings"_n, &system_contract::mvtosavings>
 
using mvfrsavings_action = sysio::action_wrapper<"mvfrsavings"_n, &system_contract::mvfrsavings>
 
using consolidate_action = sysio::action_wrapper<"consolidate"_n, &system_contract::consolidate>
 
using closerex_action = sysio::action_wrapper<"closerex"_n, &system_contract::closerex>
 
using undelegatebw_action = sysio::action_wrapper<"undelegatebw"_n, &system_contract::undelegatebw>
 
using buyram_action = sysio::action_wrapper<"buyram"_n, &system_contract::buyram>
 
using buyrambytes_action = sysio::action_wrapper<"buyrambytes"_n, &system_contract::buyrambytes>
 
using sellram_action = sysio::action_wrapper<"sellram"_n, &system_contract::sellram>
 
using refund_action = sysio::action_wrapper<"refund"_n, &system_contract::refund>
 
using regproducer_action = sysio::action_wrapper<"regproducer"_n, &system_contract::regproducer>
 
using regproducer2_action = sysio::action_wrapper<"regproducer2"_n, &system_contract::regproducer2>
 
using unregprod_action = sysio::action_wrapper<"unregprod"_n, &system_contract::unregprod>
 
using setram_action = sysio::action_wrapper<"setram"_n, &system_contract::setram>
 
using setramrate_action = sysio::action_wrapper<"setramrate"_n, &system_contract::setramrate>
 
using voteproducer_action = sysio::action_wrapper<"voteproducer"_n, &system_contract::voteproducer>
 
using voteupdate_action = sysio::action_wrapper<"voteupdate"_n, &system_contract::voteupdate>
 
using regproxy_action = sysio::action_wrapper<"regproxy"_n, &system_contract::regproxy>
 
using claimrewards_action = sysio::action_wrapper<"claimrewards"_n, &system_contract::claimrewards>
 
using rmvproducer_action = sysio::action_wrapper<"rmvproducer"_n, &system_contract::rmvproducer>
 
using updtrevision_action = sysio::action_wrapper<"updtrevision"_n, &system_contract::updtrevision>
 
using bidname_action = sysio::action_wrapper<"bidname"_n, &system_contract::bidname>
 
using bidrefund_action = sysio::action_wrapper<"bidrefund"_n, &system_contract::bidrefund>
 
using setpriv_action = sysio::action_wrapper<"setpriv"_n, &system_contract::setpriv>
 
using setalimits_action = sysio::action_wrapper<"setalimits"_n, &system_contract::setalimits>
 
using setparams_action = sysio::action_wrapper<"setparams"_n, &system_contract::setparams>
 
using setinflation_action = sysio::action_wrapper<"setinflation"_n, &system_contract::setinflation>
 
using cfgpowerup_action = sysio::action_wrapper<"cfgpowerup"_n, &system_contract::cfgpowerup>
 
using powerupexec_action = sysio::action_wrapper<"powerupexec"_n, &system_contract::powerupexec>
 
using powerup_action = sysio::action_wrapper<"powerup"_n, &system_contract::powerup>
 
- Public Types inherited from sysiosystem::native
using newaccount_action = sysio::action_wrapper<"newaccount"_n, &native::newaccount>
 
using updateauth_action = sysio::action_wrapper<"updateauth"_n, &native::updateauth>
 
using deleteauth_action = sysio::action_wrapper<"deleteauth"_n, &native::deleteauth>
 
using linkauth_action = sysio::action_wrapper<"linkauth"_n, &native::linkauth>
 
using unlinkauth_action = sysio::action_wrapper<"unlinkauth"_n, &native::unlinkauth>
 
using canceldelay_action = sysio::action_wrapper<"canceldelay"_n, &native::canceldelay>
 
using setcode_action = sysio::action_wrapper<"setcode"_n, &native::setcode>
 
using setabi_action = sysio::action_wrapper<"setabi"_n, &native::setabi>
 

Public Member Functions

 system_contract (name s, name code, datastream< const char * > ds)
 
 ~system_contract ()
 
void init (unsigned_int version, const symbol &core)
 
void onblock (ignore< block_header > header)
 
void setalimits (const name &account, int64_t ram_bytes, int64_t net_weight, int64_t cpu_weight)
 
void setacctram (const name &account, const std::optional< int64_t > &ram_bytes)
 
void setacctnet (const name &account, const std::optional< int64_t > &net_weight)
 
void setacctcpu (const name &account, const std::optional< int64_t > &cpu_weight)
 
void activate (const sysio::checksum256 &feature_digest)
 
void delegatebw (const name &from, const name &receiver, const asset &stake_net_quantity, const asset &stake_cpu_quantity, bool transfer)
 
void setrex (const asset &balance)
 
void deposit (const name &owner, const asset &amount)
 
void withdraw (const name &owner, const asset &amount)
 
void buyrex (const name &from, const asset &amount)
 
void unstaketorex (const name &owner, const name &receiver, const asset &from_net, const asset &from_cpu)
 
void sellrex (const name &from, const asset &rex)
 
void cnclrexorder (const name &owner)
 
void rentcpu (const name &from, const name &receiver, const asset &loan_payment, const asset &loan_fund)
 
void rentnet (const name &from, const name &receiver, const asset &loan_payment, const asset &loan_fund)
 
void fundcpuloan (const name &from, uint64_t loan_num, const asset &payment)
 
void fundnetloan (const name &from, uint64_t loan_num, const asset &payment)
 
void defcpuloan (const name &from, uint64_t loan_num, const asset &amount)
 
void defnetloan (const name &from, uint64_t loan_num, const asset &amount)
 
void updaterex (const name &owner)
 
void rexexec (const name &user, uint16_t max)
 
void consolidate (const name &owner)
 
void mvtosavings (const name &owner, const asset &rex)
 
void mvfrsavings (const name &owner, const asset &rex)
 
void closerex (const name &owner)
 
void undelegatebw (const name &from, const name &receiver, const asset &unstake_net_quantity, const asset &unstake_cpu_quantity)
 
void buyram (const name &payer, const name &receiver, const asset &quant)
 
void buyrambytes (const name &payer, const name &receiver, uint32_t bytes)
 
void sellram (const name &account, int64_t bytes)
 
void refund (const name &owner)
 
void regproducer (const name &producer, const public_key &producer_key, const std::string &url, uint16_t location)
 
void regproducer2 (const name &producer, const sysio::block_signing_authority &producer_authority, const std::string &url, uint16_t location)
 
void unregprod (const name &producer)
 
void setram (uint64_t max_ram_size)
 
void setramrate (uint16_t bytes_per_block)
 
void voteproducer (const name &voter, const name &proxy, const std::vector< name > &producers)
 
void voteupdate (const name &voter_name)
 
void regproxy (const name &proxy, bool isproxy)
 
void setparams (const blockchain_parameters_t &params)
 
void claimrewards (const name &owner)
 
void setpriv (const name &account, uint8_t is_priv)
 
void rmvproducer (const name &producer)
 
void updtrevision (uint8_t revision)
 
void bidname (const name &bidder, const name &newname, const asset &bid)
 
void bidrefund (const name &bidder, const name &newname)
 
void setinflation (int64_t annual_rate, int64_t inflation_pay_factor, int64_t votepay_factor)
 
void cfgpowerup (powerup_config &args)
 
void powerupexec (const name &user, uint16_t max)
 
void powerup (const name &payer, const name &receiver, uint32_t days, int64_t net_frac, int64_t cpu_frac, const asset &max_payment)
 
void limitauthchg (const name &account, const std::vector< name > &allow_perms, const std::vector< name > &disallow_perms)
 
void onlinkauth (const name &user, const name &permission, const sysio::public_key &pub_key)
 
- Public Member Functions inherited from sysiosystem::native
void newaccount (const name &creator, const name &name, ignore< authority > owner, ignore< authority > active)
 
void updateauth (name account, name permission, name parent, authority auth, binary_extension< name > authorized_by)
 
void deleteauth (name account, name permission, binary_extension< name > authorized_by)
 
void linkauth (name account, name code, name type, name requirement, binary_extension< name > authorized_by)
 
void unlinkauth (name account, name code, name type, binary_extension< name > authorized_by)
 
void canceldelay (ignore< permission_level > canceling_auth, ignore< checksum256 > trx_id)
 
void onerror (ignore< uint128_t > sender_id, ignore< std::vector< char > > sent_trx)
 
void setabi (const name &account, const std::vector< char > &abi, const binary_extension< std::string > &memo)
 
void setcode (const name &account, uint8_t vmtype, uint8_t vmversion, const std::vector< char > &code, const binary_extension< std::string > &memo)
 

Static Public Member Functions

static symbol get_core_symbol (name system_account="sysio"_n)
 

Static Public Attributes

static constexpr sysio::name active_permission {"active"_n}
 
static constexpr sysio::name token_account {"sysio.token"_n}
 
static constexpr sysio::name ram_account {"sysio.ram"_n}
 
static constexpr sysio::name ramfee_account {"sysio.ramfee"_n}
 
static constexpr sysio::name stake_account {"sysio.stake"_n}
 
static constexpr sysio::name bpay_account {"sysio.bpay"_n}
 
static constexpr sysio::name vpay_account {"sysio.vpay"_n}
 
static constexpr sysio::name names_account {"sysio.names"_n}
 
static constexpr sysio::name saving_account {"sysio.saving"_n}
 
static constexpr sysio::name rex_account {"sysio.rex"_n}
 
static constexpr sysio::name reserve_account {"sysio.reserv"_n}
 
static constexpr sysio::name null_account {"sysio.null"_n}
 
static constexpr symbol ramcore_symbol = symbol(symbol_code("RAMCORE"), 4)
 
static constexpr symbol ram_symbol = symbol(symbol_code("RAM"), 0)
 
static constexpr symbol rex_symbol = symbol(symbol_code("REX"), 4)
 

Detailed Description

The sysio.system smart contract is provided by block.one as a sample system contract, and it defines the structures and actions needed for blockchain's core functionality.

Just like in the sysio.bios sample contract implementation, there are a few actions which are not implemented at the contract level (newaccount, updateauth, deleteauth, linkauth, unlinkauth, canceldelay, onerror, setabi, setcode), they are just declared in the contract so they will show in the contract's ABI and users will be able to push those actions to the chain via the account holding the sysio.system contract, but the implementation is at the EOSIO core level. They are referred to as EOSIO native actions.

  • Users can stake tokens for CPU and Network bandwidth, and then vote for producers or delegate their vote to a proxy.
  • Producers register in order to be voted for, and can claim per-block and per-vote rewards.
  • Users can buy and sell RAM at a market-determined price.
  • Users can bid on premium names.
  • A resource exchange system (REX) allows token holders to lend their tokens, and users to rent CPU and Network resources in return for a market-determined fee.
  • A resource market separate from REX: power.

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

Member Typedef Documentation

◆ activate_action

using sysiosystem::system_contract::activate_action = sysio::action_wrapper<"activate"_n, &system_contract::activate>

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

◆ bidname_action

using sysiosystem::system_contract::bidname_action = sysio::action_wrapper<"bidname"_n, &system_contract::bidname>

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

◆ bidrefund_action

using sysiosystem::system_contract::bidrefund_action = sysio::action_wrapper<"bidrefund"_n, &system_contract::bidrefund>

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

◆ buyram_action

using sysiosystem::system_contract::buyram_action = sysio::action_wrapper<"buyram"_n, &system_contract::buyram>

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

◆ buyrambytes_action

using sysiosystem::system_contract::buyrambytes_action = sysio::action_wrapper<"buyrambytes"_n, &system_contract::buyrambytes>

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

◆ buyrex_action

using sysiosystem::system_contract::buyrex_action = sysio::action_wrapper<"buyrex"_n, &system_contract::buyrex>

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

◆ cfgpowerup_action

using sysiosystem::system_contract::cfgpowerup_action = sysio::action_wrapper<"cfgpowerup"_n, &system_contract::cfgpowerup>

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

◆ claimrewards_action

using sysiosystem::system_contract::claimrewards_action = sysio::action_wrapper<"claimrewards"_n, &system_contract::claimrewards>

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

◆ closerex_action

using sysiosystem::system_contract::closerex_action = sysio::action_wrapper<"closerex"_n, &system_contract::closerex>

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

◆ cnclrexorder_action

using sysiosystem::system_contract::cnclrexorder_action = sysio::action_wrapper<"cnclrexorder"_n, &system_contract::cnclrexorder>

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

◆ consolidate_action

using sysiosystem::system_contract::consolidate_action = sysio::action_wrapper<"consolidate"_n, &system_contract::consolidate>

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

◆ defcpuloan_action

using sysiosystem::system_contract::defcpuloan_action = sysio::action_wrapper<"defcpuloan"_n, &system_contract::defcpuloan>

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

◆ defnetloan_action

using sysiosystem::system_contract::defnetloan_action = sysio::action_wrapper<"defnetloan"_n, &system_contract::defnetloan>

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

◆ delegatebw_action

using sysiosystem::system_contract::delegatebw_action = sysio::action_wrapper<"delegatebw"_n, &system_contract::delegatebw>

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

◆ deposit_action

using sysiosystem::system_contract::deposit_action = sysio::action_wrapper<"deposit"_n, &system_contract::deposit>

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

◆ fundcpuloan_action

using sysiosystem::system_contract::fundcpuloan_action = sysio::action_wrapper<"fundcpuloan"_n, &system_contract::fundcpuloan>

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

◆ fundnetloan_action

using sysiosystem::system_contract::fundnetloan_action = sysio::action_wrapper<"fundnetloan"_n, &system_contract::fundnetloan>

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

◆ init_action

using sysiosystem::system_contract::init_action = sysio::action_wrapper<"init"_n, &system_contract::init>

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

◆ mvfrsavings_action

using sysiosystem::system_contract::mvfrsavings_action = sysio::action_wrapper<"mvfrsavings"_n, &system_contract::mvfrsavings>

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

◆ mvtosavings_action

using sysiosystem::system_contract::mvtosavings_action = sysio::action_wrapper<"mvtosavings"_n, &system_contract::mvtosavings>

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

◆ powerup_action

using sysiosystem::system_contract::powerup_action = sysio::action_wrapper<"powerup"_n, &system_contract::powerup>

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

◆ powerupexec_action

using sysiosystem::system_contract::powerupexec_action = sysio::action_wrapper<"powerupexec"_n, &system_contract::powerupexec>

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

◆ refund_action

using sysiosystem::system_contract::refund_action = sysio::action_wrapper<"refund"_n, &system_contract::refund>

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

◆ regproducer2_action

using sysiosystem::system_contract::regproducer2_action = sysio::action_wrapper<"regproducer2"_n, &system_contract::regproducer2>

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

◆ regproducer_action

using sysiosystem::system_contract::regproducer_action = sysio::action_wrapper<"regproducer"_n, &system_contract::regproducer>

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

◆ regproxy_action

using sysiosystem::system_contract::regproxy_action = sysio::action_wrapper<"regproxy"_n, &system_contract::regproxy>

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

◆ rentcpu_action

using sysiosystem::system_contract::rentcpu_action = sysio::action_wrapper<"rentcpu"_n, &system_contract::rentcpu>

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

◆ rentnet_action

using sysiosystem::system_contract::rentnet_action = sysio::action_wrapper<"rentnet"_n, &system_contract::rentnet>

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

◆ rexexec_action

using sysiosystem::system_contract::rexexec_action = sysio::action_wrapper<"rexexec"_n, &system_contract::rexexec>

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

◆ rmvproducer_action

using sysiosystem::system_contract::rmvproducer_action = sysio::action_wrapper<"rmvproducer"_n, &system_contract::rmvproducer>

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

◆ sellram_action

using sysiosystem::system_contract::sellram_action = sysio::action_wrapper<"sellram"_n, &system_contract::sellram>

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

◆ sellrex_action

using sysiosystem::system_contract::sellrex_action = sysio::action_wrapper<"sellrex"_n, &system_contract::sellrex>

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

◆ setacctcpu_action

using sysiosystem::system_contract::setacctcpu_action = sysio::action_wrapper<"setacctcpu"_n, &system_contract::setacctcpu>

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

◆ setacctnet_action

using sysiosystem::system_contract::setacctnet_action = sysio::action_wrapper<"setacctnet"_n, &system_contract::setacctnet>

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

◆ setacctram_action

using sysiosystem::system_contract::setacctram_action = sysio::action_wrapper<"setacctram"_n, &system_contract::setacctram>

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

◆ setalimits_action

using sysiosystem::system_contract::setalimits_action = sysio::action_wrapper<"setalimits"_n, &system_contract::setalimits>

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

◆ setinflation_action

using sysiosystem::system_contract::setinflation_action = sysio::action_wrapper<"setinflation"_n, &system_contract::setinflation>

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

◆ setparams_action

using sysiosystem::system_contract::setparams_action = sysio::action_wrapper<"setparams"_n, &system_contract::setparams>

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

◆ setpriv_action

using sysiosystem::system_contract::setpriv_action = sysio::action_wrapper<"setpriv"_n, &system_contract::setpriv>

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

◆ setram_action

using sysiosystem::system_contract::setram_action = sysio::action_wrapper<"setram"_n, &system_contract::setram>

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

◆ setramrate_action

using sysiosystem::system_contract::setramrate_action = sysio::action_wrapper<"setramrate"_n, &system_contract::setramrate>

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

◆ setrex_action

using sysiosystem::system_contract::setrex_action = sysio::action_wrapper<"setrex"_n, &system_contract::setrex>

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

◆ undelegatebw_action

using sysiosystem::system_contract::undelegatebw_action = sysio::action_wrapper<"undelegatebw"_n, &system_contract::undelegatebw>

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

◆ unregprod_action

using sysiosystem::system_contract::unregprod_action = sysio::action_wrapper<"unregprod"_n, &system_contract::unregprod>

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

◆ unstaketorex_action

using sysiosystem::system_contract::unstaketorex_action = sysio::action_wrapper<"unstaketorex"_n, &system_contract::unstaketorex>

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

◆ updaterex_action

using sysiosystem::system_contract::updaterex_action = sysio::action_wrapper<"updaterex"_n, &system_contract::updaterex>

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

◆ updtrevision_action

using sysiosystem::system_contract::updtrevision_action = sysio::action_wrapper<"updtrevision"_n, &system_contract::updtrevision>

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

◆ voteproducer_action

using sysiosystem::system_contract::voteproducer_action = sysio::action_wrapper<"voteproducer"_n, &system_contract::voteproducer>

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

◆ voteupdate_action

using sysiosystem::system_contract::voteupdate_action = sysio::action_wrapper<"voteupdate"_n, &system_contract::voteupdate>

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

◆ withdraw_action

using sysiosystem::system_contract::withdraw_action = sysio::action_wrapper<"withdraw"_n, &system_contract::withdraw>

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

Constructor & Destructor Documentation

◆ system_contract()

sysiosystem::system_contract::system_contract ( name s,
name code,
datastream< const char * > ds )

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

19 :native(s,code,ds),
20 _voters(get_self(), get_self().value),
21 _producers(get_self(), get_self().value),
22 _producers2(get_self(), get_self().value),
23 _global(get_self(), get_self().value),
24 _global2(get_self(), get_self().value),
25 _global3(get_self(), get_self().value),
26 _global4(get_self(), get_self().value),
27 _rammarket(get_self(), get_self().value),
28 _rexpool(get_self(), get_self().value),
29 _rexretpool(get_self(), get_self().value),
30 _rexretbuckets(get_self(), get_self().value),
31 _rexfunds(get_self(), get_self().value),
32 _rexbalance(get_self(), get_self().value),
33 _rexorders(get_self(), get_self().value)
34 {
35 _gstate = _global.exists() ? _global.get() : get_default_parameters();
36 _gstate2 = _global2.exists() ? _global2.get() : sysio_global_state2{};
37 _gstate3 = _global3.exists() ? _global3.get() : sysio_global_state3{};
38 _gstate4 = _global4.exists() ? _global4.get() : get_default_inflation_parameters();
39 }
#define value
Definition pkcs11.h:157
char * s

◆ ~system_contract()

sysiosystem::system_contract::~system_contract ( )

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

60 {
61 _global.set( _gstate, get_self() );
62 _global2.set( _gstate2, get_self() );
63 _global3.set( _gstate3, get_self() );
64 _global4.set( _gstate4, get_self() );
65 }

Member Function Documentation

◆ activate()

void sysiosystem::system_contract::activate ( const sysio::checksum256 & feature_digest)

The activate action, activates a protocol feature

Parameters
feature_digest- hash of the protocol feature to activate.

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

388 {
389 require_auth( get_self() );
390 preactivate_feature( feature_digest );
391 }

◆ bidname()

void sysiosystem::system_contract::bidname ( const name & bidder,
const name & newname,
const asset & bid )

Bid name action, allows an account bidder to place a bid for a name newname.

Parameters
bidder- the account placing the bid,
newname- the name the bid is placed for,
bid- the amount of system tokens payed for the bid.
Precondition
Bids can be placed only on top-level suffix,
Non empty name,
Names longer than 12 chars are not allowed,
Names equal with 12 chars can be created without placing a bid,
Bid has to be bigger than zero,
Bid's symbol must be system token,
Bidder account has to be different than current highest bidder,
Bid must increase current bid by 10%,
Auction must still be opened.

Definition at line 11 of file name_bidding.cpp.

11 {
12 require_auth( bidder );
13 check( newname.suffix() == newname, "you can only bid on top-level suffix" );
14
15 check( (bool)newname, "the empty name is not a valid account name to bid on" );
16 check( (newname.value & 0xFull) == 0, "13 character names are not valid account names to bid on" );
17 check( (newname.value & 0x1F0ull) == 0, "accounts with 12 character names and no dots can be created without bidding required" );
18 check( !is_account( newname ), "account already exists" );
19 check( bid.symbol == core_symbol(), "asset must be system token" );
20 check( bid.amount > 0, "insufficient bid" );
21 token::transfer_action transfer_act{ token_account, { {bidder, active_permission} } };
22 transfer_act.send( bidder, names_account, bid, std::string("bid name ")+ newname.to_string() );
23 name_bid_table bids(get_self(), get_self().value);
24 print( name{bidder}, " bid ", bid, " on ", name{newname}, "\n" );
25 auto current = bids.find( newname.value );
26 if( current == bids.end() ) {
27 bids.emplace( bidder, [&]( auto& b ) {
28 b.newname = newname;
29 b.high_bidder = bidder;
30 b.high_bid = bid.amount;
31 b.last_bid_time = current_time_point();
32 });
33 } else {
34 check( current->high_bid > 0, "this auction has already closed" );
35 check( bid.amount - current->high_bid > (current->high_bid / 10), "must increase bid by 10%" );
36 check( current->high_bidder != bidder, "account is already highest bidder" );
37
38 bid_refund_table refunds_table(get_self(), newname.value);
39
40 auto it = refunds_table.find( current->high_bidder.value );
41 if ( it != refunds_table.end() ) {
42 refunds_table.modify( it, same_payer, [&](auto& r) {
43 r.amount += asset( current->high_bid, core_symbol() );
44 });
45 } else {
46 refunds_table.emplace( bidder, [&](auto& r) {
47 r.bidder = current->high_bidder;
48 r.amount = asset( current->high_bid, core_symbol() );
49 });
50 }
51
53 t.actions.emplace_back( permission_level{current->high_bidder, active_permission},
54 get_self(), "bidrefund"_n,
55 std::make_tuple( current->high_bidder, newname )
56 );
57 t.delay_sec = 0;
58 uint128_t deferred_id = (uint128_t(newname.value) << 64) | current->high_bidder.value;
59 sysio::cancel_deferred( deferred_id );
60 t.send( deferred_id, bidder );
61
62 bids.modify( current, bidder, [&]( auto& b ) {
63 b.high_bidder = bidder;
64 b.high_bid = bid.amount;
65 b.last_bid_time = current_time_point();
66 });
67 }
68 }
void print(std::ostream &os, int const level, std::string const &title, Catch::SourceLineInfo const &info)
const mie::Vuint & r
Definition bn.cpp:28
std::string name
sysio::action_wrapper<"transfer"_n, &token::transfer > transfer_action
static constexpr sysio::name token_account
static constexpr sysio::name active_permission
static constexpr sysio::name names_account
__uint128_t uint128_t
Definition config.hpp:8
sysio::multi_index< "refunds"_n, refund_request > refunds_table
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::multi_index< "bidrefunds"_n, bid_refund > bid_refund_table
std::string to_string() const
Definition name.cpp:19
fc::unsigned_int delay_sec
upper limit on the total CPU time billed for this transaction
vector< action > actions
Here is the call graph for this function:

◆ bidrefund()

void sysiosystem::system_contract::bidrefund ( const name & bidder,
const name & newname )

Bid refund action, allows the account bidder to get back the amount it bid so far on a newname name.

Parameters
bidder- the account that gets refunded,
newname- the name for which the bid was placed and now it gets refunded for.

Definition at line 70 of file name_bidding.cpp.

70 {
71 bid_refund_table refunds_table(get_self(), newname.value);
72 auto it = refunds_table.find( bidder.value );
73 check( it != refunds_table.end(), "refund not found" );
74
76 transfer_act.send( names_account, bidder, asset(it->amount), std::string("refund bid on name ")+(name{newname}).to_string() );
77 refunds_table.erase( it );
78 }
Here is the call graph for this function:

◆ buyram()

void sysiosystem::system_contract::buyram ( const name & payer,
const name & receiver,
const asset & quant )

Buy ram action, increases receiver's ram quota based upon current price and quantity of tokens provided. An inline transfer from receiver to system contract of tokens will be executed.

Parameters
payer- the ram buyer,
receiver- the ram receiver,
quant- the quantity of tokens to buy ram with.

When buying ram the payer irreversibly transfers quant to system contract and only the receiver may reclaim the tokens via the sellram action. The receiver pays for the storage of all database records associated with this action.

RAM is a scarce resource whose supply is defined by global properties max_ram_size. RAM is priced using the bancor algorithm such that price-per-byte with a constant reserve ratio of 100:1.

.5% fee (round up)

Definition at line 43 of file delegate_bandwidth.cpp.

44 {
45 require_auth( payer );
46 update_ram_supply();
47
48 check( quant.symbol == core_symbol(), "must buy ram with core token" );
49 check( quant.amount > 0, "must purchase a positive amount" );
50
51 auto fee = quant;
52 fee.amount = ( fee.amount + 199 ) / 200;
53 // fee.amount cannot be 0 since that is only possible if quant.amount is 0 which is not allowed by the assert above.
54 // If quant.amount == 1, then fee.amount == 1,
55 // otherwise if quant.amount > 1, then 0 < fee.amount < quant.amount.
56 auto quant_after_fee = quant;
57 quant_after_fee.amount -= fee.amount;
58 // quant_after_fee.amount should be > 0 if quant.amount > 1.
59 // If quant.amount == 1, then quant_after_fee.amount == 0 and the next inline transfer will fail causing the buyram action to fail.
60 {
62 transfer_act.send( payer, ram_account, quant_after_fee, "buy ram" );
63 }
64 if ( fee.amount > 0 ) {
65 token::transfer_action transfer_act{ token_account, { {payer, active_permission} } };
66 transfer_act.send( payer, ramfee_account, fee, "ram fee" );
67 channel_to_rex( ramfee_account, fee );
68 }
69
70 int64_t bytes_out;
71
72 const auto& market = _rammarket.get(ramcore_symbol.raw(), "ram market does not exist");
73 _rammarket.modify( market, same_payer, [&]( auto& es ) {
74 bytes_out = es.direct_convert( quant_after_fee, ram_symbol ).amount;
75 });
76
77 check( bytes_out > 0, "must reserve a positive amount" );
78
79 _gstate.total_ram_bytes_reserved += uint64_t(bytes_out);
80 _gstate.total_ram_stake += quant_after_fee.amount;
81
82 user_resources_table userres( get_self(), receiver.value );
83 auto res_itr = userres.find( receiver.value );
84 if( res_itr == userres.end() ) {
85 res_itr = userres.emplace( receiver, [&]( auto& res ) {
86 res.owner = receiver;
87 res.net_weight = asset( 0, core_symbol() );
88 res.cpu_weight = asset( 0, core_symbol() );
89 res.ram_bytes = bytes_out;
90 });
91 } else {
92 userres.modify( res_itr, receiver, [&]( auto& res ) {
93 res.ram_bytes += bytes_out;
94 });
95 }
96
97 auto voter_itr = _voters.find( res_itr->owner.value );
98 if( voter_itr == _voters.end() || !has_field( voter_itr->flags1, voter_info::flags1_fields::ram_managed ) ) {
99 int64_t ram_bytes, net, cpu;
100 get_resource_limits( res_itr->owner, ram_bytes, net, cpu );
101 set_resource_limits( res_itr->owner, res_itr->ram_bytes + ram_gift_bytes, net, cpu );
102 }
103 }
static constexpr sysio::name ram_account
static constexpr symbol ram_symbol
static constexpr symbol ramcore_symbol
static constexpr sysio::name ramfee_account
sysio::multi_index< "userres"_n, user_resources > user_resources_table
signed __int64 int64_t
Definition stdint.h:135
unsigned __int64 uint64_t
Definition stdint.h:136
Here is the caller graph for this function:

◆ buyrambytes()

void sysiosystem::system_contract::buyrambytes ( const name & payer,
const name & receiver,
uint32_t bytes )

Buy a specific amount of ram bytes action. Increases receiver's ram in quantity of bytes provided. An inline transfer from receiver to system contract of tokens will be executed.

Parameters
payer- the ram buyer,
receiver- the ram receiver,
bytes- the quantity of ram to buy specified in bytes.

This action will buy an exact amount of ram and bill the payer the current market price.

Definition at line 25 of file delegate_bandwidth.cpp.

25 {
26 auto itr = _rammarket.find(ramcore_symbol.raw());
27 const int64_t ram_reserve = itr->base.balance.amount;
28 const int64_t eos_reserve = itr->quote.balance.amount;
29 const int64_t cost = exchange_state::get_bancor_input( ram_reserve, eos_reserve, bytes );
30 const int64_t cost_plus_fee = cost / double(0.995);
31 buyram( payer, receiver, asset{ cost_plus_fee, core_symbol() } );
32 }
void buyram(const name &payer, const name &receiver, const asset &quant)
static int64_t get_bancor_input(int64_t out_reserve, int64_t inp_reserve, int64_t out)
Here is the call graph for this function:

◆ buyrex()

void sysiosystem::system_contract::buyrex ( const name & from,
const asset & amount )

Buyrex action, buys REX in exchange for tokens taken out of user's REX fund by transferring core tokens from user REX fund and converts them to REX stake. By buying REX, user is lending tokens in order to be rented as CPU or NET resources. Storage change is billed to 'from' account.

Parameters
from- owner account name,
amount- amount of tokens taken out of 'from' REX fund.
Precondition
A voting requirement must be satisfied before action can be executed.
User must vote for at least 21 producers or delegate vote to proxy before buying REX.
Postcondition
User votes are updated following this action.
Tokens used in purchase are added to user's voting power.
Bought REX cannot be sold before 4 days counting from end of day of purchase.

Definition at line 40 of file rex.cpp.

41 {
42 require_auth( from );
43
44 check( amount.symbol == core_symbol(), "asset must be core token" );
45 check( 0 < amount.amount, "must use positive amount" );
46 check_voting_requirement( from );
47 transfer_from_fund( from, amount );
48 const asset rex_received = add_to_rex_pool( amount );
49 const asset delta_rex_stake = add_to_rex_balance( from, amount, rex_received );
50 runrex(2);
51 update_rex_account( from, asset( 0, core_symbol() ), delta_rex_stake );
52 // dummy action added so that amount of REX tokens purchased shows up in action trace
53 rex_results::buyresult_action buyrex_act( rex_account, std::vector<sysio::permission_level>{ } );
54 buyrex_act.send( rex_received );
55 }
action_wrapper<"buyresult"_n, &rex_results::buyresult > buyresult_action
static constexpr sysio::name rex_account

◆ cfgpowerup()

void sysiosystem::system_contract::cfgpowerup ( powerup_config & args)

Configure the power market. The market becomes available the first time this action is invoked.

Definition at line 119 of file powerup.cpp.

119 {
120 require_auth(get_self());
121 time_point_sec now = sysio::current_time_point();
122 auto core_symbol = get_core_symbol();
123 powerup_state_singleton state_sing{ get_self(), 0 };
124 auto state = state_sing.get_or_default();
125
126 sysio::check(sysio::is_account(reserve_account), "sysio.reserv account must first be created"); // cspell:disable-line
127
128 int64_t net_delta_available = 0;
129 int64_t cpu_delta_available = 0;
130 if (state_sing.exists()) {
131 update_utilization(now, state.net);
132 update_utilization(now, state.cpu);
133 update_weight(now, state.net, net_delta_available);
134 update_weight(now, state.cpu, cpu_delta_available);
135 } else {
136 state.net.utilization_timestamp = now;
137 state.cpu.utilization_timestamp = now;
138 }
139
140 auto is_default_asset = []( const sysio::asset& a ) -> bool {
141 return a.amount == 0 && a.symbol == symbol{};
142 };
143
144 auto update = [&](auto& state, auto& args) {
145 if (!args.current_weight_ratio) {
146 if (state.weight_ratio) {
147 *args.current_weight_ratio = state.weight_ratio;
148 } else {
149 *args.current_weight_ratio = state.initial_weight_ratio;
150 }
151 }
152
153 if (!args.target_weight_ratio) {
154 *args.target_weight_ratio = state.target_weight_ratio;
155 }
156
157 if (!args.assumed_stake_weight) {
158 sysio::check(state.assumed_stake_weight != 0, "assumed_stake_weight does not have a default value");
159 *args.assumed_stake_weight = state.assumed_stake_weight;
160 }
161
162 if (*args.current_weight_ratio == *args.target_weight_ratio) {
163 *args.target_timestamp = now;
164 } else {
165 if (!args.target_timestamp) {
166 sysio::check(state.target_timestamp.utc_seconds != 0, "target_timestamp does not have a default value");
167 *args.target_timestamp = state.target_timestamp;
168 }
169 sysio::check(*args.target_timestamp > now, "target_timestamp must be in the future");
170 }
171
172 if (!args.exponent) {
173 *args.exponent = state.exponent;
174 }
175
176 if (!args.decay_secs) {
177 *args.decay_secs = state.decay_secs;
178 }
179
180 if (!args.max_price) {
181 sysio::check(!is_default_asset(state.max_price), "max_price does not have a default value");
182 *args.max_price = state.max_price;
183 }
184
185 if (!args.min_price) {
186 if (is_default_asset(state.min_price)) {
187 *args.min_price = *args.max_price; // just to copy symbol of max_price
188 args.min_price->amount = 0; // min_price has a default of zero.
189 } else {
190 *args.min_price = state.min_price;
191 }
192 }
193
194 sysio::check(*args.current_weight_ratio > 0, "current_weight_ratio is too small");
195 sysio::check(*args.current_weight_ratio <= powerup_frac, "current_weight_ratio is too large");
196 sysio::check(*args.target_weight_ratio > 0, "target_weight_ratio is too small");
197 sysio::check(*args.target_weight_ratio <= *args.current_weight_ratio, "weight can't grow over time");
198 sysio::check(*args.assumed_stake_weight >= 1,
199 "assumed_stake_weight must be at least 1; a much larger value is recommended");
200 sysio::check(*args.assumed_stake_weight * int128_t(powerup_frac) / *args.target_weight_ratio <=
201 std::numeric_limits<int64_t>::max(),
202 "assumed_stake_weight/target_weight_ratio is too large");
203 sysio::check(*args.exponent >= 1.0, "exponent must be >= 1");
204 sysio::check(*args.decay_secs >= 1, "decay_secs must be >= 1");
205 sysio::check(args.max_price->symbol == core_symbol, "max_price doesn't match core symbol");
206 sysio::check(args.max_price->amount > 0, "max_price must be positive");
207 sysio::check(args.min_price->symbol == core_symbol, "min_price doesn't match core symbol");
208 sysio::check(args.min_price->amount >= 0, "min_price must be non-negative");
209 sysio::check(args.min_price->amount <= args.max_price->amount, "min_price cannot exceed max_price");
210 if (*args.exponent == 1.0) {
211 sysio::check(args.min_price->amount == args.max_price->amount, "min_price and max_price must be the same if the exponent is 1");
212 }
213
214 state.assumed_stake_weight = *args.assumed_stake_weight;
215 state.initial_weight_ratio = *args.current_weight_ratio;
216 state.target_weight_ratio = *args.target_weight_ratio;
217 state.initial_timestamp = now;
218 state.target_timestamp = *args.target_timestamp;
219 state.exponent = *args.exponent;
220 state.decay_secs = *args.decay_secs;
221 state.min_price = *args.min_price;
222 state.max_price = *args.max_price;
223 };
224
225 if (!args.powerup_days) {
226 *args.powerup_days = state.powerup_days;
227 }
228
229 if (!args.min_powerup_fee) {
230 sysio::check(!is_default_asset(state.min_powerup_fee), "min_powerup_fee does not have a default value");
231 *args.min_powerup_fee = state.min_powerup_fee;
232 }
233
234 sysio::check(*args.powerup_days > 0, "powerup_days must be > 0");
235 sysio::check(args.min_powerup_fee->symbol == core_symbol, "min_powerup_fee doesn't match core symbol");
236 sysio::check(args.min_powerup_fee->amount > 0, "min_powerup_fee must be positive");
237
238 state.powerup_days = *args.powerup_days;
239 state.min_powerup_fee = *args.min_powerup_fee;
240
241 update(state.net, args.net);
242 update(state.cpu, args.cpu);
243
244 update_weight(now, state.net, net_delta_available);
245 update_weight(now, state.cpu, cpu_delta_available);
246 sysio::check(state.net.weight >= state.net.utilization, "weight can't shrink below utilization");
247 sysio::check(state.cpu.weight >= state.cpu.utilization, "weight can't shrink below utilization");
248 state.net.adjusted_utilization = std::min(state.net.adjusted_utilization, state.net.weight);
249 state.cpu.adjusted_utilization = std::min(state.cpu.adjusted_utilization, state.cpu.weight);
250
251 adjust_resources(get_self(), reserve_account, core_symbol, net_delta_available, cpu_delta_available, true);
252 state_sing.set(state, get_self());
253}
static symbol get_core_symbol(name system_account="sysio"_n)
static constexpr sysio::name reserve_account
__int128 int128_t
Definition types.hpp:241
void update_utilization(time_point_sec now, powerup_state_resource &res)
Definition powerup.cpp:105
constexpr int64_t powerup_frac
sysio::singleton<"powup.state"_n, powerup_state > powerup_state_singleton
void update_weight(time_point_sec now, powerup_state_resource &res, int64_t &delta_available)
Definition powerup.cpp:91
const GenericPointer< typename T::ValueType > T2 T::AllocatorType & a
Definition pointer.h:1181
Here is the call graph for this function:

◆ claimrewards()

void sysiosystem::system_contract::claimrewards ( const name & owner)

Claim rewards action, claims block producing and vote rewards.

Parameters
owner- producer account claiming per-block and per-vote rewards.

New metric to be used in pervote pay calculation. Instead of vote weight ratio, we combine vote weight and time duration the vote weight has been held into one metric.

Definition at line 76 of file producer_pay.cpp.

76 {
77 require_auth( owner );
78
79 const auto& prod = _producers.get( owner.value );
80 check( prod.active(), "producer does not have an active key" );
81
82 check( _gstate.thresh_activated_stake_time != time_point(),
83 "cannot claim rewards until the chain is activated (at least 15% of all tokens participate in voting)" );
84
85 const auto ct = current_time_point();
86
87 check( ct - prod.last_claim_time > microseconds(useconds_per_day), "already claimed rewards within past day" );
88
89 const asset token_supply = token::get_supply(token_account, core_symbol().code() );
90 const auto usecs_since_last_fill = (ct - _gstate.last_pervote_bucket_fill).count();
91
92 if( usecs_since_last_fill > 0 && _gstate.last_pervote_bucket_fill > time_point() ) {
93 double additional_inflation = (_gstate4.continuous_rate * double(token_supply.amount) * double(usecs_since_last_fill)) / double(useconds_per_year);
94 check( additional_inflation <= double(std::numeric_limits<int64_t>::max() - ((1ll << 10) - 1)),
95 "overflow in calculating new tokens to be issued; inflation rate is too high" );
96 int64_t new_tokens = (additional_inflation < 0.0) ? 0 : static_cast<int64_t>(additional_inflation);
97
98 int64_t to_producers = (new_tokens * uint128_t(pay_factor_precision)) / _gstate4.inflation_pay_factor;
99 int64_t to_savings = new_tokens - to_producers;
100 int64_t to_per_block_pay = (to_producers * uint128_t(pay_factor_precision)) / _gstate4.votepay_factor;
101 int64_t to_per_vote_pay = to_producers - to_per_block_pay;
102
103 if( new_tokens > 0 ) {
104 {
105 token::issue_action issue_act{ token_account, { {get_self(), active_permission} } };
106 issue_act.send( get_self(), asset(new_tokens, core_symbol()), "issue tokens for producer pay and savings" );
107 }
108 {
109 token::transfer_action transfer_act{ token_account, { {get_self(), active_permission} } };
110 if( to_savings > 0 ) {
111 transfer_act.send( get_self(), saving_account, asset(to_savings, core_symbol()), "unallocated inflation" );
112 }
113 if( to_per_block_pay > 0 ) {
114 transfer_act.send( get_self(), bpay_account, asset(to_per_block_pay, core_symbol()), "fund per-block bucket" );
115 }
116 if( to_per_vote_pay > 0 ) {
117 transfer_act.send( get_self(), vpay_account, asset(to_per_vote_pay, core_symbol()), "fund per-vote bucket" );
118 }
119 }
120 }
121
122 _gstate.pervote_bucket += to_per_vote_pay;
123 _gstate.perblock_bucket += to_per_block_pay;
124 _gstate.last_pervote_bucket_fill = ct;
125 }
126
127 auto prod2 = _producers2.find( owner.value );
128
131 const auto last_claim_plus_3days = prod.last_claim_time + microseconds(3 * useconds_per_day);
132
133 bool crossed_threshold = (last_claim_plus_3days <= ct);
134 bool updated_after_threshold = true;
135 if ( prod2 != _producers2.end() ) {
136 updated_after_threshold = (last_claim_plus_3days <= prod2->last_votepay_share_update);
137 } else {
138 prod2 = _producers2.emplace( owner, [&]( producer_info2& info ) {
139 info.owner = owner;
140 info.last_votepay_share_update = ct;
141 });
142 }
143
144 // Note: updated_after_threshold implies cross_threshold (except if claiming rewards when the producers2 table row did not exist).
145 // The exception leads to updated_after_threshold to be treated as true regardless of whether the threshold was crossed.
146 // This is okay because in this case the producer will not get paid anything either way.
147 // In fact it is desired behavior because the producers votes need to be counted in the global total_producer_votepay_share for the first time.
148
149 int64_t producer_per_block_pay = 0;
150 if( _gstate.total_unpaid_blocks > 0 ) {
151 producer_per_block_pay = (_gstate.perblock_bucket * prod.unpaid_blocks) / _gstate.total_unpaid_blocks;
152 }
153
154 double new_votepay_share = update_producer_votepay_share( prod2,
155 ct,
156 updated_after_threshold ? 0.0 : prod.total_votes,
157 true // reset votepay_share to zero after updating
158 );
159
160 int64_t producer_per_vote_pay = 0;
161 if( _gstate2.revision > 0 ) {
162 double total_votepay_share = update_total_votepay_share( ct );
163 if( total_votepay_share > 0 && !crossed_threshold ) {
164 producer_per_vote_pay = int64_t((new_votepay_share * _gstate.pervote_bucket) / total_votepay_share);
165 if( producer_per_vote_pay > _gstate.pervote_bucket )
166 producer_per_vote_pay = _gstate.pervote_bucket;
167 }
168 } else {
169 if( _gstate.total_producer_vote_weight > 0 ) {
170 producer_per_vote_pay = int64_t((_gstate.pervote_bucket * prod.total_votes) / _gstate.total_producer_vote_weight);
171 }
172 }
173
174 if( producer_per_vote_pay < min_pervote_daily_pay ) {
175 producer_per_vote_pay = 0;
176 }
177
178 _gstate.pervote_bucket -= producer_per_vote_pay;
179 _gstate.perblock_bucket -= producer_per_block_pay;
180 _gstate.total_unpaid_blocks -= prod.unpaid_blocks;
181
182 update_total_votepay_share( ct, -new_votepay_share, (updated_after_threshold ? prod.total_votes : 0.0) );
183
184 _producers.modify( prod, same_payer, [&](auto& p) {
185 p.last_claim_time = ct;
186 p.unpaid_blocks = 0;
187 });
188
189 if ( producer_per_block_pay > 0 ) {
191 transfer_act.send( bpay_account, owner, asset(producer_per_block_pay, core_symbol()), "producer block pay" );
192 }
193 if ( producer_per_vote_pay > 0 ) {
195 transfer_act.send( vpay_account, owner, asset(producer_per_vote_pay, core_symbol()), "producer vote pay" );
196 }
197 }
const mie::Vuint & p
Definition bn.cpp:27
sysio::action_wrapper<"issue"_n, &token::issue > issue_action
static asset get_supply(const name &token_contract_account, const symbol_code &sym_code)
static constexpr sysio::name vpay_account
static constexpr sysio::name saving_account
static constexpr sysio::name bpay_account
int * count
uint8_t revision
used to track version updates in the future.
Here is the call graph for this function:

◆ closerex()

void sysiosystem::system_contract::closerex ( const name & owner)

Closerex action, deletes owner records from REX tables and frees used RAM. Owner must not have an outstanding REX balance.

Parameters
owner- user account name.
Precondition
If owner has a non-zero REX balance, the action fails; otherwise, owner REX balance entry is deleted.
If owner has no outstanding loans and a zero REX fund balance, REX fund entry is deleted.

check for any outstanding loans or rex fund

check for remaining rex balance

Definition at line 319 of file rex.cpp.

320 {
321 require_auth( owner );
322
323 if ( rex_system_initialized() )
324 runrex(2);
325
326 update_rex_account( owner, asset( 0, core_symbol() ), asset( 0, core_symbol() ) );
327
329 {
330 rex_cpu_loan_table cpu_loans( get_self(), get_self().value );
331 auto cpu_idx = cpu_loans.get_index<"byowner"_n>();
332 bool no_outstanding_cpu_loans = ( cpu_idx.find( owner.value ) == cpu_idx.end() );
333
334 rex_net_loan_table net_loans( get_self(), get_self().value );
335 auto net_idx = net_loans.get_index<"byowner"_n>();
336 bool no_outstanding_net_loans = ( net_idx.find( owner.value ) == net_idx.end() );
337
338 auto fund_itr = _rexfunds.find( owner.value );
339 bool no_outstanding_rex_fund = ( fund_itr != _rexfunds.end() ) && ( fund_itr->balance.amount == 0 );
340
341 if ( no_outstanding_cpu_loans && no_outstanding_net_loans && no_outstanding_rex_fund ) {
342 _rexfunds.erase( fund_itr );
343 }
344 }
345
347 {
348 auto rex_itr = _rexbalance.find( owner.value );
349 if ( rex_itr != _rexbalance.end() ) {
350 check( rex_itr->rex_balance.amount == 0, "account has remaining REX balance, must sell first");
351 _rexbalance.erase( rex_itr );
352 }
353 }
354 }
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::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

◆ cnclrexorder()

void sysiosystem::system_contract::cnclrexorder ( const name & owner)

Cnclrexorder action, cancels unfilled REX sell order by owner if one exists.

Parameters
owner- owner account name.
Precondition
Order cannot be cancelled once it's been filled.

Definition at line 147 of file rex.cpp.

148 {
149 require_auth( owner );
150
151 auto itr = _rexorders.require_find( owner.value, "no sellrex order is scheduled" );
152 check( itr->is_open, "sellrex order has been filled and cannot be canceled" );
153 _rexorders.erase( itr );
154 }

◆ consolidate()

void sysiosystem::system_contract::consolidate ( const name & owner)

Consolidate action, consolidates REX maturity buckets into one bucket that can be sold after 4 days starting from the end of the day.

Parameters
owner- REX owner account name.

Definition at line 251 of file rex.cpp.

252 {
253 require_auth( owner );
254
255 runrex(2);
256
257 auto bitr = _rexbalance.require_find( owner.value, "account has no REX balance" );
258 asset rex_in_sell_order = update_rex_account( owner, asset( 0, core_symbol() ), asset( 0, core_symbol() ) );
259 consolidate_rex_balance( bitr, rex_in_sell_order );
260 }

◆ defcpuloan()

void sysiosystem::system_contract::defcpuloan ( const name & from,
uint64_t loan_num,
const asset & amount )

Defcpuloan action, withdraws tokens from the fund of a specific CPU loan and adds them to REX fund.

Parameters
from- loan creator account,
loan_num- loan id,
amount- tokens transferred from CPU loan fund to REX fund.

Definition at line 190 of file rex.cpp.

191 {
192 require_auth( from );
193
194 rex_cpu_loan_table cpu_loans( get_self(), get_self().value );
195 defund_rex_loan( cpu_loans, from, loan_num, amount );
196 }

◆ defnetloan()

void sysiosystem::system_contract::defnetloan ( const name & from,
uint64_t loan_num,
const asset & amount )

Defnetloan action, withdraws tokens from the fund of a specific NET loan and adds them to REX fund.

Parameters
from- loan creator account,
loan_num- loan id,
amount- tokens transferred from NET loan fund to REX fund.

Definition at line 198 of file rex.cpp.

199 {
200 require_auth( from );
201
202 rex_net_loan_table net_loans( get_self(), get_self().value );
203 defund_rex_loan( net_loans, from, loan_num, amount );
204 }

◆ delegatebw()

void sysiosystem::system_contract::delegatebw ( const name & from,
const name & receiver,
const asset & stake_net_quantity,
const asset & stake_cpu_quantity,
bool transfer )

Delegate bandwidth and/or cpu action. Stakes SYS from the balance of from for the benefit of receiver.

Parameters
from- the account to delegate bandwidth from, that is, the account holding tokens to be staked,
receiver- the account to delegate bandwidth to, that is, the account to whose resources staked tokens are added
stake_net_quantity- tokens staked for NET bandwidth,
stake_cpu_quantity- tokens staked for CPU bandwidth,
transfer- if true, ownership of staked tokens is transferred to receiver.
Postcondition
All producers from account has voted for will have their votes updated immediately.

Definition at line 373 of file delegate_bandwidth.cpp.

376 {
377 asset zero_asset( 0, core_symbol() );
378 check( stake_cpu_quantity >= zero_asset, "must stake a positive amount" );
379 check( stake_net_quantity >= zero_asset, "must stake a positive amount" );
380 check( stake_net_quantity.amount + stake_cpu_quantity.amount > 0, "must stake a positive amount" );
381 check( !transfer || from != receiver, "cannot use transfer flag if delegating to self" );
382
383 changebw( from, receiver, stake_net_quantity, stake_cpu_quantity, transfer);
384 } // delegatebw

◆ deposit()

void sysiosystem::system_contract::deposit ( const name & owner,
const asset & amount )

Deposit to REX fund action. Deposits core tokens to user REX fund. All proceeds and expenses related to REX are added to or taken out of this fund. An inline transfer from 'owner' liquid balance is executed. All REX-related costs and proceeds are deducted from and added to 'owner' REX fund, with one exception being buying REX using staked tokens. Storage change is billed to 'owner'.

Parameters
owner- REX fund owner account,
amount- amount of tokens to be deposited.

Definition at line 11 of file rex.cpp.

12 {
13 require_auth( owner );
14
15 check( amount.symbol == core_symbol(), "must deposit core token" );
16 check( 0 < amount.amount, "must deposit a positive amount" );
17 // inline transfer from owner's token balance
18 {
19 token::transfer_action transfer_act{ token_account, { owner, active_permission } };
20 transfer_act.send( owner, rex_account, amount, "deposit to REX fund" );
21 }
22 transfer_to_fund( owner, amount );
23 }

◆ fundcpuloan()

void sysiosystem::system_contract::fundcpuloan ( const name & from,
uint64_t loan_num,
const asset & payment )

Fundcpuloan action, transfers tokens from REX fund to the fund of a specific CPU loan in order to be used for loan renewal at expiry.

Parameters
from- loan creator account,
loan_num- loan id,
payment- tokens transferred from REX fund to loan fund.

Definition at line 174 of file rex.cpp.

175 {
176 require_auth( from );
177
178 rex_cpu_loan_table cpu_loans( get_self(), get_self().value );
179 fund_rex_loan( cpu_loans, from, loan_num, payment );
180 }

◆ fundnetloan()

void sysiosystem::system_contract::fundnetloan ( const name & from,
uint64_t loan_num,
const asset & payment )

Fundnetloan action, transfers tokens from REX fund to the fund of a specific NET loan in order to be used for loan renewal at expiry.

Parameters
from- loan creator account,
loan_num- loan id,
payment- tokens transferred from REX fund to loan fund.

Definition at line 182 of file rex.cpp.

183 {
184 require_auth( from );
185
186 rex_net_loan_table net_loans( get_self(), get_self().value );
187 fund_rex_loan( net_loans, from, loan_num, payment );
188 }

◆ get_core_symbol()

static symbol sysiosystem::system_contract::get_core_symbol ( name system_account = "sysio"_n)
inlinestatic

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

723 {
724 rammarket rm(system_account, system_account.value);
725 const static auto sym = get_core_symbol( rm );
726 return sym;
727 }
sysio::multi_index< "rammarket"_n, exchange_state > rammarket
Here is the caller graph for this function:

◆ init()

void sysiosystem::system_contract::init ( unsigned_int version,
const symbol & core )

The Init action initializes the system contract for a version and a symbol. Only succeeds when:

  • version is 0 and
  • symbol is found and
  • system token supply is greater than 0,
  • and system contract wasn’t already been initialized.
Parameters
version- the version, has to be 0,
core- the system symbol.

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

490 {
491 require_auth( get_self() );
492 check( version.value == 0, "unsupported version for init action" );
493
494 auto itr = _rammarket.find(ramcore_symbol.raw());
495 check( itr == _rammarket.end(), "system contract has already been initialized" );
496
497 auto system_token_supply = sysio::token::get_supply(token_account, core.code() );
498 check( system_token_supply.symbol == core, "specified core symbol does not exist (precision mismatch)" );
499
500 check( system_token_supply.amount > 0, "system token supply must be greater than 0" );
501 _rammarket.emplace( get_self(), [&]( auto& m ) {
502 m.supply.amount = 100000000000000ll;
503 m.supply.symbol = ramcore_symbol;
504 m.base.balance.amount = int64_t(_gstate.free_ram());
505 m.base.balance.symbol = ram_symbol;
506 m.quote.balance.amount = system_token_supply.amount / 1000;
507 m.quote.balance.symbol = core;
508 });
509
510 token::open_action open_act{ token_account, { {get_self(), active_permission} } };
511 open_act.send( rex_account, core, get_self() );
512 }
symbol(uint8_t p, const char *s)
Definition symbol.hpp:62
sysio::action_wrapper<"open"_n, &token::open > open_action
Here is the call graph for this function:

◆ limitauthchg()

void sysiosystem::system_contract::limitauthchg ( const name & account,
const std::vector< name > & allow_perms,
const std::vector< name > & disallow_perms )

limitauthchg opts into or out of restrictions on updateauth, deleteauth, linkauth, and unlinkauth.

If either allow_perms or disallow_perms is non-empty, then opts into restrictions. If allow_perms is non-empty, then the authorized_by argument of the restricted actions must be in the vector, or the actions will abort. If disallow_perms is non-empty, then the authorized_by argument of the restricted actions must not be in the vector, or the actions will abort.

If both allow_perms and disallow_perms are empty, then opts out of the restrictions. limitauthchg aborts if both allow_perms and disallow_perms are non-empty.

Parameters
account- account to change
allow_perms- permissions which may use the restricted actions
disallow_perms- permissions which may not use the restricted actions

Definition at line 6 of file limit_auth_changes.cpp.

7 {
8 limit_auth_change_table table(get_self(), get_self().value);
9 require_auth(account);
10 sysio::check(allow_perms.empty() || disallow_perms.empty(), "either allow_perms or disallow_perms must be empty");
11 sysio::check(allow_perms.empty() ||
12 std::find(allow_perms.begin(), allow_perms.end(), "owner"_n) != allow_perms.end(),
13 "allow_perms does not contain owner");
14 sysio::check(disallow_perms.empty() ||
15 std::find(disallow_perms.begin(), disallow_perms.end(), "owner"_n) == disallow_perms.end(),
16 "disallow_perms contains owner");
17 auto it = table.find(account.value);
18 if(!allow_perms.empty() || !disallow_perms.empty()) {
19 if(it == table.end()) {
20 table.emplace(account, [&](auto& row){
21 row.account = account;
22 row.allow_perms = allow_perms;
23 row.disallow_perms = disallow_perms;
24 });
25 } else {
26 table.modify(it, account, [&](auto& row){
27 row.allow_perms = allow_perms;
28 row.disallow_perms = disallow_perms;
29 });
30 }
31 } else {
32 if(it != table.end())
33 table.erase(it);
34 }
35 }
sysio::multi_index<"limitauthchg"_n, limit_auth_change > limit_auth_change_table

◆ mvfrsavings()

void sysiosystem::system_contract::mvfrsavings ( const name & owner,
const asset & rex )

Mvfrsavings action, moves a specified amount of REX out of savings bucket. The moved amount will have the regular REX maturity period of 4 days.

Parameters
owner- REX owner account name.
rex- amount of REX to be moved.

Definition at line 296 of file rex.cpp.

297 {
298 require_auth( owner );
299
300 runrex(2);
301
302 auto bitr = _rexbalance.require_find( owner.value, "account has no REX balance" );
303 check( rex.amount > 0 && rex.symbol == bitr->rex_balance.symbol, "asset must be a positive amount of (REX, 4)" );
304 const int64_t rex_in_savings = read_rex_savings( bitr );
305 check( rex.amount <= rex_in_savings, "insufficient REX in savings" );
306 process_rex_maturities( bitr );
307 _rexbalance.modify( bitr, same_payer, [&]( auto& rb ) {
308 const time_point_sec maturity = get_rex_maturity();
309 if ( !rb.rex_maturities.empty() && rb.rex_maturities.back().first == maturity ) {
310 rb.rex_maturities.back().second += rex.amount;
311 } else {
312 rb.rex_maturities.emplace_back( pair_time_point_sec_int64 { maturity, rex.amount } );
313 }
314 });
315 put_rex_savings( bitr, rex_in_savings - rex.amount );
316 update_rex_account( owner, asset( 0, core_symbol() ), asset( 0, core_symbol() ) );
317 }

◆ mvtosavings()

void sysiosystem::system_contract::mvtosavings ( const name & owner,
const asset & rex )

Mvtosavings action, moves a specified amount of REX into savings bucket. REX savings bucket never matures. In order for it to be sold, it has to be moved explicitly out of that bucket. Then the moved amount will have the regular maturity period of 4 days starting from the end of the day.

Parameters
owner- REX owner account name.
rex- amount of REX to be moved.

Definition at line 262 of file rex.cpp.

263 {
264 require_auth( owner );
265
266 runrex(2);
267
268 auto bitr = _rexbalance.require_find( owner.value, "account has no REX balance" );
269 check( rex.amount > 0 && rex.symbol == bitr->rex_balance.symbol, "asset must be a positive amount of (REX, 4)" );
270 const asset rex_in_sell_order = update_rex_account( owner, asset( 0, core_symbol() ), asset( 0, core_symbol() ) );
271 const int64_t rex_in_savings = read_rex_savings( bitr );
272 check( rex.amount + rex_in_sell_order.amount + rex_in_savings <= bitr->rex_balance.amount,
273 "insufficient REX balance" );
274 process_rex_maturities( bitr );
275 _rexbalance.modify( bitr, same_payer, [&]( auto& rb ) {
276 int64_t moved_rex = 0;
277 while ( !rb.rex_maturities.empty() && moved_rex < rex.amount) {
278 const int64_t d_rex = std::min( rex.amount - moved_rex, rb.rex_maturities.back().second );
279 rb.rex_maturities.back().second -= d_rex;
280 moved_rex += d_rex;
281 if ( rb.rex_maturities.back().second == 0 ) {
282 rb.rex_maturities.pop_back();
283 }
284 }
285 if ( moved_rex < rex.amount ) {
286 const int64_t d_rex = rex.amount - moved_rex;
287 rb.matured_rex -= d_rex;
288 moved_rex += d_rex;
289 check( rex_in_sell_order.amount <= rb.matured_rex, "logic error in mvtosavings" );
290 }
291 check( moved_rex == rex.amount, "programmer error in mvtosavings" );
292 });
293 put_rex_savings( bitr, rex_in_savings + rex.amount );
294 }

◆ onblock()

void sysiosystem::system_contract::onblock ( ignore< block_header > header)

On block action. This special action is triggered when a block is applied by the given producer and cannot be generated from any other source. It is used to pay producers and calculate missed blocks of other producers. Producer pay is deposited into the producer's stake balance and can be withdrawn over time. Once a minute, it may update the active producer config from the producer votes. The action also populates the blockinfo table.

Parameters
header- the block header produced.

until activation, no new rewards are paid

start the presses

At startup the initial producer may not be one that is registered / elected and therefore there may be no producer object for them.

only update block producers once every minute, block_timestamp is in half seconds

Definition at line 10 of file producer_pay.cpp.

10 {
11 using namespace sysio;
12
13 require_auth(get_self());
14
15 // Deserialize needed fields from block header.
16 block_timestamp timestamp;
17 name producer;
18 uint16_t confirmed;
19 checksum256 previous_block_id;
20
21 _ds >> timestamp >> producer >> confirmed >> previous_block_id;
22 (void)confirmed; // Only to suppress warning since confirmed is not used.
23
24 // Add latest block information to blockinfo table.
25 add_to_blockinfo_table(previous_block_id, timestamp);
26
27 // _gstate2.last_block_num is not used anywhere in the system contract code anymore.
28 // Although this field is deprecated, we will continue updating it for now until the last_block_num field
29 // is eventually completely removed, at which point this line can be removed.
30 _gstate2.last_block_num = timestamp;
31
34 return;
35
36 if( _gstate.last_pervote_bucket_fill == time_point() )
37 _gstate.last_pervote_bucket_fill = current_time_point();
38
39
44 auto prod = _producers.find( producer.value );
45 if ( prod != _producers.end() ) {
46 _gstate.total_unpaid_blocks++;
47 _producers.modify( prod, same_payer, [&](auto& p ) {
48 p.unpaid_blocks++;
49 });
50 }
51
53 if( timestamp.slot - _gstate.last_producer_schedule_update.slot > 120 ) {
54 update_elected_producers( timestamp );
55
56 if( (timestamp.slot - _gstate.last_name_close.slot) > blocks_per_day ) {
57 name_bid_table bids(get_self(), get_self().value);
58 auto idx = bids.get_index<"highbid"_n>();
59 auto highest = idx.lower_bound( std::numeric_limits<uint64_t>::max()/2 );
60 if( highest != idx.end() &&
61 highest->high_bid > 0 &&
62 (current_time_point() - highest->last_bid_time) > microseconds(useconds_per_day) &&
64 (current_time_point() - _gstate.thresh_activated_stake_time) > microseconds(14 * useconds_per_day)
65 ) {
66 _gstate.last_name_close = timestamp;
67 channel_namebid_to_rex( highest->high_bid );
68 idx.modify( highest, same_payer, [&]( auto& b ){
69 b.high_bid = -b.high_bid;
70 });
71 }
72 }
73 }
74 }
unsigned short uint16_t
Definition stdint.h:125
Immutable except for fc::from_variant.
Definition name.hpp:43
block_timestamp last_producer_schedule_update
block_timestamp last_name_close
the sum of all producer votes

◆ onlinkauth()

void sysiosystem::system_contract::onlinkauth ( const name & user,
const name & permission,
const sysio::public_key & pub_key )

On Link Auth notify to catch auth.ext stuff for sig-em

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

515 {
516 // Convert pub_key to authority object
517 authority auth;
518 auth.threshold = 1;
519
520 auth.keys.push_back({pub_key, 1});
521
522 // Update auth with special permission.
523 updateauth_action update_auth{ get_self(), { {get_self(), active_permission} } };
524 update_auth.send(account_name, name("auth.ext"), name("owner"), auth, name(""));
525 }
sysio::action_wrapper<"updateauth"_n, &native::updateauth > updateauth_action
Definition native.hpp:314

◆ powerup()

void sysiosystem::system_contract::powerup ( const name & payer,
const name & receiver,
uint32_t days,
int64_t net_frac,
int64_t cpu_frac,
const asset & max_payment )

Powerup NET and CPU resources by percentage

Parameters
payer- the resource buyer
receiver- the resource receiver
days- number of days of resource availability. Must match market configuration.
net_frac- fraction of net (100% = 10^15) managed by this market
cpu_frac- fraction of cpu (100% = 10^15) managed by this market
max_payment- the maximum amount payer is willing to pay. Tokens are withdrawn from payer's token balance.

Definition at line 334 of file powerup.cpp.

335 {
336 require_auth(payer);
337 powerup_state_singleton state_sing{ get_self(), 0 };
338 powerup_order_table orders{ get_self(), 0 };
339 sysio::check(state_sing.exists(), "powerup hasn't been initialized");
340 auto state = state_sing.get();
341 time_point_sec now = sysio::current_time_point();
342 auto core_symbol = get_core_symbol();
343 sysio::check(max_payment.symbol == core_symbol, "max_payment doesn't match core symbol");
344 sysio::check(days == state.powerup_days, "days doesn't match configuration");
345 sysio::check(net_frac >= 0, "net_frac can't be negative");
346 sysio::check(cpu_frac >= 0, "cpu_frac can't be negative");
347 sysio::check(net_frac <= powerup_frac, "net can't be more than 100%");
348 sysio::check(cpu_frac <= powerup_frac, "cpu can't be more than 100%");
349
350 int64_t net_delta_available = 0;
351 int64_t cpu_delta_available = 0;
352 process_powerup_queue(now, core_symbol, state, orders, 2, net_delta_available, cpu_delta_available);
353
354 sysio::asset fee{ 0, core_symbol };
355 auto process = [&](int64_t frac, int64_t& amount, powerup_state_resource& state) {
356 if (!frac)
357 return;
358 amount = int128_t(frac) * state.weight / powerup_frac;
359 sysio::check(state.weight, "market doesn't have resources available");
360 sysio::check(state.utilization + amount <= state.weight, "market doesn't have enough resources available");
361 int64_t f = calc_powerup_fee(state, amount);
362 sysio::check(f > 0, "calculated fee is below minimum; try powering up with more resources");
363 fee.amount += f;
364 state.utilization += amount;
365 };
366
367 int64_t net_amount = 0;
368 int64_t cpu_amount = 0;
369 process(net_frac, net_amount, state.net);
370 process(cpu_frac, cpu_amount, state.cpu);
371 if (fee > max_payment) {
372 std::string error_msg = "max_payment is less than calculated fee: ";
373 error_msg += fee.to_string();
374 sysio::check(false, error_msg);
375 }
376 sysio::check(fee >= state.min_powerup_fee, "calculated fee is below minimum; try powering up with more resources");
377
378 orders.emplace(payer, [&](auto& order) {
379 order.id = orders.available_primary_key();
380 order.owner = receiver;
381 order.net_weight = net_amount;
382 order.cpu_weight = cpu_amount;
383 order.expires = now + sysio::days(days);
384 });
385 net_delta_available -= net_amount;
386 cpu_delta_available -= cpu_amount;
387
388 adjust_resources(payer, receiver, core_symbol, net_amount, cpu_amount, true);
389 adjust_resources(get_self(), reserve_account, core_symbol, net_delta_available, cpu_delta_available, true);
390 channel_to_rex(payer, fee, true);
391 state_sing.set(state, get_self());
392
393 // inline noop action
394 powup_results::powupresult_action powupresult_act{ reserve_account, std::vector<sysio::permission_level>{ } };
395 powupresult_act.send( fee, net_amount, cpu_amount );
396}
action_wrapper<"powupresult"_n, &powup_results::powupresult > powupresult_action
constexpr microseconds days(int64_t d)
Definition time.hpp:36
int64_t calc_powerup_fee(const powerup_state_resource &state, int64_t utilization_increase)
Definition powerup.cpp:262
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
auto process(get_latest_block_batch_info request) -> latest_block_batch_info_result
Here is the call graph for this function:

◆ powerupexec()

void sysiosystem::system_contract::powerupexec ( const name & user,
uint16_t max )

Process power queue and update state. Action does not execute anything related to a specific user.

Parameters
user- any account can execute this action
max- number of queue items to process

Definition at line 317 of file powerup.cpp.

317 {
318 require_auth(user);
319 powerup_state_singleton state_sing{ get_self(), 0 };
320 powerup_order_table orders{ get_self(), 0 };
321 sysio::check(state_sing.exists(), "powerup hasn't been initialized");
322 auto state = state_sing.get();
323 time_point_sec now = sysio::current_time_point();
324 auto core_symbol = get_core_symbol();
325
326 int64_t net_delta_available = 0;
327 int64_t cpu_delta_available = 0;
328 process_powerup_queue(now, core_symbol, state, orders, max, net_delta_available, cpu_delta_available);
329
330 adjust_resources(get_self(), reserve_account, core_symbol, net_delta_available, cpu_delta_available, true);
331 state_sing.set(state, get_self());
332}
Here is the call graph for this function:

◆ refund()

void sysiosystem::system_contract::refund ( const name & owner)

Refund action, this action is called after the delegation-period to claim all pending unstaked tokens belonging to owner.

Parameters
owner- the owner of the tokens claimed.

Definition at line 400 of file delegate_bandwidth.cpp.

400 {
401 require_auth( owner );
402
403 refunds_table refunds_tbl( get_self(), owner.value );
404 auto req = refunds_tbl.find( owner.value );
405 check( req != refunds_tbl.end(), "refund request not found" );
406 check( req->request_time + seconds(refund_delay_sec) <= current_time_point(),
407 "refund is not available yet" );
409 transfer_act.send( stake_account, req->owner, req->net_amount + req->cpu_amount, "unstake" );
410 refunds_tbl.erase( req );
411 }
static constexpr sysio::name stake_account

◆ regproducer()

void sysiosystem::system_contract::regproducer ( const name & producer,
const public_key & producer_key,
const std::string & url,
uint16_t location )

Register producer action, indicates that a particular account wishes to become a producer, this action will create a producer_config and a producer_info object for producer scope in producers tables.

Parameters
producer- account registering to be a producer candidate,
producer_key- the public key of the block producer, this is the key used by block producer to sign blocks,
url- the url of the block producer, normally the url of the block producer presentation website,
location- is the country code as defined in the ISO 3166, https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
Precondition
Producer to register is an account
Authority of producer to register

Definition at line 79 of file voting.cpp.

79 {
80 require_auth( producer );
81 check( url.size() < 512, "url too long" );
82
83 register_producer( producer, convert_to_block_signing_authority( producer_key ), url, location );
84 }
sysio::block_signing_authority convert_to_block_signing_authority(const sysio::public_key &producer_key)
string url
Definition main.cpp:166
Here is the call graph for this function:

◆ regproducer2()

void sysiosystem::system_contract::regproducer2 ( const name & producer,
const sysio::block_signing_authority & producer_authority,
const std::string & url,
uint16_t location )

Register producer action, indicates that a particular account wishes to become a producer, this action will create a producer_config and a producer_info object for producer scope in producers tables.

Parameters
producer- account registering to be a producer candidate,
producer_authority- the weighted threshold multisig block signing authority of the block producer used to sign blocks,
url- the url of the block producer, normally the url of the block producer presentation website,
location- is the country code as defined in the ISO 3166, https://en.wikipedia.org/wiki/List_of_ISO_3166_country_codes
Precondition
Producer to register is an account
Authority of producer to register

Definition at line 86 of file voting.cpp.

86 {
87 require_auth( producer );
88 check( url.size() < 512, "url too long" );
89
90 std::visit( [&](auto&& auth ) {
91 check( auth.is_valid(), "invalid producer authority" );
92 }, producer_authority );
93
94 register_producer( producer, producer_authority, url, location );
95 }

◆ regproxy()

void sysiosystem::system_contract::regproxy ( const name & proxy,
bool isproxy )

Register proxy action, sets proxy account as proxy. An account marked as a proxy can vote with the weight of other accounts which have selected it as a proxy. Other accounts must refresh their voteproducer to update the proxy's weight. Storage change is billed to proxy.

Parameters
proxy- the account registering as voter proxy (or unregistering),
isproxy- if true, proxy is registered; if false, proxy is unregistered.
Precondition
Proxy must have something staked (existing row in voters table)
New state must be different than current state

Definition at line 374 of file voting.cpp.

374 {
375 require_auth( proxy );
376
377 auto pitr = _voters.find( proxy.value );
378 if ( pitr != _voters.end() ) {
379 check( isproxy != pitr->is_proxy, "action has no effect" );
380 check( !isproxy || !pitr->proxy, "account that uses a proxy is not allowed to become a proxy" );
381 _voters.modify( pitr, same_payer, [&]( auto& p ) {
382 p.is_proxy = isproxy;
383 });
384 propagate_weight_change( *pitr );
385 } else {
386 _voters.emplace( proxy, [&]( auto& p ) {
387 p.owner = proxy;
388 p.is_proxy = isproxy;
389 });
390 }
391 }

◆ rentcpu()

void sysiosystem::system_contract::rentcpu ( const name & from,
const name & receiver,
const asset & loan_payment,
const asset & loan_fund )

Rentcpu action, uses payment to rent as many SYS tokens as possible as determined by market price and stake them for CPU for the benefit of receiver, after 30 days the rented core delegation of CPU will expire. At expiration, if balance is greater than or equal to loan_payment, loan_payment is taken out of loan balance and used to renew the loan. Otherwise, the loan is closed and user is refunded any remaining balance. Owner can fund or refund a loan at any time before its expiration. All loan expenses and refunds come out of or are added to owner's REX fund.

Parameters
from- account creating and paying for CPU loan, 'from' account can add tokens to loan balance using action fundcpuloan and withdraw from loan balance using defcpuloan
receiver- account receiving rented CPU resources,
loan_payment- tokens paid for the loan, it has to be greater than zero, amount of rented resources is calculated from loan_payment,
loan_fund- additional tokens can be zero, and is added to loan balance. Loan balance represents a reserve that is used at expiration for automatic loan renewal.

Definition at line 156 of file rex.cpp.

157 {
158 require_auth( from );
159
160 rex_cpu_loan_table cpu_loans( get_self(), get_self().value );
161 int64_t rented_tokens = rent_rex( cpu_loans, from, receiver, loan_payment, loan_fund );
162 update_resource_limits( from, receiver, 0, rented_tokens );
163 }

◆ rentnet()

void sysiosystem::system_contract::rentnet ( const name & from,
const name & receiver,
const asset & loan_payment,
const asset & loan_fund )

Rentnet action, uses payment to rent as many SYS tokens as possible as determined by market price and stake them for NET for the benefit of receiver, after 30 days the rented core delegation of NET will expire. At expiration, if balance is greater than or equal to loan_payment, loan_payment is taken out of loan balance and used to renew the loan. Otherwise, the loan is closed and user is refunded any remaining balance. Owner can fund or refund a loan at any time before its expiration. All loan expenses and refunds come out of or are added to owner's REX fund.

Parameters
from- account creating and paying for NET loan, 'from' account can add tokens to loan balance using action fundnetloan and withdraw from loan balance using defnetloan,
receiver- account receiving rented NET resources,
loan_payment- tokens paid for the loan, it has to be greater than zero, amount of rented resources is calculated from loan_payment,
loan_fund- additional tokens can be zero, and is added to loan balance. Loan balance represents a reserve that is used at expiration for automatic loan renewal.

Definition at line 165 of file rex.cpp.

166 {
167 require_auth( from );
168
169 rex_net_loan_table net_loans( get_self(), get_self().value );
170 int64_t rented_tokens = rent_rex( net_loans, from, receiver, loan_payment, loan_fund );
171 update_resource_limits( from, receiver, rented_tokens, 0 );
172 }

◆ rexexec()

void sysiosystem::system_contract::rexexec ( const name & user,
uint16_t max )

Rexexec action, processes max CPU loans, max NET loans, and max queued sellrex orders. Action does not execute anything related to a specific user.

Parameters
user- any account can execute this action,
max- number of each of CPU loans, NET loans, and sell orders to be processed.

Definition at line 244 of file rex.cpp.

245 {
246 require_auth( user );
247
248 runrex( max );
249 }

◆ rmvproducer()

void sysiosystem::system_contract::rmvproducer ( const name & producer)

Remove producer action, deactivates a producer by name, if not found asserts.

Parameters
producer- the producer account to deactivate.

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

393 {
394 require_auth( get_self() );
395 auto prod = _producers.find( producer.value );
396 check( prod != _producers.end(), "producer not found" );
397 _producers.modify( prod, same_payer, [&](auto& p) {
398 p.deactivate();
399 });
400 }

◆ sellram()

void sysiosystem::system_contract::sellram ( const name & account,
int64_t bytes )

Sell ram action, reduces quota by bytes and then performs an inline transfer of tokens to receiver based upon the average purchase price of the original quota.

Parameters
account- the ram seller account,
bytes- the amount of ram to sell in bytes.

The system contract now buys and sells RAM allocations at prevailing market prices. This may result in traders buying RAM today in anticipation of potential shortages tomorrow. Overall this will result in the market balancing the supply and demand for RAM over time.

the cast to int64_t of bytes is safe because we certify bytes is <= quota which is limited by prior purchases

.5% fee (round up)

Definition at line 111 of file delegate_bandwidth.cpp.

111 {
112 require_auth( account );
113 update_ram_supply();
114
115 check( bytes > 0, "cannot sell negative byte" );
116
117 user_resources_table userres( get_self(), account.value );
118 auto res_itr = userres.find( account.value );
119 check( res_itr != userres.end(), "no resource row" );
120 check( res_itr->ram_bytes >= bytes, "insufficient quota" );
121
122 asset tokens_out;
123 auto itr = _rammarket.find(ramcore_symbol.raw());
124 _rammarket.modify( itr, same_payer, [&]( auto& es ) {
126 tokens_out = es.direct_convert( asset(bytes, ram_symbol), core_symbol());
127 });
128
129 check( tokens_out.amount > 1, "token amount received from selling ram is too low" );
130
131 _gstate.total_ram_bytes_reserved -= static_cast<decltype(_gstate.total_ram_bytes_reserved)>(bytes); // bytes > 0 is asserted above
132 _gstate.total_ram_stake -= tokens_out.amount;
133
135 check( _gstate.total_ram_stake >= 0, "error, attempt to unstake more tokens than previously staked" );
136
137 userres.modify( res_itr, account, [&]( auto& res ) {
138 res.ram_bytes -= bytes;
139 });
140
141 auto voter_itr = _voters.find( res_itr->owner.value );
142 if( voter_itr == _voters.end() || !has_field( voter_itr->flags1, voter_info::flags1_fields::ram_managed ) ) {
143 int64_t ram_bytes, net, cpu;
144 get_resource_limits( res_itr->owner, ram_bytes, net, cpu );
145 set_resource_limits( res_itr->owner, res_itr->ram_bytes + ram_gift_bytes, net, cpu );
146 }
147
148 {
150 transfer_act.send( ram_account, account, asset(tokens_out), "sell ram" );
151 }
152 auto fee = ( tokens_out.amount + 199 ) / 200;
153 // since tokens_out.amount was asserted to be at least 2 earlier, fee.amount < tokens_out.amount
154 if ( fee > 0 ) {
155 token::transfer_action transfer_act{ token_account, { {account, active_permission} } };
156 transfer_act.send( account, ramfee_account, asset(fee, core_symbol()), "sell ram fee" );
157 channel_to_rex( ramfee_account, asset(fee, core_symbol() ));
158 }
159 }
vector< char > bytes
Definition types.hpp:243

◆ sellrex()

void sysiosystem::system_contract::sellrex ( const name & from,
const asset & rex )

Sellrex action, sells REX in exchange for core tokens by converting REX stake back into core tokens at current exchange rate. If order cannot be processed, it gets queued until there is enough in REX pool to fill order, and will be processed within 30 days at most. If successful, user votes are updated, that is, proceeds are deducted from user's voting power. In case sell order is queued, storage change is billed to 'from' account.

Parameters
from- owner account of REX,
rex- amount of REX to be sold.

REX order couldn't be filled and is added to queue. If account already has an open order, requested rex is added to existing order.

Definition at line 97 of file rex.cpp.

98 {
99 require_auth( from );
100
101 runrex(2);
102
103 auto bitr = _rexbalance.require_find( from.value, "user must first buyrex" );
104 check( rex.amount > 0 && rex.symbol == bitr->rex_balance.symbol,
105 "asset must be a positive amount of (REX, 4)" );
106 process_rex_maturities( bitr );
107 check( rex.amount <= bitr->matured_rex, "insufficient available rex" );
108
109 const auto current_order = fill_rex_order( bitr, rex );
110 if ( current_order.success && current_order.proceeds.amount == 0 ) {
111 check( false, "proceeds are negligible" );
112 }
113 asset pending_sell_order = update_rex_account( from, current_order.proceeds, current_order.stake_change );
114 if ( !current_order.success ) {
115 if ( from == "b1"_n ) {
116 check( false, "b1 sellrex orders should not be queued" );
117 }
122 auto oitr = _rexorders.find( from.value );
123 if ( oitr == _rexorders.end() ) {
124 oitr = _rexorders.emplace( from, [&]( auto& order ) {
125 order.owner = from;
126 order.rex_requested = rex;
127 order.is_open = true;
128 order.proceeds = asset( 0, core_symbol() );
129 order.stake_change = asset( 0, core_symbol() );
130 order.order_time = current_time_point();
131 });
132 } else {
133 _rexorders.modify( oitr, same_payer, [&]( auto& order ) {
134 order.rex_requested.amount += rex.amount;
135 });
136 }
137 pending_sell_order.amount = oitr->rex_requested.amount;
138 }
139 check( pending_sell_order.amount <= bitr->matured_rex, "insufficient funds for current and scheduled orders" );
140 // dummy action added so that sell order proceeds show up in action trace
141 if ( current_order.success ) {
142 rex_results::sellresult_action sellrex_act( rex_account, std::vector<sysio::permission_level>{ } );
143 sellrex_act.send( current_order.proceeds );
144 }
145 }
action_wrapper<"sellresult"_n, &rex_results::sellresult > sellresult_action

◆ setacctcpu()

void sysiosystem::system_contract::setacctcpu ( const name & account,
const std::optional< int64_t > & cpu_weight )

Set account CPU limits action, which sets the CPU limits of an account

Parameters
account- name of the account whose resource limit to be set,
cpu_weight- fractionally proportionate cpu limit of available resources based on (weight / total_weight_of_all_accounts).

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

344 {
345 require_auth( get_self() );
346
347 int64_t current_ram, current_net, current_cpu;
348 get_resource_limits( account, current_ram, current_net, current_cpu );
349
350 int64_t cpu = 0;
351
352 if( !cpu_weight ) {
353 auto vitr = _voters.find( account.value );
354 check( vitr != _voters.end() && has_field( vitr->flags1, voter_info::flags1_fields::cpu_managed ),
355 "CPU bandwidth of account is already unmanaged" );
356
357 user_resources_table userres( get_self(), account.value );
358 auto ritr = userres.find( account.value );
359
360 if( ritr != userres.end() ) {
361 cpu = ritr->cpu_weight.amount;
362 }
363
364 _voters.modify( vitr, same_payer, [&]( auto& v ) {
365 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::cpu_managed, false );
366 });
367 } else {
368 check( *cpu_weight >= -1, "invalid value for cpu_weight" );
369
370 auto vitr = _voters.find( account.value );
371 if ( vitr != _voters.end() ) {
372 _voters.modify( vitr, same_payer, [&]( auto& v ) {
373 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::cpu_managed, true );
374 });
375 } else {
376 _voters.emplace( account, [&]( auto& v ) {
377 v.owner = account;
378 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::cpu_managed, true );
379 });
380 }
381
382 cpu = *cpu_weight;
383 }
384
385 set_resource_limits( account, current_ram, current_net, cpu );
386 }

◆ setacctnet()

void sysiosystem::system_contract::setacctnet ( const name & account,
const std::optional< int64_t > & net_weight )

Set account NET limits action, which sets the NET limits of an account

Parameters
account- name of the account whose resource limit to be set,
net_weight- fractionally proportionate net limit of available resources based on (weight / total_weight_of_all_accounts).

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

300 {
301 require_auth( get_self() );
302
303 int64_t current_ram, current_net, current_cpu;
304 get_resource_limits( account, current_ram, current_net, current_cpu );
305
306 int64_t net = 0;
307
308 if( !net_weight ) {
309 auto vitr = _voters.find( account.value );
310 check( vitr != _voters.end() && has_field( vitr->flags1, voter_info::flags1_fields::net_managed ),
311 "Network bandwidth of account is already unmanaged" );
312
313 user_resources_table userres( get_self(), account.value );
314 auto ritr = userres.find( account.value );
315
316 if( ritr != userres.end() ) {
317 net = ritr->net_weight.amount;
318 }
319
320 _voters.modify( vitr, same_payer, [&]( auto& v ) {
321 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::net_managed, false );
322 });
323 } else {
324 check( *net_weight >= -1, "invalid value for net_weight" );
325
326 auto vitr = _voters.find( account.value );
327 if ( vitr != _voters.end() ) {
328 _voters.modify( vitr, same_payer, [&]( auto& v ) {
329 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::net_managed, true );
330 });
331 } else {
332 _voters.emplace( account, [&]( auto& v ) {
333 v.owner = account;
334 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::net_managed, true );
335 });
336 }
337
338 net = *net_weight;
339 }
340
341 set_resource_limits( account, current_ram, net, current_cpu );
342 }

◆ setacctram()

void sysiosystem::system_contract::setacctram ( const name & account,
const std::optional< int64_t > & ram_bytes )

Set account RAM limits action, which sets the RAM limits of an account

Parameters
account- name of the account whose resource limit to be set,
ram_bytes- ram limit in absolute bytes.

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

255 {
256 require_auth( get_self() );
257
258 int64_t current_ram, current_net, current_cpu;
259 get_resource_limits( account, current_ram, current_net, current_cpu );
260
261 int64_t ram = 0;
262
263 if( !ram_bytes ) {
264 auto vitr = _voters.find( account.value );
265 check( vitr != _voters.end() && has_field( vitr->flags1, voter_info::flags1_fields::ram_managed ),
266 "RAM of account is already unmanaged" );
267
268 user_resources_table userres( get_self(), account.value );
269 auto ritr = userres.find( account.value );
270
271 ram = ram_gift_bytes;
272 if( ritr != userres.end() ) {
273 ram += ritr->ram_bytes;
274 }
275
276 _voters.modify( vitr, same_payer, [&]( auto& v ) {
277 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::ram_managed, false );
278 });
279 } else {
280 check( *ram_bytes >= 0, "not allowed to set RAM limit to unlimited" );
281
282 auto vitr = _voters.find( account.value );
283 if ( vitr != _voters.end() ) {
284 _voters.modify( vitr, same_payer, [&]( auto& v ) {
285 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::ram_managed, true );
286 });
287 } else {
288 _voters.emplace( account, [&]( auto& v ) {
289 v.owner = account;
290 v.flags1 = set_field( v.flags1, voter_info::flags1_fields::ram_managed, true );
291 });
292 }
293
294 ram = *ram_bytes;
295 }
296
297 set_resource_limits( account, ram, current_net, current_cpu );
298 }

◆ setalimits()

void sysiosystem::system_contract::setalimits ( const name & account,
int64_t ram_bytes,
int64_t net_weight,
int64_t cpu_weight )

Set account limits action sets the resource limits of an account

Parameters
account- name of the account whose resource limit to be set,
ram_bytes- ram limit in absolute bytes,
net_weight- fractionally proportionate net limit of available resources based on (weight / total_weight_of_all_accounts),
cpu_weight- fractionally proportionate cpu limit of available resources based on (weight / total_weight_of_all_accounts).

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

237 {
238 require_auth( get_self() );
239
240 user_resources_table userres( get_self(), account.value );
241 auto ritr = userres.find( account.value );
242 check( ritr == userres.end(), "only supports unlimited accounts" );
243
244 auto vitr = _voters.find( account.value );
245 if( vitr != _voters.end() ) {
246 bool ram_managed = has_field( vitr->flags1, voter_info::flags1_fields::ram_managed );
247 bool net_managed = has_field( vitr->flags1, voter_info::flags1_fields::net_managed );
248 bool cpu_managed = has_field( vitr->flags1, voter_info::flags1_fields::cpu_managed );
249 check( !(ram_managed || net_managed || cpu_managed), "cannot use setalimits on an account with managed resources" );
250 }
251
252 set_resource_limits( account, ram, net, cpu );
253 }

◆ setinflation()

void sysiosystem::system_contract::setinflation ( int64_t annual_rate,
int64_t inflation_pay_factor,
int64_t votepay_factor )

Change the annual inflation rate of the core token supply and specify how the new issued tokens will be distributed based on the following structure.

Parameters
annual_rate- Annual inflation rate of the core token supply. (eg. For 5% Annual inflation => annual_rate=500 For 1.5% Annual inflation => annual_rate=150
inflation_pay_factor- Inverse of the fraction of the inflation used to reward block producers. The remaining inflation will be sent to the sysio.saving account. (eg. For 20% of inflation going to block producer rewards => inflation_pay_factor = 50000 For 100% of inflation going to block producer rewards => inflation_pay_factor = 10000).
votepay_factor- Inverse of the fraction of the block producer rewards to be distributed proportional to blocks produced. The remaining rewards will be distributed proportional to votes received. (eg. For 25% of block producer rewards going towards block pay => votepay_factor = 40000 For 75% of block producer rewards going towards block pay => votepay_factor = 13333).

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

411 {
412 require_auth(get_self());
413 check(annual_rate >= 0, "annual_rate can't be negative");
414 if ( inflation_pay_factor < pay_factor_precision ) {
415 check( false, "inflation_pay_factor must not be less than " + std::to_string(pay_factor_precision) );
416 }
417 if ( votepay_factor < pay_factor_precision ) {
418 check( false, "votepay_factor must not be less than " + std::to_string(pay_factor_precision) );
419 }
420 _gstate4.continuous_rate = get_continuous_rate(annual_rate);
421 _gstate4.inflation_pay_factor = inflation_pay_factor;
422 _gstate4.votepay_factor = votepay_factor;
423 _global4.set( _gstate4, get_self() );
424 }
double get_continuous_rate(int64_t annual_rate)
Here is the call graph for this function:

◆ setparams()

void sysiosystem::system_contract::setparams ( const blockchain_parameters_t & params)

Set the blockchain parameters. By tunning these parameters a degree of customization can be achieved.

Parameters
params- New blockchain parameters to set.

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

116 {
117 require_auth( get_self() );
118 (sysio::blockchain_parameters&)(_gstate) = params;
119 check( 3 <= _gstate.max_authority_depth, "max_authority_depth should be at least 3" );
120#ifndef SYSTEM_BLOCKCHAIN_PARAMETERS
121 set_blockchain_parameters( params );
122#else
123 constexpr size_t param_count = 18;
124 // an upper bound on the serialized size
125 char buf[1 + sizeof(params) + param_count];
126 datastream<char*> stream(buf, sizeof(buf));
127
128 stream << uint8_t(17);
129 stream << uint8_t(0) << params.max_block_net_usage
130 << uint8_t(1) << params.target_block_net_usage_pct
131 << uint8_t(2) << params.max_transaction_net_usage
132 << uint8_t(3) << params.base_per_transaction_net_usage
133 << uint8_t(4) << params.net_usage_leeway
134 << uint8_t(5) << params.context_free_discount_net_usage_num
135 << uint8_t(6) << params.context_free_discount_net_usage_den
136
137 << uint8_t(7) << params.max_block_cpu_usage
138 << uint8_t(8) << params.target_block_cpu_usage_pct
139 << uint8_t(9) << params.max_transaction_cpu_usage
140 << uint8_t(10) << params.min_transaction_cpu_usage
141
142 << uint8_t(11) << params.max_transaction_lifetime
143 << uint8_t(12) << params.deferred_trx_expiration_window
144 << uint8_t(13) << params.max_transaction_delay
145 << uint8_t(14) << params.max_inline_action_size
146 << uint8_t(15) << params.max_inline_action_depth
147 << uint8_t(16) << params.max_authority_depth;
148 if(params.max_action_return_value_size)
149 {
150 stream << uint8_t(17) << params.max_action_return_value_size.value();
151 ++buf[0];
152 }
153
154 set_parameters_packed(buf, stream.tellp());
155#endif
156 }
unsigned char uint8_t
Definition stdint.h:124
account_query_db::get_accounts_by_authorizers_params params
uint8_t buf[2048]

◆ setpriv()

void sysiosystem::system_contract::setpriv ( const name & account,
uint8_t is_priv )

Set privilege status for an account. Allows to set privilege status for an account (turn it on/off).

Parameters
account- the account to set the privileged status for.
is_priv- 0 for false, > 0 for true.

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

232 {
233 require_auth( get_self() );
234 set_privileged( account, ispriv );
235 }

◆ setram()

void sysiosystem::system_contract::setram ( uint64_t max_ram_size)

Set ram action sets the ram supply.

Parameters
max_ram_size- the amount of ram supply to set.

decreasing ram might result market maker issues

Increase the amount of ram for sale based upon the change in max ram size.

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

67 {
68 require_auth( get_self() );
69
70 check( _gstate.max_ram_size < max_ram_size, "ram may only be increased" );
71 check( max_ram_size < 1024ll*1024*1024*1024*1024, "ram size is unrealistic" );
72 check( max_ram_size > _gstate.total_ram_bytes_reserved, "attempt to set max below reserved" );
73
74 auto delta = int64_t(max_ram_size) - int64_t(_gstate.max_ram_size);
75 auto itr = _rammarket.find(ramcore_symbol.raw());
76
80 _rammarket.modify( itr, same_payer, [&]( auto& m ) {
81 m.base.balance.amount += delta;
82 });
83
84 _gstate.max_ram_size = max_ram_size;
85 }

◆ setramrate()

void sysiosystem::system_contract::setramrate ( uint16_t bytes_per_block)

Set ram rate action, sets the rate of increase of RAM in bytes per block. It is capped by the uint16_t to a maximum rate of 3 TB per year. If update_ram_supply hasn't been called for the most recent block, then new ram will be allocated at the old rate up to the present block before switching the rate.

Parameters
bytes_per_block- the amount of bytes per block increase to set.

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

105 {
106 require_auth( get_self() );
107
108 update_ram_supply();
109 _gstate2.new_ram_per_block = bytes_per_block;
110 }

◆ setrex()

void sysiosystem::system_contract::setrex ( const asset & balance)

Setrex action, sets total_rent balance of REX pool to the passed value.

Parameters
balance- amount to set the REX pool balance.

Definition at line 232 of file rex.cpp.

233 {
234 require_auth( "sysio"_n );
235
236 check( balance.amount > 0, "balance must be set to have a positive amount" );
237 check( balance.symbol == core_symbol(), "balance symbol must be core symbol" );
238 check( rex_system_initialized(), "rex system is not initialized" );
239 _rexpool.modify( _rexpool.begin(), same_payer, [&]( auto& pool ) {
240 pool.total_rent = balance;
241 });
242 }

◆ undelegatebw()

void sysiosystem::system_contract::undelegatebw ( const name & from,
const name & receiver,
const asset & unstake_net_quantity,
const asset & unstake_cpu_quantity )

Undelegate bandwidth action, decreases the total tokens delegated by from to receiver and/or frees the memory associated with the delegation if there is nothing left to delegate. This will cause an immediate reduction in net/cpu bandwidth of the receiver. A transaction is scheduled to send the tokens back to from after the staking period has passed. If existing transaction is scheduled, it will be canceled and a new transaction issued that has the combined undelegated amount. The from account loses voting power as a result of this call and all producer tallies are updated.

Parameters
from- the account to undelegate bandwidth from, that is, the account whose tokens will be unstaked,
receiver- the account to undelegate bandwidth to, that is, the account to whose benefit tokens have been staked,
unstake_net_quantity- tokens to be unstaked from NET bandwidth,
unstake_cpu_quantity- tokens to be unstaked from CPU bandwidth,
Postcondition
Unstaked tokens are transferred to from liquid balance via a deferred transaction with a delay of 3 days.
If called during the delay period of a previous undelegatebw action, pending action is canceled and timer is reset.
All producers from account has voted for will have their votes updated immediately.
Bandwidth and storage for the deferred transaction are billed to from.

Definition at line 386 of file delegate_bandwidth.cpp.

388 {
389 asset zero_asset( 0, core_symbol() );
390 check( unstake_cpu_quantity >= zero_asset, "must unstake a positive amount" );
391 check( unstake_net_quantity >= zero_asset, "must unstake a positive amount" );
392 check( unstake_cpu_quantity.amount + unstake_net_quantity.amount > 0, "must unstake a positive amount" );
393 check( _gstate.thresh_activated_stake_time != time_point(),
394 "cannot undelegate bandwidth until the chain is activated (at least 15% of all tokens participate in voting)" );
395
396 changebw( from, receiver, -unstake_net_quantity, -unstake_cpu_quantity, false);
397 } // undelegatebw

◆ unregprod()

void sysiosystem::system_contract::unregprod ( const name & producer)

Unregister producer action, deactivates the block producer with account name producer.

Deactivate the block producer with account name producer.

Parameters
producer- the block producer account to unregister.

Definition at line 97 of file voting.cpp.

97 {
98 require_auth( producer );
99
100 const auto& prod = _producers.get( producer.value, "producer not found" );
101 _producers.modify( prod, same_payer, [&]( producer_info& info ){
102 info.deactivate();
103 });
104 }

◆ unstaketorex()

void sysiosystem::system_contract::unstaketorex ( const name & owner,
const name & receiver,
const asset & from_net,
const asset & from_cpu )

Unstaketorex action, uses staked core tokens to buy REX. Storage change is billed to 'owner' account.

Parameters
owner- owner of staked tokens,
receiver- account name that tokens have previously been staked to,
from_net- amount of tokens to be unstaked from NET bandwidth and used for REX purchase,
from_cpu- amount of tokens to be unstaked from CPU bandwidth and used for REX purchase.
Precondition
A voting requirement must be satisfied before action can be executed.
User must vote for at least 21 producers or delegate vote to proxy before buying REX.
Postcondition
User votes are updated following this action.
Tokens used in purchase are added to user's voting power.
Bought REX cannot be sold before 4 days counting from end of day of purchase.

Definition at line 57 of file rex.cpp.

58 {
59 require_auth( owner );
60
61 check( from_net.symbol == core_symbol() && from_cpu.symbol == core_symbol(), "asset must be core token" );
62 check( (0 <= from_net.amount) && (0 <= from_cpu.amount) && (0 < from_net.amount || 0 < from_cpu.amount),
63 "must unstake a positive amount to buy rex" );
64 check_voting_requirement( owner );
65
66 {
67 del_bandwidth_table dbw_table( get_self(), owner.value );
68 auto del_itr = dbw_table.require_find( receiver.value, "delegated bandwidth record does not exist" );
69 check( from_net.amount <= del_itr->net_weight.amount, "amount exceeds tokens staked for net");
70 check( from_cpu.amount <= del_itr->cpu_weight.amount, "amount exceeds tokens staked for cpu");
71 dbw_table.modify( del_itr, same_payer, [&]( delegated_bandwidth& dbw ) {
72 dbw.net_weight.amount -= from_net.amount;
73 dbw.cpu_weight.amount -= from_cpu.amount;
74 });
75 if ( del_itr->is_empty() ) {
76 dbw_table.erase( del_itr );
77 }
78 }
79
80 update_resource_limits( name(0), receiver, -from_net.amount, -from_cpu.amount );
81
82 const asset payment = from_net + from_cpu;
83 // inline transfer from stake_account to rex_account
84 {
86 transfer_act.send( stake_account, rex_account, payment, "buy REX with staked tokens" );
87 }
88 const asset rex_received = add_to_rex_pool( payment );
89 auto rex_stake_delta = add_to_rex_balance( owner, payment, rex_received );
90 runrex(2);
91 update_rex_account( owner, asset( 0, core_symbol() ), rex_stake_delta - payment, true );
92 // dummy action added so that amount of REX tokens purchased shows up in action trace
93 rex_results::buyresult_action buyrex_act( rex_account, std::vector<sysio::permission_level>{ } );
94 buyrex_act.send( rex_received );
95 }
sysio::multi_index< "delband"_n, delegated_bandwidth > del_bandwidth_table

◆ updaterex()

void sysiosystem::system_contract::updaterex ( const name & owner)

Updaterex action, updates REX owner vote weight to current value of held REX tokens.

Parameters
owner- REX owner account.

Definition at line 206 of file rex.cpp.

207 {
208 require_auth( owner );
209
210 runrex(2);
211
212 auto itr = _rexbalance.require_find( owner.value, "account has no REX balance" );
213 const asset init_stake = itr->vote_stake;
214
215 auto rexpool_itr = _rexpool.begin();
216 const int64_t total_rex = rexpool_itr->total_rex.amount;
217 const int64_t total_lendable = rexpool_itr->total_lendable.amount;
218 const int64_t rex_balance = itr->rex_balance.amount;
219
220 asset current_stake( 0, core_symbol() );
221 if ( total_rex > 0 ) {
222 current_stake.amount = ( uint128_t(rex_balance) * total_lendable ) / total_rex;
223 }
224 _rexbalance.modify( itr, same_payer, [&]( auto& rb ) {
225 rb.vote_stake = current_stake;
226 });
227
228 update_rex_account( owner, asset( 0, core_symbol() ), current_stake - init_stake, true );
229 process_rex_maturities( itr );
230 }
Here is the call graph for this function:
Here is the caller graph for this function:

◆ updtrevision()

void sysiosystem::system_contract::updtrevision ( uint8_t revision)

Update revision action, updates the current revision.

Parameters
revision- it has to be incremented by 1 compared with current revision.
Precondition
Current revision can not be higher than 254, and has to be smaller than or equal 1 (“set upper bound to greatest revision supported in the code”).

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

402 {
403 require_auth( get_self() );
404 check( _gstate2.revision < 255, "can not increment revision" ); // prevent wrap around
405 check( revision == _gstate2.revision + 1, "can only increment revision by one" );
406 check( revision <= 1, // set upper bound to greatest revision supported in the code
407 "specified revision is not yet supported by the code" );
408 _gstate2.revision = revision;
409 }

◆ voteproducer()

void sysiosystem::system_contract::voteproducer ( const name & voter,
const name & proxy,
const std::vector< name > & producers )

Vote producer action, votes for a set of producers. This action updates the list of producers voted for, for voter account. If voting for a proxy, the producer votes will not change until the proxy updates their own vote. Voter can vote for a proxy or a list of at most 30 producers. Storage change is billed to voter.

Parameters
voter- the account to change the voted producers for,
proxy- the proxy to change the voted producers for,
producers- the list of producers to vote for, a maximum of 30 producers is allowed.
Precondition
Producers must be sorted from lowest to highest and must be registered and active
If proxy is set then no producers can be voted for
If proxy is set then proxy account must exist and be registered as a proxy
Every listed producer or proxy must have been previously registered
Voter must authorize this action
Voter must have previously staked some EOS for voting
Voter->staked must be up to date
Postcondition
Every producer previously voted for will have vote reduced by previous vote weight
Every producer newly voted for will have vote increased by new vote amount
Prior proxy will proxied_vote_weight decremented by previous vote weight
New proxy will proxied_vote_weight incremented by new vote weight

Definition at line 202 of file voting.cpp.

202 {
203 if ( voter_name == "b1"_n ) {
204 require_auth("sysio"_n);
205 } else {
206 require_auth( voter_name );
207 }
208
209 vote_stake_updater( voter_name );
210 update_votes( voter_name, proxy, producers, true );
211 auto rex_itr = _rexbalance.find( voter_name.value );
212 if( rex_itr != _rexbalance.end() && rex_itr->rex_balance.amount > 0 ) {
213 check_voting_requirement( voter_name, "voter holding REX tokens must vote for at least 21 producers or for a proxy" );
214 }
215 }
schedule config_dir_name data_dir_name p2p_port http_port file_size name name keys peers producers(dont_start)) FC_REFLECT(testnet_def
Here is the call graph for this function:

◆ voteupdate()

void sysiosystem::system_contract::voteupdate ( const name & voter_name)

Update the vote weight for the producers or proxy voter_name currently votes for. This will also update the staked value for the voter_name by checking rexbal and all delegated NET and CPU.

Parameters
voter_name- the account to update the votes for,
Postcondition
the voter.staked will be updated
previously voted for producers vote weight will be updated with new weight
previously voted for proxy vote weight will be updated with new weight

Definition at line 217 of file voting.cpp.

217 {
218 auto voter = _voters.find( voter_name.value );
219 check( voter != _voters.end(), "no voter found" );
220
221 int64_t new_staked = 0;
222
223 updaterex(voter_name);
224
225 // get rex bal
226 auto rex_itr = _rexbalance.find( voter_name.value );
227 if( rex_itr != _rexbalance.end() && rex_itr->rex_balance.amount > 0 ) {
228 new_staked += rex_itr->vote_stake.amount;
229 }
230 del_bandwidth_table del_tbl( get_self(), voter_name.value );
231
232 auto del_itr = del_tbl.begin();
233 while(del_itr != del_tbl.end()) {
234 new_staked += del_itr->net_weight.amount + del_itr->cpu_weight.amount;
235 del_itr++;
236 }
237
238 if( voter->staked != new_staked){
239 // check if staked and new_staked are different and only
240 _voters.modify( voter, same_payer, [&]( auto& av ) {
241 av.staked = new_staked;
242 });
243 }
244
245 update_votes(voter_name, voter->proxy, voter->producers, true);
246 } // voteupdate
void updaterex(const name &owner)
Definition rex.cpp:206
Here is the call graph for this function:

◆ withdraw()

void sysiosystem::system_contract::withdraw ( const name & owner,
const asset & amount )

Withdraw from REX fund action, withdraws core tokens from user REX fund. An inline token transfer to user balance is executed.

Parameters
owner- REX fund owner account,
amount- amount of tokens to be withdrawn.

Definition at line 25 of file rex.cpp.

26 {
27 require_auth( owner );
28
29 check( amount.symbol == core_symbol(), "must withdraw core token" );
30 check( 0 < amount.amount, "must withdraw a positive amount" );
31 update_rex_account( owner, asset( 0, core_symbol() ), asset( 0, core_symbol() ) );
32 transfer_from_fund( owner, amount );
33 // inline transfer to owner's token balance
34 {
36 transfer_act.send( rex_account, owner, amount, "withdraw from REX fund" );
37 }
38 }

Member Data Documentation

◆ active_permission

sysio::name sysiosystem::system_contract::active_permission {"active"_n}
staticconstexpr

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

702{"active"_n};

◆ bpay_account

sysio::name sysiosystem::system_contract::bpay_account {"sysio.bpay"_n}
staticconstexpr

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

707{"sysio.bpay"_n};

◆ names_account

sysio::name sysiosystem::system_contract::names_account {"sysio.names"_n}
staticconstexpr

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

709{"sysio.names"_n};

◆ null_account

sysio::name sysiosystem::system_contract::null_account {"sysio.null"_n}
staticconstexpr

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

713{"sysio.null"_n};

◆ ram_account

sysio::name sysiosystem::system_contract::ram_account {"sysio.ram"_n}
staticconstexpr

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

704{"sysio.ram"_n};

◆ ram_symbol

symbol sysiosystem::system_contract::ram_symbol = symbol(symbol_code("RAM"), 0)
staticconstexpr

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

◆ ramcore_symbol

symbol sysiosystem::system_contract::ramcore_symbol = symbol(symbol_code("RAMCORE"), 4)
staticconstexpr

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

◆ ramfee_account

sysio::name sysiosystem::system_contract::ramfee_account {"sysio.ramfee"_n}
staticconstexpr

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

705{"sysio.ramfee"_n};

◆ reserve_account

sysio::name sysiosystem::system_contract::reserve_account {"sysio.reserv"_n}
staticconstexpr

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

712{"sysio.reserv"_n}; // cspell:disable-line

◆ rex_account

sysio::name sysiosystem::system_contract::rex_account {"sysio.rex"_n}
staticconstexpr

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

711{"sysio.rex"_n};

◆ rex_symbol

symbol sysiosystem::system_contract::rex_symbol = symbol(symbol_code("REX"), 4)
staticconstexpr

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

◆ saving_account

sysio::name sysiosystem::system_contract::saving_account {"sysio.saving"_n}
staticconstexpr

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

710{"sysio.saving"_n};

◆ stake_account

sysio::name sysiosystem::system_contract::stake_account {"sysio.stake"_n}
staticconstexpr

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

706{"sysio.stake"_n};

◆ token_account

sysio::name sysiosystem::system_contract::token_account {"sysio.token"_n}
staticconstexpr

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

703{"sysio.token"_n};

◆ vpay_account

sysio::name sysiosystem::system_contract::vpay_account {"sysio.vpay"_n}
staticconstexpr

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

708{"sysio.vpay"_n};

The documentation for this class was generated from the following files: