Skip to content

Commit 1acae25

Browse files
Merge pull request #459 from tronprotocol/SunNetwork-v1.5.2
Release for sun-sdk v1.5.2
2 parents 5c37d6d + cb02cdd commit 1acae25

File tree

22 files changed

+405
-180
lines changed

22 files changed

+405
-180
lines changed

dapp-chain/side-chain/actuator/src/main/java/org/tron/core/actuator/VMActuator.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,9 @@ public class VMActuator implements Actuator2 {
8484
@Setter
8585
private boolean isConstantCall = false;
8686

87+
@Getter
88+
private boolean isSideChainGateWayContractCall;
89+
8790
@Setter
8891
private boolean enableEventLinstener;
8992

@@ -117,6 +120,10 @@ public void validate(Object object) throws ContractValidateException {
117120

118121
//Load Config
119122
ConfigLoader.load(context.getStoreFactory());
123+
if (context.getTrxCap().checkIfSideChainGateWayContractCall(context.getStoreFactory()
124+
.getChainBaseManager().getDynamicPropertiesStore())) {
125+
isSideChainGateWayContractCall = true;
126+
}
120127
trx = context.getTrxCap().getInstance();
121128
blockCap = context.getBlockCap();
122129
//Route Type
@@ -490,7 +497,9 @@ private void call()
490497
if (isConstantCall) {
491498
energyLimit = Constant.ENERGY_LIMIT_IN_CONSTANT_TX;
492499
} else if (!VMConfig.isVmResourceChargingOn()) {
493-
energyLimit = 10_000_000;
500+
energyLimit = Constant.ENERGY_LIMIT_IN_CHARGING_OFF;
501+
} else if (VMConfig.isAllowDapp152() && isSideChainGateWayContractCall()) {
502+
energyLimit = Constant.ENERGY_LIMIT_ALLOW_DAPP_152;
494503
} else {
495504
AccountCapsule creator = repository
496505
.getAccount(deployedContract.getInstance().getOriginAddress().toByteArray());

dapp-chain/side-chain/actuator/src/main/java/org/tron/core/utils/ProposalUtil.java

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -302,7 +302,7 @@ public static void validator(ChainBaseManager manager, ForkUtils forkUtils,
302302
* Side Chain proposals
303303
*/
304304
case ALLOW_CHARGING_FEE: {
305-
if (value != 1 && Long.valueOf(value) != 0) {
305+
if (value != 1 && value != 0) {
306306
throw new ContractValidateException(
307307
"this value[ENERGY_CHARGING_SWITCH] is only allowed to be 1 or 0");
308308
}
@@ -471,6 +471,16 @@ public static void validator(ChainBaseManager manager, ForkUtils forkUtils,
471471
}
472472
break;
473473
}
474+
case ALLOW_DAPP_152: {
475+
if (!forkUtils.pass(ForkBlockVersionEnum.DAPP_CHAIN_1_5_2)) {
476+
throw new ContractValidateException(BAD_PARAM_ID);
477+
}
478+
if (value != 1) {
479+
throw new ContractValidateException(
480+
"this value[ALLOW_DAPP_152] is only allowed to be 1");
481+
}
482+
break;
483+
}
474484
default:
475485
break;
476486
}
@@ -528,7 +538,8 @@ public enum ProposalType {
528538
FUND_DISTRIBUTION_DAYS(1_000_009), // 1, 1_000_009
529539
WITNESS_REWARD_PERCENTAGE(1_000_010), // number, 1_000_010
530540
WITNESS_MAX_NUMBER(1_000_011), // number, 1_000_011
531-
ALLOW_UPDATE_GATEWAY102(1_000_012); // 1 (hard fork), 1_000_012
541+
ALLOW_UPDATE_GATEWAY102(1_000_012), // 1 (hard fork), 1_000_012
542+
ALLOW_DAPP_152(1_000_013);
532543
//ALLOW_UPDATE_SUN_NETWORK_150(1_000_013); // 1 (hard fork), 1_000_013
533544

534545
private long code;
@@ -618,6 +629,7 @@ public static long validateStringContent(ProposalType proposalType, String conte
618629
case WITNESS_REWARD_PERCENTAGE:
619630
case WITNESS_MAX_NUMBER:
620631
case ALLOW_UPDATE_GATEWAY102:
632+
case ALLOW_DAPP_152:
621633
//case ALLOW_UPDATE_SUN_NETWORK_150:
622634
try {
623635
value = Long.valueOf(content);

dapp-chain/side-chain/actuator/src/main/java/org/tron/core/vm/config/VMConfig.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ public class VMConfig {
5858
@Setter
5959
public static boolean isAllowUpdateGateway102 = false;
6060

61+
@Getter
62+
@Setter
63+
public static boolean isAllowDapp152 = false;
64+
6165
private VMConfig() {
6266
}
6367

@@ -76,6 +80,7 @@ public static boolean vmTraceCompressed() {
7680
public static void handleProposalInVM(DynamicPropertiesStore dynamicPropertiesStore) {
7781
isVmResourceChargingOn = isChargingResourceProposalOn(dynamicPropertiesStore);
7882
isAllowUpdateGateway102 = isAllowUpdateGatewayV102(dynamicPropertiesStore);
83+
isAllowDapp152 = isAllowDapp152(dynamicPropertiesStore);
7984
}
8085

8186
public static void initVmHardFork(boolean pass) {
@@ -131,4 +136,8 @@ private static boolean isAllowUpdateGatewayV102(DynamicPropertiesStore dynamicPr
131136
return dynamicPropertiesStore.getAllowUpdateGatewayV102() == 1;
132137
}
133138

139+
private static boolean isAllowDapp152(DynamicPropertiesStore dynamicPropertiesStore) {
140+
return dynamicPropertiesStore.getAllowDappV152() == 1;
141+
}
142+
134143
}

dapp-chain/side-chain/chainbase/src/main/java/org/tron/common/utils/DBConfig.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -197,6 +197,10 @@ public class DBConfig {
197197
@Setter
198198
private static long updateGateway_v1_0_2; //committee parameter
199199

200+
@Getter
201+
@Setter
202+
private static long allowDapp_v1_5_2;
203+
200204

201205
public static boolean getEnergyLimitHardFork() {
202206
return ENERGY_LIMIT_HARD_FORK;

dapp-chain/side-chain/chainbase/src/main/java/org/tron/core/config/Parameter.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ public class ChainConstant {
1818
public static final int SINGLE_REPEAT = 1;
1919
public static final int BLOCK_FILLED_SLOTS_NUMBER = 128;
2020
public static final int MAX_FROZEN_NUMBER = 1;
21-
public static final int BLOCK_VERSION = 10001;
21+
public static final int BLOCK_VERSION = 10002;
2222
}
2323

2424
public class NodeConstant {

dapp-chain/side-chain/chainbase/src/main/java/org/tron/core/config/args/Parameter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,8 @@ public enum ForkBlockVersionEnum {
1010
VERSION_3_5(7),
1111
VERSION_3_6(8),
1212
DAPP_CHAIN_1_0_2(10000),
13-
DAPP_CHAIN_1_5_0(10001);
13+
DAPP_CHAIN_1_5_0(10001),
14+
DAPP_CHAIN_1_5_2(10002);
1415

1516
@Getter
1617
private int value;

dapp-chain/side-chain/chainbase/src/main/java/org/tron/core/store/DynamicPropertiesStore.java

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
import java.util.Arrays;
66
import java.util.List;
77
import java.util.Optional;
8+
import java.util.stream.Collectors;
89
import java.util.stream.IntStream;
910
import lombok.extern.slf4j.Slf4j;
1011
import org.joda.time.DateTime;
@@ -234,6 +235,9 @@ public class DynamicPropertiesStore extends TronStoreWithRevoking<BytesCapsule>
234235
private static final byte[] UPDATE_GATEWAY_V_1_0_2 = "UPDATE_GATEWAY_V_1_0_2"
235236
.getBytes();
236237

238+
// for 1_000_013 proposl
239+
private static final byte[] ALLOW_DAPP_V_1_5_2 = "ALLOW_DAPP_V_1_5_2".getBytes();
240+
237241
@Autowired
238242
private DynamicPropertiesStore(@Value("properties") String dbName) {
239243
super(dbName);
@@ -888,6 +892,12 @@ private DynamicPropertiesStore(@Value("properties") String dbName) {
888892
this.saveAllowUpdateGatewayV102(DBConfig.getUpdateGateway_v1_0_2());
889893
}
890894

895+
try {
896+
this.getAllowDappV152();
897+
} catch (IllegalArgumentException e) {
898+
this.saveAllowDappV152(DBConfig.getAllowDapp_v1_5_2());
899+
}
900+
891901
}
892902

893903
public String intArrayToString(int[] a) {
@@ -2476,6 +2486,19 @@ public long getAllowUpdateGatewayV102() {
24762486
.orElseThrow(() -> new IllegalArgumentException("not found UPDATE_GATEWAY_V_1_0_2"));
24772487
}
24782488

2489+
public void saveAllowDappV152(long value) {
2490+
this.put(ALLOW_DAPP_V_1_5_2,
2491+
new BytesCapsule(ByteArray.fromLong(value)));
2492+
}
2493+
2494+
public long getAllowDappV152() {
2495+
return Optional.ofNullable(getUnchecked(ALLOW_DAPP_V_1_5_2))
2496+
.map(BytesCapsule::getData)
2497+
.map(ByteArray::toLong)
2498+
2499+
.orElseThrow(() -> new IllegalArgumentException("not found UPDATE_GATEWAY_V_1_0_2"));
2500+
}
2501+
24792502
public void saveProposalExpireTime(long proposalExpireTime) {
24802503
logger.debug("PROPOSAL_EXPIRE_TIME:" + proposalExpireTime);
24812504
this.put(PROPOSAL_EXPIRE_TIME,

dapp-chain/side-chain/common/src/main/java/org/tron/core/Constant.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,9 @@ public class Constant {
3535
public static final long MAX_RESULT_SIZE_IN_TX = 64; // max 8 * 8 items in result
3636
public static final long PB_DEFAULT_ENERGY_LIMIT = 0L;
3737
public static final long CREATOR_DEFAULT_ENERGY_LIMIT = 1000 * 10_000L;
38+
public static final long ENERGY_LIMIT_IN_CHARGING_OFF = 10_000_000L;
39+
public static final long ENERGY_LIMIT_ALLOW_DAPP_152 = 100 * 1_000_000L;
40+
3841

3942

4043
// Numbers

dapp-chain/side-chain/framework/src/main/java/org/tron/core/Wallet.java

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1065,6 +1065,12 @@ public Protocol.SideChainParameters getSideChainParameters() {
10651065
.setValue(String
10661066
.valueOf(dbManager.getDynamicPropertiesStore().getAllowUpdateGatewayV102()))
10671067
.build());
1068+
builder.addChainParameter(
1069+
Protocol.SideChainParameters.SideChainParameter.newBuilder()
1070+
.setKey("getAllowDapp_v1_0_5")
1071+
.setValue(String
1072+
.valueOf(dbManager.getDynamicPropertiesStore().getAllowDappV152()))
1073+
.build());
10681074
builder.addChainParameter(
10691075
Protocol.SideChainParameters.SideChainParameter.newBuilder()
10701076
.setKey("getAllowTvmSolidity059")

dapp-chain/side-chain/framework/src/main/java/org/tron/core/config/args/Args.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -600,6 +600,10 @@ public class Args extends CommonParameter {
600600
@Setter
601601
private long updateGateway_v1_0_2; //committee parameter
602602

603+
@Getter
604+
@Setter
605+
private int allowDapp_v1_0_5;
606+
603607
@Autowired(required = false)
604608
@Getter
605609
private static ConcurrentHashMap<Long, List<ContractLogTrigger>>
@@ -708,6 +712,7 @@ public static void clearParam() {
708712
INSTANCE.voteSwitch = 0;
709713
INSTANCE.witnessMaxActiveNum = 27;
710714
INSTANCE.updateGateway_v1_0_2 = 0;
715+
INSTANCE.allowDapp_v1_0_5 = 0;
711716
}
712717

713718
/**
@@ -1212,6 +1217,10 @@ public static void setParam(final String[] args, final String confFileName) {
12121217
config.hasPath("committee.chargingSwitchOn") ? config
12131218
.getInt("committee.chargingSwitchOn") : 0;
12141219

1220+
INSTANCE.allowDapp_v1_0_5 =
1221+
config.hasPath("committee.allowDapp152") ? config
1222+
.getInt("committee.allowDapp152") : 0;
1223+
12151224
INSTANCE.sideChainChargingType =
12161225
config.hasPath("sidechain.chargingType") ? config
12171226
.getInt("sidechain.chargingType") : 0;
@@ -1702,7 +1711,7 @@ public static void initDBConfig(Args cfgArgs) {
17021711
DBConfig.setVoteSwitch(cfgArgs.getVoteSwitch());
17031712
DBConfig.setWitnessMaxActiveNum(cfgArgs.getWitnessMaxActiveNum());
17041713
DBConfig.setUpdateGateway_v1_0_2(cfgArgs.getUpdateGateway_v1_0_2());
1705-
1714+
DBConfig.setAllowDapp_v1_5_2(cfgArgs.getAllowDapp_v1_0_5());
17061715

17071716
}
17081717

0 commit comments

Comments
 (0)