Skip to content

Commit d7b976f

Browse files
committed
feat(*): disable market transaction
1 parent 114bbec commit d7b976f

File tree

2 files changed

+26
-3
lines changed

2 files changed

+26
-3
lines changed

actuator/src/main/java/org/tron/core/utils/ProposalUtil.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,8 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
356356
break;
357357
}
358358
case ALLOW_MARKET_TRANSACTION: {
359-
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)) {
359+
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_1)
360+
|| forkController.pass(ForkBlockVersionEnum.VERSION_4_8_1)) {
360361
throw new ContractValidateException(
361362
"Bad chain parameter id [ALLOW_MARKET_TRANSACTION]");
362363
}

framework/src/test/java/org/tron/core/actuator/utils/ProposalUtilTest.java

Lines changed: 24 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,8 @@
11
package org.tron.core.actuator.utils;
22

3+
import static org.junit.Assert.assertEquals;
4+
import static org.junit.Assert.assertThrows;
5+
36
import com.google.protobuf.ByteString;
47
import java.util.ArrayList;
58
import java.util.Arrays;
@@ -11,6 +14,7 @@
1114
import org.junit.Assert;
1215
import org.junit.BeforeClass;
1316
import org.junit.Test;
17+
import org.junit.function.ThrowingRunnable;
1418
import org.tron.common.BaseTest;
1519
import org.tron.common.utils.ByteArray;
1620
import org.tron.common.utils.ForkController;
@@ -438,9 +442,28 @@ public void validateCheck() {
438442
testAllowTvmCancunProposal();
439443

440444
testAllowTvmBlobProposal();
441-
445+
ThrowingRunnable r0 = () -> ProposalUtil.validator(dynamicPropertiesStore, forkUtils,
446+
ProposalType.ALLOW_MARKET_TRANSACTION.getCode(), 0);
447+
ThrowingRunnable r1 = () -> ProposalUtil.validator(dynamicPropertiesStore, forkUtils,
448+
ProposalType.ALLOW_MARKET_TRANSACTION.getCode(), 1);
449+
ContractValidateException thrown = assertThrows(ContractValidateException.class, r1);
450+
assertEquals("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]", thrown.getMessage());
451+
452+
forkUtils.getManager().getDynamicPropertiesStore().statsByVersion(
453+
ForkBlockVersionEnum.VERSION_4_1.getValue(), stats);
454+
try {
455+
r1.run();
456+
} catch (Throwable e) {
457+
Assert.fail(e.getMessage());
458+
}
459+
thrown = assertThrows(ContractValidateException.class, r0);
460+
assertEquals("This value[ALLOW_MARKET_TRANSACTION] is only allowed to be 1",
461+
thrown.getMessage());
442462
testAllowTvmSelfdestructRestrictionProposal();
443463

464+
thrown = assertThrows(ContractValidateException.class, r1);
465+
assertEquals("Bad chain parameter id [ALLOW_MARKET_TRANSACTION]", thrown.getMessage());
466+
444467
forkUtils.getManager().getDynamicPropertiesStore()
445468
.statsByVersion(ForkBlockVersionEnum.ENERGY_LIMIT.getValue(), stats);
446469
forkUtils.reset();
@@ -710,7 +733,6 @@ private void testAllowTvmSelfdestructRestrictionProposal() {
710733
"[ALLOW_TVM_SELFDESTRUCT_RESTRICTION] has been valid, no need to propose again",
711734
e.getMessage());
712735
}
713-
714736
}
715737

716738
@Test

0 commit comments

Comments
 (0)