Skip to content

Commit

Permalink
Merge pull request #612 from GolosChain/develop
Browse files Browse the repository at this point in the history
Merge changes from Sprint-apr-08
  • Loading branch information
afalaleev authored Apr 23, 2019
2 parents 5ef635a + 53d7b8f commit 118b37c
Show file tree
Hide file tree
Showing 25 changed files with 533 additions and 206 deletions.
2 changes: 2 additions & 0 deletions Docker/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -48,10 +48,12 @@ COPY --from=builder /golos.contracts/cyberway.contracts/tests/test_contracts /op
COPY --from=builder /golos.contracts/cyberway.contracts/scripts/bios-boot-sequence /opt/cyberway.contracts/scripts/bios-boot-sequence
COPY --from=builder /golos.contracts/scripts /opt/golos.contracts/scripts
COPY --from=builder /golos.contracts/scripts/boot-sequence.py /opt/golos.contracts/scripts/boot-sequence.py
COPY --from=builder /golos.contracts/genesis /opt/golos.contracts/genesis

COPY --from=builder /usr/local/lib/libbson-1.0.so.0.0.0 /usr/local/lib/
COPY --from=cyberway /opt/cyberway/bin/cleos /opt/cyberway/bin/cleos
COPY --from=cyberway /opt/cyberway/bin/keosd /opt/cyberway/bin/keosd
COPY --from=cyberway /opt/cyberway/bin/create-genesis /opt/cyberway/bin/create-genesis

RUN ldconfig && ln -s ../cyberway.contracts /opt/golos.contracts/cyberway.contracts

Expand Down
2 changes: 1 addition & 1 deletion cyberway.contracts
2 changes: 1 addition & 1 deletion docs/ru-RU/golos.vesting_contract.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ name: vesting_param,
1) `vesting_withdraw` — содержит параметры, которые используется для вывода вестинга в токены (конвертирования, «понижения»). Имеет вид структуры:
```cpp
struct vesting_withdraw : parameter {
uint32_t intervals;
uint8_t intervals;
uint32_t interval_seconds;
}
```
Expand Down
70 changes: 70 additions & 0 deletions genesis/genesis-info.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
{
"state_file": "golos.dat",
"genesis_json": "genesis.json",
"params":{
"stake":{
"max_proxies":[30, 10, 3, 1],
"frame_length":1800,
"payout_step_length":43200,
"payout_steps_num":12,
"min_own_staked_for_election":0
}
},
"accounts": [
# {"name": "cyber", "owner_key": "INITIAL", "active_key": "INITIAL",
# "abi": {"path": "$CYBERWAY_CONTRACTS/cyber.bios/cyber.bios.abi", "hash":""},
# "code": {"path": "$CYBERWAY_CONTRACTS/cyber.bios/cyber.bios.wasm", "hash":""}
# },
# {"name": "cyber.domain", "owner_key": "INITIAL", "active_key": "INITIAL",
# "abi": {"path": "$CYBERWAY_CONTRACTS/cyber.domain/cyber.domain.abi", "hash":""},
# "code": {"path": "$CYBERWAY_CONTRACTS/cyber.domain/cyber.domain.wasm", "hash":""}
# },
{"name": "cyber.token", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$CYBERWAY_CONTRACTS/cyber.token/cyber.token.abi", "hash":""},
"code": {"path": "$CYBERWAY_CONTRACTS/cyber.token/cyber.token.wasm", "hash":""}
},
# {"name": "cyber.msig", "owner_key": "INITIAL", "active_key": "INITIAL",
# "abi": {"path": "$CYBERWAY_CONTRACTS/cyber.msig/cyber.msig.abi", "hash":""},
# "code": {"path": "$CYBERWAY_CONTRACTS/cyber.msig/cyber.msig.wasm", "hash":""}
# },
# {"name": "cyber.govern", "owner_key": "INITIAL", "active_key": "INITIAL",
# "abi": {"path": "$CYBERWAY_CONTRACTS/cyber.govern/cyber.govern.abi", "hash":""},
# "code": {"path": "$CYBERWAY_CONTRACTS/cyber.govern/cyber.govern.wasm", "hash":""}
# },
# {"name": "cyber.stake", "owner_key": "INITIAL", "active_key": "INITIAL",
# "abi": {"path": "$CYBERWAY_CONTRACTS/cyber.stake/cyber.stake.abi", "hash":""},
# "code": {"path": "$CYBERWAY_CONTRACTS/cyber.stake/cyber.stake.wasm", "hash":""}
# },

{"name": "gls.issuer", "owner_key": "INITIAL", "active_key": "INITIAL"},
{"name": "gls.ctrl", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.ctrl/golos.ctrl.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.ctrl/golos.ctrl.wasm", "hash":""}
},
{"name": "gls.emit", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.emit/golos.emit.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.emit/golos.emit.wasm", "hash":""}
},
{"name": "gls.vesting", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.vesting/golos.vesting.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.vesting/golos.vesting.wasm", "hash":""}
},
{"name": "gls.publish", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.publication/golos.publication.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.publication/golos.publication.wasm", "hash":""}
},
{"name": "gls.social", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.social/golos.social.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.social/golos.social.wasm", "hash":""}
},
{"name": "gls.charge", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.charge/golos.charge.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.charge/golos.charge.wasm", "hash":""}
},
{"name": "gls.referral", "owner_key": "INITIAL", "active_key": "INITIAL",
"abi": {"path": "$GOLOS_CONTRACTS/golos.referral/golos.referral.abi", "hash":""},
"code": {"path": "$GOLOS_CONTRACTS/golos.referral/golos.referral.wasm", "hash":""}
},
{"name": "gls.worker", "owner_key": "INITIAL", "active_key": "INITIAL"}
]
}
25 changes: 25 additions & 0 deletions genesis/genesis.json.tmpl
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
{
"initial_timestamp": "${INITIAL_TIMESTAMP}",
"initial_key": "GLS6MRyAjQq8ud7hVNYcfnVPJqcVpscN5So8BhtHuGYqET5GDW5CV",
"initial_configuration": {
"max_block_net_usage": 1048576,
"target_block_net_usage_pct": 1000,
"max_transaction_net_usage": 524288,
"base_per_transaction_net_usage": 12,
"net_usage_leeway": 500,
"context_free_discount_net_usage_num": 20,
"context_free_discount_net_usage_den": 100,
"max_block_cpu_usage": 2500000,
"target_block_cpu_usage_pct": 1000,
"max_transaction_cpu_usage": 1800000,
"min_transaction_cpu_usage": 100,
"max_transaction_lifetime": 3600,
"deferred_trx_expiration_window": 600,
"max_transaction_delay": 3888000,
"max_inline_action_size": 4096,
"max_inline_action_depth": 4,
"max_authority_depth": 6
},
"initial_chain_id": "0000000000000000000000000000000000000000000000000000000000000000",
"genesis_data_hash": "${GENESIS_DATA_HASH}"
}
46 changes: 46 additions & 0 deletions golos.charge/golos.charge.abi
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,44 @@
}
]
},
{
"name": "useandnotify",
"base": "",
"fields": [
{
"name": "user",
"type": "name"
},
{
"name": "token_code",
"type": "symbol_code"
},
{
"name": "charge_id",
"type": "uint8"
},
{
"name": "price_arg",
"type": "int64"
},
{
"name": "id",
"type": "uint64"
},
{
"name": "code",
"type": "name"
},
{
"name": "action_name",
"type": "name"
},
{
"name": "cutoff",
"type": "int64"
}
]
},
{
"name": "removestored",
"base": "",
Expand Down Expand Up @@ -287,6 +325,14 @@
"name": "use",
"type": "use"
},
{
"name": "usenotifygt",
"type": "useandnotify"
},
{
"name": "usenotifylt",
"type": "useandnotify"
},
{
"name": "useandstore",
"type": "useandstore"
Expand Down
28 changes: 27 additions & 1 deletion golos.charge/golos.charge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,33 @@ void charge::send_charge_event(name user, const balance& state) {
eosio::event(_self, "chargestate"_n, std::make_tuple(user, state)).send();
}

EOSIO_DISPATCH(charge, (use)(useandstore)(removestored)(setrestorer) )
template<typename Lambda>
void charge::consume_and_notify(name user, symbol_code token_code, uint8_t charge_id, int64_t price_arg, int64_t id, name code, name action_name, int64_t cutoff, name issuer, Lambda &&compare) {
auto charge = consume_charge(issuer, user, token_code, charge_id, price_arg);
auto new_val = from_fixp(FP(charge.data()));

if (compare(new_val, cutoff)) {
action(
permission_level{code, action_name},
code, action_name,
std::make_tuple(user, id, new_val)
).send();
}
}

void charge::usenotifygt(name user, symbol_code token_code, uint8_t charge_id, int64_t price_arg, int64_t id, name code, name action_name, int64_t cutoff) {
auto issuer = token::get_issuer(config::token_name, token_code);
require_auth(issuer);
consume_and_notify(user, token_code, charge_id, price_arg, id, code, action_name, cutoff, issuer, [](auto value, auto limit) {return value > limit;});
}

void charge::usenotifylt(name user, symbol_code token_code, uint8_t charge_id, int64_t price_arg, int64_t id, name code, name action_name, int64_t cutoff) {
auto issuer = token::get_issuer(config::token_name, token_code);
require_auth(issuer);
consume_and_notify(user, token_code, charge_id, price_arg, id, code, action_name, cutoff, issuer, [](auto value, auto limit) {return value < limit;});
}

EOSIO_DISPATCH(charge, (use)(usenotifygt)(usenotifylt)(useandstore)(removestored)(setrestorer) )

} /// namespace golos

7 changes: 6 additions & 1 deletion golos.charge/golos.charge.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,15 +33,20 @@ class charge : public contract {
return restorers_table.find(symbol(token_code, charge_id).raw()) != restorers_table.end();
}
[[eosio::action]] void use(name user, symbol_code token_code, uint8_t charge_id, int64_t price, int64_t cutoff, int64_t vesting_price);
[[eosio::action]] void useandstore(name user, symbol_code token_code, uint8_t charge_id, int64_t stamp_id, int64_t price);
[[eosio::action]] void usenotifygt(name user, symbol_code token_code, uint8_t charge_id, int64_t price_arg, int64_t id, name code, name action_name, int64_t cutoff);
[[eosio::action]] void usenotifylt(name user, symbol_code token_code, uint8_t charge_id, int64_t price_arg, int64_t id, name code, name action_name, int64_t cutoff);
[[eosio::action]] void removestored(name user, symbol_code token_code, uint8_t charge_id, int64_t stamp_id);
[[eosio::action]] void useandstore(name user, symbol_code token_code, uint8_t charge_id, int64_t stamp_id, int64_t price_arg);

[[eosio::action]] void setrestorer(symbol_code token_code, uint8_t charge_id, std::string func_str,
int64_t max_prev, int64_t max_vesting, int64_t max_elapsed);

void on_transfer(name from, name to, asset quantity, std::string memo);
//TODO:? user can restore a charge by transferring some amount to this contract (it will send these funds to the issuer)
//a price is specified in a settings, charge_id is in a memo (default charge_id for empty memo)

template<typename Lambda>
void consume_and_notify(name user, symbol_code token_code, uint8_t charge_id, int64_t price_arg, int64_t id, name code, name action_name, int64_t cutoff, name issuer, Lambda &&compare);

private:
struct balance {
Expand Down
4 changes: 2 additions & 2 deletions golos.ctrl/include/golos.ctrl/parameters.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,7 @@ struct update_auth_period: parameter {

void validate() const override {
eosio_assert(period > 0, "update auth period can't be 0");
}
}
};

} // param
Expand All @@ -75,7 +75,7 @@ using msig_perms_param = param_wrapper<param::msig_permissions,3>;
using witness_votes_param = param_wrapper<param::witness_votes,1>;
using update_auth_param = param_wrapper<param::update_auth_period,1>;

using ctrl_param = std::variant<ctrl_token_param, multisig_acc_param, max_witnesses_param,
using ctrl_param = std::variant<ctrl_token_param, multisig_acc_param, max_witnesses_param,
msig_perms_param, witness_votes_param, update_auth_param>;

struct [[eosio::table]] ctrl_state {
Expand Down
46 changes: 34 additions & 12 deletions golos.publication/golos.publication.abi
Original file line number Diff line number Diff line change
Expand Up @@ -734,30 +734,40 @@
]
},
{
"name": "create_event",
"name": "calcrwrdwt",
"base": "",
"fields": [
{"name": "record_id", "type": "uint64"}
{
"name": "account",
"type": "name"
},
{
"name": "mssg_id",
"type": "int64"
},
{
"name": "post_charge",
"type": "base_t"
}
]
},
{
"name": "post_event",
"name": "create_event",
"base": "",
"fields": [
{"name": "author", "type": "name"},
{"name": "permlink", "type": "string"},
{"name": "netshares", "type": "base_t"},
{"name": "voteshares", "type": "base_t"},
{"name": "sumcuratorsw", "type": "base_t"}
{"name": "record_id", "type": "uint64"}
]
},
{
"name": "post_close",
"name": "post_event",
"base": "",
"fields": [
{"name": "author", "type": "name"},
{"name": "permlink", "type": "string"},
{"name": "rewardweight", "type": "base_t"}
{"name": "netshares", "type": "base_t"},
{"name": "voteshares", "type": "base_t"},
{"name": "sumcuratorsw", "type": "base_t"},
{"name": "sharesfn", "type": "base_t"}
]
},
{
Expand All @@ -781,15 +791,23 @@
{"name": "funds", "type": "asset"},
{"name": "rshares", "type": "wide_t"}
]
},
{
"name": "reward_weight_event",
"base": "",
"fields": [
{"name": "message_id", "type": "mssgid"},
{"name": "rewardweight", "type": "base_t"}
]
}
],
"events": [
{"name": "poolstate", "type": "pool_event"},
{"name": "poolerase", "type": "uint64"},
{"name": "postcreate","type": "create_event"},
{"name": "poststate", "type": "post_event"},
{"name": "postclose", "type": "post_close"},
{"name": "votestate", "type": "vote_event"}
{"name": "votestate", "type": "vote_event"},
{"name": "rewardweight", "type": "reward_weight_event"}
],
"actions": [
{
Expand Down Expand Up @@ -843,6 +861,10 @@
{
"name": "setcurprcnt",
"type": "setcurprcnt"
},
{
"name": "calcrwrdwt",
"type": "calcrwrdwt"
}
],
"tables": [
Expand Down
Loading

0 comments on commit 118b37c

Please sign in to comment.