Skip to content

Commit 76eb155

Browse files
committed
Merge branch 'testnet' into collated-data-opt
2 parents a505e32 + 47b0e57 commit 76eb155

File tree

193 files changed

+8960
-4685
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

193 files changed

+8960
-4685
lines changed

.lldbinit

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
# to make this (local) .lldbinit work, don't forget to add the following line to global ~/.lldbinit:
2+
# settings set target.load-cwd-lldbinit true
3+
4+
command script import lldb_addons.py
5+
6+
settings set target.process.thread.step-avoid-regexp tolk::ASTNodeBase::as<.+>|tolk::Vertex<.+>::get_.+|std::.+

crypto/smartcont/tolk-stdlib/common.tolk

Lines changed: 271 additions & 114 deletions
Large diffs are not rendered by default.
Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
// A part of standard library for Tolk
2+
tolk 1.2
3+
4+
enum ExoticCellType: int8 {
5+
Ordinary = -1
6+
PrunedBranch = 1
7+
LibraryReference = 2
8+
MerkleProof = 3
9+
MerkleUpdate = 4
10+
}
11+
12+
/// Transforms an ordinary or exotic cell into a slice, as if it were an ordinary cell.
13+
/// A flag is returned indicating whether c is exotic.
14+
/// If so, ExoticCellType can later be deserialized from the first eight bits of s.
15+
/// ```
16+
/// var (s, isExotic) = c.beginParseSpecial();
17+
/// if (isExotic) {
18+
/// // use unsafe cast because the first 8 bits hold a correct value, no need for validation
19+
/// val cellType = s.loadInt(8) as ExoticCellType;
20+
/// }
21+
/// ```
22+
@pure
23+
fun cell.beginParseSpecial(self): (slice, bool)
24+
asm "XCTOS"
25+
26+
/// Creates an exotic or ordinary cell from a builder.
27+
@pure
28+
fun builder.endCellSpecial(self, isExotic: bool = true): cell
29+
asm "ENDXC"
30+
31+
/// Returns i-th hash of the cell.
32+
@pure
33+
fun cell.hashOfLevel(self, level: int): uint256
34+
asm "CHASHIX"
35+
36+
/// Returns i-th depth of the cell.
37+
@pure
38+
fun cell.depthOfLevel(self, level: int): int
39+
asm "CDEPTHIX"
40+
41+
/// Loads an exotic cell and returns an ordinary cell.
42+
/// If the cell is already ordinary, does nothing. Throws an exception if cannot be loaded.
43+
@pure
44+
fun cell.loadSpecial(self): cell
45+
asm "XLOAD"
46+
47+
/// Transforms an ordinary or exotic cell into a library reference
48+
/// (into an exotic cell with contents "8 bits cell type" + "256 bits lib hash").
49+
@pure
50+
fun cell.toLibraryReference(self): cell {
51+
return beginCell()
52+
.storeInt(ExoticCellType.LibraryReference as int, 8)
53+
.storeUint(self.hash(), 256)
54+
.endCellSpecial()
55+
}

crypto/smartcont/tolk-stdlib/gas-payments.tolk

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 1.1
2+
tolk 1.2
33

44
/**
55
Gas and payment related primitives.
@@ -33,10 +33,12 @@ fun setGasLimit(limit: int): void
3333
asm "SETGASLIMIT"
3434

3535
/// Calculates fee (amount in nanotoncoins to be paid) for a transaction which consumed `gasUsed` gas units.
36+
@pure
3637
fun calculateGasFee(workchain: int8, gasUsed: int): coins
3738
asm(gasUsed workchain) "GETGASFEE"
3839

3940
/// Same as [calculateGasFee], but without flat price. [Docs about fees](https://docs.ton.org/develop/howto/fees-low-level)
41+
@pure
4042
fun calculateGasFeeWithoutFlatPrice(workchain: int8, gasUsed: coins): coins
4143
asm(gasUsed workchain) "GETGASFEESIMPLE"
4244

@@ -46,10 +48,12 @@ fun calculateStorageFee(workchain: int8, seconds: int, bits: int, cells: int): c
4648
asm(cells bits seconds workchain) "GETSTORAGEFEE"
4749

4850
/// Calculates amount of nanotoncoins you should pay to send a message of a specified size.
51+
@pure
4952
fun calculateForwardFee(workchain: int8, bits: int, cells: int): coins
5053
asm(cells bits workchain) "GETFORWARDFEE"
5154

5255
/// Same as [calculateForwardFee], but without lump price. [Docs about fees](https://docs.ton.org/develop/howto/fees-low-level)
56+
@pure
5357
fun calculateForwardFeeWithoutLumpPrice(workchain: int8, bits: int, cells: int): coins
5458
asm(cells bits workchain) "GETFORWARDFEESIMPLE"
5559

crypto/smartcont/tolk-stdlib/lisp-lists.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 1.1
2+
tolk 1.2
33

44
/**
55
Lisp-style lists are nested 2-elements tuples: `[1, [2, [3, null]]]` represents list `[1, 2, 3]`.

crypto/smartcont/tolk-stdlib/tvm-dicts.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 1.1
2+
tolk 1.2
33

44
/**
55
Low-level API working with TVM dictionaries.

crypto/smartcont/tolk-stdlib/tvm-lowlevel.tolk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
// A part of standard library for Tolk
2-
tolk 1.1
2+
tolk 1.2
33

44
/// Usually `c3` has a continuation initialized by the whole code of the contract. It is used for function calls.
55
/// The primitive returns the current value of `c3`.

lldb_addons.py

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
# noinspection PyUnresolvedReferences
2+
import lldb
3+
4+
5+
def call_cpp_debug_print(valobj, arg_type: str):
6+
type = valobj.GetType()
7+
if type.is_reference or type.is_pointer:
8+
addr = valobj.Dereference().GetAddress()
9+
else:
10+
addr = valobj.GetAddress()
11+
if not addr.IsValid():
12+
return "nullptr"
13+
14+
s = valobj.GetFrame().EvaluateExpression('debug_print(({}*){})'.format(arg_type, addr)).GetSummary()
15+
s = str(s)[1:-1] # trim quotes
16+
17+
if "{enum.Op.cl}" in s:
18+
s = s.replace("{enum.Op.cl}", valobj.GetChildMemberWithName("cl").GetValue())
19+
if "{enum.AsmOp.t}" in s:
20+
s = s.replace("{enum.AsmOp.t}", valobj.GetChildMemberWithName("t").GetValue())
21+
return s
22+
23+
24+
def print_td_RefInt256(valobj, internal_dict, options):
25+
n = valobj.EvaluateExpression("ptr.value.n").GetValueAsUnsigned()
26+
if n == 0:
27+
return "0"
28+
if n == 1:
29+
return valobj.EvaluateExpression("ptr.value.digits[0]").GetValueAsUnsigned()
30+
return "n=" + str(n)
31+
32+
33+
def print_ast_vertex(valobj, internal_dict, options):
34+
type = valobj.GetType()
35+
if type.is_reference or type.is_pointer:
36+
addr = valobj.Dereference().GetAddress()
37+
else:
38+
addr = valobj.GetAddress()
39+
if not addr.IsValid():
40+
return "nullptr"
41+
42+
s = valobj.GetFrame().EvaluateExpression('debug_print((tolk::ASTNodeBase*){})'.format(addr)).GetSummary()
43+
s = str(s)[1:-1] # trim quotes
44+
45+
return s
46+
47+
48+
def __lldb_init_module(debugger, _):
49+
types_with_debug_print = [
50+
'tolk::Op',
51+
'tolk::TypeData',
52+
'tolk::VarDescr',
53+
'tolk::TmpVar',
54+
'tolk::VarDescrList',
55+
'tolk::AsmOp',
56+
'tolk::AsmOpList',
57+
'tolk::Stack',
58+
'tolk::SrcRange',
59+
'tolk::LocalVarData',
60+
'tolk::FunctionData',
61+
'tolk::GlobalVarData',
62+
'tolk::GlobalConstData',
63+
'tolk::AliasDeclarationData',
64+
'tolk::StructFieldData',
65+
'tolk::StructData',
66+
'tolk::EnumMemberData',
67+
'tolk::EnumDefData',
68+
'tolk::FlowContext',
69+
'tolk::SinkExpression',
70+
'tolk::InfoAboutExpr',
71+
'tolk::GenericsDeclaration',
72+
'tolk::GenericsSubstitutions',
73+
]
74+
for arg_type in types_with_debug_print:
75+
debugger.HandleCommand('type summary add --python-script "return lldb_addons.call_cpp_debug_print(valobj, \'{}\')" {}'.format(arg_type, arg_type))
76+
77+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTNodeBase')
78+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTNodeDeclaredTypeBase')
79+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTNodeExpressionBase')
80+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTNodeStatementBase')
81+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTTypeLeaf')
82+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTTypeVararg')
83+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTExprLeaf')
84+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTExprUnary')
85+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTExprBinary')
86+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTExprVararg')
87+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTStatementUnary')
88+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" tolk::ASTStatementVararg')
89+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" -x "^tolk::V<.+>$"')
90+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_ast_vertex" -x "^tolk::Vertex<.+>$"')
91+
debugger.HandleCommand('type summary add --python-function "lldb_addons.print_td_RefInt256" td::RefInt256')

overlay/overlay-manager.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -598,8 +598,12 @@ BroadcastCheckResult Certificate::check(PublicKeyHash node, OverlayIdShort overl
598598
}
599599

600600
tl_object_ptr<ton_api::overlay_Certificate> Certificate::tl() const {
601-
return create_tl_object<ton_api::overlay_certificate>(issued_by_.get<PublicKey>().tl(), expire_at_, max_size_,
602-
signature_.clone_as_buffer_slice());
601+
if (flags_ == cert_default_flags(max_size_)) {
602+
return create_tl_object<ton_api::overlay_certificate>(issued_by_.get<PublicKey>().tl(), expire_at_, max_size_,
603+
signature_.clone_as_buffer_slice());
604+
}
605+
return create_tl_object<ton_api::overlay_certificateV2>(issued_by_.get<PublicKey>().tl(), expire_at_, max_size_,
606+
flags_, signature_.clone_as_buffer_slice());
603607
}
604608

605609
tl_object_ptr<ton_api::overlay_Certificate> Certificate::empty_tl() {

tl/generate/scheme/ton_api.tl

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -984,10 +984,11 @@ validatorStats.validatedBlock
984984
self:int256
985985
valid:Bool comment:string
986986
bytes:int collated_data_bytes:int
987-
total_time:double work_time:double cpu_work_time:double time_stats:string
987+
total_time:double work_time:double actual_time:double cpu_work_time:double time_stats:string
988988
work_time_real_stats:string
989989
work_time_cpu_stats:string
990-
storage_stat_cache:validatorStats.storageStatCacheStats = validatorStats.ValidatedBlock;
990+
storage_stat_cache:validatorStats.storageStatCacheStats
991+
parallel_accounts_validation:Bool = validatorStats.ValidatedBlock;
991992

992993
validatorStats.newValidatorGroup.node id:int256 pubkey:PublicKey adnl_id:int256 weight:long = validatorStats.newValidatorGroup.Node;
993994
validatorStats.newValidatorGroup session_id:int256 shard:tonNode.shardId cc_seqno:int

0 commit comments

Comments
 (0)