Skip to content

Commit 06016cc

Browse files
authored
Merge pull request #5250 from 317787106/feature/merge_472_develop
merge release_v4.7.2 into develop
2 parents 40b7e1c + dce0e65 commit 06016cc

805 files changed

Lines changed: 6740 additions & 182762 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.circleci/config.yml

Lines changed: 0 additions & 26 deletions
This file was deleted.

DownloadLinks.sh

Lines changed: 0 additions & 21 deletions
This file was deleted.

actuator/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ description = "actuator – a series of transactions for blockchain."
33
// Dependency versions
44
// ---------------------------------------
55

6-
def junitVersion = "4.12"
6+
def junitVersion = "4.13.2"
77
def mockitoVersion = "2.1.0"
88
def testNgVersion = "6.11"
99
def slf4jVersion = "1.7.25"

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

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -681,6 +681,17 @@ public static void validator(DynamicPropertiesStore dynamicPropertiesStore,
681681
}
682682
break;
683683
}
684+
case ALLOW_TVM_SHANGHAI: {
685+
if (!forkController.pass(ForkBlockVersionEnum.VERSION_4_7_2)) {
686+
throw new ContractValidateException(
687+
"Bad chain parameter id [ALLOW_TVM_SHANGHAI]");
688+
}
689+
if (value != 1) {
690+
throw new ContractValidateException(
691+
"This value[ALLOW_TVM_SHANGHAI] is only allowed to be 1");
692+
}
693+
break;
694+
}
684695
default:
685696
break;
686697
}
@@ -753,7 +764,8 @@ public enum ProposalType { // current value, value range
753764
ALLOW_DYNAMIC_ENERGY(72), // 0, 1
754765
DYNAMIC_ENERGY_THRESHOLD(73), // 0, [0, LONG]
755766
DYNAMIC_ENERGY_INCREASE_FACTOR(74), // 0, [0, 10_000]
756-
DYNAMIC_ENERGY_MAX_FACTOR(75); // 0, [0, 100_000]
767+
DYNAMIC_ENERGY_MAX_FACTOR(75), // 0, [0, 100_000]
768+
ALLOW_TVM_SHANGHAI(76); // 0, 1
757769

758770
private long code;
759771

actuator/src/main/java/org/tron/core/vm/Op.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ public class Op {
148148

149149
/* Push Operations */
150150
// Place item on stack
151+
public static final int PUSH0 = 0x5f;
151152
public static final int PUSH1 = 0x60;
152153
public static final int PUSH2 = 0x61;
153154
public static final int PUSH3 = 0x62;

actuator/src/main/java/org/tron/core/vm/OperationActions.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -643,6 +643,11 @@ public static void jumpDestAction(Program program) {
643643
program.step();
644644
}
645645

646+
public static void push0Action(Program program) {
647+
program.stackPush(DataWord.ZERO());
648+
program.step();
649+
}
650+
646651
public static void pushAction(Program program) {
647652
int n = program.getCurrentOpIntValue() - Op.PUSH1 + 1;
648653
program.step();

actuator/src/main/java/org/tron/core/vm/OperationRegistry.java

Lines changed: 19 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public enum Version {
1111
TRON_V1_0,
1212
TRON_V1_1,
1313
TRON_V1_2,
14+
TRON_V1_3,
1415
// add more
1516
// TRON_V2,
1617
// ETH
@@ -22,6 +23,7 @@ public enum Version {
2223
tableMap.put(Version.TRON_V1_0, newTronV10OperationSet());
2324
tableMap.put(Version.TRON_V1_1, newTronV11OperationSet());
2425
tableMap.put(Version.TRON_V1_2, newTronV12OperationSet());
26+
tableMap.put(Version.TRON_V1_3, newTronV13OperationSet());
2527
}
2628

2729
public static JumpTable newTronV10OperationSet() {
@@ -47,12 +49,18 @@ public static JumpTable newTronV12OperationSet() {
4749
return table;
4850
}
4951

52+
public static JumpTable newTronV13OperationSet() {
53+
JumpTable table = newTronV12OperationSet();
54+
appendShangHaiOperations(table);
55+
return table;
56+
}
57+
5058
// Just for warming up class to avoid out_of_time
5159
public static void init() {}
5260

5361
public static JumpTable getTable() {
5462
// always get the table which has the newest version
55-
JumpTable table = tableMap.get(Version.TRON_V1_2);
63+
JumpTable table = tableMap.get(Version.TRON_V1_3);
5664

5765
// next make the corresponding changes, exclude activating opcode
5866
if (VMConfig.allowHigherLimitForMaxCpuTimeOfOneTx()) {
@@ -617,4 +625,14 @@ public static void appendDelegateOperations(JumpTable table) {
617625
OperationActions::unDelegateResourceAction,
618626
proposal));
619627
}
628+
629+
public static void appendShangHaiOperations(JumpTable table) {
630+
BooleanSupplier proposal = VMConfig::allowTvmShanghai;
631+
632+
table.set(new Operation(
633+
Op.PUSH0, 0, 1,
634+
EnergyCost::getBaseTierCost,
635+
OperationActions::push0Action,
636+
proposal));
637+
}
620638
}

actuator/src/main/java/org/tron/core/vm/config/ConfigLoader.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ public static void load(StoreFactory storeFactory) {
3838
VMConfig.initDynamicEnergyThreshold(ds.getDynamicEnergyThreshold());
3939
VMConfig.initDynamicEnergyIncreaseFactor(ds.getDynamicEnergyIncreaseFactor());
4040
VMConfig.initDynamicEnergyMaxFactor(ds.getDynamicEnergyMaxFactor());
41+
VMConfig.initAllowTvmShangHai(ds.getAllowTvmShangHai());
4142
}
4243
}
4344
}

actuator/src/main/java/org/tron/core/vm/config/VMConfig.java

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,8 @@ public class VMConfig {
4747

4848
private static long DYNAMIC_ENERGY_MAX_FACTOR = 0L;
4949

50+
private static boolean ALLOW_TVM_SHANGHAI = false;
51+
5052
private VMConfig() {
5153
}
5254

@@ -130,6 +132,10 @@ public static void initDynamicEnergyMaxFactor(long maxFactor) {
130132
DYNAMIC_ENERGY_MAX_FACTOR = maxFactor;
131133
}
132134

135+
public static void initAllowTvmShangHai(long allow) {
136+
ALLOW_TVM_SHANGHAI = allow == 1;
137+
}
138+
133139
public static boolean getEnergyLimitHardFork() {
134140
return CommonParameter.ENERGY_LIMIT_HARD_FORK;
135141
}
@@ -201,4 +207,8 @@ public static long getDynamicEnergyIncreaseFactor() {
201207
public static long getDynamicEnergyMaxFactor() {
202208
return DYNAMIC_ENERGY_MAX_FACTOR;
203209
}
210+
211+
public static boolean allowTvmShanghai() {
212+
return ALLOW_TVM_SHANGHAI;
213+
}
204214
}

actuator/src/main/java/org/tron/core/vm/nativecontract/DelegateResourceProcessor.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,7 +96,7 @@ public void validate(DelegateResourceParam param, Repository repo) throws Contra
9696
break;
9797
default:
9898
throw new ContractValidateException(
99-
"ResourceCode error, valid ResourceCode[BANDWIDTH、ENERGY]");
99+
"Unknown ResourceCode, valid ResourceCode[BANDWIDTH、ENERGY]");
100100
}
101101

102102
byte[] receiverAddress = param.getReceiverAddress();

0 commit comments

Comments
 (0)