diff --git a/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java b/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java index 62e7ce6ec08..84409b8af61 100644 --- a/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java +++ b/actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java @@ -924,7 +924,6 @@ private long increase(long lastUsage, long usage, long lastTime, long now, long } if (lastTime != now) { - assert now > lastTime; if (lastTime + windowSize > now) { long delta = now - lastTime; double decay = (windowSize - delta) / (double) windowSize; @@ -973,8 +972,6 @@ public long calculateGlobalEnergyLimit(AccountCapsule accountCapsule) { long totalEnergyLimit = getDynamicPropertiesStore().getTotalEnergyCurrentLimit(); long totalEnergyWeight = getDynamicPropertiesStore().getTotalEnergyWeight(); - assert totalEnergyWeight > 0; - if (hardenResourceCalculation()) { return BigInteger.valueOf(energyWeight) .multiply(BigInteger.valueOf(totalEnergyLimit)) diff --git a/chainbase/src/main/java/org/tron/common/zksnark/MerklePath.java b/chainbase/src/main/java/org/tron/common/zksnark/MerklePath.java index 96d6ceac893..7beba9f9eff 100644 --- a/chainbase/src/main/java/org/tron/common/zksnark/MerklePath.java +++ b/chainbase/src/main/java/org/tron/common/zksnark/MerklePath.java @@ -75,7 +75,6 @@ private static long convertVectorToLong(List v) throws ZksnarkException } public byte[] encode() throws ZksnarkException { - assert (authenticationPath.size() == index.size()); List> pathByteList = Lists.newArrayList(); long indexLong; // 64 for (int i = 0; i < authenticationPath.size(); i++) { diff --git a/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java b/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java index 0c429178636..267abbf06c4 100644 --- a/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java +++ b/chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java @@ -155,8 +155,6 @@ public long calculateGlobalEnergyLimit(AccountCapsule accountCapsule) { long totalEnergyWeight = dynamicPropertiesStore.getTotalEnergyWeight(); if (dynamicPropertiesStore.allowNewReward() && totalEnergyWeight <= 0) { return 0; - } else { - assert totalEnergyWeight > 0; } if (hardenCalculation()) { return calculateGlobalLimitV1(frozeBalance, totalEnergyLimit, totalEnergyWeight); @@ -205,4 +203,3 @@ private long scaleByRate(long value, long numerator, long denominator) { } } - diff --git a/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java b/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java index 6706c430084..8b6f96504ec 100644 --- a/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java +++ b/chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java @@ -63,7 +63,6 @@ protected long increase(long lastUsage, long usage, long lastTime, long now, lon } if (lastTime != now) { - assert now > lastTime; if (lastTime + windowSize > now) { long delta = now - lastTime; double decay = (windowSize - delta) / (double) windowSize; diff --git a/common/src/main/java/org/tron/core/config/args/CommitteeConfig.java b/common/src/main/java/org/tron/core/config/args/CommitteeConfig.java index 660fa289e3b..2696c220231 100644 --- a/common/src/main/java/org/tron/core/config/args/CommitteeConfig.java +++ b/common/src/main/java/org/tron/core/config/args/CommitteeConfig.java @@ -1,11 +1,14 @@ package org.tron.core.config.args; +import static org.tron.core.exception.TronError.ErrCode.PARAMETER_INIT; + import com.typesafe.config.Config; import com.typesafe.config.ConfigBeanFactory; import com.typesafe.config.ConfigValue; import lombok.Getter; import lombok.Setter; import lombok.extern.slf4j.Slf4j; +import org.tron.core.exception.TronError; /** * Committee (governance) configuration bean. @@ -160,11 +163,11 @@ private void postProcess() { // cross-field: allowOldRewardOpt requires at least one reward/vote flag if (allowOldRewardOpt == 1 && allowNewRewardAlgorithm != 1 && allowNewReward != 1 && allowTvmVote != 1) { - throw new IllegalArgumentException( + throw new TronError( "At least one of the following proposals is required to be opened first: " + "committee.allowNewRewardAlgorithm = 1" + " or committee.allowNewReward = 1" - + " or committee.allowTvmVote = 1."); + + " or committee.allowTvmVote = 1.", PARAMETER_INIT); } } } diff --git a/common/src/test/java/org/tron/core/config/args/CommitteeConfigTest.java b/common/src/test/java/org/tron/core/config/args/CommitteeConfigTest.java index 559198100fb..4e3cff119d5 100644 --- a/common/src/test/java/org/tron/core/config/args/CommitteeConfigTest.java +++ b/common/src/test/java/org/tron/core/config/args/CommitteeConfigTest.java @@ -5,6 +5,7 @@ import com.typesafe.config.Config; import com.typesafe.config.ConfigFactory; import org.junit.Test; +import org.tron.core.exception.TronError; public class CommitteeConfigTest { @@ -57,7 +58,7 @@ public void testDynamicEnergyThresholdClamped() { .getDynamicEnergyThreshold()); } - @Test(expected = IllegalArgumentException.class) + @Test(expected = TronError.class) public void testAllowOldRewardOptWithoutPrerequisites() { CommitteeConfig.fromConfig(withRef("committee { allowOldRewardOpt = 1 }")); } diff --git a/framework/src/main/java/org/tron/core/config/args/Args.java b/framework/src/main/java/org/tron/core/config/args/Args.java index 0bca242606e..8d56a2193f0 100644 --- a/framework/src/main/java/org/tron/core/config/args/Args.java +++ b/framework/src/main/java/org/tron/core/config/args/Args.java @@ -1045,8 +1045,9 @@ private static void loadDnsPublishParameters(NodeConfig.DnsConfig dns, String serverType = dns.getServerType(); if (StringUtils.isNotEmpty(serverType)) { if (!"aws".equalsIgnoreCase(serverType) && !"aliyun".equalsIgnoreCase(serverType)) { - throw new IllegalArgumentException( - "Check node.dns.serverType, must be aws or aliyun"); + throw new TronError( + "Check node.dns.serverType, must be aws or aliyun", + TronError.ErrCode.PARAMETER_INIT); } if ("aws".equalsIgnoreCase(serverType)) { publishConfig.setDnsType(DnsType.AwsRoute53); @@ -1088,7 +1089,8 @@ private static void loadDnsPublishParameters(NodeConfig.DnsConfig dns, } private static void logEmptyError(String arg) { - throw new IllegalArgumentException(String.format("Check %s, must not be null or empty", arg)); + throw new TronError(String.format("Check %s, must not be null or empty", arg), + TronError.ErrCode.PARAMETER_INIT); } // createTriggerConfig removed — logic moved to applyEventConfig() @@ -1315,4 +1317,3 @@ private static Map getOptionGroup() { return optionGroupMap; } } - diff --git a/framework/src/main/java/org/tron/core/trie/TrieImpl.java b/framework/src/main/java/org/tron/core/trie/TrieImpl.java index 586c3b2b893..f4d2d73a36f 100644 --- a/framework/src/main/java/org/tron/core/trie/TrieImpl.java +++ b/framework/src/main/java/org/tron/core/trie/TrieImpl.java @@ -762,7 +762,6 @@ private void parse() { public Node branchNodeGetChild(int hex) { parse(); - assert getType() == NodeType.BranchNode; Object n = children[hex]; if (n == null && parsedRlp != null) { if (parsedRlp.isList(hex)) { @@ -782,7 +781,6 @@ public Node branchNodeGetChild(int hex) { public Node branchNodeSetChild(int hex, Node node) { parse(); - assert getType() == NodeType.BranchNode; children[hex] = node == null ? NULL_NODE : node; dirty = true; return this; @@ -790,7 +788,6 @@ public Node branchNodeSetChild(int hex, Node node) { public byte[] branchNodeGetValue() { parse(); - assert getType() == NodeType.BranchNode; Object n = children[16]; if (n == null && parsedRlp != null) { byte[] bytes = parsedRlp.getBytes(16); @@ -806,7 +803,6 @@ public byte[] branchNodeGetValue() { public Node branchNodeSetValue(byte[] val) { parse(); - assert getType() == NodeType.BranchNode; children[16] = val == null ? NULL_NODE : val; dirty = true; return this; @@ -814,7 +810,6 @@ public Node branchNodeSetValue(byte[] val) { public int branchNodeCompactIdx() { parse(); - assert getType() == NodeType.BranchNode; int cnt = 0; int idx = -1; for (int i = 0; i < 16; i++) { @@ -831,7 +826,6 @@ public int branchNodeCompactIdx() { public boolean branchNodeCanCompact() { parse(); - assert getType() == NodeType.BranchNode; int cnt = 0; for (int i = 0; i < 16; i++) { cnt += branchNodeGetChild(i) == null ? 0 : 1; @@ -844,25 +838,21 @@ public boolean branchNodeCanCompact() { public TrieKey kvNodeGetKey() { parse(); - assert getType() != NodeType.BranchNode; return (TrieKey) children[0]; } public Node kvNodeGetChildNode() { parse(); - assert getType() == NodeType.KVNodeNode; return (Node) children[1]; } public byte[] kvNodeGetValue() { parse(); - assert getType() == NodeType.KVNodeValue; return (byte[]) children[1]; } public Node kvNodeSetValue(byte[] value) { parse(); - assert getType() == NodeType.KVNodeValue; children[1] = value; dirty = true; return this; @@ -870,13 +860,11 @@ public Node kvNodeSetValue(byte[] value) { public Object kvNodeGetValueOrNode() { parse(); - assert getType() != NodeType.BranchNode; return children[1]; } public Node kvNodeSetValueOrNode(Object valueOrNode) { parse(); - assert getType() != NodeType.BranchNode; if (valueOrNode instanceof byte[] && children[1] instanceof byte[] && (children[1] == valueOrNode || Arrays.equals((byte[]) children[1], (byte[]) valueOrNode))) {