mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
updated func/fift
- updated func/fift - updated liteclient/liteserver - bugfixes
This commit is contained in:
parent
d41ce55305
commit
acf16718e6
45 changed files with 1360 additions and 185 deletions
|
@ -241,6 +241,28 @@ bool MsgAddressInt::extract_std_address(vm::CellSlice& cs, ton::WorkchainId& wor
|
|||
return false;
|
||||
}
|
||||
|
||||
bool MsgAddressInt::store_std_address(vm::CellBuilder& cb, ton::WorkchainId workchain,
|
||||
const ton::StdSmcAddress& addr) const {
|
||||
if (workchain >= -128 && workchain < 128) {
|
||||
return cb.store_long_bool(4, 3) // addr_std$10 anycast:(Maybe Anycast)
|
||||
&& cb.store_long_bool(workchain, 8) // workchain_id:int8
|
||||
&& cb.store_bits_bool(addr); // address:bits256 = MsgAddressInt;
|
||||
} else {
|
||||
return cb.store_long_bool(0xd00, 12) // addr_var$11 anycast:(Maybe Anycast) addr_len:(## 9)
|
||||
&& cb.store_long_bool(workchain, 32) // workchain_id:int32
|
||||
&& cb.store_bits_bool(addr); // address:(bits addr_len) = MsgAddressInt;
|
||||
}
|
||||
}
|
||||
|
||||
Ref<vm::CellSlice> MsgAddressInt::pack_std_address(ton::WorkchainId workchain, const ton::StdSmcAddress& addr) const {
|
||||
vm::CellBuilder cb;
|
||||
if (store_std_address(cb, workchain, addr)) {
|
||||
return vm::load_cell_slice_ref(cb.finalize());
|
||||
} else {
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
const MsgAddressInt t_MsgAddressInt;
|
||||
|
||||
bool MsgAddress::validate_skip(vm::CellSlice& cs, bool weak) const {
|
||||
|
|
|
@ -285,6 +285,8 @@ struct MsgAddressInt final : TLB_Complex {
|
|||
bool rewrite = true) const;
|
||||
bool extract_std_address(vm::CellSlice& cs, ton::WorkchainId& workchain, ton::StdSmcAddress& addr,
|
||||
bool rewrite = true) const;
|
||||
bool store_std_address(vm::CellBuilder& cb, ton::WorkchainId workchain, const ton::StdSmcAddress& addr) const;
|
||||
Ref<vm::CellSlice> pack_std_address(ton::WorkchainId workchain, const ton::StdSmcAddress& addr) const;
|
||||
};
|
||||
|
||||
extern const MsgAddressInt t_MsgAddressInt;
|
||||
|
|
|
@ -727,3 +727,33 @@ after:^VmCont = VmCont;
|
|||
vmc_while_body$110011 cond:^VmCont body:^VmCont
|
||||
after:^VmCont = VmCont;
|
||||
vmc_pushint$1111 value:int32 next:^VmCont = VmCont;
|
||||
|
||||
//
|
||||
// DNS RECORDS
|
||||
//
|
||||
_ (HashmapE 16 ^DNSRecord) = DNS_RecordSet;
|
||||
|
||||
chunk_ref$_ {n:#} ref:^(TextChunks (n + 1)) = TextChunkRef (n + 1);
|
||||
chunk_ref_empty$_ = TextChunkRef 0;
|
||||
text_chunk$_ {n:#} len:(## 8) data:(bits (len * 8)) next:(TextChunkRef n) = TextChunks (n + 1);
|
||||
text_chunk_empty$_ = TextChunks 0;
|
||||
text$_ chunks:(## 8) rest:(TextChunks chunks) = Text;
|
||||
dns_text#1eda _:Text = DNSRecord;
|
||||
|
||||
dns_next_resolver#ba93 resolver:MsgAddressInt = DNSRecord; // usually in record #-1
|
||||
|
||||
dns_adnl_address#ad01 adnl_addr:bits256 flags:(## 8) { flags <= 1 }
|
||||
proto_list:flags . 0?ProtoList = DNSRecord; // often in record #2
|
||||
proto_list_nil$0 = ProtoList;
|
||||
proto_list_next$1 head:Protocol tail:ProtoList = ProtoList;
|
||||
proto_http#4854 = Protocol;
|
||||
|
||||
dns_smc_address#9fd3 smc_addr:MsgAddressInt flags:(## 8) { flags <= 1 }
|
||||
cap_list:flags . 0?SmcCapList = DNSRecord; // often in record #1
|
||||
cap_list_nil$0 = SmcCapList;
|
||||
cap_list_next$1 head:SmcCapability tail:SmcCapList = SmcCapList;
|
||||
cap_method_seqno#5371 = SmcCapability;
|
||||
cap_method_pubkey#71f4 = SmcCapability;
|
||||
cap_is_wallet#2177 = SmcCapability;
|
||||
cap_name#ff name:Text = SmcCapability;
|
||||
|
||||
|
|
|
@ -633,6 +633,88 @@ void init_words_custom(fift::Dictionary& d) {
|
|||
d.def_stack_word("isWorkchainDescr? ", interpret_is_workchain_descr);
|
||||
}
|
||||
|
||||
tlb::TypenameLookup tlb_dict;
|
||||
|
||||
// ( S -- T -1 or 0 ) Looks up TLB type by name
|
||||
void interpret_tlb_type_lookup(vm::Stack& stack) {
|
||||
auto ptr = tlb_dict.lookup(stack.pop_string());
|
||||
if (ptr) {
|
||||
stack.push_make_object<tlb::TlbTypeHolder>(ptr);
|
||||
}
|
||||
stack.push_bool(ptr);
|
||||
}
|
||||
|
||||
td::Ref<tlb::TlbTypeHolder> pop_tlb_type(vm::Stack& stack) {
|
||||
auto res = stack.pop_object<tlb::TlbTypeHolder>();
|
||||
if (res.is_null()) {
|
||||
throw vm::VmError{vm::Excno::type_chk, "not a TLB type"};
|
||||
}
|
||||
return res;
|
||||
}
|
||||
|
||||
// ( T -- S ) Gets TLB type name
|
||||
void interpret_tlb_type_name(vm::Stack& stack) {
|
||||
stack.push_string((*pop_tlb_type(stack))->get_type_name());
|
||||
}
|
||||
|
||||
// ( T -- ) Prints TLB type name
|
||||
void interpret_print_tlb_type(vm::Stack& stack) {
|
||||
std::cout << (*pop_tlb_type(stack))->get_type_name();
|
||||
}
|
||||
|
||||
// ( s T -- ) Dumps (part of) slice s as a value of TLB type T
|
||||
void interpret_tlb_dump_as(vm::Stack& stack) {
|
||||
auto tp = pop_tlb_type(stack);
|
||||
(*tp)->print(std::cout, stack.pop_cellslice());
|
||||
}
|
||||
|
||||
// ( s T -- s' S -1 or 0 )
|
||||
// Detects prefix of slice s that is a value of TLB type T, returns the remainder as s', and prints the value into String S.
|
||||
void interpret_tlb_dump_to_str(vm::Stack& stack) {
|
||||
auto tp = pop_tlb_type(stack);
|
||||
auto cs = stack.pop_cellslice();
|
||||
std::ostringstream os;
|
||||
bool ok = (*tp)->print_skip(os, cs.write());
|
||||
if (ok) {
|
||||
stack.push(std::move(cs));
|
||||
stack.push_string(os.str());
|
||||
}
|
||||
stack.push_bool(ok);
|
||||
}
|
||||
|
||||
// ( s T -- s' -1 or 0 ) Skips the only prefix of slice s that can be a value of TLB type T
|
||||
void interpret_tlb_skip(vm::Stack& stack) {
|
||||
auto tp = pop_tlb_type(stack);
|
||||
auto cs = stack.pop_cellslice();
|
||||
bool ok = (*tp)->skip(cs.write());
|
||||
if (ok) {
|
||||
stack.push(std::move(cs));
|
||||
}
|
||||
stack.push_bool(ok);
|
||||
}
|
||||
|
||||
// ( s T -- s' -1 or 0 ) Checks whether a prefix of slice s is a valid value of TLB type T, and skips it
|
||||
void interpret_tlb_validate_skip(vm::Stack& stack) {
|
||||
auto tp = pop_tlb_type(stack);
|
||||
auto cs = stack.pop_cellslice();
|
||||
bool ok = (*tp)->validate_skip(cs.write());
|
||||
if (ok) {
|
||||
stack.push(std::move(cs));
|
||||
}
|
||||
stack.push_bool(ok);
|
||||
}
|
||||
|
||||
void init_words_tlb(fift::Dictionary& d) {
|
||||
tlb_dict.register_types(block::gen::register_simple_types);
|
||||
d.def_stack_word("tlb-type-lookup ", interpret_tlb_type_lookup);
|
||||
d.def_stack_word("tlb-type-name ", interpret_tlb_type_name);
|
||||
d.def_stack_word("tlb. ", interpret_print_tlb_type);
|
||||
d.def_stack_word("tlb-dump-as ", interpret_tlb_dump_as);
|
||||
d.def_stack_word("(tlb-dump-str?) ", interpret_tlb_dump_to_str);
|
||||
d.def_stack_word("tlb-skip ", interpret_tlb_skip);
|
||||
d.def_stack_word("tlb-validate-skip ", interpret_tlb_validate_skip);
|
||||
}
|
||||
|
||||
void usage(const char* progname) {
|
||||
std::cerr
|
||||
<< "Creates initial state for a TON blockchain, using configuration defined by Fift-language source files\n";
|
||||
|
@ -739,6 +821,7 @@ int main(int argc, char* const argv[]) {
|
|||
fift::init_words_vm(config.dictionary);
|
||||
fift::init_words_ton(config.dictionary);
|
||||
init_words_custom(config.dictionary);
|
||||
init_words_tlb(config.dictionary);
|
||||
|
||||
if (script_mode) {
|
||||
fift::import_cmdline_args(config.dictionary, source_list.empty() ? "" : source_list[0], argc - optind,
|
||||
|
|
|
@ -191,7 +191,8 @@ void test2(vm::CellSlice& cs) {
|
|||
}
|
||||
|
||||
void usage() {
|
||||
std::cout << "usage: dump-block [-S][<boc-file>]\n\tor dump-block -h\n\tDumps specified blockchain block or state "
|
||||
std::cout << "usage: dump-block [-t<typename>][-S][<boc-file>]\n\tor dump-block -h\n\tDumps specified blockchain "
|
||||
"block or state "
|
||||
"from <boc-file>, or runs some tests\n\t-S\tDump a blockchain state instead of a block\n";
|
||||
std::exit(2);
|
||||
}
|
||||
|
@ -199,15 +200,20 @@ void usage() {
|
|||
int main(int argc, char* const argv[]) {
|
||||
int i;
|
||||
int new_verbosity_level = VERBOSITY_NAME(INFO);
|
||||
bool dump_state = false, dump_vmcont = false;
|
||||
const char* tname = nullptr;
|
||||
const tlb::TLB* type = &block::gen::t_Block;
|
||||
auto zerostate = std::make_unique<block::ZerostateInfo>();
|
||||
while ((i = getopt(argc, argv, "CShv:")) != -1) {
|
||||
while ((i = getopt(argc, argv, "CSt:hv:")) != -1) {
|
||||
switch (i) {
|
||||
case 'C':
|
||||
dump_vmcont = true;
|
||||
type = &block::gen::t_VmCont;
|
||||
break;
|
||||
case 'S':
|
||||
dump_state = true;
|
||||
type = &block::gen::t_ShardStateUnsplit;
|
||||
break;
|
||||
case 't':
|
||||
tname = optarg;
|
||||
type = nullptr;
|
||||
break;
|
||||
case 'v':
|
||||
new_verbosity_level = VERBOSITY_NAME(FATAL) + (verbosity = td::to_integer<int>(td::Slice(optarg)));
|
||||
|
@ -233,13 +239,18 @@ int main(int argc, char* const argv[]) {
|
|||
vm::CellSlice cs{vm::NoVm(), boc};
|
||||
cs.print_rec(std::cout);
|
||||
std::cout << std::endl;
|
||||
auto& type = !dump_vmcont
|
||||
? (dump_state ? (const tlb::TLB&)block::gen::t_ShardStateUnsplit : block::gen::t_Block)
|
||||
: block::gen::t_VmCont;
|
||||
type.print_ref(std::cout, boc);
|
||||
if (!type) {
|
||||
tlb::TypenameLookup dict(block::gen::register_simple_types);
|
||||
type = dict.lookup(tname);
|
||||
if (!type) {
|
||||
std::cerr << "unknown TL-B type " << tname << std::endl;
|
||||
std::exit(3);
|
||||
}
|
||||
}
|
||||
type->print_ref(std::cout, boc);
|
||||
std::cout << std::endl;
|
||||
bool ok = type.validate_ref(boc);
|
||||
std::cout << "(" << (ok ? "" : "in") << "valid " << type << ")" << std::endl;
|
||||
bool ok = type->validate_ref(boc);
|
||||
std::cout << "(" << (ok ? "" : "in") << "valid " << *type << ")" << std::endl;
|
||||
}
|
||||
}
|
||||
if (!done) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue