1
0
Fork 0
mirror of https://github.com/ton-blockchain/ton synced 2025-03-09 15:40:10 +00:00
This commit is contained in:
ton 2020-04-10 23:06:01 +04:00
parent 8be3fc99ed
commit be9c34c62d
699 changed files with 1171 additions and 978 deletions

View file

@ -142,12 +142,12 @@ variable special-dict
{ make-msg-fwd-prices 24 config! } : config.mc_fwd_prices!
{ make-msg-fwd-prices 25 config! } : config.fwd_prices!
// mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num
{ 4 0 reverse <b x{c1} s, swap 32 u, swap 32 u, swap 32 u, swap 32 u, b>
// mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num mc-shuffle
{ 4 1 reverse <b x{c201_} s, swap 1 i, swap 32 u, swap 32 u, swap 32 u, swap 32 u, b>
} : make-catchain-params
{ make-catchain-params 28 config! } : config.catchain_params!
// round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size
{ 8 0 reverse <b x{d6} s, { swap 32 u, } 8 times b> } : make-vsession-params
// round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size new-cc-ids
{ 8 1 reverse <b x{d701_} s, swap 1 i, swap 8 u, { swap 32 u, } 7 times b> } : make-vsession-params
{ make-vsession-params 29 config! } : config.consensus_params!
// b [underload soft hard] -- b'

View file

@ -76,21 +76,22 @@ builder pack_complaint_status(cell complaint, cell voters, int vset_id, int weig
.store_int(weight_remaining, 64);
}
;; validator_complaint#ba validator_pubkey:uint256 description:^ComplaintDescr
;; severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams
;; validator_complaint#bc validator_pubkey:uint256 description:^ComplaintDescr
;; created_at:uint32 severity:uint8 reward_addr:uint256 paid:Grams suggested_fine:Grams
;; suggested_fine_part:uint32 = ValidatorComplaint;
_ unpack_complaint(slice cs) inline_ref {
throw_unless(9, cs~load_int(8) == 0xba - 0x100);
var res = (cs~load_uint(256), cs~load_ref(), cs~load_uint(8), cs~load_uint(256), cs~load_grams(), cs~load_grams(), cs~load_uint(32));
throw_unless(9, cs~load_int(8) == 0xbc - 0x100);
var res = (cs~load_uint(256), cs~load_ref(), cs~load_uint(32), cs~load_uint(8), cs~load_uint(256), cs~load_grams(), cs~load_grams(), cs~load_uint(32));
cs.end_parse();
return res;
}
builder pack_complaint(int validator_pubkey, cell description, int severity, int reward_addr, int paid, int suggested_fine, int suggested_fine_part) inline_ref {
builder pack_complaint(int validator_pubkey, cell description, int created_at, int severity, int reward_addr, int paid, int suggested_fine, int suggested_fine_part) inline_ref {
return begin_cell()
.store_int(0xba - 0x100, 8)
.store_int(0xbc - 0x100, 8)
.store_uint(validator_pubkey, 256)
.store_ref(description)
.store_uint(created_at, 32)
.store_uint(severity, 8)
.store_uint(reward_addr, 256)
.store_grams(paid)
@ -459,8 +460,9 @@ int register_complaint(s_addr, complaint, msg_value) {
if (expire_in <= 0) { ;; already expired
return -4;
}
var (validator_pubkey, description, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = unpack_complaint(complaint);
var (validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = unpack_complaint(complaint);
reward_addr = src_addr;
created_at = now();
;; compute complaint storage/creation price
var (deposit, bit_price, cell_price) = get_complaint_prices();
var (_, bits, refs) = slice_compute_data_size(complaint, 4096);
@ -470,7 +472,7 @@ int register_complaint(s_addr, complaint, msg_value) {
return -5;
}
;; re-pack modified complaint
cell complaint = pack_complaint(validator_pubkey, description, severity, reward_addr, paid, suggested_fine, suggested_fine_part).end_cell();
cell complaint = pack_complaint(validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part).end_cell();
var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs);
var (fs, f) = frozen_dict.udict_get?(256, validator_pubkey);
ifnot (f) { ;; no such validator, cannot complain
@ -502,7 +504,7 @@ int register_complaint(s_addr, complaint, msg_value) {
}
(cell, cell, int) punish(credits, frozen, complaint) inline_ref {
var (validator_pubkey, description, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = complaint.begin_parse().unpack_complaint();
var (validator_pubkey, description, created_at, severity, reward_addr, paid, suggested_fine, suggested_fine_part) = complaint.begin_parse().unpack_complaint();
var (cs, f) = frozen.udict_get?(256, validator_pubkey);
ifnot (f) {
;; no validator to punish
@ -1073,3 +1075,73 @@ int compute_returned_stake(int wallet_addr) method_id {
var (val, f) = credits.udict_get?(256, wallet_addr);
return f ? val~load_grams() : 0;
}
;; returns the list of past election ids
tuple past_election_ids() method_id {
var (elect, credits, past_elections, grams, active_id, active_hash) = load_data();
var id = (1 << 32);
var list = null();
do {
(id, var fs, var f) = past_elections.udict_get_prev?(32, id);
if (f) {
list = cons(id, list);
}
} until (~ f);
return list;
}
tuple past_elections() method_id {
var (elect, credits, past_elections, grams, active_id, active_hash) = load_data();
var id = (1 << 32);
var list = null();
do {
(id, var fs, var found) = past_elections.udict_get_prev?(32, id);
if (found) {
var info = [unpack_past_election(fs)];
list = cons(pair(id, info), list);
}
} until (~ found);
return list;
}
_ complete_unpack_complaint(slice cs) inline_ref {
var (complaint, voters, vset_id, weight_remaining) = cs.unpack_complaint_status();
var voters_list = null();
var voter_id = (1 << 32);
do {
(voter_id, _, var f) = voters.udict_get_prev?(16, voter_id);
if (f) {
voters_list = cons(voter_id, voters_list);
}
} until (~ f);
return [[complaint.begin_parse().unpack_complaint()], voters_list, vset_id, weight_remaining];
}
cell get_past_complaints(int election_id) inline_ref {
var (elect, credits, past_elections, grams, active_id, active_hash) = load_data();
var (fs, found?) = past_elections.udict_get?(32, election_id);
ifnot (found?) {
return null();
}
var (unfreeze_at, stake_held, vset_hash, frozen_dict, total_stake, bonuses, complaints) = unpack_past_election(fs);
return complaints;
}
_ show_complaint(int election_id, int chash) method_id {
var complaints = get_past_complaints(election_id);
var (cs, found) = complaints.udict_get?(256, chash);
return found ? complete_unpack_complaint(cs) : null();
}
tuple list_complaints(int election_id) method_id {
var complaints = get_past_complaints(election_id);
int id = (1 << 255) + ((1 << 255) - 1);
var list = null();
do {
(id, var cs, var found?) = complaints.udict_get_prev?(256, id);
if (found?) {
list = cons(pair(id, complete_unpack_complaint(cs)), list);
}
} until (~ found?);
return list;
}

View file

@ -25,7 +25,8 @@ hashu dup =: basestate0_rhash
."root hash=" dup 64x. space 256 u>B dup B>base64url type cr
"basestate0" +suffix +".rhash" B>file
basestate0_rhash basestate0_fhash now 0 2 32 0 add-std-workchain
// root-hash file-hash start-at actual-min-split min-split-depth max-split-depth wc-id
basestate0_rhash basestate0_fhash now 0 4 8 0 add-std-workchain
config.workchains!
// SmartContract #1 (Simple wallet)
@ -157,7 +158,7 @@ Masterchain swap
*
*/
// version capabilities
1 capCreateStats capBounceMsgBody or capReportVersion or capShortDeque or config.version!
1 capCreateStats capBounceMsgBody or capReportVersion or capShortDequeue or config.version!
// max-validators max-main-validators min-validators
// 9 4 1 config.validator_num!
1000 100 13 config.validator_num!
@ -183,15 +184,15 @@ config.special!
// lump_price bit_price cell_price ihr_factor first_frac next_frac
1000000 1000 sg* 100000 sg* 3/2 sg*/ 1/3 sg*/ 1/3 sg*/ config.fwd_prices!
10000000 10000 sg* 1000000 sg* 3/2 sg*/ 1/3 sg*/ 1/3 sg*/ config.mc_fwd_prices!
// mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num
250 250 1000 7 config.catchain_params!
// round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size
3 2000 16000 3 8 4 2 *Mi 2 *Mi config.consensus_params!
// mc-cc-lifetime sh-cc-lifetime sh-val-lifetime sh-val-num mc-shuffle
250 250 1000 7 true config.catchain_params!
// round-candidates next-cand-delay-ms consensus-timeout-ms fast-attempts attempt-duration cc-max-deps max-block-size max-collated-size new-cc-ids
3 2000 16000 3 8 4 2 *Mi 2 *Mi true config.consensus_params!
128 *Ki 512 *Ki 1 *Mi triple // [ underload soft hard ] : block bytes limit
100000 500000 1000000 triple // gas limits
1000 5000 10000 triple // lt limits
128 *Ki 512 *Ki 1 *Mi triple // [ underload soft hard ] : block bytes limit
2000000 10000000 20000000 triple // gas limits
1000 5000 10000 triple // lt limits
triple dup untriple config.mc_block_limits!
untriple config.block_limits!