mirror of
https://github.com/ton-blockchain/ton
synced 2025-03-09 15:40:10 +00:00
Add account state by transaction and emulator (extended) (#592)
* account_state_by_transaction * Correct time calculation * Bug fixes * Refactor * namespace block::transaction * smc.forget * RunEmulator: remove wallet_id * Refactor & fixes * AccountStateByTransaction: use shardchain block instead of masterchain block * transaction emulator core * refactor * tx emulator major functionality * small format changes * readme * clean * return json, add support for init messages * tx emulator readme * refactor getConfigParam and getConfigAll * add shardchain_libs_boc parameter * option to change verbosity level of transaction emulator * fix deserializing ShardAccount with account_none * add mode needSpecialSmc when unpack config * emulator: block::Transaction -> block::transaction::Transaction * Refactor * emulator: Fix bug * emulator: Support for emulator-extern * emulator: Refactor * Return vm log and vm exit code. * fix build on macos, emulator_static added * adjust documentation * ignore_chksig for external messages * tvm emulator, run get method * Added more params for transaction emulator * Added setters for optional transaction emulator params, moved libs to a new setter * Added actions cell output to transaction emulator * fix tonlib build * refactoring, rand seed as hex size 64, tvm emulator send message * tvm send message, small refactoring * fix config decoding, rename * improve documentation * macos export symbols * Added run_get_method to transaction emulator emscipten wrapper * Fixed empty action list serialization * Changed actions list cell to serialize as json null instead of empty string in transaction emulator * stack as boc * log gas remaining * Fix prev_block_id * fix build errors * Refactor fetch_config_params * fix failing unwrap of optional rand_seed * lookup correct shard, choose prev_block based on account shard * fix tonlib android jni build --------- Co-authored-by: legaii <jgates.ardux@gmail.com> Co-authored-by: ms <dungeon666master@protonmail.com> Co-authored-by: krigga <krigga7@gmail.com>
This commit is contained in:
parent
adf67aa869
commit
3b3c25b654
32 changed files with 2095 additions and 158 deletions
83
emulator/transaction-emulator.h
Normal file
83
emulator/transaction-emulator.h
Normal file
|
@ -0,0 +1,83 @@
|
|||
#pragma once
|
||||
#include "crypto/common/refcnt.hpp"
|
||||
#include "ton/ton-types.h"
|
||||
#include "crypto/vm/cells.h"
|
||||
#include "block/transaction.h"
|
||||
#include "block/block-auto.h"
|
||||
#include "block/block-parse.h"
|
||||
#include "block/mc-config.h"
|
||||
|
||||
namespace emulator {
|
||||
class TransactionEmulator {
|
||||
block::Config config_;
|
||||
vm::Dictionary libraries_;
|
||||
int vm_log_verbosity_;
|
||||
ton::UnixTime unixtime_;
|
||||
ton::LogicalTime lt_;
|
||||
td::BitArray<256> rand_seed_;
|
||||
bool ignore_chksig_;
|
||||
|
||||
public:
|
||||
TransactionEmulator(block::Config&& config, int vm_log_verbosity = 0) :
|
||||
config_(std::move(config)), libraries_(256), vm_log_verbosity_(vm_log_verbosity),
|
||||
unixtime_(0), lt_(0), rand_seed_(0), ignore_chksig_(false) {
|
||||
}
|
||||
|
||||
struct EmulationResult {
|
||||
std::string vm_log;
|
||||
|
||||
EmulationResult(std::string vm_log_) : vm_log(vm_log_) {}
|
||||
virtual ~EmulationResult() = default;
|
||||
};
|
||||
|
||||
struct EmulationSuccess: EmulationResult {
|
||||
td::Ref<vm::Cell> transaction;
|
||||
block::Account account;
|
||||
td::Ref<vm::Cell> actions;
|
||||
|
||||
EmulationSuccess(td::Ref<vm::Cell> transaction_, block::Account account_, std::string vm_log_, td::Ref<vm::Cell> actions_) :
|
||||
EmulationResult(vm_log_), transaction(transaction_), account(account_) , actions(actions_)
|
||||
{}
|
||||
};
|
||||
|
||||
struct EmulationExternalNotAccepted: EmulationResult {
|
||||
int vm_exit_code;
|
||||
|
||||
EmulationExternalNotAccepted(std::string vm_log_, int vm_exit_code_) :
|
||||
EmulationResult(vm_log_), vm_exit_code(vm_exit_code_)
|
||||
{}
|
||||
};
|
||||
|
||||
struct EmulationChain {
|
||||
std::vector<td::Ref<vm::Cell>> transactions;
|
||||
block::Account account;
|
||||
};
|
||||
|
||||
const block::Config& get_config() {
|
||||
return config_;
|
||||
}
|
||||
|
||||
td::Result<std::unique_ptr<EmulationResult>> emulate_transaction(
|
||||
block::Account&& account, td::Ref<vm::Cell> msg_root, ton::UnixTime utime, ton::LogicalTime lt, int trans_type);
|
||||
|
||||
td::Result<EmulationSuccess> emulate_transaction(block::Account&& account, td::Ref<vm::Cell> original_trans);
|
||||
td::Result<EmulationChain> emulate_transactions_chain(block::Account&& account, std::vector<td::Ref<vm::Cell>>&& original_transactions);
|
||||
|
||||
void set_unixtime(ton::UnixTime unixtime);
|
||||
void set_lt(ton::LogicalTime lt);
|
||||
void set_rand_seed(td::BitArray<256>& rand_seed);
|
||||
void set_ignore_chksig(bool ignore_chksig);
|
||||
void set_config(block::Config &&config);
|
||||
void set_libs(vm::Dictionary &&libs);
|
||||
|
||||
private:
|
||||
bool check_state_update(const block::Account& account, const block::gen::Transaction::Record& trans);
|
||||
|
||||
td::Result<std::unique_ptr<block::transaction::Transaction>> create_transaction(
|
||||
td::Ref<vm::Cell> msg_root, block::Account* acc,
|
||||
ton::UnixTime utime, ton::LogicalTime lt, int trans_type,
|
||||
block::StoragePhaseConfig* storage_phase_cfg,
|
||||
block::ComputePhaseConfig* compute_phase_cfg,
|
||||
block::ActionPhaseConfig* action_phase_cfg);
|
||||
};
|
||||
} // namespace emulator
|
Loading…
Add table
Add a link
Reference in a new issue