Skip to content
This repository was archived by the owner on Oct 4, 2019. It is now read-only.

Commit 1a5c254

Browse files
authored
Merge pull request #729 from GolosChain/golos-v0.18.0
Golos v0.18.0
2 parents cbd8613 + e49113b commit 1a5c254

10 files changed

Lines changed: 207 additions & 76 deletions

File tree

libraries/api/chain_api_properties.cpp

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@ namespace golos { namespace api {
1010
sbd_interest_rate(src.sbd_interest_rate)
1111
{
1212
if (db.has_hardfork(STEEMIT_HARDFORK_0_18__673)) {
13-
create_account_with_golos_modifier = src.create_account_with_golos_modifier;
14-
create_account_delegation_ratio = src.create_account_delegation_ratio;
13+
create_account_min_golos_fee = src.create_account_min_golos_fee;
14+
create_account_min_delegation = src.create_account_min_delegation;
1515
create_account_delegation_time = src.create_account_delegation_time;
16-
min_delegation_multiplier = src.min_delegation_multiplier;
16+
min_delegation = src.min_delegation;
1717
}
1818
}
1919

20-
} } // golos::api
20+
} } // golos::api

libraries/api/include/golos/api/chain_api_properties.hpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,16 +16,16 @@ namespace golos { namespace api {
1616
uint32_t maximum_block_size;
1717
uint16_t sbd_interest_rate;
1818

19-
fc::optional<uint32_t> create_account_with_golos_modifier;
20-
fc::optional<uint32_t> create_account_delegation_ratio;
21-
fc::optional<fc::microseconds> create_account_delegation_time;
22-
fc::optional<uint32_t> min_delegation_multiplier;
19+
fc::optional<asset> create_account_min_golos_fee;
20+
fc::optional<asset> create_account_min_delegation;
21+
fc::optional<uint32_t> create_account_delegation_time;
22+
fc::optional<asset> min_delegation;
2323
};
2424

2525
} } // golos::api
2626

2727
FC_REFLECT(
2828
(golos::api::chain_api_properties),
29-
(account_creation_fee)(maximum_block_size)(maximum_block_size)
30-
(create_account_with_golos_modifier)(create_account_delegation_ratio)
31-
(create_account_delegation_time)(min_delegation_multiplier))
29+
(account_creation_fee)(maximum_block_size)(sbd_interest_rate)
30+
(create_account_min_golos_fee)(create_account_min_delegation)
31+
(create_account_delegation_time)(min_delegation))

libraries/chain/database.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1671,10 +1671,10 @@ namespace golos { namespace chain {
16711671
calc_median(&chain_properties_17::account_creation_fee);
16721672
calc_median(&chain_properties_17::maximum_block_size);
16731673
calc_median(&chain_properties_17::sbd_interest_rate);
1674-
calc_median(&chain_properties_18::create_account_with_golos_modifier);
1675-
calc_median(&chain_properties_18::create_account_delegation_ratio);
1674+
calc_median(&chain_properties_18::create_account_min_golos_fee);
1675+
calc_median(&chain_properties_18::create_account_min_delegation);
16761676
calc_median(&chain_properties_18::create_account_delegation_time);
1677-
calc_median(&chain_properties_18::min_delegation_multiplier);
1677+
calc_median(&chain_properties_18::min_delegation);
16781678

16791679
modify(wso, [&](witness_schedule_object &_wso) {
16801680
_wso.median_props = median_props;

libraries/chain/steem_evaluator.cpp

Lines changed: 19 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -108,20 +108,14 @@ namespace golos { namespace chain {
108108
}
109109

110110
void account_create_evaluator::do_apply(const account_create_operation &o) {
111-
database &_db = db();
112-
const auto &creator = _db.get_account(o.creator);
113-
114-
const auto &props = _db.get_dynamic_global_properties();
115-
const auto& median_props = _db.get_witness_schedule_object().median_props;
111+
const auto& creator = _db.get_account(o.creator);
116112

117-
FC_ASSERT(creator.balance >=
118-
o.fee, "Insufficient balance to create account.", ("creator.balance", creator.balance)("required", o.fee));
113+
FC_ASSERT(creator.balance >= o.fee,
114+
"Insufficient balance to create account.", ("creator.balance", creator.balance)("required", o.fee));
119115

120116
if (_db.has_hardfork(STEEMIT_HARDFORK_0_1)) {
121-
auto min_fee = _db.get_witness_schedule_object().median_props.account_creation_fee;
122-
if (_db.has_hardfork(STEEMIT_HARDFORK_0_18__535)) {
123-
min_fee *= median_props.create_account_with_golos_modifier;
124-
}
117+
const auto& median_props = _db.get_witness_schedule_object().median_props;
118+
auto min_fee = median_props.account_creation_fee;
125119
FC_ASSERT(o.fee >= min_fee,
126120
"Insufficient Fee: ${f} required, ${p} provided.", ("f", min_fee)("p", o.fee));
127121
}
@@ -145,6 +139,7 @@ namespace golos { namespace chain {
145139
c.balance -= o.fee;
146140
});
147141

142+
const auto& props = _db.get_dynamic_global_properties();
148143
const auto& new_account = _db.create<account_object>([&](account_object& acc) {
149144
acc.name = o.new_account_name;
150145
acc.memo_key = o.memo_key;
@@ -187,18 +182,20 @@ namespace golos { namespace chain {
187182

188183
const auto& v_share_price = _db.get_dynamic_global_properties().get_vesting_share_price();
189184
const auto& median_props = _db.get_witness_schedule_object().median_props;
190-
auto target_delegation =
191-
median_props.create_account_delegation_ratio *
192-
median_props.create_account_with_golos_modifier *
193-
median_props.account_creation_fee * v_share_price;
194-
auto current_delegation =
195-
median_props.create_account_delegation_ratio * o.fee * v_share_price + o.delegation;
185+
const auto target = median_props.create_account_min_golos_fee + median_props.create_account_min_delegation;
186+
auto target_delegation = target * v_share_price;
187+
auto min_fee = median_props.account_creation_fee.amount.value;
188+
#ifdef STEEMIT_BUILD_TESTNET
189+
if (!min_fee)
190+
min_fee = 1;
191+
#endif
192+
auto current_delegation = o.fee * target.amount.value / min_fee * v_share_price + o.delegation;
196193

197194
FC_ASSERT(current_delegation >= target_delegation,
198195
"Inssufficient Delegation ${f} required, ${p} provided.",
199196
("f", target_delegation)("p", current_delegation)("o.fee", o.fee) ("o.delegation", o.delegation));
200-
FC_ASSERT(o.fee >= median_props.account_creation_fee,
201-
"Insufficient Fee: ${f} required, ${p} provided.", ("f", median_props.account_creation_fee)("p", o.fee));
197+
FC_ASSERT(o.fee >= median_props.create_account_min_golos_fee,
198+
"Insufficient Fee: ${f} required, ${p} provided.", ("f", median_props.create_account_min_golos_fee)("p", o.fee));
202199

203200
for (auto& a : o.owner.account_auths) {
204201
_db.get_account(a.first);
@@ -239,7 +236,7 @@ namespace golos { namespace chain {
239236
d.delegator = o.creator;
240237
d.delegatee = o.new_account_name;
241238
d.vesting_shares = o.delegation;
242-
d.min_delegation_time = now + median_props.create_account_delegation_time;
239+
d.min_delegation_time = now + fc::seconds(median_props.create_account_delegation_time);
243240
});
244241
}
245242
if (o.fee.amount > 0) {
@@ -2200,8 +2197,8 @@ namespace golos { namespace chain {
22002197

22012198
const auto& median_props = _db.get_witness_schedule_object().median_props;
22022199
const auto v_share_price = _db.get_dynamic_global_properties().get_vesting_share_price();
2203-
auto min_delegation = median_props.account_creation_fee * median_props.min_delegation_multiplier * v_share_price;
2204-
auto min_update = median_props.account_creation_fee * v_share_price;
2200+
auto min_delegation = median_props.min_delegation * v_share_price;
2201+
auto min_update = median_props.create_account_min_golos_fee * v_share_price;
22052202

22062203
auto now = _db.head_block_time();
22072204
auto delta = delegation ?

libraries/protocol/include/golos/protocol/steem_operations.hpp

Lines changed: 25 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -443,6 +443,7 @@ namespace golos { namespace protocol {
443443
uint16_t sbd_interest_rate = STEEMIT_DEFAULT_SBD_INTEREST_RATE;
444444

445445
void validate() const {
446+
FC_ASSERT(account_creation_fee.symbol == STEEM_SYMBOL);
446447
FC_ASSERT(account_creation_fee.amount >= STEEMIT_MIN_ACCOUNT_CREATION_FEE);
447448
FC_ASSERT(maximum_block_size >= STEEMIT_MIN_BLOCK_SIZE_LIMIT);
448449
FC_ASSERT(sbd_interest_rate >= 0);
@@ -462,39 +463,42 @@ namespace golos { namespace protocol {
462463
struct chain_properties_18: public chain_properties_17 {
463464

464465
/**
465-
* Modifier for delegated GP on account creation
466-
*
467-
* target_delegation =
468-
* create_account_delegation_ratio * create_account_with_golos_modifier * account_creation_fee
466+
* Minimum fee (in GOLOS) payed when create account with delegation
469467
*/
470-
uint32_t create_account_with_golos_modifier = GOLOS_CREATE_ACCOUNT_WITH_GOLOS_MODIFIER;
468+
asset create_account_min_golos_fee =
469+
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE * GOLOS_CREATE_ACCOUNT_WITH_GOLOS_MODIFIER, STEEM_SYMBOL);
471470

472471
/**
473-
* Ratio for delegated GP on account creation
472+
* Minimum GP delegation amount when create account with delegation
474473
*
475-
* target_delegation =
476-
* create_account_delegation_ratio * create_account_with_golos_modifier * account_creation_fee
474+
* Note: this minimum is applied only when fee is minimal. If fee is greater,
475+
* then actual delegation can be less (up to 0 if fee part is greater or equal than account_creation_fee)
477476
*/
478-
uint32_t create_account_delegation_ratio = GOLOS_CREATE_ACCOUNT_DELEGATION_RATIO;
477+
asset create_account_min_delegation =
478+
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE *
479+
GOLOS_CREATE_ACCOUNT_WITH_GOLOS_MODIFIER * GOLOS_CREATE_ACCOUNT_DELEGATION_RATIO, STEEM_SYMBOL);
479480

480481
/**
481-
* Minimum time of delegated GP on create account
482+
* Minimum time of delegated GP on create account (in seconds)
482483
*/
483-
fc::microseconds create_account_delegation_time = GOLOS_CREATE_ACCOUNT_DELEGATION_TIME;
484+
uint32_t create_account_delegation_time = (GOLOS_CREATE_ACCOUNT_DELEGATION_TIME).to_seconds();
484485

485486
/**
486-
* Multiplier of minimum delegated GP
487-
*
488-
* minimum delegated GP = delegation_multiplier * account_creation_fee
487+
* Minimum delegated GP
489488
*/
490-
uint32_t min_delegation_multiplier = GOLOS_MIN_DELEGATION_MULTIPLIER;
489+
asset min_delegation =
490+
asset(STEEMIT_MIN_ACCOUNT_CREATION_FEE * GOLOS_MIN_DELEGATION_MULTIPLIER, STEEM_SYMBOL);
491+
491492

492493
void validate() const {
493494
chain_properties_17::validate();
494-
FC_ASSERT(min_delegation_multiplier > 0);
495-
FC_ASSERT(create_account_delegation_time.count() > GOLOS_CREATE_ACCOUNT_DELEGATION_TIME.count() / 2);
496-
FC_ASSERT(create_account_delegation_ratio > 0);
497-
FC_ASSERT(create_account_with_golos_modifier > 0);
495+
FC_ASSERT(create_account_min_golos_fee.amount > 0);
496+
FC_ASSERT(create_account_min_golos_fee.symbol == STEEM_SYMBOL);
497+
FC_ASSERT(create_account_min_delegation.amount > 0);
498+
FC_ASSERT(create_account_min_delegation.symbol == STEEM_SYMBOL);
499+
FC_ASSERT(min_delegation.amount > 0);
500+
FC_ASSERT(min_delegation.symbol == STEEM_SYMBOL);
501+
FC_ASSERT(create_account_delegation_time > (GOLOS_CREATE_ACCOUNT_DELEGATION_TIME).to_seconds() / 2);
498502
}
499503

500504
chain_properties_18& operator=(const chain_properties_17& src) {
@@ -1153,8 +1157,8 @@ FC_REFLECT(
11531157
(account_creation_fee)(maximum_block_size)(sbd_interest_rate))
11541158
FC_REFLECT_DERIVED(
11551159
(golos::protocol::chain_properties_18),((golos::protocol::chain_properties_17)),
1156-
(create_account_with_golos_modifier)(create_account_delegation_ratio)
1157-
(create_account_delegation_time)(min_delegation_multiplier))
1160+
(create_account_min_golos_fee)(create_account_min_delegation)
1161+
(create_account_delegation_time)(min_delegation))
11581162

11591163
FC_REFLECT_TYPENAME((golos::protocol::versioned_chain_properties))
11601164

libraries/wallet/include/golos/wallet/wallet.hpp

Lines changed: 19 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,17 @@ namespace golos { namespace wallet {
3232
vector<string> key_approvals_to_remove;
3333
};
3434

35+
struct optional_chain_props {
36+
fc::optional<asset> account_creation_fee;
37+
fc::optional<uint32_t> maximum_block_size;
38+
fc::optional<uint16_t> sbd_interest_rate;
39+
40+
fc::optional<asset> create_account_min_golos_fee;
41+
fc::optional<asset> create_account_min_delegation;
42+
fc::optional<uint32_t> create_account_delegation_time;
43+
fc::optional<asset> min_delegation;
44+
};
45+
3546
struct memo_data {
3647

3748
static optional<memo_data> from_string( string str ) {
@@ -678,7 +689,7 @@ namespace golos { namespace wallet {
678689
*/
679690
annotated_signed_transaction update_chain_properties(
680691
string witness_name,
681-
const chain_properties& props,
692+
const optional_chain_props& props,
682693
bool broadcast = false
683694
);
684695

@@ -1203,10 +1214,15 @@ FC_API( golos::wallet::wallet_api,
12031214
(get_outbox)
12041215
)
12051216

1206-
FC_REFLECT( (golos::wallet::memo_data), (from)(to)(nonce)(check)(encrypted) )
1217+
FC_REFLECT((golos::wallet::memo_data), (from)(to)(nonce)(check)(encrypted))
12071218
FC_REFLECT(
12081219
(golos::wallet::approval_delta),
12091220
(active_approvals_to_add)(active_approvals_to_remove)
12101221
(owner_approvals_to_add)(owner_approvals_to_remove)
12111222
(posting_approvals_to_add)(posting_approvals_to_remove)
1212-
(key_approvals_to_add)(key_approvals_to_remove) )
1223+
(key_approvals_to_add)(key_approvals_to_remove))
1224+
1225+
FC_REFLECT((golos::wallet::optional_chain_props),
1226+
(account_creation_fee)(maximum_block_size)(sbd_interest_rate)
1227+
(create_account_min_golos_fee)(create_account_min_delegation)
1228+
(create_account_delegation_time)(min_delegation))

libraries/wallet/wallet.cpp

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -290,10 +290,10 @@ namespace golos { namespace wallet {
290290

291291
auto hf = _remote_database_api->get_hardfork_version();
292292
if (hf >= hardfork_version(0, STEEMIT_HARDFORK_0_18)) {
293-
result["create_account_with_golos_modifier"] = median_props.create_account_with_golos_modifier;
294-
result["create_account_delegation_ratio"] = median_props.create_account_delegation_ratio;
293+
result["create_account_min_golos_fee"] = median_props.create_account_min_golos_fee;
294+
result["create_account_min_delegation"] = median_props.create_account_min_delegation;
295295
result["create_account_delegation_time"] = median_props.create_account_delegation_time;
296-
result["min_delegation_multiplier"] = median_props.min_delegation_multiplier;
296+
result["min_delegation"] = median_props.min_delegation;
297297
}
298298

299299
return result;
@@ -1834,9 +1834,6 @@ fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_st
18341834
auto prop = my->_remote_database_api->get_chain_properties();
18351835
auto hf = my->_remote_database_api->get_hardfork_version();
18361836
fee = prop.account_creation_fee;
1837-
if (hf >= hardfork_version(0, STEEMIT_HARDFORK_0_18)) {
1838-
fee *= prop.create_account_with_golos_modifier;
1839-
}
18401837
}
18411838
return create_account_with_keys(
18421839
creator, new_account_name, json_meta, fee,
@@ -1895,16 +1892,40 @@ fc::ecc::private_key wallet_api::derive_private_key(const std::string& prefix_st
18951892

18961893
annotated_signed_transaction wallet_api::update_chain_properties(
18971894
string witness_account_name,
1898-
const chain_properties& props,
1895+
const optional_chain_props& props,
18991896
bool broadcast
19001897
) {
19011898
FC_ASSERT(!is_locked());
19021899

19031900
signed_transaction tx;
19041901
chain_properties_update_operation op;
1902+
chain_api_properties ap;
1903+
chain_properties p;
1904+
1905+
// copy defaults in case of missing witness object
1906+
ap.account_creation_fee = p.account_creation_fee;
1907+
ap.maximum_block_size = p.maximum_block_size;
1908+
ap.sbd_interest_rate = p.sbd_interest_rate;
1909+
1910+
auto wit = my->_remote_witness_api->get_witness_by_account(witness_account_name);
1911+
if (wit.valid()) {
1912+
FC_ASSERT(wit->owner == witness_account_name);
1913+
ap = wit->props;
1914+
}
1915+
#define SET_PROP(X) {p.X = !!props.X ? *(props.X) : ap.X;}
1916+
SET_PROP(account_creation_fee);
1917+
SET_PROP(maximum_block_size);
1918+
SET_PROP(sbd_interest_rate);
1919+
#undef SET_PROP
1920+
#define SET_PROP(X) {if (!!props.X) p.X = *(props.X); else if (!!ap.X) p.X = *(ap.X);}
1921+
SET_PROP(create_account_min_golos_fee);
1922+
SET_PROP(create_account_min_delegation);
1923+
SET_PROP(create_account_delegation_time);
1924+
SET_PROP(min_delegation);
1925+
#undef SET_PROP
19051926

19061927
op.owner = witness_account_name;
1907-
op.props = props;
1928+
op.props = p;
19081929
tx.operations.push_back(op);
19091930

19101931
tx.validate();

plugins/mongo_db/include/golos/plugins/mongo_db/mongo_db_state.hpp

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,8 @@ namespace mongo_db {
9292

9393
bool format_comment(const std::string& auth, const std::string& perm);
9494

95+
void format_account(const std::string& name);
96+
9597
named_document create_document(const std::string& name,
9698
const std::string& key, const std::string& keyval);
9799

0 commit comments

Comments
 (0)