Skip to content

Commit bba0678

Browse files
committed
use allowMutiSign proposal instead of creating a new one
1 parent c64d5dd commit bba0678

9 files changed

Lines changed: 18 additions & 52 deletions

File tree

‎src/main/java/org/tron/common/runtime/config/VMConfig.java‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ public class VMConfig {
4949
private static boolean ALLOW_TVM_TRANSFER_TRC10 = false;
5050

5151
@Setter
52-
private static boolean IMPROVE_TRANSFER_TRC10_SECURITY = false;
52+
private static boolean ALLOW_MULTI_SIGN = false;
5353

5454
private VMConfig() {
5555
}
@@ -75,8 +75,8 @@ public static void initVmHardFork() {
7575
ENERGY_LIMIT_HARD_FORK = ForkController.instance().pass(ForkBlockVersionConsts.ENERGY_LIMIT);
7676
//VERSION_3_5_HARD_FORK = ForkController.instance().pass(ForkBlockVersionEnum.VERSION_3_5);
7777
}
78-
public static void initImproveTransferTrc10Security(long allow) {
79-
IMPROVE_TRANSFER_TRC10_SECURITY = allow ==1 ;
78+
public static void initAllowMultiSign(long allow) {
79+
ALLOW_MULTI_SIGN = allow ==1 ;
8080
}
8181

8282
public static void initAllowTvmTransferTrc10(long allow) { ALLOW_TVM_TRANSFER_TRC10 = allow == 1;
@@ -90,8 +90,8 @@ public static boolean allowTvmTransferTrc10() {
9090
return ALLOW_TVM_TRANSFER_TRC10;
9191
}
9292

93-
public static boolean improveTransferTrc10Security() {
94-
return IMPROVE_TRANSFER_TRC10_SECURITY;
93+
public static boolean allowMultiSign() {
94+
return ALLOW_MULTI_SIGN;
9595
}
9696

9797
}

‎src/main/java/org/tron/common/runtime/vm/VM.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -637,7 +637,7 @@ public void step(Program program) {
637637
*/
638638
case ADDRESS: {
639639
DataWord address = program.getContractAddress();
640-
if (VMConfig.improveTransferTrc10Security()) { // improve_transfer_trc10_security proposal
640+
if (VMConfig.allowMultiSign()) { // allowMultiSigns proposal
641641
address = new DataWord(address.getLast20Bytes());
642642
}
643643

@@ -666,7 +666,7 @@ public void step(Program program) {
666666
case ORIGIN: {
667667
DataWord originAddress = program.getOriginAddress();
668668

669-
if (VMConfig.improveTransferTrc10Security()) { //improve_transfer_trc10_security proposal
669+
if (VMConfig.allowMultiSign()) { //allowMultiSign proposal
670670
originAddress = new DataWord(originAddress.getLast20Bytes());
671671
}
672672

@@ -1247,7 +1247,7 @@ public void step(Program program) {
12471247
boolean isTokenTransferMsg = false;
12481248
if (op == CALLTOKEN) {
12491249
tokenId = program.stackPop();
1250-
if (VMConfig.improveTransferTrc10Security()) { // improve_transfer_trc10_security proposal
1250+
if (VMConfig.allowMultiSign()) { // allowMultiSign proposal
12511251
isTokenTransferMsg = true;
12521252
}
12531253
}

‎src/main/java/org/tron/common/runtime/vm/program/Program.java‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1419,7 +1419,7 @@ public interface ProgramOutListener {
14191419
* @param msg
14201420
*/
14211421
public void checkTokenId(MessageCall msg) {
1422-
if(VMConfig.improveTransferTrc10Security()){ //improve_transfer_trc10_security proposal
1422+
if(VMConfig.allowMultiSign()){ //allowMultiSign proposal
14231423
// tokenid should not get Long type overflow
14241424
long tokenId = msg.getTokenId().sValue().longValueExact();
14251425
// tokenId can only be 0 when isTokenTransferMsg == false
@@ -1433,7 +1433,7 @@ public void checkTokenId(MessageCall msg) {
14331433
}
14341434

14351435
public boolean isTokenTransfer(MessageCall msg) {
1436-
if(VMConfig.improveTransferTrc10Security()) { //improve_transfer_trc10_security proposal
1436+
if(VMConfig.allowMultiSign()) { //allowMultiSign proposal
14371437
return msg.isTokenTransferMsg();
14381438
}
14391439
else {
@@ -1442,7 +1442,7 @@ public boolean isTokenTransfer(MessageCall msg) {
14421442
}
14431443

14441444
public void checkTokenIdInTokenBalance(DataWord tokenIdDataWord) {
1445-
if(VMConfig.improveTransferTrc10Security()){ //improve_transfer_trc10_security proposal
1445+
if(VMConfig.allowMultiSign()){ //allowMultiSigns proposal
14461446
// tokenid should not get Long type overflow
14471447
long tokenId = tokenIdDataWord.sValue().longValueExact();
14481448
// or tokenId can only be (MIN_TOKEN_ID, Long.Max]

‎src/main/java/org/tron/common/storage/Value.java‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ public Value(byte[] any, int type) {
4343
System.arraycopy(any, 0, this.any, 0, any.length);
4444
this.type = new Type(type);
4545
} else {
46-
if (VMConfig.improveTransferTrc10Security()) {
46+
if (VMConfig.allowMultiSign()) {
4747
this.type = new Type(VALUE_TYPE_UNKNOWN);
4848
}
4949
}
@@ -58,7 +58,7 @@ private Value(Value value) {
5858
System.arraycopy(value.getAny(), 0, this.any, 0, value.getAny().length);
5959
this.type = value.getType().clone();
6060
} else {
61-
if (VMConfig.improveTransferTrc10Security()) {
61+
if (VMConfig.allowMultiSign()) {
6262
this.type = new Type(VALUE_TYPE_UNKNOWN);
6363
}
6464
}

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

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -327,10 +327,6 @@ public class Args {
327327
@Setter
328328
private long allowTvmTransferTrc10; //committee parameter
329329

330-
@Getter
331-
@Setter
332-
private long improveTransferTrc10Security; //committee parameter
333-
334330
@Getter
335331
@Setter
336332
private int tcpNettyWorkThreadNum;
@@ -469,7 +465,6 @@ public static void clearParam() {
469465
INSTANCE.allowCreationOfContracts = 0;
470466
INSTANCE.allowAdaptiveEnergy = 0;
471467
INSTANCE.allowTvmTransferTrc10 = 0;
472-
INSTANCE.improveTransferTrc10Security = 0;
473468
INSTANCE.allowDelegateResource = 0;
474469
INSTANCE.allowSameTokenName = 0;
475470
INSTANCE.tcpNettyWorkThreadNum = 0;
@@ -789,10 +784,6 @@ public static void setParam(final String[] args, final String confFileName) {
789784
config.hasPath("committee.allowTvmTransferTrc10") ? config
790785
.getInt("committee.allowTvmTransferTrc10") : 0;
791786

792-
INSTANCE.improveTransferTrc10Security =
793-
config.hasPath("committee.improveTransferTrc10Security") ? config
794-
.getInt("committee.improveTransferTrc10Security") : 0;
795-
796787
INSTANCE.tcpNettyWorkThreadNum = config.hasPath("node.tcpNettyWorkThreadNum") ? config
797788
.getInt("node.tcpNettyWorkThreadNum") : 0;
798789

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

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -158,8 +158,6 @@ private static class DynamicResourceProperties {
158158
private static final byte[] AVAILABLE_CONTRACT_TYPE = "AVAILABLE_CONTRACT_TYPE".getBytes();
159159
private static final byte[] ACTIVE_DEFAULT_OPERATIONS = "ACTIVE_DEFAULT_OPERATIONS".getBytes();
160160

161-
private static final byte[] IMPROVE_TRANSFER_TRC10_SECURITY = "IMPROVE_TRANSFER_TRC10_SECURITY".getBytes();
162-
163161

164162
@Autowired
165163
private DynamicPropertiesStore(@Value("properties") String dbName) {
@@ -471,12 +469,6 @@ private DynamicPropertiesStore(@Value("properties") String dbName) {
471469
this.saveAllowTvmTransferTrc10(Args.getInstance().getAllowTvmTransferTrc10());
472470
}
473471

474-
try {
475-
this.getImproveTransferTrc10Security();
476-
} catch (IllegalArgumentException e) {
477-
this.saveImproveTransferTrc10Security(Args.getInstance().getImproveTransferTrc10Security());
478-
}
479-
480472
try {
481473
this.getAvailableContractType();
482474
} catch (IllegalArgumentException e) {
@@ -1214,19 +1206,6 @@ public long getAllowTvmTransferTrc10() {
12141206
() -> new IllegalArgumentException("not found ALLOW_TVM_TRANSFER_TRC10"));
12151207
}
12161208

1217-
public void saveImproveTransferTrc10Security(long value) {
1218-
this.put(IMPROVE_TRANSFER_TRC10_SECURITY,
1219-
new BytesCapsule(ByteArray.fromLong(value)));
1220-
}
1221-
1222-
public long getImproveTransferTrc10Security() {
1223-
return Optional.ofNullable(getUnchecked(IMPROVE_TRANSFER_TRC10_SECURITY))
1224-
.map(BytesCapsule::getData)
1225-
.map(ByteArray::toLong)
1226-
.orElseThrow(
1227-
() -> new IllegalArgumentException("not found IMPROVE_TRANSFER_TRC10_SECURITY"));
1228-
}
1229-
12301209
public void saveAvailableContractType(byte[] value) {
12311210
this.put(AVAILABLE_CONTRACT_TYPE,
12321211
new BytesCapsule(value));

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1191,7 +1191,7 @@ public boolean processTransaction(final TransactionCapsule trxCap, BlockCapsule
11911191
consumeBandwidth(trxCap, trace);
11921192

11931193
VMConfig.initVmHardFork();
1194-
VMConfig.initImproveTransferTrc10Security(dynamicPropertiesStore.getImproveTransferTrc10Security());
1194+
VMConfig.initAllowMultiSign(dynamicPropertiesStore.getAllowMultiSign());
11951195
VMConfig.initAllowTvmTransferTrc10(dynamicPropertiesStore.getAllowTvmTransferTrc10());
11961196
trace.init(blockCap, eventPluginLoaded);
11971197
trace.checkIsConstant();

‎src/main/java/org/tron/core/witness/ProposalController.java‎

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,6 @@ public void setDynamicParameters(ProposalCapsule proposalCapsule) {
194194
}
195195
break;
196196
}
197-
case (22): {
198-
manager.getDynamicPropertiesStore().saveImproveTransferTrc10Security(entry.getValue());
199-
break;
200-
}
201197

202198
default:
203199
break;

‎src/test/java/org/tron/common/runtime/vm/CreateContractSuicideTest.java‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ function fun() {
105105

106106

107107
@Test
108-
public void testAAfterTransferTrc10SecurityProposal()
108+
public void testAAfterAllowMultiSignProposal()
109109
throws ContractExeException, ReceiptCheckErrException, VMIllegalException, ContractValidateException {
110110
byte[] stats = new byte[27];
111111
Arrays.fill(stats, (byte) 1);
@@ -116,7 +116,7 @@ public void testAAfterTransferTrc10SecurityProposal()
116116
.statsByVersion(ForkBlockVersionEnum.VERSION_3_2_2.getValue(), stats);
117117
this.manager.getDynamicPropertiesStore()
118118
.statsByVersion(ForkBlockVersionEnum.VERSION_3_5.getValue(), stats);
119-
VMConfig.initImproveTransferTrc10Security(1);
119+
VMConfig.initAllowMultiSign(1);
120120

121121
Transaction aTrx = TVMTestUtils.generateDeploySmartContractAndGetTransaction(
122122
"testA", address, abi, aCode, value, fee, consumeUserResourcePercent, null, engeryLimit);
@@ -145,9 +145,9 @@ public void testAAfterTransferTrc10SecurityProposal()
145145
}
146146

147147
@Test
148-
public void testABeforeTransferTrc10SecurityProposal()
148+
public void testABeforeAllowMultiSignProposal()
149149
throws ContractExeException, ReceiptCheckErrException, VMIllegalException, ContractValidateException {
150-
VMConfig.initImproveTransferTrc10Security(0);
150+
VMConfig.initAllowMultiSign(0);
151151
byte[] address = Hex.decode(OWNER_ADDRESS);
152152
Transaction aTrx = TVMTestUtils.generateDeploySmartContractAndGetTransaction(
153153
"testA", address, abi, aCode, value, fee, consumeUserResourcePercent, null, engeryLimit);

0 commit comments

Comments
 (0)