mirror of
https://github.com/ton-blockchain/ton
synced 2025-02-12 11:12:16 +00:00
Add more recent blocks to "previous blocks info"
This commit is contained in:
parent
f03f6ce7ca
commit
a01c7e2e75
3 changed files with 34 additions and 8 deletions
|
@ -2292,7 +2292,8 @@ Ref<vm::Cell> ConfigInfo::lookup_library(td::ConstBitPtr root_hash) const {
|
|||
td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
|
||||
// [ wc:Integer shard:Integer seqno:Integer root_hash:Integer file_hash:Integer] = BlockId;
|
||||
// [ last_mc_blocks:[BlockId...]
|
||||
// prev_key_block:BlockId ] : PrevBlocksInfo
|
||||
// prev_key_block:BlockId
|
||||
// last_mc_blocks_100[BlockId...] ] : PrevBlocksInfo
|
||||
auto block_id_to_tuple = [](const ton::BlockIdExt& block_id) -> vm::Ref<vm::Tuple> {
|
||||
td::RefInt256 shard = td::make_refint(block_id.id.shard);
|
||||
if (shard->sgn() < 0) {
|
||||
|
@ -2302,25 +2303,44 @@ td::Result<Ref<vm::Tuple>> ConfigInfo::get_prev_blocks_info() const {
|
|||
td::make_refint(block_id.id.seqno), td::bits_to_refint(block_id.root_hash.bits(), 256),
|
||||
td::bits_to_refint(block_id.file_hash.bits(), 256));
|
||||
};
|
||||
std::vector<vm::StackEntry> last_mc_blocks;
|
||||
std::vector<vm::StackEntry> tuple;
|
||||
|
||||
std::vector<vm::StackEntry> last_mc_blocks;
|
||||
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
||||
for (ton::BlockSeqno seqno = block_id.id.seqno; seqno > 0 && last_mc_blocks.size() < 16;) {
|
||||
--seqno;
|
||||
ton::BlockIdExt block_id;
|
||||
if (!get_old_mc_block_id(seqno, block_id)) {
|
||||
ton::BlockIdExt id;
|
||||
if (!get_old_mc_block_id(seqno, id)) {
|
||||
return td::Status::Error("cannot fetch old mc block");
|
||||
}
|
||||
last_mc_blocks.push_back(block_id_to_tuple(block_id));
|
||||
last_mc_blocks.push_back(block_id_to_tuple(id));
|
||||
}
|
||||
tuple.push_back(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)));
|
||||
|
||||
ton::BlockIdExt last_key_block;
|
||||
ton::LogicalTime last_key_block_lt;
|
||||
if (!get_last_key_block(last_key_block, last_key_block_lt)) {
|
||||
return td::Status::Error("cannot fetch last key block");
|
||||
}
|
||||
return vm::make_tuple_ref(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks)),
|
||||
block_id_to_tuple(last_key_block));
|
||||
tuple.push_back(block_id_to_tuple(last_key_block));
|
||||
|
||||
if (get_global_version() >= 9) {
|
||||
std::vector<vm::StackEntry> last_mc_blocks_100;
|
||||
for (ton::BlockSeqno seqno = block_id.id.seqno / 100 * 100; last_mc_blocks_100.size() < 16;) {
|
||||
ton::BlockIdExt id;
|
||||
if (!get_old_mc_block_id(seqno, id)) {
|
||||
return td::Status::Error("cannot fetch old mc block");
|
||||
}
|
||||
last_mc_blocks_100.push_back(block_id_to_tuple(id));
|
||||
if (seqno < 100) {
|
||||
break;
|
||||
}
|
||||
seqno -= 100;
|
||||
}
|
||||
tuple.push_back(td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(last_mc_blocks_100)));
|
||||
}
|
||||
|
||||
return td::make_cnt_ref<std::vector<vm::StackEntry>>(std::move(tuple));
|
||||
}
|
||||
|
||||
td::optional<PrecompiledContractsConfig::Contract> PrecompiledContractsConfig::get_contract(
|
||||
|
|
|
@ -1336,7 +1336,8 @@ Ref<vm::Tuple> Transaction::prepare_vm_c7(const ComputePhaseConfig& cfg) const {
|
|||
// See crypto/block/mc-config.cpp#2223 (get_prev_blocks_info)
|
||||
// [ wc:Integer shard:Integer seqno:Integer root_hash:Integer file_hash:Integer] = BlockId;
|
||||
// [ last_mc_blocks:[BlockId...]
|
||||
// prev_key_block:BlockId ] : PrevBlocksInfo
|
||||
// prev_key_block:BlockId
|
||||
// last_mc_blocks_100:[BlockId...] ] : PrevBlocksInfo
|
||||
// The only context where PrevBlocksInfo (13 parameter of c7) is null is inside emulator
|
||||
// where it need to be set via transaction_emulator_set_prev_blocks_info (see emulator/emulator-extern.cpp)
|
||||
// Inside validator, collator and liteserver checking external message contexts
|
||||
|
|
|
@ -114,11 +114,16 @@ Operations for working with Merkle proofs, where cells can have non-zero level a
|
|||
|
||||
## Version 9
|
||||
|
||||
### c7 tuple
|
||||
c7 tuple parameter number **13** (previous blocks info tuple) now has the third element. It contains ids of the 16 last masterchain blocks with seqno divisible by 100.
|
||||
Example: if the last masterchain block seqno is `19071` then the list contains block ids with seqnos `19000`, `18900`, ..., `17500`.
|
||||
|
||||
### New TVM instructions
|
||||
- `SECP256K1_XONLY_PUBKEY_TWEAK_ADD` (`key tweak - 0 or f x y -1`) - performs [`secp256k1_xonly_pubkey_tweak_add`](https://github.com/bitcoin-core/secp256k1/blob/master/include/secp256k1_extrakeys.h#L120).
|
||||
`key` and `tweak` are 256-bit unsigned integers. 65-byte public key is returned as `uint8 f`, `uint256 x, y` (as in `ECRECOVER`). Gas cost: `1276`.
|
||||
- `mask SETCONTCTRMANY` (`cont - cont'`) - takes continuation, performs the equivalent of `c[i] PUSHCTR SWAP c[i] SETCONTCNR` for each `i` that is set in `mask` (mask is in `0..255`).
|
||||
- `SETCONTCTRMANYX` (`cont mask - cont'`) - same as `SETCONTCTRMANY`, but takes `mask` from stack.
|
||||
- `PREVMCBLOCKS_100` returns the third element of the previous block info tuple (see above).
|
||||
|
||||
### Other changes
|
||||
- Fix `RAWRESERVE` action with flag `4` (use original balance of the account) by explicitly setting `original_balance` to `balance - msg_balance_remaining`.
|
||||
|
|
Loading…
Reference in a new issue