Skip to content

Commit c93f6c0

Browse files
authored
Merge pull request #1350 from tronprotocol/develop
update vm impl
2 parents 1984b2b + 10005ac commit c93f6c0

File tree

275 files changed

+19061
-5855
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

275 files changed

+19061
-5855
lines changed

.gitignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,4 +51,7 @@ src/main/resources/META-INF/
5151
/output_witness/
5252
output*
5353
nodeId.properties
54-
Wallet
54+
Wallet
55+
56+
# vm_trace
57+
/vm_trace/

.travis.yml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,3 +25,5 @@ deploy:
2525
branch: develop
2626

2727

28+
29+

README.md

Lines changed: 57 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<h1 align="center">
22
<br>
3-
<img width=20% src="https://raw.githubusercontent.com/tronprotocol/wiki/master/images/java-tron.png">
3+
<img width=20% src="https://github.com/tronprotocol/wiki/blob/master/images/java-tron.jpg?raw=true">
44
<br>
55
java-tron
66
<br>
@@ -62,6 +62,12 @@ TRON Protocol and the Tron Virtual Machine (TVM) allow anyone to develop decentr
6262

6363
* JDK 1.8 (JDK 1.9+ are not supported yet)
6464
* 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.
65+
* Open **UDP** ports for connection to the network
66+
* **MINIMUM** 2 ENERGY Cores
67+
68+
## Build and Deploy automatically using scripts
69+
70+
- Please take a look at the [Tron Deployment Scripts](https://github.com/tronprotocol/TronDeployment) repository.
6571

6672
## Getting the code with git
6773

@@ -126,7 +132,7 @@ cd java-tron
126132

127133
* Build in [IntelliJ IDEA](https://www.jetbrains.com/idea/) (community version is enough):
128134

129-
** Please run ./gradlew build once to build the protocol files **
135+
**Please run ./gradlew build once to build the protocol files**
130136

131137
1. Start IntelliJ. Select `File` -> `Open`, then locate to the java-tron folder which you have git cloned to your local drive. Then click `Open` button on the right bottom.
132138
2. Check on `Use auto-import` on the `Import Project from Gradle` dialog. Select JDK 1.8 in the `Gradle JVM` option. Then click `OK`.
@@ -142,10 +148,54 @@ https://github.com/tronprotocol/Documentation/blob/master/TRX/Solidity_and_Full_
142148

143149
## Running a local node and connecting to the public testnet
144150

145-
* Ensure that the version number is consistent with the version number of the test network. If it is not consistent, please modify the node.p2p.version in the config.conf file and delete the out-directory directory (if it exists).
146-
* The current p2p.version is **619**
151+
* Use the [Testnet Config](https://github.com/tronprotocol/TronDeployment/blob/master/test_net_config.conf) or use the [Tron Deployment Scripts](https://github.com/tronprotocol/TronDeployment)
152+
153+
154+
### Running a Super Representative Node for mainnet
155+
156+
* Use the executable JAR(Recommended way)
157+
158+
```bash
159+
java -jar FullNode.jar -p your private key --witness -c your config.conf(Example:/data/java-tron/config.conf)
160+
Example:
161+
java -jar FullNode.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf
162+
163+
```
164+
165+
This is similar to running a private testnet, except that the IPs in the `config.conf` are officially declared by TRON.
166+
167+
<details>
168+
<summary>Correct output</summary>
169+
170+
```bash
171+
172+
20:43:18.138 INFO [main] [o.t.p.FullNode](FullNode.java:21) Full node running.
173+
20:43:18.486 INFO [main] [o.t.c.c.a.Args](Args.java:429) Bind address wasn't set, Punching to identify it...
174+
20:43:18.493 INFO [main] [o.t.c.c.a.Args](Args.java:433) UDP local bound to: 10.0.8.146
175+
20:43:18.495 INFO [main] [o.t.c.c.a.Args](Args.java:448) External IP wasn't set, using checkip.amazonaws.com to identify it...
176+
20:43:19.450 INFO [main] [o.t.c.c.a.Args](Args.java:461) External address identified: 47.74.147.87
177+
20:43:19.599 INFO [main] [o.s.c.a.AnnotationConfigApplicationContext](AbstractApplicationContext.java:573) Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@124c278f: startup date [Fri Apr 27 20:43:19 CST 2018]; root of context hierarchy
178+
20:43:19.972 INFO [main] [o.s.b.f.a.AutowiredAnnotationBeanPostProcessor](AutowiredAnnotationBeanPostProcessor.java:153) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
179+
20:43:20.380 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:244) update latest block header timestamp = 0
180+
20:43:20.383 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:252) update latest block header number = 0
181+
20:43:20.393 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:260) update latest block header id = 00
182+
20:43:20.394 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:265) update state flag = 0
183+
20:43:20.559 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
184+
20:43:20.567 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
185+
20:43:20.568 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
186+
20:43:20.568 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
187+
20:43:20.569 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
188+
20:43:20.596 INFO [main] [o.t.c.d.Manager](Manager.java:300) create genesis block
189+
20:43:20.607 INFO [main] [o.t.c.d.Manager](Manager.java:306) save block: BlockCapsule
190+
191+
```
192+
193+
Then observe whether block synchronization success,If synchronization successfully explains the success of the super node
194+
195+
</details>
196+
147197

148-
### How to run a Super Node
198+
### Running a Super Representative Node for private testnet
149199
* use master branch
150200
* You should modify the config.conf
151201
1. Replace existing entry in genesis.block.witnesses with your address.
@@ -157,17 +207,11 @@ https://github.com/tronprotocol/Documentation/blob/master/TRX/Solidity_and_Full_
157207

158208
```bash
159209
cd build/libs
160-
java -jar java-tron.jar -p yourself private key --witness -c yourself config.conf(Example:/data/java-tron/config.conf)
210+
java -jar FullNode.jar -p your private key --witness -c your config.conf (Example:/data/java-tron/config.conf)
161211
Example:
162-
java -jar java-tron.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf
212+
java -jar FullNode.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf
163213

164214
```
165-
166-
* In the Terminal
167-
Un the config.conf localwitness add your private key.
168-
```bash
169-
./gradlew run -Pwitness
170-
```
171215

172216
<details>
173217
<summary>Show Output</summary>
@@ -286,50 +330,6 @@ In the `Program arguments` option, fill in `--witness`:
286330
287331
Then, run `FullNode::main()` again.
288332
289-
### Running a Super Node
290-
291-
* Use the executable JAR(Recommended way)
292-
293-
```bash
294-
cd build/libs
295-
java -jar java-tron.jar -p yourself private key --witness -c yourself config.conf(Example:/data/java-tron/config.conf)
296-
Example:
297-
java -jar java-tron.jar -p 650950B193DDDDB35B6E48912DD28F7AB0E7140C1BFDEFD493348F02295BD812 --witness -c /data/java-tron/config.conf
298-
299-
```
300-
301-
This is similar to running a private testnet, except that the IPs in the `config.conf` are officially declared by TRON.
302-
303-
<details>
304-
<summary>Correct output</summary>
305-
306-
```bash
307-
308-
20:43:18.138 INFO [main] [o.t.p.FullNode](FullNode.java:21) Full node running.
309-
20:43:18.486 INFO [main] [o.t.c.c.a.Args](Args.java:429) Bind address wasn't set, Punching to identify it...
310-
20:43:18.493 INFO [main] [o.t.c.c.a.Args](Args.java:433) UDP local bound to: 10.0.8.146
311-
20:43:18.495 INFO [main] [o.t.c.c.a.Args](Args.java:448) External IP wasn't set, using checkip.amazonaws.com to identify it...
312-
20:43:19.450 INFO [main] [o.t.c.c.a.Args](Args.java:461) External address identified: 47.74.147.87
313-
20:43:19.599 INFO [main] [o.s.c.a.AnnotationConfigApplicationContext](AbstractApplicationContext.java:573) Refreshing org.springframework.context.annotation.AnnotationConfigApplicationContext@124c278f: startup date [Fri Apr 27 20:43:19 CST 2018]; root of context hierarchy
314-
20:43:19.972 INFO [main] [o.s.b.f.a.AutowiredAnnotationBeanPostProcessor](AutowiredAnnotationBeanPostProcessor.java:153) JSR-330 'javax.inject.Inject' annotation found and supported for autowiring
315-
20:43:20.380 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:244) update latest block header timestamp = 0
316-
20:43:20.383 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:252) update latest block header number = 0
317-
20:43:20.393 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:260) update latest block header id = 00
318-
20:43:20.394 INFO [main] [o.t.c.d.DynamicPropertiesStore](DynamicPropertiesStore.java:265) update state flag = 0
319-
20:43:20.559 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
320-
20:43:20.567 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
321-
20:43:20.568 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
322-
20:43:20.568 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
323-
20:43:20.569 INFO [main] [o.t.c.c.TransactionCapsule](TransactionCapsule.java:83) Transaction create succeeded!
324-
20:43:20.596 INFO [main] [o.t.c.d.Manager](Manager.java:300) create genesis block
325-
20:43:20.607 INFO [main] [o.t.c.d.Manager](Manager.java:306) save block: BlockCapsule
326-
327-
```
328-
329-
Then observe whether block synchronization success,If synchronization successfully explains the success of the super node
330-
331-
</details>
332-
333333
# Quick Start
334334
335335
Read the [Quick Start](http://wiki.tron.network/en/latest/The_TRON_Network.html#how-to-build).

build.gradle

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ repositories {
4949
maven { url 'http://mvnrepository.com' }
5050
mavenLocal()
5151
mavenCentral()
52+
maven { url 'http://repo.spring.io/plugins-release' }
5253
}
5354
def versions = [
5455
checkstyle: '8.7',
@@ -68,6 +69,24 @@ configurations.getByName('checkstyleConfig') {
6869
transitive = false
6970
}
7071

72+
static def isWindows() {
73+
return org.gradle.internal.os.OperatingSystem.current().isWindows()
74+
}
75+
76+
if (isWindows()) {
77+
ext {
78+
leveldbGroup = "org.ethereum"
79+
leveldbName = "leveldbjni-all"
80+
leveldbVersion = "1.18.3"
81+
}
82+
} else {
83+
ext {
84+
leveldbGroup = "org.fusesource.leveldbjni"
85+
leveldbName = "leveldbjni-all"
86+
leveldbVersion = "1.8"
87+
}
88+
}
89+
7190
dependencies {
7291
//local libraries
7392
compile fileTree(dir: 'libs', include: '*.jar')
@@ -95,8 +114,7 @@ dependencies {
95114

96115
compile "org.iq80.leveldb:leveldb:0.7"
97116

98-
compile group: 'org.fusesource.leveldbjni', name: 'leveldbjni-all',
99-
version: '1.8'
117+
compile group: leveldbGroup, name: leveldbName, version: leveldbVersion
100118

101119
compile "org.apache.commons:commons-collections4:4.0"
102120

core/Contract.proto

Lines changed: 0 additions & 29 deletions
This file was deleted.

deploy.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
#!/bin/bash
22
ssh [email protected] -p 22008 sh /home/tron/workspace/deploy_all.sh
3-
3+
./gradlew stest

src/main/java/org/tron/common/application/Application.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,4 +43,5 @@ public interface Application {
4343
void addService(Service service);
4444

4545
Manager getDbManager();
46+
4647
}

src/main/java/org/tron/common/application/ApplicationFactory.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -15,22 +15,10 @@
1515

1616
package org.tron.common.application;
1717

18-
import com.google.inject.Guice;
19-
import com.google.inject.Injector;
2018
import org.springframework.context.ApplicationContext;
2119

2220
public class ApplicationFactory {
2321

24-
/**
25-
* Build a Guice instance.
26-
*
27-
* @return Guice
28-
*/
29-
public Injector buildGuice() {
30-
return Guice.createInjector(
31-
new Module());
32-
}
33-
3422
/**
3523
* Build a new application.
3624
*/

src/main/java/org/tron/common/application/ApplicationImpl.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,6 @@
66
import org.tron.core.config.args.Args;
77
import org.tron.core.db.BlockStore;
88
import org.tron.core.db.Manager;
9-
import org.tron.core.db.RevokingStore;
109
import org.tron.core.net.node.Node;
1110
import org.tron.core.net.node.NodeDelegate;
1211
import org.tron.core.net.node.NodeDelegateImpl;
@@ -25,7 +24,7 @@ public class ApplicationImpl implements Application {
2524

2625
@Autowired
2726
private Manager dbManager;
28-
27+
2928
private boolean isProducer;
3029

3130
private void resetP2PNode() {
@@ -76,6 +75,7 @@ public void shutdown() {
7675
closeAllStore();
7776
}
7877
closeConnection();
78+
dbManager.stopRepushThread();
7979
System.err.println("******** end to shutdown ********");
8080
}
8181

src/main/java/org/tron/common/application/CliApplication.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,4 +75,5 @@ public void addService(Service service) {
7575
public Manager getDbManager() {
7676
return null;
7777
}
78+
7879
}

0 commit comments

Comments
 (0)