Skip to content

Commit 3062f6d

Browse files
authored
Merge branch 'develop' into hotfix/trace_result_set
2 parents 4da6781 + 8b5a2cb commit 3062f6d

File tree

195 files changed

+35295
-444
lines changed

Some content is hidden

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

195 files changed

+35295
-444
lines changed

.circleci/config.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ jobs:
1818
#
1919
# - run:
2020
# name: Daily Build Report
21-
# command: curl http://60.205.215.34/Daily_Build_Task_Report
21+
# command: curl http://47.95.206.44:50080/Daily_Build_Task_Report
2222
#
2323
# - run:
2424
# name: Download Links

.gitignore

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,4 +54,4 @@ nodeId.properties
5454
Wallet
5555

5656
# vm_trace
57-
/vm_trace/
57+
/vm_trace/

DownloadLinks.sh

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,21 @@
1-
PassFlag=`curl -s http://60.205.215.34/Daily_Build_Task_Report | grep "Failed: 0" | wc -c`
1+
PassFlag=`curl -s http://47.95.206.44:50080/Daily_Build_Task_Report | grep "Failed: 0" | wc -c`
22

33
if [ $PassFlag -eq 0 ]; then
44
echo "Daily Build Stest Fail"
55
echo "To view Daily Replay and Stress Test logs please visit website below on browsers"
6-
echo "--- http://60.205.215.34/latestReplayLog"
7-
echo "--- http://60.205.215.34/latestStressLog"
6+
echo "--- http://47.95.206.44:50080/latestReplayLog"
7+
echo "--- http://47.95.206.44:50080/latestStressLog"
88

99
else
1010
echo "Daily Build Stest Pass"
1111
echo "Build on `date +"%Y-%m-%d"` 3:00:00 (CST), UTC +8"
1212
echo "Please visit following website to download java-tron.jar on browsers"
13-
echo "--- http://60.205.215.34/Daily_Build/java-tron.jar"
13+
echo "--- http://47.95.206.44:50080/Daily_Build/jFava-tron.jar"
1414
echo "To view Daily Replay and Stress Test logs please visit website below on browsers"
15-
echo "--- http://60.205.215.34/latestReplayLog"
16-
echo "--- http://60.205.215.34/latestStressLog"
15+
echo "--- http://47.95.206.44:50080/latestReplayLog"
16+
echo "--- http://47.95.206.44:50080/latestStressLog"
1717
echo "The following compressed package is provided for user to set up Fullnode. Please use Linux OS to Download"
18-
echo "--- curl -# -O http://60.205.215.34/Daily_Build/java-tron.tar.gz"
18+
echo "--- curl -# -O http://47.95.206.44:50080/Daily_Build/java-tron.tar.gz"
1919
echo "To unzip file use the command below"
2020
echo "--- tar -xzvf java-tron.tar.gz"
2121
fi

deploy.sh

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,19 @@
11
#!/bin/bash
22
if [[ "$TRAVIS_BRANCH" = "develop" || "$TRAVIS_BRANCH" = "master" ]];then
33
stestlogname="`date +%Y%m%d%H%M%S`_stest.log"
4+
timeout 10 ping -c 5 47.93.42.145 > /dev/null || exit 1
5+
timeout 10 ping -c 5 47.93.18.60 > /dev/null || exit 1
46
stest_server=""
5-
docker_num_in_67=`ssh -p 22008 -t [email protected] 'docker ps -a | wc -l'`
6-
docker_num_in_67=`echo $docker_num_in_67 | tr -d "\r"`
7-
docker_num_in_122=`ssh -p 22008 -t [email protected] 'docker ps -a | wc -l'`
8-
docker_num_in_122=`echo $docker_num_in_122 | tr -d "\r"`
9-
if [ $docker_num_in_67 -le $docker_num_in_122 ];
7+
docker_num_in_145=`ssh -p 22008 -t [email protected] 'docker ps -a | wc -l'`
8+
docker_num_in_145=`echo $docker_num_in_145 | tr -d "\r"`
9+
docker_num_in_60=`ssh -p 22008 -t [email protected] 'docker ps -a | wc -l'`
10+
docker_num_in_60=`echo $docker_num_in_60 | tr -d "\r"`
11+
if [ $docker_num_in_145 -le $docker_num_in_60 ];
1012
then
11-
docker_num=$docker_num_in_67
13+
docker_num=$docker_num_in_145
1214
stest_server=47.93.42.145
1315
else
14-
docker_num=$docker_num_in_122
16+
docker_num=$docker_num_in_60
1517
stest_server=47.93.18.60
1618
fi
1719

src/main/java/org/tron/common/overlay/discover/node/NodeHandler.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ public NodeHandler(Node node, NodeManager nodeManager) {
9595
this.node = node;
9696
this.nodeManager = nodeManager;
9797
this.inetSocketAddress = new InetSocketAddress(node.getHost(), node.getPort());
98-
this.nodeStatistics = new NodeStatistics(node);
98+
this.nodeStatistics = new NodeStatistics();
9999
changeState(State.Discovered);
100100
}
101101

@@ -201,8 +201,7 @@ public void handlePing(PingMessage msg) {
201201
public void handlePong(PongMessage msg) {
202202
if (waitForPong) {
203203
waitForPong = false;
204-
getNodeStatistics().discoverMessageLatency
205-
.add((double) System.currentTimeMillis() - pingSent);
204+
getNodeStatistics().discoverMessageLatency.add(System.currentTimeMillis() - pingSent);
206205
getNodeStatistics().lastPongReplyTime.set(System.currentTimeMillis());
207206
node.setId(msg.getFrom().getId());
208207
if (msg.getVersion() != Args.getInstance().getNodeP2pVersion()) {

src/main/java/org/tron/common/overlay/discover/node/statistics/NodeStatistics.java

Lines changed: 22 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
import java.util.concurrent.atomic.AtomicInteger;
2222
import java.util.concurrent.atomic.AtomicLong;
2323
import lombok.Getter;
24+
import lombok.Setter;
2425
import org.tron.common.overlay.discover.node.Node;
2526
import org.tron.core.config.args.Args;
2627
import org.tron.protos.Protocol.ReasonCode;
@@ -48,12 +49,15 @@ public class NodeStatistics {
4849
public final MessageCount tcpFlow = new MessageCount();
4950

5051
public final SimpleStatter discoverMessageLatency;
52+
public final SimpleStatter pingMessageLatency;
53+
5154
public final AtomicLong lastPongReplyTime = new AtomicLong(0L); // in milliseconds
5255

5356
private Reputation reputation;
5457

55-
public NodeStatistics(Node node) {
56-
discoverMessageLatency = new SimpleStatter(node.getIdString());
58+
public NodeStatistics() {
59+
discoverMessageLatency = new SimpleStatter();
60+
pingMessageLatency = new SimpleStatter();
5761
reputation = new Reputation(this);
5862
}
5963

@@ -182,40 +186,26 @@ public String toString() {
182186
}
183187

184188
public class SimpleStatter {
185-
186-
private final String name;
187-
private volatile double last;
188-
private volatile double sum;
189-
private AtomicInteger count = new AtomicInteger();
190-
191-
public SimpleStatter(String name) {
192-
this.name = name;
193-
}
194-
195-
public void add(double value) {
189+
private long sum;
190+
@Getter
191+
private long count;
192+
@Getter
193+
private long last;
194+
@Getter
195+
private long min;
196+
@Getter
197+
private long max;
198+
199+
public void add(long value) {
196200
last = value;
197201
sum += value;
198-
count.incrementAndGet();
199-
}
200-
201-
public double getLast() {
202-
return last;
203-
}
204-
205-
public int getCount() {
206-
return count.get();
207-
}
208-
209-
public double getSum() {
210-
return sum;
211-
}
212-
213-
public double getAvrg() {
214-
return count.get() == 0 ? 0 : sum / count.get();
202+
min = min == 0? value : Math.min(min, value);
203+
max = Math.max(max, value);
204+
count++;
215205
}
216206

217-
public String getName() {
218-
return name;
207+
public long getAvrg() {
208+
return count == 0 ? 0 : sum / count;
219209
}
220210

221211
}

src/main/java/org/tron/common/overlay/server/Channel.java

Lines changed: 1 addition & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,3 @@
1-
/*
2-
* Copyright (c) [2016] [ <ether.camp> ]
3-
* This file is part of the ethereumJ library.
4-
*
5-
* The ethereumJ library is free software: you can redistribute it and/or modify
6-
* it under the terms of the GNU Lesser General Public License as published by
7-
* the Free Software Foundation, either version 3 of the License, or
8-
* (at your option) any later version.
9-
*
10-
* The ethereumJ library is distributed in the hope that it will be useful,
11-
* but WITHOUT ANY WARRANTY; without even the implied warranty of
12-
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13-
* GNU Lesser General Public License for more details.
14-
*
15-
* You should have received a copy of the GNU Lesser General Public License
16-
* along with the ethereumJ library. If not, see <http://www.gnu.org/licenses/>.
17-
*/
181
package org.tron.common.overlay.server;
192

203
import io.netty.channel.ChannelHandlerContext;
@@ -90,10 +73,6 @@ public class Channel {
9073

9174
private volatile boolean isDisconnect;
9275

93-
private String remoteId;
94-
95-
private PeerStatistics peerStats = new PeerStatistics();
96-
9776
private boolean isTrustPeer;
9877

9978
private boolean isFastForwardPeer;
@@ -103,8 +82,6 @@ public void init(ChannelPipeline pipeline, String remoteId, boolean discoveryMod
10382

10483
this.channelManager = channelManager;
10584

106-
this.remoteId = remoteId;
107-
10885
isActive = remoteId != null && !remoteId.isEmpty();
10986

11087
startTime = System.currentTimeMillis();
@@ -129,7 +106,7 @@ public void init(ChannelPipeline pipeline, String remoteId, boolean discoveryMod
129106
}
130107

131108
public void publicHandshakeFinished(ChannelHandlerContext ctx, HelloMessage msg) {
132-
isTrustPeer = channelManager.getTrustNodes().containsKey(getInetAddress());
109+
isTrustPeer = channelManager.getTrustNodes().getIfPresent(getInetAddress()) != null;
133110
isFastForwardPeer = channelManager.getFastForwardNodes().containsKey(getInetAddress());
134111
ctx.pipeline().remove(handshakeHandler);
135112
msgQueue.activate(ctx);
@@ -197,10 +174,6 @@ public enum TronState {
197174
SYNC_FAILED
198175
}
199176

200-
public PeerStatistics getPeerStats() {
201-
return peerStats;
202-
}
203-
204177
public Node getNode() {
205178
return node;
206179
}

src/main/java/org/tron/common/overlay/server/ChannelManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ public class ChannelManager {
5050
.maximumSize(1000).expireAfterWrite(30, TimeUnit.SECONDS).recordStats().build();
5151

5252
@Getter
53-
private Map<InetAddress, Node> trustNodes = new ConcurrentHashMap();
53+
private Cache<InetAddress, Node> trustNodes = CacheBuilder.newBuilder().maximumSize(100).build();
5454

5555
@Getter
5656
private Map<InetAddress, Node> activeNodes = new ConcurrentHashMap();
@@ -126,7 +126,7 @@ public void notifyDisconnect(Channel channel) {
126126

127127
public synchronized boolean processPeer(Channel peer) {
128128

129-
if (!trustNodes.containsKey(peer.getInetAddress())) {
129+
if (trustNodes.getIfPresent(peer.getInetAddress()) == null) {
130130
if (recentlyDisconnected.getIfPresent(peer) != null) {
131131
logger.info("Peer {} recently disconnected.", peer.getInetAddress());
132132
return false;

src/main/java/org/tron/common/overlay/server/FastForward.java

Lines changed: 8 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package org.tron.common.overlay.server;
22

3+
import com.google.protobuf.ByteString;
34
import java.net.InetAddress;
45
import java.net.InetSocketAddress;
56
import java.util.List;
@@ -13,10 +14,8 @@
1314
import org.tron.common.backup.BackupManager;
1415
import org.tron.common.backup.BackupManager.BackupStatusEnum;
1516
import org.tron.common.overlay.discover.node.Node;
16-
import org.tron.common.overlay.discover.node.NodeManager;
1717
import org.tron.core.config.args.Args;
18-
import org.tron.core.db.Manager;
19-
import org.tron.core.db.WitnessStore;
18+
import org.tron.core.db.WitnessScheduleStore;
2019
import org.tron.core.services.WitnessService;
2120
import org.tron.protos.Protocol.ReasonCode;
2221

@@ -27,12 +26,6 @@ public class FastForward {
2726
@Autowired
2827
private ApplicationContext ctx;
2928

30-
private Manager manager;
31-
32-
private WitnessStore witnessStore;
33-
34-
private NodeManager nodeManager;
35-
3629
private ChannelManager channelManager;
3730

3831
private BackupManager backupManager;
@@ -41,7 +34,8 @@ public class FastForward {
4134

4235
private Args args = Args.getInstance();
4336
private List<Node> fastForwardNodes = args.getFastForwardNodes();
44-
private byte[] witnessAddress = args.getLocalWitnesses().getWitnessAccountAddress();
37+
private ByteString witnessAddress = ByteString
38+
.copyFrom(args.getLocalWitnesses().getWitnessAccountAddress());
4539
private int keySize = args.getLocalWitnesses().getPrivateKeys().size();
4640

4741
public void init() {
@@ -53,21 +47,14 @@ public void init() {
5347
return;
5448
}
5549

56-
manager = ctx.getBean(Manager.class);
57-
witnessStore = ctx.getBean(WitnessStore.class);
58-
nodeManager = ctx.getBean(NodeManager.class);
5950
channelManager = ctx.getBean(ChannelManager.class);
6051
backupManager = ctx.getBean(BackupManager.class);
61-
62-
if (args.getFastForwardNodes().size() > 0) {
63-
fastForwardNodes = args.getFastForwardNodes();
64-
}
52+
WitnessScheduleStore witnessScheduleStore = ctx.getBean(WitnessScheduleStore.class);
6553

6654
executorService.scheduleWithFixedDelay(() -> {
6755
try {
68-
if (witnessStore.get(witnessAddress) != null &&
69-
backupManager.getStatus().equals(BackupStatusEnum.MASTER) &&
70-
!WitnessService.isNeedSyncCheck()) {
56+
if (witnessScheduleStore.getActiveWitnesses().contains(witnessAddress) &&
57+
backupManager.getStatus().equals(BackupStatusEnum.MASTER)) {
7158
connect();
7259
} else {
7360
disconnect();
@@ -90,11 +77,10 @@ private void disconnect() {
9077
InetAddress address = new InetSocketAddress(node.getHost(), node.getPort()).getAddress();
9178
channelManager.getActiveNodes().remove(address);
9279
channelManager.getActivePeers().forEach(channel -> {
93-
if (channel.getNode().equals(node)) {
80+
if (channel.getInetAddress().equals(address)) {
9481
channel.disconnect(ReasonCode.RESET);
9582
}
9683
});
9784
});
9885
}
99-
10086
}

src/main/java/org/tron/common/overlay/server/HandshakeHandler.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ private void handleHelloMsg(ChannelHandlerContext ctx, HelloMessage msg) {
123123

124124
if (remoteId.length != 64) {
125125
InetAddress address = ((InetSocketAddress) ctx.channel().remoteAddress()).getAddress();
126-
if (!channelManager.getTrustNodes().keySet().contains(address) && !syncPool.isCanConnect()) {
126+
if (channelManager.getTrustNodes().getIfPresent(address) == null && !syncPool.isCanConnect()) {
127127
channel.disconnect(ReasonCode.TOO_MANY_PEERS);
128128
return;
129129
}

0 commit comments

Comments
 (0)