Giter VIP home page Giter VIP logo

ever-executor's Introduction

ever-executor

Transaction executor for Everscale/Venom nodes

Table of Contents

About

Implementation of transaction executor for Everscale/Venom nodes in safe Rust.

Getting Started

Prerequisites

Rust complier v1.65+.

Installing

git clone --recurse-submodules https://github.com/tonlabs/ever-executor.git
cd ever-executor
cargo build --release

Usage

This project output is the library which is used as a part of Everscale/Venom node. Also it can be used in standalone tools.

Contributing

Contribution to the project is expected to be done via pull requests submission.

License

See the LICENSE file for details.

Tags

blockchain everscale rust venom-blockchain venom-developer-program venom-tvm

ever-executor's People

Contributors

atomxy avatar bvscd avatar joydark avatar lenykholodov avatar mskvortsov avatar sumrachek avatar tonjen avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

ever-executor's Issues

Compute phase: gas fees deduction logic

Hi!

In the compute_phase function, you try to deduct the gas_fee, and in case of an error (not sufficient balance), you just show the debug message, but it doesn't lead (well, not obvious, at least) to any kind of phase error.
Could you please point to the logic that recovers this situation?

if !acc_balance.grams.sub(&vm_phase.gas_fees)? {
   log::debug!(target: "executor", "can't sub funds: {} from acc_balance: {}", vm_phase.gas_fees, acc_balance.grams);
}

You also do the fee deduction from the msg_balance, but it may silently fail by the same reason, because .sub always
returns Ok(bool).
https://github.com/tonlabs/ton-labs-executor/blob/be2f1ec60e09857d8b8f489c1e79f000bba32269/src/ordinary_transaction.rs#L185

Bounce message creation logic is inconsistent with the whitepaper

Hi!

In the whitepaper (https://ton.org/tblkch.pdf), the following text appears:

4.2.5
...
Action phase - If the smart contract has terminated successfully (with exit code 0 or 1), the actions from the list are performed. If it is impossible to perform all of them—for example, because of insufficient funds to transfer with an outbound message—then the transaction is aborted and the account state is rolled back. The transaction is also aborted if the smart contract did not terminate successfully, or if it was not possible to invoke the smart contract at all because it is uninitialized or frozen.

Bounce phase — If the transaction has been aborted, and the inbound message has its bounce flag set, then it is “bounced” by automatically generating an outbound message (with the bounce flag clear) to its
original sender. Almost all value of the original inbound message (minus gas payments and forwarding fees) is transferred to the generated message, which otherwise has an empty body

It turns out, the bounce message has to be generated if any kind of error occurs, both on compute or on action phase. However,
in the executor, the logic is different. It creates the bounce message in case of the compute phase failure, but the action phase errors are mostly ignored. I came to this conclusion by looking at the line:
https://github.com/tonlabs/ton-labs-executor/blob/4cfc1dcd0b923ca8cdff88024f9bb2a2c3cdaa19/src/ordinary_transaction.rs#L224

Could you please clarify the following:
1) Is it the intentional deviation from the whitepaper specification?
2) If it is intentional, why it is done this way?
3) Am I correct that after unsuccessful action phase, th current implementation (commit 4cfc) does not revert the contract state to its original content? If not, could you please point out where it gets restored?

Action phase: processing messages with SENDMSG_ALL_BALANCE flag

Hi!

The processing logic of messages with SENDMSG_ALL_BALANCE seems incorrect to me. Could you please prove me wrong. Take in mind that Rust is not my native language, so I may miss something important.

During the processing of actions, starting at :
https://github.com/tonlabs/ton-labs-executor/blob/be2f1ec60e09857d8b8f489c1e79f000bba32269/src/transaction_executor.rs#L488

you put all messages with the flag into out_msgs0 collection, skipping their processing with 'continue' statment.

if (mode & SENDMSG_ALL_BALANCE) != 0 {
        out_msgs0.push((mode, out_msg));
        continue
}

After this initial iteration over the action list, you start to process out_msgs0 collection. But, this time, you also
skip messages with this flag set, using the same continue statement. You put them into out_msgs collection without processing.

 for (i, (mode, mut out_msg)) in out_msgs0.into_iter().enumerate() {
            if (mode & SENDMSG_ALL_BALANCE) == 0 {
                out_msgs.push(out_msg);
                continue
  }

This is strange, because the outmsg_action_handler contains the logic for processing messages with this flag set.
https://github.com/tonlabs/ton-labs-executor/blob/be2f1ec60e09857d8b8f489c1e79f000bba32269/src/transaction_executor.rs#L837

Am I missing something?

The repo does not seem to build

The error I'm getting when trying to build this is

error[E0432]: unresolved imports `ton_block::GasFlatPfx`, `ton_block::GasPrices`, `ton_block::GasPricesEx`
  --> .../ton-labs-executor-1c02eaf6bb19aa83/1f7e80b/src/blockchain_config.rs:17:5

See 20200710v2_build_sh.log for more details.

It is not clear to me how is it supposed to work. Let's look e.g. at ton_block::GasFlatPfx.

Frozen accounts recovery logic is missing?

Hi!

My question belongs to the logic of the function:
https://github.com/tonlabs/ton-labs-executor/blob/be2f1ec60e09857d8b8f489c1e79f000bba32269/src/ordinary_transaction.rs#L62

Consider the following case:

  1. We have an active account with some balance that is not enough to cover fwd_fee + storage_fee.
  2. The incoming message is internal and has bounce flag unset and has some value attached to it.

After processing the storage phase, the account will become frozen due to condition (1):
https://github.com/tonlabs/ton-labs-executor/blob/be2f1ec60e09857d8b8f489c1e79f000bba32269/src/transaction_executor.rs#L235

Next, we go to the credit phase. It increases the balance of the account by the message value, but the account is still in
frozen state, you do not switch it back to Active, despite the fact that its balance is now non-negative and could cover the due expenses.

What is worse, you now go to compute phase and spend gas despite the fact that the account is frozen and has no state
that could be changed further (only state_init hash).

You the finalize the account state in:
https://github.com/tonlabs/ton-labs-executor/blob/be2f1ec60e09857d8b8f489c1e79f000bba32269/src/ordinary_transaction.rs#L237

Am I missing something? Is it by design?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.