Skip to content

dev-release4.7.1 #5027

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 54 commits into from
Feb 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
54 commits
Select commit Hold shift + click to select a range
057f3f0
feat(event): skip log warning when solidity block number is 0
tomatoishealthy Feb 8, 2023
d3262a2
Merge pull request #4974 from guoquanwu/feature/event-log-optimize
tomatoishealthy Feb 13, 2023
e693d8a
feat(log): separate database logs
halibobo1205 Feb 8, 2023
c728bfb
Merge pull request #4985 from halibobo1205/feat/opt_db_log
forfreeday Feb 13, 2023
ed38d78
feat(db): optimize the judgement of node type
halibobo1205 Feb 8, 2023
1450156
Merge pull request #4986 from halibobo1205/feat/lite_node
halibobo1205 Feb 13, 2023
a3628fd
fix(net):change the default IP of the node
jwrct Feb 14, 2023
ab07d2f
fix(net):change the log level of bad message from warn to error
jwrct Feb 14, 2023
b41826f
fix(net):fix the issue of fast forwarding service
jwrct Feb 14, 2023
cd57342
Merge pull request #4990 from chengtx01/release_v4.7.1
jwrct Feb 15, 2023
96b0cfc
Merge pull request #4991 from chengtx01/optimize_net_logs
jwrct Feb 15, 2023
b169228
Merge pull request #4992 from chengtx01/fix_relay_service
jwrct Feb 15, 2023
9e086c7
add fastForwardNode to activeNodes only if not exist
317787106 Feb 15, 2023
a5f9c6f
fix(net): solve the problem of obtaining the same block during block …
xxo1shine Feb 15, 2023
5a70a07
fet(net): olve the problem of reporting 'no need sync'
xxo1shine Feb 15, 2023
d585cf3
solve check style problem
xxo1shine Feb 15, 2023
9cf633d
Merge pull request #4995 from wubin01/sync_opt
xxo1shine Feb 15, 2023
15b36cc
feat(stake2.0): optimize code, remove useless code
Feb 15, 2023
a82003c
optimize chain inventory message processing logic
xxo1shine Feb 15, 2023
789739b
Merge pull request #4996 from wubin01/sync
xxo1shine Feb 16, 2023
2a7f5aa
Merge pull request #4994 from 317787106/hotfix/fastforward
317787106 Feb 16, 2023
6c51cff
feat(log): add encoder to avoid any external usage
halibobo1205 Feb 16, 2023
760a3dd
feat(net):update libp2p to beta version
jwrct Feb 16, 2023
eab196d
Merge pull request #5002 from chengtx01/optimize_net_logs
jwrct Feb 16, 2023
a46a607
Merge pull request #5001 from halibobo1205/feat/opt_db_log
halibobo1205 Feb 16, 2023
f1f9353
Merge pull request #4997 from chaosuper12321/feature/stake2.0_optimiz…
zhang0125 Feb 16, 2023
b265649
feat(version): update Version
forfreeday Feb 20, 2023
ebf49a9
Merge pull request #5007 from forfreeday/feature/update_versin_4.7.1
forfreeday Feb 20, 2023
14e9047
feat(net): optimize the logic of obtaining block ID
xxo1shine Feb 20, 2023
092d9ce
feat(log): use AsyncAppender for DB
halibobo1205 Feb 20, 2023
8862018
feat(db): add sending timeout of zmq
317787106 Feb 20, 2023
df638e6
Merge pull request #5009 from wubin01/sync_fail
xxo1shine Feb 20, 2023
69deaae
fix(db): use constant ZMQ_SEND_TIME_OUT
317787106 Feb 20, 2023
c09446f
Merge pull request #5010 from halibobo1205/feat/opt_db_log
halibobo1205 Feb 20, 2023
6b2a7f9
fix(net): optimize log of P2pEventHandlerImpl
317787106 Feb 20, 2023
14c1c80
fix(db): reorder setSendTimeOut function
317787106 Feb 20, 2023
5ec01d4
Merge pull request #5012 from 317787106/hotfix/zmq_lock
317787106 Feb 20, 2023
e860b0b
fix(db): revert timeout of sending data to zmq
317787106 Feb 21, 2023
e4f8766
Merge pull request #5014 from 317787106/hotfix/revert_zmq_timeout
lvs007 Feb 21, 2023
8fd659f
feature(consensus): optimize signatures
halibobo1205 Feb 21, 2023
8179896
Merge pull request #3 from halibobo1205/feat/opt-sig
halibobo1205 Feb 21, 2023
acdb2e5
feat(net):update libp2p to latest version
jwrct Feb 21, 2023
1a212fa
Merge pull request #5015 from chengtx01/update_libp2p_version
jwrct Feb 22, 2023
6b99d36
Merge pull request #4 from tronprotocol/release_v4.7.1
halibobo1205 Feb 22, 2023
5e203bd
feat(net):update libp2p to v0.1.4
jwrct Feb 22, 2023
6ae8610
Merge pull request #6 from chengtx01/update_libp2p_version
halibobo1205 Feb 22, 2023
2e4ed64
fix(api): add input check
halibobo1205 Feb 22, 2023
7b90c6b
Merge pull request #8 from halibobo1205/fix/delegate_check
halibobo1205 Feb 22, 2023
662959d
feature(tvm): optimize signatures
CodeNinjaEvan Feb 24, 2023
f8bab83
feature(tvm): optimize the check of cpu time
CodeNinjaEvan Feb 24, 2023
954125e
Merge pull request #5022 from halibobo1205/release_v4.7.1
halibobo1205 Feb 27, 2023
36fc506
Merge pull request #5024 from tronprotocol/release_v4.7.1
halibobo1205 Feb 27, 2023
772eb45
update a new version. version name:GreatVoyage-v4.7.0.1-75-g36fc5063e…
lvs007 Feb 27, 2023
da2673c
Merge pull request #5025 from tronprotocol/version/GreatVoyage-v4.7.0…
halibobo1205 Feb 27, 2023
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 14 additions & 3 deletions actuator/src/main/java/org/tron/core/vm/PrecompiledContracts.java
Original file line number Diff line number Diff line change
Expand Up @@ -62,8 +62,10 @@
import org.tron.core.exception.ZksnarkException;
import org.tron.core.vm.config.VMConfig;
import org.tron.core.vm.program.Program;
import org.tron.core.vm.program.Program.OutOfTimeException;
import org.tron.core.vm.repository.Repository;
import org.tron.core.vm.utils.FreezeV2Util;
import org.tron.core.vm.utils.MUtil;
import org.tron.core.vm.utils.VoteRewardUtil;
import org.tron.protos.Protocol;
import org.tron.protos.Protocol.Permission;
Expand Down Expand Up @@ -944,24 +946,33 @@ public Pair<Boolean, byte[]> execute(byte[] rawData) {
long totalWeight = 0L;
List<byte[]> executedSignList = new ArrayList<>();
for (byte[] sign : signatures) {
if (ByteArray.matrixContains(executedSignList, sign)) {
continue;
}
byte[] recoveredAddr = recoverAddrBySign(sign, hash);

sign = merge(recoveredAddr, sign);
if (ByteArray.matrixContains(executedSignList, recoveredAddr)) {
if (ByteArray.matrixContains(executedSignList, sign)) {
continue;
}
MUtil.checkCPUTime();
}
long weight = TransactionCapsule.getWeight(permission, recoveredAddr);
if (weight == 0) {
//incorrect sign
return Pair.of(true, DATA_FALSE);
}
totalWeight += weight;
executedSignList.add(sign);
executedSignList.add(recoveredAddr);
}

if (totalWeight >= permission.getThreshold()) {
return Pair.of(true, dataOne());
}
}
} catch (Throwable t) {
if (t instanceof OutOfTimeException) {
throw t;
}
logger.info("ValidateMultiSign error:{}", t.getMessage());
}
}
Expand Down
9 changes: 9 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/utils/MUtil.java
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
package org.tron.core.vm.utils;

import org.tron.common.utils.ForkController;
import org.tron.core.capsule.AccountCapsule;
import org.tron.core.config.Parameter;
import org.tron.core.exception.ContractValidateException;
import org.tron.core.vm.VMUtils;
import org.tron.core.vm.program.Program.OutOfTimeException;
import org.tron.core.vm.repository.Repository;
import org.tron.protos.Protocol;

Expand Down Expand Up @@ -55,4 +58,10 @@ public static boolean isNullOrEmpty(String str) {
public static boolean isNotNullOrEmpty(String str) {
return !isNullOrEmpty(str);
}

public static void checkCPUTime() {
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_7_1)) {
throw new OutOfTimeException("CPU timeout for 0x0a executing");
}
}
}
166 changes: 84 additions & 82 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,82 +1,84 @@
allprojects {
version = "1.0.0"
apply plugin: "java"
}

subprojects {
apply plugin: "java"
apply plugin: "jacoco"
apply plugin: "maven"
apply plugin: "maven-publish"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

buildscript {
repositories {
mavenCentral()
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
}
}

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
}

dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile "org.slf4j:jcl-over-slf4j:1.7.25"
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
compile "com.google.code.findbugs:jsr305:3.0.0"
compile group: 'org.springframework', name: 'spring-context', version: '5.3.18'
compile group: 'org.springframework', name: 'spring-tx', version: '5.3.18'
compile "org.apache.commons:commons-lang3:3.4"
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
compile "org.apache.commons:commons-collections4:4.1"
compile group: 'joda-time', name: 'joda-time', version: '2.3'

}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}


tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

configurations.all {
resolutionStrategy {
force group: 'com.google.guava', name: 'guava', version: '30.1-jre'
}
}
}

task copyToParent(type: Copy) {
into "$buildDir/libs"
subprojects {
from tasks.withType(Jar)
}
}

build.finalizedBy(copyToParent)

allprojects {
version = "1.0.0"
apply plugin: "java"
}

subprojects {
apply plugin: "java"
apply plugin: "jacoco"
apply plugin: "maven"
apply plugin: "maven-publish"

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8

[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

buildscript {
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven {
url "https://plugins.gradle.org/m2/"
}
}
dependencies {
classpath 'com.google.protobuf:protobuf-gradle-plugin:0.9.1'
classpath "gradle.plugin.com.github.johnrengelman:shadow:7.1.2"
}
}

repositories {
mavenLocal()
mavenCentral()
maven { url 'https://repo.spring.io/plugins-release' }
maven { url 'https://jitpack.io' }
}

dependencies {
compile group: 'org.slf4j', name: 'slf4j-api', version: '1.7.25'
compile group: 'org.slf4j', name: 'jcl-over-slf4j', version: '1.7.25'
compile "org.slf4j:jcl-over-slf4j:1.7.25"
compile group: 'ch.qos.logback', name: 'logback-classic', version: '1.2.9'
compileOnly 'org.projectlombok:lombok:1.18.12'
annotationProcessor 'org.projectlombok:lombok:1.18.12'
testCompileOnly 'org.projectlombok:lombok:1.18.12'
testAnnotationProcessor 'org.projectlombok:lombok:1.18.12'
compile group: 'com.google.guava', name: 'guava', version: '24.1-jre'
compile "com.google.code.findbugs:jsr305:3.0.0"
compile group: 'org.springframework', name: 'spring-context', version: '5.3.18'
compile group: 'org.springframework', name: 'spring-tx', version: '5.3.18'
compile "org.apache.commons:commons-lang3:3.4"
compile group: 'org.apache.commons', name: 'commons-math', version: '2.2'
compile "org.apache.commons:commons-collections4:4.1"
compile group: 'joda-time', name: 'joda-time', version: '2.3'

}

task sourcesJar(type: Jar, dependsOn: classes) {
classifier = "sources"
from sourceSets.main.allSource
}


tasks.withType(AbstractArchiveTask) {
preserveFileTimestamps = false
reproducibleFileOrder = true
}

configurations.all {
resolutionStrategy {
force group: 'com.google.guava', name: 'guava', version: '30.1-jre'
}
}
}

task copyToParent(type: Copy) {
into "$buildDir/libs"
subprojects {
from tasks.withType(Jar)
}
}

build.finalizedBy(copyToParent)

Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,9 @@ public boolean pass(ForkBlockVersionEnum forkBlockVersionEnum) {
}

public synchronized boolean pass(int version) {
if (manager == null) {
throw new IllegalStateException("not inited");
}
if (version > ForkBlockVersionEnum.VERSION_4_0.getValue()) {
return passNew(version);
} else {
Expand Down
32 changes: 32 additions & 0 deletions chainbase/src/main/java/org/tron/core/ChainBaseManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import com.google.protobuf.ByteString;
import java.util.List;
import javax.annotation.PostConstruct;
import lombok.Getter;
import lombok.Setter;
import lombok.extern.slf4j.Slf4j;
Expand Down Expand Up @@ -236,6 +237,14 @@ public class ChainBaseManager {
@Autowired
private DbStatService dbStatService;

@Getter
@Setter
private NodeType nodeType;

@Getter
@Setter
private long lowestBlockNum = -1; // except num = 0.

public void closeOneStore(ITronChainBase database) {
logger.info("******** Begin to close {}. ********", database.getName());
try {
Expand Down Expand Up @@ -414,5 +423,28 @@ public static synchronized void init(ChainBaseManager manager) {
AssetUtil.setAccountAssetStore(manager.getAccountAssetStore());
AssetUtil.setDynamicPropertiesStore(manager.getDynamicPropertiesStore());
}

@PostConstruct
private void init() {
this.lowestBlockNum = this.blockIndexStore.getLimitNumber(1, 1).stream()
.map(BlockId::getNum).findFirst().orElse(0L);
this.nodeType = getLowestBlockNum() > 1 ? NodeType.LITE : NodeType.FULL;
}

public boolean isLiteNode() {
return getNodeType() == NodeType.LITE;
}

public enum NodeType {
FULL(0),
LITE(1);

@Getter
private final int type;

NodeType(int type) {
this.type = type;
}
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -46,9 +46,11 @@
import org.tron.common.overlay.message.Message;
import org.tron.common.parameter.CommonParameter;
import org.tron.common.utils.ByteArray;
import org.tron.common.utils.ForkController;
import org.tron.common.utils.ReflectUtils;
import org.tron.common.utils.Sha256Hash;
import org.tron.core.actuator.TransactionFactory;
import org.tron.core.config.Parameter;
import org.tron.core.db.TransactionContext;
import org.tron.core.db.TransactionTrace;
import org.tron.core.exception.BadItemException;
Expand Down Expand Up @@ -213,6 +215,11 @@ public static long getWeight(Permission permission, byte[] address) {
return 0;
}

/**
* make sure ForkController.init(ChainBaseManager) is invoked before invoke this method.
*
* @see ForkController#init(org.tron.core.ChainBaseManager)
*/
public static long checkWeight(Permission permission, List<ByteString> sigs, byte[] hash,
List<ByteString> approveList)
throws SignatureException, PermissionException, SignatureFormatException {
Expand All @@ -237,6 +244,9 @@ public static long checkWeight(Permission permission, List<ByteString> sigs, byt
ByteArray.toHexString(sig.toByteArray()) + " is signed by " + encode58Check(address)
+ " but it is not contained of permission.");
}
if (ForkController.instance().pass(Parameter.ForkBlockVersionEnum.VERSION_4_7_1)) {
base64 = encode58Check(address);
}
if (addMap.containsKey(base64)) {
throw new PermissionException(encode58Check(address) + " has signed twice!");
}
Expand Down
22 changes: 20 additions & 2 deletions chainbase/src/main/java/org/tron/core/db/BlockIndexStore.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package org.tron.core.db;

import java.util.Arrays;
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import lombok.extern.slf4j.Slf4j;
import org.apache.commons.lang3.ArrayUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
Expand All @@ -12,6 +16,7 @@
import org.tron.core.exception.ItemNotFoundException;

@Component
@Slf4j(topic = "DB")
public class BlockIndexStore extends TronStoreWithRevoking<BytesCapsule> {


Expand Down Expand Up @@ -44,4 +49,17 @@ public BytesCapsule get(byte[] key)
}
return new BytesCapsule(value);
}
}

public List<BlockId> getLimitNumber(long startNumber, long limit) {
return pack(revokingDB.getValuesNext(ByteArray.fromLong(startNumber), limit));
}

private List<BlockId> pack(Set<byte[]> values) {
List<BlockId> blocks = new ArrayList<>();
for (byte[] bytes : values) {
blocks.add(new BlockId(Sha256Hash.wrap(bytes)));
}
blocks.sort(Comparator.comparing(BlockId::getNum));
return blocks;
}
}
Loading