mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
speed up synchronization
- download old files in chunks - updated docs - fixed elector/config smartcontracts
This commit is contained in:
parent
0dae2c157b
commit
7f3a22a217
21 changed files with 365 additions and 191 deletions
|
@ -26,7 +26,7 @@
|
|||
|
||||
(int, int) check_validator_set(cell vset) {
|
||||
var cs = vset.begin_parse();
|
||||
throw_if(9, (cs~load_uint(8) - 0x11) & -2); ;; validators#11 or validators_ext#12
|
||||
throw_unless(9, cs~load_uint(8) == 0x12); ;; validators_ext#12 only
|
||||
int utime_since = cs~load_uint(32);
|
||||
int utime_until = cs~load_uint(32);
|
||||
int total = cs~load_uint(16);
|
||||
|
@ -103,7 +103,7 @@
|
|||
.end_cell(), 0);
|
||||
}
|
||||
|
||||
() after_code_upgrade(slice param, cell old_code) impure method_id(1666) {
|
||||
() after_code_upgrade(slice param, cont old_code) impure method_id(1666) {
|
||||
}
|
||||
|
||||
_ perform_action(cfg_dict, public_key, action, cs) {
|
||||
|
@ -119,7 +119,7 @@ _ perform_action(cfg_dict, public_key, action, cs) {
|
|||
var new_code = cs~load_ref();
|
||||
set_code(new_code);
|
||||
var old_code = get_c3();
|
||||
set_c3(new_code);
|
||||
set_c3(new_code.begin_parse().bless());
|
||||
after_code_upgrade(cs, old_code);
|
||||
throw(0);
|
||||
return (cfg_dict, public_key);
|
||||
|
@ -231,7 +231,7 @@ cell register_vote(vote_dict, action, cs, idx, weight) {
|
|||
if (ds.slice_bits() >= 40) {
|
||||
var tag = ds~load_uint(8);
|
||||
var since = ds.preload_uint(32);
|
||||
if ((tag == 0x11) & (since >= now())) {
|
||||
if ((since <= now()) & (tag == 0x12)) {
|
||||
;; next validator set becomes active!
|
||||
var cur_vset = cfg_dict~idict_set_get_ref(kl, 34, next_vset); ;; next_vset -> cur_vset
|
||||
cfg_dict~idict_set_get_ref(kl, 32, cur_vset); ;; cur_vset -> prev_vset
|
||||
|
@ -241,3 +241,7 @@ cell register_vote(vote_dict, action, cs, idx, weight) {
|
|||
}
|
||||
set_data(begin_cell().store_ref(cfg_dict).store_slice(cs).end_cell());
|
||||
}
|
||||
|
||||
int seqno() impure method_id {
|
||||
return get_data().begin_parse().preload_uint(32);
|
||||
}
|
||||
|
|
|
@ -338,7 +338,7 @@ int upgrade_code(s_addr, cs, query_id) {
|
|||
var code = cs~load_ref();
|
||||
set_code(code);
|
||||
ifnot(cs.slice_empty?()) {
|
||||
set_c3(code);
|
||||
set_c3(code.begin_parse().bless());
|
||||
;; run_method3(1666, s_addr, cs, query_id);
|
||||
after_code_upgrade(s_addr, cs, query_id);
|
||||
throw(0);
|
||||
|
|
|
@ -215,10 +215,11 @@ now dup orig_vset_valid_for + 0 config.validators!
|
|||
*
|
||||
*/
|
||||
"auto/config-code.fif" include // code in separate source file
|
||||
<b 0 32 u,
|
||||
<b configdict ref, // initial configuration
|
||||
0 32 u, // seqno
|
||||
"config-master" +suffix +".pk" load-generate-keypair drop
|
||||
B,
|
||||
configdict ref,
|
||||
newdict dict, // vote dict
|
||||
b> // data
|
||||
empty_cell // libraries
|
||||
GR$10 // balance
|
||||
|
|
|
@ -35,8 +35,10 @@ int check_data_signature(slice data, slice signature, int public_key) asm "CHKSI
|
|||
|
||||
cell get_data() asm "c4 PUSH";
|
||||
() set_data(cell c) impure asm "c4 POP";
|
||||
cell get_c3() impure asm "c3 PUSH";
|
||||
() set_c3(cell c) impure asm "c3 POP";
|
||||
cont get_c3() impure asm "c3 PUSH";
|
||||
() set_c3(cont c) impure asm "c3 POP";
|
||||
cont bless(slice s) impure asm "BLESS";
|
||||
|
||||
() accept_message() impure asm "ACCEPT";
|
||||
() commit() impure asm "COMMIT";
|
||||
|
||||
|
|
|
@ -9,14 +9,14 @@
|
|||
$# dup 2 < swap 3 > or ' usage if
|
||||
|
||||
"config-master" constant file-base
|
||||
0 constant seqno
|
||||
0 constant qseqno
|
||||
-1 constant idx
|
||||
true constant bounce
|
||||
"auto/config-code.fif" constant config-source
|
||||
100 constant interval // valid for 100 seconds
|
||||
|
||||
$1 =: file-base
|
||||
$2 parse-int =: seqno
|
||||
$2 parse-int =: qseqno
|
||||
def? $3 { @' $3 } { "config-query" } cond constant savefile
|
||||
|
||||
file-base +".addr" load-address
|
||||
|
@ -30,7 +30,7 @@ config-source include
|
|||
dup <s csr. cr
|
||||
|
||||
// create a message
|
||||
<b x{4e436f64} s, seqno 32 u, now interval + 32 u, swap ref, b>
|
||||
<b x{4e436f64} s, qseqno 32 u, now interval + 32 u, swap ref, b>
|
||||
dup ."signing message: " <s csr. cr
|
||||
dup hashu config_pk ed25519_sign_uint
|
||||
<b b{1000100} s, config_addr addr, 0 Gram, b{00} s,
|
||||
|
|
|
@ -1,11 +1,19 @@
|
|||
#!/usr/bin/fift -s
|
||||
"TonUtil.fif" include
|
||||
|
||||
{ ."usage: " @' $0 type ." <filename-base> <dest-addr> <seqno> <amount> [-B <body-boc>] [-C <transfer-comment>] [<savefile>]" cr
|
||||
{ ."usage: " @' $0 type ." <filename-base> <dest-addr> <seqno> <amount> [-n] [-B <body-boc>] [-C <transfer-comment>] [<savefile>]" cr
|
||||
."Creates a request to simple wallet created by new-wallet.fif, with private key loaded from file <filename-base>.pk "
|
||||
."and address from <filename-base>.addr, and saves it into <savefile>.boc ('wallet-query.boc' by default)" cr 1 halt
|
||||
} : usage
|
||||
"" =: comment // comment for simple transfers
|
||||
true =: allow-bounce
|
||||
def? $5 { @' $5 "-n" $= { false =: allow-bounce [forget] $5
|
||||
def? $6 { @' $6 =: $5 [forget] $6 } if
|
||||
def? $7 { @' $7 =: $6 [forget] $7 } if
|
||||
@' $# 1- =: $#
|
||||
} if
|
||||
} if
|
||||
|
||||
def? $6 { @' $5 dup "-B" $= swap "-C" $= tuck or
|
||||
{ @' $6 swap { =: comment } { =: body-boc-file } cond [forget] $6
|
||||
def? $7 { @' $7 =: $5 [forget] $7 } { [forget] $5 } cond
|
||||
|
@ -17,7 +25,7 @@ $# dup 4 < swap 5 > or ' usage if
|
|||
true constant bounce
|
||||
|
||||
$1 =: file-base
|
||||
$2 bounce parse-load-address =: bounce 2=: dest_addr
|
||||
$2 bounce parse-load-address allow-bounce and =: bounce 2=: dest_addr
|
||||
$3 parse-int =: seqno
|
||||
$4 $>GR =: amount
|
||||
def? $5 { @' $5 } { "wallet-query" } cond constant savefile
|
||||
|
|
|
@ -626,9 +626,23 @@ inline void throw_rangechk(bool ok) {
|
|||
}
|
||||
} // namespace
|
||||
|
||||
int exec_bless_pop_c3(VmState* st) {
|
||||
Stack& stack = st->get_stack();
|
||||
VM_LOG(st) << "execute CTOSBLESSPOPc3";
|
||||
stack.check_underflow(1);
|
||||
throw_typechk(st->set_c(3, Ref<OrdCont>{true, vm::load_cell_slice_ref(stack.pop_cell()), st->get_cp()}));
|
||||
return 0;
|
||||
}
|
||||
|
||||
int exec_pop_ctr(VmState* st, unsigned args) {
|
||||
unsigned idx = args & 15;
|
||||
VM_LOG(st) << "execute POP c" << idx;
|
||||
/*
|
||||
if (idx == 3 && st->get_stack().depth() > 0 && st->get_stack().tos().is(StackEntry::t_cell)) {
|
||||
// temp hack: accept cell argument for POP c3 and do auto-BLESSing
|
||||
return exec_bless_pop_c3(st);
|
||||
}
|
||||
*/
|
||||
throw_typechk(st->set(idx, st->get_stack().pop_chk()));
|
||||
return 0;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue