Skip to content

Commit d4fcef4

Browse files
authored
Version 11: fix account storage stat and null in RUNVM (#1690)
* Bugfix in AccountStorageStat::remove_cell * Fix returning null as c4/c5 in RUNVM
1 parent d1e00f5 commit d4fcef4

File tree

4 files changed

+20
-8
lines changed

4 files changed

+20
-8
lines changed

crypto/block/account-storage-stat.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ td::Status AccountStorageStat::remove_cell(const Ref<vm::Cell>& cell) {
154154
if (e.refcnt_diff < 0 && !e.refcnt) {
155155
TRY_STATUS(fetch_from_dict(e));
156156
}
157-
if (e.refcnt.value() + e.refcnt_diff != 0) {
157+
if (e.refcnt_diff >= 0 || e.refcnt.value() + e.refcnt_diff != 0) {
158158
return td::Status::OK();
159159
}
160160
bool spec;

crypto/vm/vm.cpp

Lines changed: 14 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -785,11 +785,20 @@ void VmState::restore_parent_vm(int res) {
785785
cur_stack.push(std::move(child_state.stack->at(i)));
786786
}
787787
cur_stack.push_smallint(res);
788-
if (parent->return_data) {
789-
cur_stack.push_cell(child_state.get_committed_state().c4);
790-
}
791-
if (parent->return_actions) {
792-
cur_stack.push_cell(child_state.get_committed_state().c5);
788+
if (global_version >= 11 && !child_state.get_committed_state().committed) {
789+
if (parent->return_data) {
790+
cur_stack.push_null();
791+
}
792+
if (parent->return_actions) {
793+
cur_stack.push_null();
794+
}
795+
} else {
796+
if (parent->return_data) {
797+
cur_stack.push_cell(child_state.get_committed_state().c4);
798+
}
799+
if (parent->return_actions) {
800+
cur_stack.push_cell(child_state.get_committed_state().c5);
801+
}
793802
}
794803
if (parent->return_gas) {
795804
cur_stack.push_smallint(child_state.gas.gas_consumed());

doc/GlobalVersions.md

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -221,4 +221,7 @@ Reserve modes `+1`, `+4` and `+8` ("reserve all except", "add original balance"
221221
Along with the storage stat (cells and bits count), each account now stores the hash of the **storage dict**.
222222

223223
**Storage dict** is the dictionary that stores refcnt for each cell in the account state.
224-
This is required to help computing storage stats in the future, after collator-validator separation.
224+
This is required to help computing storage stats in the future, after collator-validator separation.
225+
226+
### Other TVM changes
227+
- Fix returning `null` as `c4` and `c5` (when VM state is not committed) in `RUNVM`.

test/regression-tests.ans

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Test_Fift_test_rist255_default f4d7558f200a656934f986145c19b1dedbe2ad029292a5a97
2525
Test_Fift_test_secp256k1_default 3118450dace6af05fcdbd54a87d9446162ce11ac6ef6dfc57998cf113587d602
2626
Test_Fift_test_sort2_default 9b57d47e6a10e7d1bbb565db35400debf2f963031f434742a702ec76555a5d3a
2727
Test_Fift_test_sort_default 9b57d47e6a10e7d1bbb565db35400debf2f963031f434742a702ec76555a5d3a
28-
Test_Fift_test_tvm_runvm_default ff3d2a4031b543c18d6b555f0a1f1a891c7825e6d1e2e9beb4bf13b37441450b
28+
Test_Fift_test_tvm_runvm_default b3e0d70c00f0e8bdf6d45c56c7c0817fa5be7a3fc540190786233a394de72e42
2929
Test_Fift_testvm2_default 8a6e35fc0224398be9d2de39d31c86ea96965ef1eca2aa9e0af2303150ed4a7b
3030
Test_Fift_testvm3_default 3c1b77471c5fd914ed8b5f528b9faed618e278693f5030b953ff150e543864ae
3131
Test_Fift_testvm4_default 8a6e35fc0224398be9d2de39d31c86ea96965ef1eca2aa9e0af2303150ed4a7b

0 commit comments

Comments
 (0)