Skip to content

Commit fe58a49

Browse files
authored
Merge pull request tronprotocol#1882 from tronprotocol/master
Merge master to develop
2 parents 5e67d75 + 4671374 commit fe58a49

7 files changed

Lines changed: 70 additions & 53 deletions

File tree

‎src/main/java/org/tron/common/runtime/RuntimeImpl.java‎

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -402,6 +402,9 @@ private void create()
402402
if (callValue < 0) {
403403
throw new ContractValidateException("callValue must >= 0");
404404
}
405+
if (tokenValue < 0) {
406+
throw new ContractValidateException("tokenValue must >= 0");
407+
}
405408
if (newSmartContract.getOriginEnergyLimit() <= 0) {
406409
throw new ContractValidateException("The originEnergyLimit must be > 0");
407410
}
@@ -485,17 +488,22 @@ private void call()
485488
}
486489

487490
long callValue = contract.getCallValue();
488-
if (VMConfig.getEnergyLimitHardFork() && callValue < 0) {
489-
throw new ContractValidateException("callValue must >= 0");
490-
}
491-
492491
long tokenValue = 0;
493492
long tokenId = 0;
494493
if (VMConfig.allowTvmTransferTrc10()) {
495494
tokenValue = contract.getCallTokenValue();
496495
tokenId = contract.getTokenId();
497496
}
498497

498+
if (VMConfig.getEnergyLimitHardFork()) {
499+
if (callValue < 0) {
500+
throw new ContractValidateException("callValue must >= 0");
501+
}
502+
if (tokenValue < 0) {
503+
throw new ContractValidateException("tokenValue must >= 0");
504+
}
505+
}
506+
499507
byte[] code = this.deposit.getCode(contractAddress);
500508
if (isNotEmpty(code)) {
501509

‎src/main/java/org/tron/core/config/Parameter.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ interface ChainConstant {
1414
int BLOCK_SIZE = 2_000_000;
1515
int BLOCK_PRODUCED_INTERVAL = 3000; //ms,produce block period, must be divisible by 60. millisecond
1616
long CLOCK_MAX_DELAY = 3600000; // 3600 * 1000 ms
17-
int BLOCK_PRODUCED_TIME_OUT = 75; // 75%
17+
int BLOCK_PRODUCED_TIME_OUT = 50; // 50%
1818
long PRECISION = 1000_000;
1919
long WINDOW_SIZE_MS = 24 * 3600 * 1000L;
2020
long MS_PER_DAY = 24 * 3600 * 1000L;

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -687,6 +687,12 @@ public static void setParam(final String[] args, final String confFileName) {
687687

688688
INSTANCE.blockProducedTimeOut = config.hasPath("node.blockProducedTimeOut") ?
689689
config.getInt("node.blockProducedTimeOut") : ChainConstant.BLOCK_PRODUCED_TIME_OUT;
690+
if (INSTANCE.blockProducedTimeOut < 30) {
691+
INSTANCE.blockProducedTimeOut = 30;
692+
}
693+
if (INSTANCE.blockProducedTimeOut > 100) {
694+
INSTANCE.blockProducedTimeOut = 100;
695+
}
690696

691697
INSTANCE.netMaxTrxPerSecond = config.hasPath("node.netMaxTrxPerSecond") ?
692698
config.getInt("node.netMaxTrxPerSecond") : NetConstants.NET_MAX_TRX_PER_SECOND;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1098,7 +1098,7 @@ public synchronized BlockCapsule generateBlock(
10981098
// if (lastHeadBlockIsMaintenanceBefore != lastHeadBlockIsMaintenance()) {
10991099
if (!witnessController.validateWitnessSchedule(witnessCapsule.getAddress(), when)) {
11001100
logger.info("It's not my turn, "
1101-
+ "and the first block after the maintenance period has just been processed");
1101+
+ "and the first block after the maintenance period has just been processed.");
11021102

11031103
logger.info("when:{},lastHeadBlockIsMaintenanceBefore:{},lastHeadBlockIsMaintenanceAfter:{}",
11041104
when, lastHeadBlockIsMaintenanceBefore, lastHeadBlockIsMaintenance());

‎src/main/java/org/tron/core/services/WitnessService.java‎

Lines changed: 48 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -190,47 +190,48 @@ private BlockProductionCondition tryProduceBlock() throws InterruptedException {
190190
return BlockProductionCondition.LOW_PARTICIPATION;
191191
}
192192

193-
long slot = controller.getSlotAtTime(now);
194-
logger.debug("Slot:" + slot);
195-
196-
if (slot == 0) {
197-
logger.info("Not time yet,now:{},headBlockTime:{},headBlockNumber:{},headBlockId:{}",
198-
new DateTime(now),
199-
new DateTime(
200-
this.tronApp.getDbManager().getDynamicPropertiesStore()
201-
.getLatestBlockHeaderTimestamp()),
202-
this.tronApp.getDbManager().getDynamicPropertiesStore().getLatestBlockHeaderNumber(),
203-
this.tronApp.getDbManager().getDynamicPropertiesStore().getLatestBlockHeaderHash());
204-
return BlockProductionCondition.NOT_TIME_YET;
205-
}
206-
207-
if (now < controller.getManager().getDynamicPropertiesStore().getLatestBlockHeaderTimestamp()) {
208-
logger.warn("have a timestamp:{} less than or equal to the previous block:{}",
209-
new DateTime(now), new DateTime(
210-
this.tronApp.getDbManager().getDynamicPropertiesStore()
211-
.getLatestBlockHeaderTimestamp()));
212-
return BlockProductionCondition.EXCEPTION_PRODUCING_BLOCK;
213-
}
214-
215193
if (!controller.activeWitnessesContain(this.getLocalWitnessStateMap().keySet())) {
216194
logger.info("Unelected. Elected Witnesses: {}",
217195
StringUtil.getAddressStringList(controller.getActiveWitnesses()));
218196
return BlockProductionCondition.UNELECTED;
219197
}
220198

221-
final ByteString scheduledWitness = controller.getScheduledWitness(slot);
222-
223-
if (!this.getLocalWitnessStateMap().containsKey(scheduledWitness)) {
224-
logger.info("It's not my turn, ScheduledWitness[{}],slot[{}],abSlot[{}],",
225-
ByteArray.toHexString(scheduledWitness.toByteArray()), slot,
226-
controller.getAbSlotAtTime(now));
227-
return NOT_MY_TURN;
228-
}
199+
try {
229200

230-
BlockCapsule block;
201+
BlockCapsule block;
231202

232-
try {
233203
synchronized (tronApp.getDbManager()) {
204+
long slot = controller.getSlotAtTime(now);
205+
logger.debug("Slot:" + slot);
206+
if (slot == 0) {
207+
logger.info("Not time yet,now:{},headBlockTime:{},headBlockNumber:{},headBlockId:{}",
208+
new DateTime(now),
209+
new DateTime(
210+
this.tronApp.getDbManager().getDynamicPropertiesStore()
211+
.getLatestBlockHeaderTimestamp()),
212+
this.tronApp.getDbManager().getDynamicPropertiesStore().getLatestBlockHeaderNumber(),
213+
this.tronApp.getDbManager().getDynamicPropertiesStore().getLatestBlockHeaderHash());
214+
return BlockProductionCondition.NOT_TIME_YET;
215+
}
216+
217+
if (now < controller.getManager().getDynamicPropertiesStore()
218+
.getLatestBlockHeaderTimestamp()) {
219+
logger.warn("have a timestamp:{} less than or equal to the previous block:{}",
220+
new DateTime(now), new DateTime(
221+
this.tronApp.getDbManager().getDynamicPropertiesStore()
222+
.getLatestBlockHeaderTimestamp()));
223+
return BlockProductionCondition.EXCEPTION_PRODUCING_BLOCK;
224+
}
225+
226+
final ByteString scheduledWitness = controller.getScheduledWitness(slot);
227+
228+
if (!this.getLocalWitnessStateMap().containsKey(scheduledWitness)) {
229+
logger.info("It's not my turn, ScheduledWitness[{}],slot[{}],abSlot[{}],",
230+
ByteArray.toHexString(scheduledWitness.toByteArray()), slot,
231+
controller.getAbSlotAtTime(now));
232+
return NOT_MY_TURN;
233+
}
234+
234235
long scheduledTime = controller.getSlotTime(slot);
235236

236237
if (scheduledTime - now > PRODUCE_TIME_OUT) {
@@ -247,22 +248,23 @@ private BlockProductionCondition tryProduceBlock() throws InterruptedException {
247248

248249
block = generateBlock(scheduledTime, scheduledWitness,
249250
controller.lastHeadBlockIsMaintenance());
251+
}
250252

251-
if (block == null) {
252-
logger.warn("exception when generate block");
253-
return BlockProductionCondition.EXCEPTION_PRODUCING_BLOCK;
254-
}
253+
if (block == null) {
254+
logger.warn("exception when generate block");
255+
return BlockProductionCondition.EXCEPTION_PRODUCING_BLOCK;
256+
}
255257

256-
int blockProducedTimeOut = Args.getInstance().getBlockProducedTimeOut();
258+
int blockProducedTimeOut = Args.getInstance().getBlockProducedTimeOut();
257259

258-
if (DateTime.now().getMillis() - now
259-
> ChainConstant.BLOCK_PRODUCED_INTERVAL * blockProducedTimeOut / 100) {
260-
logger.warn("Task timeout ( > {}ms),startTime:{},endTime:{}",
261-
ChainConstant.BLOCK_PRODUCED_INTERVAL * blockProducedTimeOut / 100,
262-
new DateTime(now), DateTime.now());
263-
tronApp.getDbManager().eraseBlock();
264-
return BlockProductionCondition.TIME_OUT;
265-
}
260+
long timeout = Math
261+
.min(ChainConstant.BLOCK_PRODUCED_INTERVAL * blockProducedTimeOut / 100 + 500,
262+
ChainConstant.BLOCK_PRODUCED_INTERVAL);
263+
if (DateTime.now().getMillis() - now > timeout) {
264+
logger.warn("Task timeout ( > {}ms),startTime:{},endTime:{}", timeout, new DateTime(now),
265+
DateTime.now());
266+
tronApp.getDbManager().eraseBlock();
267+
return BlockProductionCondition.TIME_OUT;
266268
}
267269

268270
logger.info(
@@ -271,6 +273,7 @@ private BlockProductionCondition tryProduceBlock() throws InterruptedException {
271273
block.getTransactions().size(),
272274
new DateTime(block.getTimeStamp()),
273275
block.getParentHash());
276+
274277
broadcastBlock(block);
275278

276279
return BlockProductionCondition.PRODUCED;

‎src/main/java/org/tron/program/Version.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22

33
public class Version {
44

5-
private static final String version = "3.2.2";
5+
private static final String version = "3.2.3";
66

77
public static String getVersion() {
88
return version;

‎src/test/java/org/tron/core/net/node/override/HandshakeHandlerTest.java‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ protected void sendHelloMsg(ChannelHandlerContext ctx, long time) {
2929
manager.getGenesisBlockId(), manager.getSolidBlockId(), manager.getHeadBlockId());
3030
ctx.writeAndFlush(message.getSendData());
3131
channel.getNodeStatistics().messageStatistics.addTcpOutMessage(message);
32-
logger.info("Handshake Send to {}, {} ", ctx.channel().remoteAddress(), message);
32+
logger.info("Handshake Send to {}, {}", ctx.channel().remoteAddress(), message);
3333
}
3434

3535
public void close() {

0 commit comments

Comments
 (0)