Skip to content

Commit 5f118df

Browse files
committed
refactor(*): remove runtime-inactive assert statements from non-test code
1 parent 77c8e33 commit 5f118df

6 files changed

Lines changed: 0 additions & 21 deletions

File tree

actuator/src/main/java/org/tron/core/vm/repository/RepositoryImpl.java

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -900,7 +900,6 @@ private long increase(long lastUsage, long usage, long lastTime, long now, long
900900
long averageUsage = divideCeil(usage * precision, windowSize);
901901

902902
if (lastTime != now) {
903-
assert now > lastTime;
904903
if (lastTime + windowSize > now) {
905904
long delta = now - lastTime;
906905
double decay = (windowSize - delta) / (double) windowSize;
@@ -930,8 +929,6 @@ public long calculateGlobalEnergyLimit(AccountCapsule accountCapsule) {
930929
long totalEnergyLimit = getDynamicPropertiesStore().getTotalEnergyCurrentLimit();
931930
long totalEnergyWeight = getDynamicPropertiesStore().getTotalEnergyWeight();
932931

933-
assert totalEnergyWeight > 0;
934-
935932
return (long) (energyWeight * ((double) totalEnergyLimit / totalEnergyWeight));
936933
}
937934

chainbase/src/main/java/org/tron/common/zksnark/MerklePath.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,6 @@ private static long convertVectorToLong(List<Boolean> v) throws ZksnarkException
7575
}
7676

7777
public byte[] encode() throws ZksnarkException {
78-
assert (authenticationPath.size() == index.size());
7978
List<List<Byte>> pathByteList = Lists.newArrayList();
8079
long indexLong; // 64
8180
for (int i = 0; i < authenticationPath.size(); i++) {

chainbase/src/main/java/org/tron/core/db/EnergyProcessor.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -153,7 +153,6 @@ public long calculateGlobalEnergyLimit(AccountCapsule accountCapsule) {
153153
if (dynamicPropertiesStore.allowNewReward() && totalEnergyWeight <= 0) {
154154
return 0;
155155
} else {
156-
assert totalEnergyWeight > 0;
157156
}
158157
return (long) (energyWeight * ((double) totalEnergyLimit / totalEnergyWeight));
159158
}
@@ -187,4 +186,3 @@ private long getHeadSlot() {
187186

188187
}
189188

190-

chainbase/src/main/java/org/tron/core/db/ResourceProcessor.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,6 @@ protected long increase(long lastUsage, long usage, long lastTime, long now, lon
4949
long averageUsage = divideCeil(usage * precision, windowSize);
5050

5151
if (lastTime != now) {
52-
assert now > lastTime;
5352
if (lastTime + windowSize > now) {
5453
long delta = now - lastTime;
5554
double decay = (windowSize - delta) / (double) windowSize;

crypto/src/main/java/org/tron/common/crypto/Blake2bfMessageDigest.java

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ public static class Blake2bfDigest implements Digest {
7979
// for tests
8080
Blake2bfDigest(
8181
final long[] h, final long[] m, final long[] t, final boolean f, final long rounds) {
82-
assert rounds <= 4294967295L; // uint max value
8382
buffer = new byte[MESSAGE_LENGTH_BYTES];
8483
bufferPos = 0;
8584

@@ -269,4 +268,3 @@ private void mix(
269268
}
270269
}
271270
}
272-

framework/src/main/java/org/tron/core/trie/TrieImpl.java

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -758,7 +758,6 @@ private void parse() {
758758

759759
public Node branchNodeGetChild(int hex) {
760760
parse();
761-
assert getType() == NodeType.BranchNode;
762761
Object n = children[hex];
763762
if (n == null && parsedRlp != null) {
764763
if (parsedRlp.isList(hex)) {
@@ -778,15 +777,13 @@ public Node branchNodeGetChild(int hex) {
778777

779778
public Node branchNodeSetChild(int hex, Node node) {
780779
parse();
781-
assert getType() == NodeType.BranchNode;
782780
children[hex] = node == null ? NULL_NODE : node;
783781
dirty = true;
784782
return this;
785783
}
786784

787785
public byte[] branchNodeGetValue() {
788786
parse();
789-
assert getType() == NodeType.BranchNode;
790787
Object n = children[16];
791788
if (n == null && parsedRlp != null) {
792789
byte[] bytes = parsedRlp.getBytes(16);
@@ -802,15 +799,13 @@ public byte[] branchNodeGetValue() {
802799

803800
public Node branchNodeSetValue(byte[] val) {
804801
parse();
805-
assert getType() == NodeType.BranchNode;
806802
children[16] = val == null ? NULL_NODE : val;
807803
dirty = true;
808804
return this;
809805
}
810806

811807
public int branchNodeCompactIdx() {
812808
parse();
813-
assert getType() == NodeType.BranchNode;
814809
int cnt = 0;
815810
int idx = -1;
816811
for (int i = 0; i < 16; i++) {
@@ -827,7 +822,6 @@ public int branchNodeCompactIdx() {
827822

828823
public boolean branchNodeCanCompact() {
829824
parse();
830-
assert getType() == NodeType.BranchNode;
831825
int cnt = 0;
832826
for (int i = 0; i < 16; i++) {
833827
cnt += branchNodeGetChild(i) == null ? 0 : 1;
@@ -840,39 +834,33 @@ public boolean branchNodeCanCompact() {
840834

841835
public TrieKey kvNodeGetKey() {
842836
parse();
843-
assert getType() != NodeType.BranchNode;
844837
return (TrieKey) children[0];
845838
}
846839

847840
public Node kvNodeGetChildNode() {
848841
parse();
849-
assert getType() == NodeType.KVNodeNode;
850842
return (Node) children[1];
851843
}
852844

853845
public byte[] kvNodeGetValue() {
854846
parse();
855-
assert getType() == NodeType.KVNodeValue;
856847
return (byte[]) children[1];
857848
}
858849

859850
public Node kvNodeSetValue(byte[] value) {
860851
parse();
861-
assert getType() == NodeType.KVNodeValue;
862852
children[1] = value;
863853
dirty = true;
864854
return this;
865855
}
866856

867857
public Object kvNodeGetValueOrNode() {
868858
parse();
869-
assert getType() != NodeType.BranchNode;
870859
return children[1];
871860
}
872861

873862
public Node kvNodeSetValueOrNode(Object valueOrNode) {
874863
parse();
875-
assert getType() != NodeType.BranchNode;
876864
children[1] = valueOrNode;
877865
dirty = true;
878866
return this;

0 commit comments

Comments
 (0)