Skip to content

Commit b46814a

Browse files
authored
Merge pull request #2813 from tronprotocol/release_3.6.6_fix_rename
change rootConstantCall to constantCall
2 parents d47b56a + a5f1e5f commit b46814a

File tree

6 files changed

+32
-30
lines changed

6 files changed

+32
-30
lines changed

src/main/java/org/tron/common/runtime/RuntimeImpl.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -565,7 +565,7 @@ private void call()
565565
tokenValue, tokenId, blockCap.getInstance(), deposit, vmStartInUs,
566566
vmShouldEndInUs, energyLimit);
567567
if (isConstantCall) {
568-
programInvoke.setRootConstantCall();
568+
programInvoke.setConstantCall();
569569
}
570570
this.vm = new VM(config);
571571
rootInternalTransaction = new InternalTransaction(trx, trxType);

src/main/java/org/tron/common/runtime/vm/PrecompiledContracts.java

+10-11
Original file line numberDiff line numberDiff line change
@@ -353,11 +353,11 @@ private static boolean validateV(byte[] v) {
353353

354354
/**
355355
* Computes modular exponentiation on big numbers
356-
*
356+
* <p>
357357
* format of data[] array: [length_of_BASE] [length_of_EXPONENT] [length_of_MODULUS] [BASE]
358358
* [EXPONENT] [MODULUS] where every length is a 32-byte left-padded integer representing the
359359
* number of bytes. Call data is assumed to be infinitely right-padded with zero bytes.
360-
*
360+
* <p>
361361
* Returns an output as a byte array with the same length as the modulus
362362
*/
363363
public static class ModExp extends PrecompiledContract {
@@ -470,11 +470,11 @@ private BigInteger parseArg(byte[] data, int offset, int len) {
470470

471471
/**
472472
* Computes point addition on Barreto–Naehrig curve. See {@link BN128Fp} for details<br/> <br/>
473-
*
473+
* <p>
474474
* input data[]:<br/> two points encoded as (x, y), where x and y are 32-byte left-padded
475475
* integers,<br/> if input is shorter than expected, it's assumed to be right-padded with zero
476476
* bytes<br/> <br/>
477-
*
477+
* <p>
478478
* output:<br/> resulting point (x', y'), where x and y encoded as 32-byte left-padded
479479
* integers<br/>
480480
*/
@@ -517,11 +517,11 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
517517
/**
518518
* Computes multiplication of scalar value on a point belonging to Barreto–Naehrig curve. See
519519
* {@link BN128Fp} for details<br/> <br/>
520-
*
520+
* <p>
521521
* input data[]:<br/> point encoded as (x, y) is followed by scalar s, where x, y and s are
522522
* 32-byte left-padded integers,<br/> if input is shorter than expected, it's assumed to be
523523
* right-padded with zero bytes<br/> <br/>
524-
*
524+
* <p>
525525
* output:<br/> resulting point (x', y'), where x and y encoded as 32-byte left-padded
526526
* integers<br/>
527527
*/
@@ -557,15 +557,15 @@ public Pair<Boolean, byte[]> execute(byte[] data) {
557557

558558
/**
559559
* Computes pairing check. <br/> See {@link PairingCheck} for details.<br/> <br/>
560-
*
560+
* <p>
561561
* Input data[]: <br/> an array of points (a1, b1, ... , ak, bk), <br/> where "ai" is a point of
562562
* {@link BN128Fp} curve and encoded as two 32-byte left-padded integers (x; y) <br/> "bi" is a
563563
* point of {@link BN128G2} curve and encoded as four 32-byte left-padded integers {@code (ai + b;
564564
* ci + d)}, each coordinate of the point is a big-endian {@link } number, so {@code b} precedes
565565
* {@code a} in the encoding: {@code (b, a; d, c)} <br/> thus each pair (ai, bi) has 192 bytes
566566
* length, if 192 is not a multiple of {@code data.length} then execution fails <br/> the number
567567
* of pairs is derived from input length by dividing it by 192 (the length of a pair) <br/> <br/>
568-
*
568+
* <p>
569569
* output: <br/> pairing product which is either 0 or 1, encoded as 32-byte left-padded integer
570570
* <br/>
571571
*/
@@ -648,7 +648,6 @@ private Pair<BN128G1, BN128G2> decodePair(byte[] in, int offset) {
648648
}
649649

650650

651-
652651
public static class ValidateMultiSign extends PrecompiledContract {
653652

654653
private static final int ENGERYPERSIGN = 1500;
@@ -716,6 +715,7 @@ public Pair<Boolean, byte[]> execute(byte[] rawData) {
716715

717716

718717
public static class BatchValidateSign extends PrecompiledContract {
718+
719719
private static final ExecutorService workers;
720720
private static final int ENGERYPERSIGN = 1500;
721721
private static final int MAX_SIZE = 16;
@@ -779,7 +779,7 @@ private Pair<Boolean, byte[]> doExecute(byte[] data)
779779
}
780780
byte[] res = new byte[WORD_SIZE];
781781
if (isConstantCall()) {
782-
//for static call not use thread pool to avoid potential effect
782+
//for constant call not use thread pool to avoid potential effect
783783
for (int i = 0; i < cnt; i++) {
784784
if (DataWord
785785
.equalAddressByteArray(addresses[i], recoverAddrBySign(signatures[i], hash))) {
@@ -816,7 +816,6 @@ private Pair<Boolean, byte[]> doExecute(byte[] data)
816816
}
817817

818818

819-
820819
}
821820

822821
private static byte[] recoverAddrBySign(byte[] sign, byte[] hash) {

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

+7-7
Original file line numberDiff line numberDiff line change
@@ -537,8 +537,8 @@ this, new DataWord(newAddress), getContractAddress(), value, new DataWord(0),
537537
new DataWord(0),
538538
newBalance, null, deposit, false, byTestingSuite(), vmStartInUs,
539539
getVmShouldEndInUs(), energyLimit.longValueSafe());
540-
if (isRootConstantCall()) {
541-
programInvoke.setRootConstantCall();
540+
if (isConstantCall()) {
541+
programInvoke.setConstantCall();
542542
}
543543
ProgramResult createResult = ProgramResult.createEmpty();
544544

@@ -755,8 +755,8 @@ this, new DataWord(contextAddress),
755755
!isTokenTransfer ? new DataWord(0) : msg.getTokenId(),
756756
contextBalance, data, deposit, msg.getType().callIsStatic() || isStaticCall(),
757757
byTestingSuite(), vmStartInUs, getVmShouldEndInUs(), msg.getEnergy().longValueSafe());
758-
if (isRootConstantCall()) {
759-
programInvoke.setRootConstantCall();
758+
if (isConstantCall()) {
759+
programInvoke.setConstantCall();
760760
}
761761
VM vm = new VM(config);
762762
Program program = new Program(programCode, programInvoke, internalTx, config,
@@ -1055,8 +1055,8 @@ public boolean isStaticCall() {
10551055
return invoke.isStaticCall();
10561056
}
10571057

1058-
public boolean isRootConstantCall() {
1059-
return invoke.isRootConstantCall();
1058+
public boolean isConstantCall() {
1059+
return invoke.isConstantCall();
10601060
}
10611061

10621062
public ProgramResult getResult() {
@@ -1461,7 +1461,7 @@ public void callToPrecompiledAddress(MessageCall msg,
14611461
// this is the depositImpl, not contractState as above
14621462
contract.setDeposit(deposit);
14631463
contract.setResult(this.result);
1464-
contract.setConstantCall(isRootConstantCall());
1464+
contract.setConstantCall(isConstantCall());
14651465
contract.setVmShouldEndInUs(getVmShouldEndInUs());
14661466
Pair<Boolean, byte[]> out = contract.execute(data);
14671467

src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvoke.java

+2-2
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,7 @@ public interface ProgramInvoke {
7373

7474
BlockCapsule getBlockByNum(int index);
7575

76-
void setRootConstantCall();
76+
void setConstantCall();
7777

78-
boolean isRootConstantCall();
78+
boolean isConstantCall();
7979
}

src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeImpl.java

+5-5
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ public class ProgramInvokeImpl implements ProgramInvoke {
5656
private boolean byTestingSuite = false;
5757
private int callDeep = 0;
5858
private boolean isStaticCall = false;
59-
private boolean isRootConstantCall = false;
59+
private boolean isConstantCall = false;
6060

6161
public ProgramInvokeImpl(DataWord address, DataWord origin, DataWord caller, DataWord balance,
6262
DataWord callValue, DataWord tokenValue, DataWord tokenId, byte[] msgData,
@@ -382,13 +382,13 @@ public BlockCapsule getBlockByNum(int index) {
382382
}
383383

384384
@Override
385-
public void setRootConstantCall() {
386-
isRootConstantCall = true;
385+
public void setConstantCall() {
386+
isConstantCall = true;
387387
}
388388

389389
@Override
390-
public boolean isRootConstantCall() {
391-
return isRootConstantCall;
390+
public boolean isConstantCall() {
391+
return isConstantCall;
392392
}
393393

394394
}

src/main/java/org/tron/common/runtime/vm/program/invoke/ProgramInvokeMockImpl.java

+7-4
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,8 @@ public class ProgramInvokeMockImpl implements ProgramInvoke {
5050

5151
private boolean isConstantCall;
5252

53+
private boolean isStaticCall;
54+
5355
public ProgramInvokeMockImpl(byte[] msgDataRaw) {
5456
this();
5557
this.msgData = Arrays.clone(msgDataRaw);
@@ -225,7 +227,7 @@ public void setOwnerAddress(byte[] ownerAddress) {
225227

226228
@Override
227229
public boolean isStaticCall() {
228-
return isConstantCall;
230+
return isStaticCall;
229231
}
230232

231233
@Override
@@ -252,12 +254,13 @@ public BlockCapsule getBlockByNum(int index) {
252254
}
253255

254256
@Override
255-
public void setRootConstantCall() {
257+
public void setConstantCall() {
258+
isConstantCall = true;
256259
}
257260

258261
@Override
259-
public boolean isRootConstantCall() {
260-
return false;
262+
public boolean isConstantCall() {
263+
return isConstantCall;
261264
}
262265

263266
@Override

0 commit comments

Comments
 (0)