Giter VIP home page Giter VIP logo

everx-labs / evernode-se Goto Github PK

View Code? Open in Web Editor NEW
50.0 8.0 27.0 11.1 MB

Local Node for DApp development and testing in TVM blockchains (Everscale, TON, Venom, etc)

Home Page: https://docs.evercloud.dev/products/simple-emulator-se

License: Apache License 2.0

Dockerfile 1.61% Shell 2.04% JavaScript 11.63% Rust 71.89% Batchfile 0.29% Solidity 8.93% HTML 2.44% CSS 0.27% Procfile 0.04% D 0.87%
local blockchain node everscale toncoin solidity testing testing-tools ton venom everscale-blockchain venom-blockchain venom-developer-program

evernode-se's Introduction

Evernode Simple Emulator (SE)

Local Node with GraphQL API for DApp development and testing in TVM compatible blockchains (Everscale, Venom, TON, Gosh, etc.).

Have a question? Get quick help in our channel:

Channel on Telegram

What is Evernode Simple Emulator?

Evernode Simple Emulator (SE) is a local instance of Evernode Platform that developer can run on their machine in one click to test applications locally.

At the moment we publish Evernode SE only as a docker image. But you can access non-docker builds of SE in community repos:

Use-cases

  • Test your applications locally
  • Test your contracts
  • Run SE remotely on a server and test your application on a light local network from different devices.

How to install

Pre-requisites

Attention! Docker daemon must be running.

Install via EVERDEV Development Environment

If you have EVERDEV installed globally on your machine, run this command

$ everdev se start

Checkout other Evernode SE commands accessible from EVERDEV.

Install via docker command

Run this command

$ docker run -d --name local-node -e USER_AGREEMENT=yes -p80:80 tonlabs/local-node

To check that SE has been installed successfully check its local playground at http://0.0.0.0/graphql. For Windows, use http://127.0.0.1/graphql or http://localhost/graphql.

If you specified another port then add it to the local url http://0.0.0.0:port/graphql

Find out more about GraphQL API.

How to change the blockchain configuration

Evernode SE loads the blockchain configuration (config params) during its start from the configuration file blockchain.conf.json instead of special smart contract, which stores various config params in the real networks.

In order to change some of these params, do the following:

  1. Get blockchain.conf.json file and store it to the host's filesystem accessible by docker. In our example we store it at /home/user/blockchain.conf.json.
  2. Edit the downloaded file, changing parameters you need. If one of the parameters is omitted or renamed, Evernode SE will not start.
  3. Create a new docker container, overriding its configuration file (its path in the image is /ton-node/blockchain.conf.json) with the file from the host's filesystem. Change /home/user/blockchain.conf.json to correct path pointing to the edited blockchain configuration file:
$ docker run -d --name local-node -e USER_AGREEMENT=yes -p80:80 \
     -v /home/user/blockchain.conf.json:/ton-node/blockchain.conf.json \
     tonlabs/local-node
  1. All the subsequent config changes will require only restart of the created container.

How to work with logs

By default, Evernode SE logs the most of the information to the console, which is accessible by the next command:

$ docker logs local-node

More verbose logging is configured to /ton-node/log/ directory inside the running docker container. By default, there are two files: ton-node.log for all logging and tvm.log for tracing of TVM execution: code, stack, control registers, gas, etc.

Logging configuration is stored in /ton-node/log_cfg.yml file by default, but you can change this path with ton-node-config file in log_path field. In order to change the default logging verbosity of other parameters, you can configure logging in several ways:

  1. In the running container by changing /ton-node/log_cfg.yml file:
$ docker exec -it local-node bash
bash-5.0# vi /ton-node/log_cfg.yml

(in order to exit from VI editor with saving changes press the ESC key, then type :wq and press the ENTER key)

Note: log_cfg.yml file is normally scanned for changes every 30 seconds, so all changes made to this file in running container will be applied only after the scan.

Note: after recreation of the container, all changes made in its files will be lost, so use the second way, if you need to keep them.

  1. Before starting of the container, download and edit a copy of log_cfg.yml file, then mount this file to container's file system in docker run command:
$ docker run -d --name local-node -e USER_AGREEMENT=yes -p80:80 \
     -v /home/user/log_cfg.yml:/ton-node/log_cfg.yml \
     tonlabs/local-node

After starting of Evernode SE, you can edit this file in your file system without restart.

More information about log4rs configuration in the log4rs documentation.

How to connect to Evernode SE Graphql API from SDK

Attention at the moment there are a few differences in SE behaviour comparing with a real TON blockchain . Read about them before you start implemennting. Please note that we plan to upgrade the SE behaviour in the next releases so that it will work the same way as a real network.

To connect to local blockchain from your application specify SE endpoints in SDK Client network config. .

Evernode SE components

Ever Live explorer

Ever Live explorer runs on the same IP and port as Evernode SE, just open http://ip_address:port (e.g. http://127.0.0.1)

How to build docker image locally

In order to build and use Evernode Simple Emulator you need Docker. To build docker image, run from the repository root:

Linux/Mac:

./build.sh

Windows:

build.cmd

Memory limits

Evernode SE needs about 1Gb of memory but it is not limited to this value. There is an instance of ArangoDB inside and GraphQL server running in NodeJS environment which can require more memory during the high load over a long period of time. If there is a need to hardly limit memory consumption then you can change default setting for these services. ArangoDB config is placed at /arango/config and GraphQL server entrypoint is at /q-server/entrypoint. There is some minimum required memory limits are preconfigured in ./memory/config for ArangoDB and ./memory/entrypoint. You can copy them to evernode-se container with the following commands

docker cp ./memory/config evernode-se:/arango/config
docker cp ./memory/entrypoint evernode-se:/q-server/entrypoint

Memory configuration values for ArangoDB can be found in official documentation

Note Node engine also consumes memory and can not be limited. So during the work memory consumption will be slightly increasing.

Warning Memory limitation affects Evernode SE performance so use it only if necessary

SE live control (REST API)

Evernode SE has special REST endpoint /se that allows to perform live control over running Evernode SE instance.

While the Evernode SE is running it has several properties that effect node behaviour:

  • gen_time_delta – each time the node issues new block it sets the block's gen_utime to now() + gen_time_delta. When the node starts it sets the gen_time_delta to 0.
  • seq_mode – if this mode is on then evernode SE produces separate block for each transaction and each block has unique gen_utime, equals to the gen_utime of the previous block + 1.

SE control commands (must be sent using POST HTTP method):

  • /se/increase-time?delta=<seconds> – increase gen_time_delta by specified value.

  • /se/reset-time – resets gen_time_delta to 0.

  • /se/time-delta – returns current gen_time_delta value.

  • /se/seq-mode-on – turns on the sequential mode.

  • /se/seq-mode-off – turns off the sequential mode.

  • /se/time – returns current node time with included time delta. If seq mode is on then returned time is a time of the next block.

Note for SE Developers

This repository contains several useful tools for SE development and debugging. Dev tools resided in dev folder and requires Node.js to execute (so you have to run npm i inside this folder to prepare dev tools).

If you want to debug SE without docker you have to run evernode-se with following additional components:

  • Q Server (required to communicate with ever-sdk):

    • Checkout ever-q-server from official repository.
    • Inside ever-q-server folder run:
      npm i
      
    • Inside evernode-se folder run:
      node path-to-q-server/index --config ./dev/q-server.json
      
  • Arango DB (required to ever-q-server):

    • Download and install from official site.
    • Start Arango DB Server.
    • For the first time or if you want to reset database to initial state run:
      node ./dev/reset-db
      
  • Evernode SE in debug mode

    cargo run --release --bin evernode_se -- --workdir ./docker/ton-node --config ton-node.conf.json --blockchain-config blockchain.conf.json
    

Troubleshooting

Error: connect ENOENT /var/run/docker.sock

Getting this error means docker service is not running or missing due to incorrect Docker installation, partiularly in the case of Docker Desktop. Try reinstalling Docker and making sure the daemon is running.

Ever.live at localhost isn't available

If you use certain adblockers, after you have started Evernode SE the Ever Live explorer at http://127.0.0.1/landing might fail to load (you get a rotating icon and varous warnings and errors in the console).

Try disabling the adblockers for the SE Ever Live explorer.

evernode-se's People

Contributors

a-zorina avatar alex-novikov-1990 avatar alexeyvavilin avatar atomxy avatar bvscd avatar d3p avatar elasticlove1 avatar fairyfromalfeya avatar igorkoval avatar ilyar avatar joydark avatar melsomino avatar sumrachek avatar tonjen avatar yaroslavser avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

evernode-se's Issues

Time synchronization issue after some time of continuous load

I've been running a test which works with localnode. It generates lots of messages while pushing to GOSH, deployed on the localnode. At first it works well, but after a couple of hours localnode seems to lose time synchronization:

2023-06-08T19:58:58.048555Z TRACE ThreadId(03) git-remote-helper:run:push:push_ref:push_commit_object:push_new_blob:push:tokio::spawn::push_diff:push_diff:inner_push_diff:deploy_diff:send_message:blockchain_client::send_message: callback: 
SendFailed: {
    shard_block_id: "0470a4d6fcc37b88a30f7386cc246efc71edaf303cd45e93b6981bae96f16269",
    message_id: "7cd39d44257ae092d9d675dc4cd2a4e0a82c08cd32c712fb08734e116abef773"
    error: "Send message failed: The time on the device is out of sync with the time on the server. Synchronize your device time with internet time"
}
ClientError {
    code: 606,
    message: "The time on the device is out of sync with the time on the server. Synchronize your device time with internet time",
    data: Object {
        "delta_ms": Number(227369),
        "threshold_ms": Number(15000),
        "config_servers": Array [
            String("localhost/"),
        ],
        "endpoint": String("http://localhost/graphql"),
    },

Unable to start se

I tried to start SE with the command tondev se start but it didn't work: tondev se info shows that the default instance has state "exited".
Also I tried docker run -e USER_AGREEMENT=yes -p80:80 tonlabs/local-node and the container exited with the following output:

16:08:57 system | node_workers.1 started (pid=14)
16:08:57 node_workers.1 | + set -e
16:08:57 node_workers.1 | + cd /ton-node
16:08:57 node_workers.1 | + exec /node/ton-node --config ./ton-node.conf.json --blockchain-config ./blockchain.conf.json
16:08:57 system | arango.1 started (pid=12)
16:08:57 arango.1 | + set -e
16:08:57 arango.1 | + ARANGO_INIT_PORT=8529
16:08:57 arango.1 | + ARANGO_ENDPOINT=tcp://127.0.0.1:8529
16:08:57 arango.1 | + ARANGO_INIT_PIDFILE=/run/arango-init.pid
16:08:57 arango.1 | + export GLIBCXX_FORCE_NEW=1
16:08:57 arango.1 | + GLIBCXX_FORCE_NEW=1
16:08:57 arango.1 | + NUMACTL=
16:08:57 arango.1 | + '[' -d /sys/devices/system/node/node1 -a -f /proc/self/numa_maps ']'
16:08:57 arango.1 | + arangod --config /arango/config --server.endpoint tcp://127.0.0.1:8529 --server.authentication=false --log.foreground-tty true --database.auto-upgrade true
16:08:57 system | nginx.1 started (pid=13)
16:08:57 system | q_server.1 started (pid=11)
16:08:57 q_server.1 | + set -e
16:08:57 q_server.1 | + export 'Q_DATA_MUT=http://127.0.0.1:8529'
16:08:57 q_server.1 | + export 'Q_DATA_HOT=http://127.0.0.1:8529'
16:08:57 q_server.1 | + export 'Q_SLOW_QUERIES_MUT=http://127.0.0.1:8529'
16:08:57 q_server.1 | + export 'Q_SLOW_QUERIES_HOT=http://127.0.0.1:8529'
16:08:57 q_server.1 | + export 'Q_REQUESTS_MODE=rest'
16:08:57 q_server.1 | + export 'Q_REQUESTS_SERVER=http://127.0.0.1'
16:08:57 q_server.1 | + export 'Q_HOST=127.0.0.1'
16:08:57 q_server.1 | + export 'Q_PORT=4000'
16:08:57 q_server.1 | + cd /home/node/ton-q-server
16:08:57 q_server.1 | + exec node index.js
16:08:57 arango.1 | /arango/entrypoint: line 34: 20 Illegal instruction (core dumped) $NUMACTL arangod --config /arango/config --server.endpoint $ARANGO_ENDPOINT --server.authentication=false --log.foreground-tty true --database.auto-upgrade true
16:08:57 arango.1 | + exit 1
16:08:57 system | arango.1 stopped (rc=1)
16:08:57 system | sending SIGTERM to q_server.1 (pid 11)
16:08:57 system | sending SIGTERM to nginx.1 (pid 13)
16:08:57 system | sending SIGTERM to node_workers.1 (pid 14)
16:08:57 system | node_workers.1 stopped (rc=-15)
16:08:57 system | q_server.1 stopped (rc=-15)
16:08:57 system | nginx.1 stopped (rc=0)

How are the config files generated?

How are the initial config files of a SE node generated? By what? What's the algorightm? How do I generate or re-generate them on my own?

[Windows] Subscribe for transactions with addresses (ABIv1) test failed

Steps to reproduce:

Result:

PS>$env:USE_NODE_SE="true";$env:TON_NETWORK_ADDRESS="http://localhost:8080";node run
1.11.0
✓ Test versions compatibility (1 / 0)
✓ crypto (2 / 0)
✓ encode_message (3 / 0)
✓ net (4 / 0)
✓ Block signatures (5 / 0)
✓ All Accounts (6 / 0)
✓ Ranges (7 / 0)
✓ Wait For (8 / 0)
𐄂 Subscribe for transactions with addresses (ABIv1) (8 / 1) - [
    {
        "matcherResult": {
            "pass": false
        },
        "message": "\u001b[2mexpect(\u001b[22m\u001b[31mreceived\u001b[39m\u001b[2m).\u001b[22mtoBeGreaterThan\u001b[2m(\u001b[22m\u001b[32mexpected\u001b[39m\u001b[2m)\u001b[22m\n\nExpected: > \u001b[32m0\u001b[39m\nReceived:   \u001b[31m0\u001b[39m"
    }
]
✓ Subscribe for transactions with addresses (ABIv2) (9 / 1)
✓ Subscribe for messages (ABI v1) (10 / 1)
✓ Subscribe for messages (ABI v2) (11 / 1)
✓ Transactions with addresses (12 / 1)
✓ Check shard_hashes greater then 0 (13 / 1)
---
success: 13
failure: 1

PS: I've open PR with a workaround for tests everx-labs/ever-sdk-js#206

Unobvious operation of these states when updating a smart contract.

There are two of the easiest smart contracts firstContract and secondContract.
Deploy 'firstContract' smart contract and calling external method contract "setValue", set value a,b=12.
Data state contract: m_value = 24, version = 1. Calling 'updateContractCode' and set code from 'secondContract'. After update smart contract check values version=2 but m_value=0.
Waiting that m_value=24,, because tvm.resetStorage don't calling.
This is inappropriate behavior on upgraded data states to default value.

firstContract code:
`pragma ton-solidity >= 0.57.0;

pragma AbiHeader time;
pragma AbiHeader expire;
pragma AbiHeader pubkey;

contract firstContract {

uint32 nonce_;
uint public m_version = 1;
uint public m_value;

address owner;

constructor(address owner_ ) public {
	tvm.accept();
	owner = owner_;
}

modifier checkOwnerAndAccept {
	require(msg.sender == owner, 120);
	tvm.accept();
	_;
}

function setValue(uint a, uint b) external {
	tvm.rawReserve(1 ton, 0);
	m_value = a + b; 
}

function getOwner() external view responsible returns (address) {
	return {value: 0, flag: 64, bounce: false} owner;

}

function updateContractCode(TvmCell newcode) public view checkOwnerAndAccept {
	tvm.setcode(newcode);
	tvm.setCurrentCode(newcode);
	
	TvmCell stateVars = abi.encode(m_version);
    onCodeUpgrade(stateVars);
}

function onCodeUpgrade(TvmCell stateVars) private pure {}

}`

secondContract code:
`pragma ton-solidity >= 0.57.0;

pragma AbiHeader time;
pragma AbiHeader expire;
pragma AbiHeader pubkey;

contract secondContract {

uint32 nonce_;
uint public m_version; 
uint public m_value;

address owner;

modifier checkOwnerAndAccept {
	require(msg.sender == owner, 110);
	tvm.accept();
	_;
}

function setValue(uint a, uint b) external {
	tvm.rawReserve(1 ton, 0);
	m_value = a + b; 
}

function getOwner() external view responsible returns (address) {
	return {value: 0, flag: 64, bounce: false} owner;

}

function updateContractCode(TvmCell newcode) public checkOwnerAndAccept {
	tvm.setcode(newcode);
	tvm.setCurrentCode(newcode);
	TvmCell stateVars = abi.encode(m_version);

	onCodeUpgrade(stateVars);
}

function onCodeUpgrade(TvmCell stateVars) private {
	(uint version) = abi.decode(stateVars, (uint));
	m_version = version + 1;
}

}`

Why honcho in particular?

  1. Why is honcho in particular used here?

  2. What's the neccessity? Why not run all of them without honcho, as ordinary processes? Is it specific to the fact that it's all done in Docker?

Memory leak in node

Description:

The node has a memory leak. Memory fills even in an idle state. After that, it crashes and restarts

Screenshot 2022-11-29 at 19 20 32

The results of calling `selfdestruct` function in EvernodeSE and Devnet differ.

Problem

We need to destruct the contact and transfer its tokens to some destination account.

Version

tonlabs/local-node:0.35.0

Expected behaviour

  • Desctructed contract has zero balance and "non exists" type.
  • Account destination has positive balance

Resulting behaviour

  • in Devnet
    • as expected
  • in Evernode SE
    • Desctructed contract is not destructed, its balance unchanged, but transfer to destination account exists!
    • Account destination has positive balance!

How to reproduce a bug

To reproduce this bug clone https://github.com/Artem-Zhdanov/evernode-se-selfdestruct-bug

everdev se start

Intall dependencies and run

npm i
node selfdestruct.js

Open http://localhost and finds accounts in the output

Build failed. aes-ctr crate is DEPRECATED

root@13485a15bdb7:/tonos-se/ton-node-se# cargo build --release
Updating crates.io index
Updating git repository https://github.com/tonlabs/ton-labs-block.git
Updating git repository https://github.com/tonlabs/ton-labs-block-json.git
Updating git repository https://github.com/tonlabs/ton-labs-executor.git
Updating git repository https://github.com/tonlabs/ton-labs-types.git
Updating git repository https://github.com/tonlabs/ton-labs-vm.git
Updating git repository https://github.com/tonlabs/ton-labs-tl.git
Updating git repository https://github.com/tonlabs/ton-labs-assembler.git
Updating git repository https://github.com/paritytech/rust-secp256k1
Updating git repository https://github.com/tonlabs/TON-SDK.git
Updating git repository https://github.com/tonlabs/lockfree.git
error: failed to select a version for the requirement stream-cipher = "^0.3"
candidate versions found which didn't match: 0.99.99, 0.7.1, 0.6.0, ...
location searched: crates.io index
required by package aes-ctr v0.3.0
... which is depended on by adnl v0.0.4 (/tonos-se/ton-node-se/adnl)
... which is depended on by ton_node_startup v0.28.4 (/tonos-se/ton-node-se/ton_node_startup)

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.