Skip to content
This repository was archived by the owner on Jun 30, 2025. It is now read-only.

Commit ae27ade

Browse files
author
zonLi
committed
add tron-vm.md
1 parent f4dab9f commit ae27ade

File tree

6 files changed

+498
-2
lines changed

6 files changed

+498
-2
lines changed

docs/Official_Public_Node.md

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
# Full Node
2+
* GRPC port: 50051
3+
* P2P network port: 18888
4+
* HTTP port : 8090
5+
```
6+
54.236.37.243
7+
52.53.189.99
8+
18.196.99.16
9+
34.253.187.192
10+
52.56.56.149
11+
35.180.51.163
12+
54.252.224.209
13+
18.228.15.36
14+
52.15.93.92
15+
34.220.77.106
16+
13.127.47.162
17+
13.124.62.58
18+
47.74.149.206
19+
47.90.240.187
20+
47.90.215.84
21+
47.254.77.146
22+
47.74.242.55
23+
47.75.249.119
24+
47.90.201.118
25+
47.74.21.68
26+
47.74.13.168
27+
47.74.33.41
28+
47.52.59.134
29+
47.74.229.70
30+
47.254.27.69
31+
47.89.243.195
32+
47.90.201.112
33+
47.88.174.175
34+
47.74.224.123
35+
47.75.249.4
36+
```
37+
38+
# Solidity Node
39+
* GRPC port: 50051
40+
* HTTP port : 8091
41+
```
42+
47.89.187.247
43+
47.91.18.255
44+
47.75.10.71
45+
47.251.52.228
46+
47.251.48.82
47+
47.74.147.80
48+
34.234.164.105
49+
18.221.34.0
50+
35.178.11.0
51+
35.180.18.107
52+
```
Lines changed: 88 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,88 @@
1+
# Deployment of SolidityNode and FullNode on the same host
2+
3+
Create separate directories for fullnode and soliditynode
4+
```
5+
/deploy/fullnode
6+
/deploy/soliditynode
7+
```
8+
9+
Create two folders for fullnode and soliditynode.
10+
11+
Clone our latest master branch of https://github.com/tronprotocol/java-tron and extract it to
12+
```
13+
/deploy/java-tron
14+
```
15+
16+
Make sure you have the proper dependencies.
17+
18+
* JDK 1.8 (JDK 1.9+ is not supported yet)
19+
* On Linux Ubuntu system (e.g. Ubuntu 16.04.4 LTS), ensure that the machine has [__Oracle JDK 8__](https://www.digitalocean.com/community/tutorials/how-to-install-java-with-apt-get-on-ubuntu-16-04), instead of having __Open JDK 8__ in the system. If you are building the source code by using __Open JDK 8__, you will get [__Build Failed__](https://github.com/tronprotocol/java-tron/issues/337) result.
20+
* Open **UDP** ports for connection to the network
21+
* **MINIMUM** 2 CPU Cores
22+
23+
## Deployment guide
24+
25+
1. Build the java-tron project
26+
```
27+
cd /deploy/java-tron
28+
./gradlew build
29+
```
30+
31+
2. Copy the FullNode.jar and SolidityNode.jar along with config files into the respective directories.
32+
```
33+
download your needed config file from https://github.com/tronprotocol/TronDeployment.
34+
main_net_config.conf is the config for mainnet, and test_net_config.conf is the config for testnet.
35+
please rename the config file to `config.conf` and use this config.conf to start fullnode and soliditynode.
36+
37+
cp build/libs/FullNode.jar ../fullnode
38+
cp build/libs/SolidityNode.jar ../soliditynode
39+
```
40+
41+
3. You can now run your Fullnode using the following command:
42+
```
43+
java -jar FullNode.jar -c config.conf // make sure that your config.conf is downloaded from https://github.com/tronprotocol/TronDeployment
44+
```
45+
46+
4. Configure the SolidityNode configuration file. You'll need to edit `config.conf` to connect to your local `FullNode`. Change `trustNode` in `node` to local `127.0.0.1:50051`, which is the default rpc port. Set `listen.port` to any number within the range of 1024-65535. Please don't use any ports between 0-1024 since you'll most likely hit conflicts with other system services. Also change `rpc port` to `50052` or something to avoid conflicts. **Please forward the UDP port 18888 for FullNode.**
47+
```
48+
rpc {
49+
port = 50052
50+
}
51+
```
52+
53+
5. You can now run your SolidityNode using the following command:
54+
```
55+
java -jar SolidityNode.jar -c config.conf //make sure that your config.conf is downloaded from https://github.com/tronprotocol/TronDeployment
56+
```
57+
58+
# Logging and network connection verification
59+
60+
Logs for both nodes are located in `/deploy/\*/logs/tron.log`. Use `tail -f /logs/tron.log/` to follow along with the block syncing.
61+
62+
You should see something similar to this in your logs for block synchronization:
63+
64+
## FullNode
65+
66+
12:00:57.658 INFO [pool-7-thread-1] [o.t.c.n.n.NodeImpl](NodeImpl.java:830) Success handle block Num:236610,ID:0000000000039c427569efa27cc2493c1fff243cc1515aa6665c617c45d2e1bf
67+
68+
## SolidityNode
69+
70+
12:00:40.691 INFO [pool-17-thread-1] [o.t.p.SolidityNode](SolidityNode.java:88) sync solidity block, lastSolidityBlockNum:209671, remoteLastSolidityBlockNum:211823
71+
72+
# Stop node gracefully
73+
Create file stop.sh,use kill -15 to close java-tron.jar(or FullNode.jar、SolidityNode.jar).
74+
You need to modify pid=`ps -ef |grep java-tron.jar |grep -v grep |awk '{print $2}'` to find the correct pid.
75+
```
76+
#!/bin/bash
77+
while true; do
78+
pid=`ps -ef |grep java-tron.jar |grep -v grep |awk '{print $2}'`
79+
if [ -n "$pid" ]; then
80+
kill -15 $pid
81+
echo "The java-tron process is exiting, it may take some time, forcing the exit may cause damage to the database, please wait patiently..."
82+
sleep 1
83+
else
84+
echo "java-tron killed successfully!"
85+
break
86+
fi
87+
done
88+
```

docs/Tron-VM.md

Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
1+
# TRON Virtual Machine (TVM)
2+
3+
TRON Virtual Machine (TVM) is a lightweight, Turing complete virtual machine developed for the TRON's ecosystem. Its goal is to provide millions of global developers with a custom-built blockchain system that is efficient, convenient, stable, secure and scalable.
4+
5+
TVM can connect seamlessly with existing development ecosystem and supports DPOS. TVM is able to be compatible with EVM environment in the beginning, so that instead of learning a new programming language, developers can develop, debug and compile smart contracts in a Remix environment with Solidity and other languages. Once you’ve built and uploaded your smart contract to TRON’s mainnet, it will be executed on the TVM of the SR node to be isolated from external connections.
6+
7+
Furthermore, TVM employs the concept of Bandwidth. Different from the gas mechanism on Ethereum’s EVM, operations of transaction or smart contracts on TVM are free, with no tokens consumed. Technically, executable computation capacity on TVM is not restricted by total holding of tokens.
8+
9+
## Features of TVM
10+
1. Lightweight
11+
12+
TVM adopts a lightweight architecture with the aim of reducing resource consumption to guarantee system performance.
13+
14+
2. Stability and security
15+
16+
With a meticulous design paradigm and fine-grained underlying operation code, TVM can guarantee the preciseness of every step of a computation, diminishing ambiguity to the largest extent. Out of security reasons, transfers and smart contract running cost only bandwidth points, not TRX, which exempts TRON from being attacked similarly to Ethereum for its mode of gas consumption. Stability of bandwidth consumption is achieved while the cost of each computational step is fixed.
17+
18+
3. Compatibility
19+
20+
Currently, TVM is compatible with EVM and will be with more mainstream VMs in the future. Thereby, all smart contracts on EVM are executable on TVM. By connecting seamlessly to existing development ecosystem, higher efficiency can be achieved by developers. Needless to learn a new programming language, they can use mainstream programming languages for smart contract such as Solidity to develop, debug and compile smart contracts in the Remix environment, which greatly reduces development costs.
21+
22+
4. Developer-friendly
23+
24+
Thanks to TVM’s bandwidth setup, developments costs are reduced and developers can focus on the logic of their contract code. TVM also offers all-in-one interfaces for contract deployment, triggering and viewing, for the convenience of developers.
25+
The following interfaces are available in Tron Wallet-CLI:
26+
27+
+ deploycontract(password, contractAddress, ABI, code, data, value)
28+
+ triggercontract(password, contractAddress, selector, data, value)
29+
+ getcontract(contractAddress)
30+
Developers can call these interfaces to deploy, trigger or check smart contracts.
31+
32+
## How TVM works
33+
34+
![Flowchart of Tron Virtual Machine](https://raw.githubusercontent.com/ybhgenius/Documentation/master/images/Virtual_Machine/虚拟机.png)
35+
36+
The above flowchart shows how TVM works:
37+
Compilation of Tron smart contract→execution and computing engines of VM→Interoperation service layer for external interfaces.
38+
39+
Put simply, the flow is as follows:
40+
+ Currently, TVM is compatible mainly with Solidity. The compiler translates Solidity smart contract into bytecode readable and executable on TVM.
41+
+ A virtual machine processes data through opcode, which is equivalent to operating a logic of a stack-based finite state machine.
42+
+ TVM accesses blockchain data and invoke External Data Interface through the Interoperation layer.
43+
44+
## Future development of TVM
45+
1. More developer-friendly debugging tools
46+
47+
Tron will be committed to the development of optimized debugging tools and the establishment of standardized symbol and data format, for improved developer efficiency.
48+
49+
2. Fulfillment of diversified processing demands
50+
51+
Different from gas consumption mechanism for every transaction on EVM, there is no charge on TVM. Each operation only occupies bandwidth, which will be released within a certain amount of time after completion of transaction. It takes developers very little to develop smart contracts with more complex logic. It is our belief that besides being used for digital asset transactions, smart contracts could also be suitably applied to areas such as game development, financial risk modeling and scientific computing. The design of TVM inherently supports multi-scenario tasks, and further optimizations of processing speed, response time, and floating point compatibility.
52+
53+
3. Improvement of Just-In-Time (JIT) compilation speed and integration of WebAssembly
54+
55+
Improving JIT compilation speed is conducive to faster interpretation and optimized compilation of local code. Meanwhile, Tron is planning to further optimize its TVM based on WebAssembly (WASM). WebAssembly, spearheaded by Apple, Google, Microsoft and Mozilla, is designed to break bottlenecks of current Web browsers and can be generated through compiling C/C++ and other programming languages. Integrating WASM, TVM will be able to provide high performance and high throughput for blockchain to cope with complex scenarios.
56+
57+
## The following is a guide to TVM (smart contract deployment)
58+
59+
1. Compile contract
60+
61+
Contract compilation address: [https://remix.ethereum.org](https://remix.ethereum.org)
62+
63+
2. Get ABI and bytecode
64+
```text
65+
pragma solidity^0.4.11;
66+
67+
contract Tron {
68+
uint256 tron;
69+
constructor() public { }
70+
71+
72+
function set(uint256 number) public returns(bool){
73+
tron = number;
74+
return true;
75+
}
76+
}
77+
78+
ABI: [{“constant":false,"inputs":[{"name":"number","type":"uint256"}],"name":"set","outputs":[{"name":"","type":"bool"}],"payable":false,"stateMutability":"nonpayable","type":"function"},{"inputs":[],"payable":false,"stateMutability":"nonpayable","type":"constructor"}]
79+
80+
ByteCode: 608060405234801561001057600080fd5b5060c48061001f6000396000f300608060405260043610603f576000357c0100000000000000000000000000000000000000000000000000000000900463ffffffff16806360fe47b1146044575b600080fd5b348015604f57600080fd5b50606c600480360381019080803590602001909291905050506086565b604051808215151515815260200191505060405180910390f35b600081600081905550600190509190505600a165627a7a723058209791df3f67e9af451c35d7ae55bda5e352764f6a38ea23fa850b1c1fe1bc72e90029
81+
```
82+
3. Deploy contract
83+
84+
Wallet-cli-vm branch: [https://github.com/tronprotocol/wallet-cli/tree/wallet-cli-vm](https://github.com/tronprotocol/wallet-cli/tree/wallet-cli-vm)
85+
Java-tron-vm branch: [https://github.com/tronprotocol/java-tron/tree/develop_vm](https://github.com/tronprotocol/java-tron/tree/develop_vm)
86+
Password: password of client-end wallet
87+
ContractAddress: customized contract address (in Tron’s required format)
88+
ABI: interface description
89+
Data: parameters of the initial function
90+
Value: reserved field
91+
deploycontract(Password, ContractAddress, ABI, Code, Data, Value)
92+
93+
4. Invoke contract
94+
95+
Selector: function selector
96+
Data: parameters
97+
triggercontract(Password, ContractAddress, Selector, Data, Value)
98+
99+
5. Check contract
100+
```text
101+
getcontract(ContractAddress)
102+
```
103+
104+
The above is an introduction of Tron Virtual Machine and a guide to deployment. We welcome everyone to check out TVM and give us your thoughts and suggestions. We will continue to perfect and update TVM for optimal performance on TRON mainnet.

docs/Tron-overview.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -800,7 +800,7 @@ If it contains library, before deploy the contract you need to deploy the librar
800800
The address of the library deployed before is: TSEJ29gnBkxQZR3oDdLdeQtQQykpVLSk54
801801
When you deploy, you need to use browser/oneLibrary.sol.Math3:TSEJ29gnBkxQZR3oDdLdeQtQQykpVLSk54 as the parameter of deploycontract.
802802

803-
# 6 Built-in Contracts and API introduction
803+
# 6 Built-in Contracts and API Introduction
804804
## 6.1 Built-in Contracts
805805
Please refer to:
806806
[https://github.com/tronprotocol/Documentation/blob/master/%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3/%E6%B3%A2%E5%9C%BA%E5%8D%8F%E8%AE%AE/%E4%BA%A4%E6%98%93%E6%93%8D%E4%BD%9C%E7%B1%BB%E5%9E%8B%E8%AF%B4%E6%98%8E.md](https://github.com/tronprotocol/Documentation/blob/master/%E4%B8%AD%E6%96%87%E6%96%87%E6%A1%A3/%E6%B3%A2%E5%9C%BA%E5%8D%8F%E8%AE%AE/%E4%BA%A4%E6%98%93%E6%93%8D%E4%BD%9C%E7%B1%BB%E5%9E%8B%E8%AF%B4%E6%98%8E.md)

0 commit comments

Comments
 (0)