mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated vm
- updated func/fift - additional checks in block validator - docs - tunnel prototype in ADNL
This commit is contained in:
parent
ba76f1404e
commit
54c7a4dcc3
50 changed files with 972 additions and 300 deletions
|
@ -52,43 +52,50 @@
|
|||
// elected-for elections-begin-before elections-end-before stakes-frozen
|
||||
{ 4 0 reverse <b { swap 32 u, } 4 times b> 15 config! } : config.election_params!
|
||||
|
||||
dictnew 0 2constant validator-dict
|
||||
{ @' validator-dict } : validator-dict@
|
||||
{ validator-dict@ nip } : validator#
|
||||
variable validator-dict
|
||||
dictnew 0 validator-dict 2!
|
||||
{ validator-dict @ second } : validator#
|
||||
// val-pubkey weight --
|
||||
{ dup 0<= abort"validator weight must be non-negative"
|
||||
dup 64 ufits not abort"validator weight must fit into 64 bits"
|
||||
over Blen 32 <> abort"validator public key must be 32 bytes long"
|
||||
<b x{538e81278a} s, rot B, swap 64 u, b> <s
|
||||
validator-dict@ dup 1+ 3 -roll swap
|
||||
validator-dict 2@ dup 1+ 3 -roll swap
|
||||
16 udict!+ 0= abort"cannot add validator"
|
||||
swap 2 'nop does : validator-dict
|
||||
swap validator-dict 2!
|
||||
} : add-validator
|
||||
// since-ut until-ut main-val-cnt-or-0 --
|
||||
{ ?dup 0= { validator# } if
|
||||
validator# 0= abort"no initial validators defined"
|
||||
rot <b x{11} s, swap 32 u, rot 32 u, validator# 16 u, swap 16 u,
|
||||
validator-dict@ drop <s s, b>
|
||||
validator-dict @ first <s s, b>
|
||||
34 config!
|
||||
} : config.validators!
|
||||
|
||||
dictnew constant workchain-dict
|
||||
variable workchain-dict
|
||||
// root-hash file-hash enable-utime actual-min-split min-split max-split workchain-id --
|
||||
{ <b x{a6} s, 5 roll 32 u, 4 roll 8 u, 3 roll 8 u, rot 8 u, x{e000} s,
|
||||
3 roll 256 u, rot 256 u, 0 32 u, x{1} s, -1 32 i, 0 64 u, b>
|
||||
dup isWorkchainDescr? not abort"invalid WorkchainDescr created"
|
||||
<s swap @' workchain-dict 32 idict!+ 0= abort"cannot add workchain"
|
||||
=: workchain-dict
|
||||
<s swap workchain-dict @ 32 idict!+ 0= abort"cannot add workchain"
|
||||
workchain-dict !
|
||||
} : add-std-workchain
|
||||
// --
|
||||
{ @' workchain-dict dict>s s>c 12 config! } : config.workchains!
|
||||
{ workchain-dict @ dict>s s>c 12 config! } : config.workchains!
|
||||
|
||||
dictnew constant special-dict
|
||||
variable special-dict
|
||||
// special-smc-addr --
|
||||
{ x{} swap @' special-dict 256 udict! not abort"cannot add a new special smart contract"
|
||||
=: special-dict
|
||||
{ x{} swap special-dict @ 256 udict! not abort"cannot add a new special smart contract"
|
||||
special-dict !
|
||||
} : make_special
|
||||
{ @' special-dict dict>s s>c 31 config! } : config.special!
|
||||
{ special-dict @ dict>s s>c 31 config! } : config.special!
|
||||
|
||||
// ( l -- D ) Converts a list of parameter indices into a dictionary
|
||||
{ dictnew { swap uncons -rot <b swap rot 32 b>idict! not abort"cannot add parameter index" over null?
|
||||
} until nip
|
||||
} : param-list-to-dict
|
||||
{ param-list-to-dict 9 config! } : config.mandatory_params!
|
||||
{ param-list-to-dict 10 config! } : config.critical_params!
|
||||
|
||||
// bit-pps cell-pps mc-bit-pps mc-cell-pps --
|
||||
{ <b x{cc} s, 0 32 u, 4 roll 64 u, 3 roll 64 u, rot 64 u, swap 64 u,
|
||||
|
|
|
@ -217,6 +217,7 @@ builder pack_proposal(cell voters, int sum_weight, int vset_id, slice body) inli
|
|||
int msg_seqno = cs~load_uint(32);
|
||||
var valid_until = cs~load_uint(32);
|
||||
throw_if(35, valid_until < now());
|
||||
throw_if(39, slice_depth(cs) > 64);
|
||||
var (cfg_dict, stored_seqno, public_key, vote_dict) = load_data();
|
||||
throw_unless(33, msg_seqno == stored_seqno);
|
||||
ifnot ((action - 0x566f7465) & -2) {
|
||||
|
@ -228,6 +229,7 @@ builder pack_proposal(cell voters, int sum_weight, int vset_id, slice body) inli
|
|||
stored_seqno += 1;
|
||||
store_data(cfg_dict, stored_seqno, public_key, vote_dict);
|
||||
commit();
|
||||
var (_, bits, refs) = cs.slice_compute_data_size(1024);
|
||||
(vote_dict, var accepted) = register_vote(vote_dict, action, cs, idx, weight, total_weight, config_param(34).cell_hash());
|
||||
store_data(cfg_dict, stored_seqno, public_key, vote_dict);
|
||||
ifnot (accepted.null?()) {
|
||||
|
|
|
@ -1,5 +1,7 @@
|
|||
#!/usr/bin/create-state -s
|
||||
"TonUtil.fif" include
|
||||
"Asm.fif" include
|
||||
"Lists.fif" include
|
||||
|
||||
def? $1 { @' $1 } { "" } cond constant suffix
|
||||
{ suffix $+ } : +suffix
|
||||
|
@ -199,6 +201,9 @@ smc1_addr config.minter_smc!
|
|||
|
||||
1000000000000 -17 of-cc 666666666666 239 of-cc cc+ config.to_mint!
|
||||
|
||||
( 9 10 18 20 21 22 23 24 25 28 34 ) config.mandatory_params!
|
||||
( -1000 -1001 9 10 32 34 36 ) config.critical_params!
|
||||
|
||||
"validator-keys" +suffix +".pub" file>B
|
||||
{ dup Blen } { 32 B| swap dup ."Validator public key = " Bx. cr
|
||||
17 add-validator } while drop
|
||||
|
|
|
@ -42,8 +42,10 @@ int string_hash(slice s) asm "SHA256U";
|
|||
int check_signature(int hash, slice signature, int public_key) asm "CHKSIGNU";
|
||||
int check_data_signature(slice data, slice signature, int public_key) asm "CHKSIGNS";
|
||||
|
||||
(int, int, int) compute_data_size(cell c, int max_cells) asm "CDATASIZE";
|
||||
(int, int, int) slice_compute_data_size(slice s, int max_cells) asm "SDATASIZE";
|
||||
(int, int, int) compute_data_size(cell c, int max_cells) impure asm "CDATASIZE";
|
||||
(int, int, int) slice_compute_data_size(slice s, int max_cells) impure asm "SDATASIZE";
|
||||
(int, int, int, int) compute_data_size?(cell c, int max_cells) asm "CDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
||||
(int, int, int, int) slice_compute_data_size?(cell c, int max_cells) asm "SDATASIZEQ NULLSWAPIFNOT2 NULLSWAPIFNOT";
|
||||
|
||||
;; () throw_if(int excno, int cond) impure asm "THROWARGIF";
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue