5353import static java .lang .StrictMath .min ;
5454import static java .lang .String .format ;
5555import static org .apache .commons .lang3 .ArrayUtils .*;
56+ import static org .tron .common .runtime .utils .MUtil .convertToTronAddress ;
5657import static org .tron .common .runtime .utils .MUtil .transfer ;
5758import static org .tron .common .utils .BIUtil .isPositive ;
5859import static org .tron .common .utils .BIUtil .toBI ;
@@ -359,8 +360,8 @@ public void allocateMemory(int offset, int size) {
359360
360361 public void suicide (DataWord obtainerAddress ) {
361362
362- byte [] owner = getOwnerAddress ().getLast20Bytes ();
363- byte [] obtainer = obtainerAddress .getLast20Bytes ();
363+ byte [] owner = convertToTronAddress ( getOwnerAddress ().getLast20Bytes () );
364+ byte [] obtainer = convertToTronAddress ( obtainerAddress .getLast20Bytes () );
364365 long balance = getStorage ().getBalance (owner );
365366
366367 if (logger .isInfoEnabled ())
@@ -393,7 +394,7 @@ public void createContract(DataWord value, DataWord memStart, DataWord memSize)
393394 return ;
394395 }
395396
396- byte [] senderAddress = this .getOwnerAddress ().getLast20Bytes ();
397+ byte [] senderAddress = convertToTronAddress ( this .getOwnerAddress ().getLast20Bytes () );
397398 long endowment = value .value ().longValue ();
398399 if (getStorage ().getBalance (senderAddress ) < endowment ) {
399400 stackPushZero ();
@@ -510,7 +511,7 @@ this, new DataWord(newAddress), getOwnerAddress(), value,
510511 refundGas (refundGas , "remain gas from the internal call" );
511512 if (logger .isInfoEnabled ()) {
512513 logger .info ("The remaining gas is refunded, account: [{}], gas: [{}] " ,
513- Hex .toHexString (getOwnerAddress ().getLast20Bytes ()),
514+ Hex .toHexString (convertToTronAddress ( getOwnerAddress ().getLast20Bytes () )),
514515 refundGas );
515516 }
516517 }
@@ -536,8 +537,8 @@ public void callToAddress(MessageCall msg) {
536537 byte [] data = memoryChunk (msg .getInDataOffs ().intValue (), msg .getInDataSize ().intValue ());
537538
538539 // FETCH THE SAVED STORAGE
539- byte [] codeAddress = msg .getCodeAddress ().getLast20Bytes ();
540- byte [] senderAddress = getOwnerAddress ().getLast20Bytes ();
540+ byte [] codeAddress = convertToTronAddress ( msg .getCodeAddress ().getLast20Bytes () );
541+ byte [] senderAddress = convertToTronAddress ( getOwnerAddress ().getLast20Bytes () );
541542 byte [] contextAddress = msg .getType ().callIsStateless () ? senderAddress : codeAddress ;
542543
543544 if (logger .isInfoEnabled ())
@@ -679,7 +680,7 @@ public void storageSave(DataWord word1, DataWord word2) {
679680 //storageSave(word1.getData(), word2.getData());
680681 DataWord keyWord = word1 .clone ();
681682 DataWord valWord = word2 .clone ();
682- getStorage ().addStorageValue (getOwnerAddress ().getLast20Bytes (), keyWord , valWord );
683+ getStorage ().addStorageValue (convertToTronAddress ( getOwnerAddress ().getLast20Bytes () ), keyWord , valWord );
683684 }
684685
685686 /*
@@ -695,7 +696,7 @@ public byte[] getCode() {
695696 }
696697
697698 public byte [] getCodeAt (DataWord address ) {
698- byte [] code = invoke .getDeposit ().getCode (address .getLast20Bytes ());
699+ byte [] code = invoke .getDeposit ().getCode (convertToTronAddress ( address .getLast20Bytes () ));
699700 return nullToEmpty (code );
700701 }
701702
@@ -725,7 +726,7 @@ public DataWord getBlockHash(int index) {
725726 }
726727
727728 public DataWord getBalance (DataWord address ) {
728- long balance = getStorage ().getBalance (address .getLast20Bytes ());
729+ long balance = getStorage ().getBalance (convertToTronAddress ( address .getLast20Bytes () ));
729730 return new DataWord (balance );
730731 }
731732
@@ -780,7 +781,7 @@ public byte[] getReturnDataBufferData(DataWord off, DataWord size) {
780781 }
781782
782783 public DataWord storageLoad (DataWord key ) {
783- DataWord ret = getStorage ().getStorageValue (getOwnerAddress ().getLast20Bytes (), key .clone ());
784+ DataWord ret = getStorage ().getStorageValue (convertToTronAddress ( getOwnerAddress ().getLast20Bytes () ), key .clone ());
784785 return ret == null ? null : ret .clone ();
785786 }
786787
@@ -1118,8 +1119,8 @@ public void callToPrecompiledAddress(MessageCall msg, PrecompiledContracts.Preco
11181119 // Repository track = getStorage().startTracking();
11191120 Deposit deposit = getStorage ();
11201121
1121- byte [] senderAddress = this .getOwnerAddress ().getLast20Bytes ();
1122- byte [] codeAddress = msg .getCodeAddress ().getLast20Bytes ();
1122+ byte [] senderAddress = convertToTronAddress ( this .getOwnerAddress ().getLast20Bytes () );
1123+ byte [] codeAddress = convertToTronAddress ( msg .getCodeAddress ().getLast20Bytes () );
11231124 byte [] contextAddress = msg .getType ().callIsStateless () ? senderAddress : codeAddress ;
11241125
11251126
0 commit comments