Skip to content

Commit 4103dfe

Browse files
authored
Merge pull request #6010 from tronprotocol/release_v4.7.6
Release v4.7.6 merge to master
2 parents a8ad2a1 + 0f39d7a commit 4103dfe

Some content is hidden

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

44 files changed

+1052
-44
lines changed

build.gradle

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ subprojects {
3939
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
4040
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
4141
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
42-
compile group: 'com.google.guava', name: 'guava', version: '30.1-jre'
4342
compile "com.google.code.findbugs:jsr305:3.0.0"
4443
compile group: 'org.springframework', name: 'spring-context', version: '5.3.18'
4544
compile group: 'org.springframework', name: 'spring-tx', version: '5.3.18'
@@ -68,12 +67,6 @@ subprojects {
6867
preserveFileTimestamps = false
6968
reproducibleFileOrder = true
7069
}
71-
72-
configurations.all {
73-
resolutionStrategy {
74-
force group: 'com.google.guava', name: 'guava', version: '30.1-jre'
75-
}
76-
}
7770
}
7871

7972
task copyToParent(type: Copy) {

chainbase/src/main/java/org/tron/core/ChainBaseManager.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,10 @@ public class ChainBaseManager {
244244
@Setter
245245
private long lowestBlockNum = -1; // except num = 0.
246246

247+
@Getter
248+
@Setter
249+
private long latestSaveBlockTime;
250+
247251
// for test only
248252
public List<ByteString> getWitnesses() {
249253
return witnessScheduleStore.getActiveWitnesses();
@@ -381,6 +385,7 @@ private void init() {
381385
this.lowestBlockNum = this.blockIndexStore.getLimitNumber(1, 1).stream()
382386
.map(BlockId::getNum).findFirst().orElse(0L);
383387
this.nodeType = getLowestBlockNum() > 1 ? NodeType.LITE : NodeType.FULL;
388+
this.latestSaveBlockTime = System.currentTimeMillis();
384389
}
385390

386391
public void shutdown() {

chainbase/src/main/java/org/tron/core/capsule/TransactionCapsule.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,6 +59,7 @@
5959
import org.tron.core.exception.P2pException;
6060
import org.tron.core.exception.PermissionException;
6161
import org.tron.core.exception.SignatureFormatException;
62+
import org.tron.core.exception.TransactionExpirationException;
6263
import org.tron.core.exception.ValidateSignatureException;
6364
import org.tron.core.store.AccountStore;
6465
import org.tron.core.store.DynamicPropertiesStore;
@@ -869,4 +870,12 @@ public void removeRedundantRet() {
869870
this.transaction = transactionBuilder.build();
870871
}
871872
}
873+
874+
public void checkExpiration(long nextSlotTime) throws TransactionExpirationException {
875+
if (getExpiration() < nextSlotTime) {
876+
throw new TransactionExpirationException(String.format(
877+
"Transaction expiration time is %d, but next slot time is %d",
878+
getExpiration(), nextSlotTime));
879+
}
880+
}
872881
}

common/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ dependencies {
4646
compile 'org.aspectj:aspectjrt:1.8.13'
4747
compile 'org.aspectj:aspectjweaver:1.8.13'
4848
compile 'org.aspectj:aspectjtools:1.8.13'
49-
compile group: 'io.github.tronprotocol', name: 'libp2p', version: '2.2.1',{
49+
compile group: 'io.github.tronprotocol', name: 'libp2p', version: '2.2.4',{
5050
exclude group: 'io.grpc', module: 'grpc-context'
5151
exclude group: 'io.grpc', module: 'grpc-core'
5252
exclude group: 'io.grpc', module: 'grpc-netty'

common/src/main/java/org/tron/common/parameter/CommonParameter.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -333,6 +333,9 @@ public class CommonParameter {
333333
public boolean isOpenFullTcpDisconnect;
334334
@Getter
335335
@Setter
336+
public int inactiveThreshold;
337+
@Getter
338+
@Setter
336339
public boolean nodeDetectEnable;
337340
@Getter
338341
@Setter

common/src/main/java/org/tron/core/Constant.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -198,6 +198,8 @@ public class Constant {
198198

199199
public static final String NODE_IS_OPEN_FULL_TCP_DISCONNECT = "node.isOpenFullTcpDisconnect";
200200

201+
public static final String NODE_INACTIVE_THRESHOLD = "node.inactiveThreshold";
202+
201203
public static final String NODE_DETECT_ENABLE = "node.nodeDetectEnable";
202204

203205
public static final String NODE_MAX_TRANSACTION_PENDING_SIZE = "node.maxTransactionPendingSize";

framework/build.gradle

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
plugins {
2+
id "org.gradle.test-retry" version "1.5.9"
23
id "org.sonarqube" version "2.6"
34
id "com.gorylenko.gradle-git-properties" version "2.4.1"
45
}
@@ -113,6 +114,10 @@ run {
113114
}
114115

115116
test {
117+
retry {
118+
maxRetries = 5
119+
maxFailures = 20
120+
}
116121
testLogging {
117122
exceptionFormat = 'full'
118123
}

framework/src/main/java/org/tron/core/Wallet.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -549,6 +549,7 @@ public GrpcAPI.Return broadcastTransaction(Transaction signedTransaction) {
549549
throw new ContractValidateException(ActuatorConstant.CONTRACT_NOT_EXIST);
550550
}
551551
TransactionMessage message = new TransactionMessage(trx.getInstance().toByteArray());
552+
trx.checkExpiration(tronNetDelegate.getNextBlockSlotTime());
552553
dbManager.pushTransaction(trx);
553554
int num = tronNetService.fastBroadcastTransaction(message);
554555
if (num == 0 && minEffectiveConnection != 0) {

framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -173,6 +173,7 @@ public static void clearParam() {
173173
PARAMETER.receiveTcpMinDataLength = 2048;
174174
PARAMETER.isOpenFullTcpDisconnect = false;
175175
PARAMETER.nodeDetectEnable = false;
176+
PARAMETER.inactiveThreshold = 600;
176177
PARAMETER.supportConstant = false;
177178
PARAMETER.debug = false;
178179
PARAMETER.minTimeRatio = 0.0;
@@ -845,6 +846,12 @@ public static void setParam(final String[] args, final String confFileName) {
845846
PARAMETER.nodeDetectEnable = config.hasPath(Constant.NODE_DETECT_ENABLE)
846847
&& config.getBoolean(Constant.NODE_DETECT_ENABLE);
847848

849+
PARAMETER.inactiveThreshold = config.hasPath(Constant.NODE_INACTIVE_THRESHOLD)
850+
? config.getInt(Constant.NODE_INACTIVE_THRESHOLD) : 600;
851+
if (PARAMETER.inactiveThreshold < 1) {
852+
PARAMETER.inactiveThreshold = 1;
853+
}
854+
848855
PARAMETER.maxTransactionPendingSize = config.hasPath(Constant.NODE_MAX_TRANSACTION_PENDING_SIZE)
849856
? config.getInt(Constant.NODE_MAX_TRANSACTION_PENDING_SIZE) : 2000;
850857

framework/src/main/java/org/tron/core/db/Manager.java

Lines changed: 15 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1384,6 +1384,7 @@ public void updateDynamicProperties(BlockCapsule block) {
13841384
(chainBaseManager.getDynamicPropertiesStore().getLatestBlockHeaderNumber()
13851385
- chainBaseManager.getDynamicPropertiesStore().getLatestSolidifiedBlockNum()
13861386
+ 1));
1387+
chainBaseManager.setLatestSaveBlockTime(System.currentTimeMillis());
13871388
Metrics.gaugeSet(MetricKeys.Gauge.HEADER_HEIGHT, block.getNum());
13881389
Metrics.gaugeSet(MetricKeys.Gauge.HEADER_TIME, block.getTimeStamp());
13891390
}
@@ -1568,6 +1569,7 @@ public BlockCapsule generateBlock(Miner miner, long blockTime, long timeout) {
15681569
List<TransactionCapsule> toBePacked = new ArrayList<>();
15691570
long currentSize = blockCapsule.getInstance().getSerializedSize();
15701571
boolean isSort = Args.getInstance().isOpenTransactionSort();
1572+
int[] logSize = new int[] {pendingTransactions.size(), rePushTransactions.size(), 0, 0};
15711573
while (pendingTransactions.size() > 0 || rePushTransactions.size() > 0) {
15721574
boolean fromPending = false;
15731575
TransactionCapsule trx;
@@ -1643,6 +1645,11 @@ public BlockCapsule generateBlock(Miner miner, long blockTime, long timeout) {
16431645
tmpSession.merge();
16441646
toBePacked.add(trx);
16451647
currentSize += trxPackSize;
1648+
if (fromPending) {
1649+
logSize[2] += 1;
1650+
} else {
1651+
logSize[3] += 1;
1652+
}
16461653
} catch (Exception e) {
16471654
logger.warn("Process trx {} failed when generating block {}, {}.", trx.getTransactionId(),
16481655
blockCapsule.getNum(), e.getMessage());
@@ -1659,11 +1666,14 @@ public BlockCapsule generateBlock(Miner miner, long blockTime, long timeout) {
16591666
BlockCapsule capsule = new BlockCapsule(blockCapsule.getInstance());
16601667
capsule.generatedByMyself = true;
16611668
Metrics.histogramObserve(timer);
1662-
logger.info("Generate block {} success, trxs:{}, pendingCount: {}, rePushCount: {},"
1663-
+ " postponedCount: {}, blockSize: {} B",
1664-
capsule.getNum(), capsule.getTransactions().size(),
1665-
pendingTransactions.size(), rePushTransactions.size(), postponedTrxCount,
1666-
capsule.getSerializedSize());
1669+
logger.info("Generate block {} success, trxs:{}, before pendingCount: {}, rePushCount: {}, "
1670+
+ "from pending: {}, rePush: {}, after pendingCount: {}, rePushCount: {}, "
1671+
+ "postponedCount: {}, blockSize: {} B",
1672+
capsule.getNum(), capsule.getTransactions().size(),
1673+
logSize[0], logSize[1], logSize[2], logSize[3],
1674+
pendingTransactions.size(), rePushTransactions.size(), postponedTrxCount,
1675+
capsule.getSerializedSize());
1676+
16671677
return capsule;
16681678
}
16691679

0 commit comments

Comments
 (0)