Skip to content

Commit 7aaac97

Browse files
committed
refactor
1 parent 0b9faef commit 7aaac97

3 files changed

Lines changed: 7 additions & 9 deletions

File tree

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -616,6 +616,11 @@ public enum OpCode {
616616
*/
617617
DELEGATECALL(0xf4, 6, 1, OpCode.Tier.SpecialTier, CallFlags.Call, CallFlags.Stateless, CallFlags.Delegate),
618618

619+
/**
620+
* (0xf5) Skinny CREATE2, same as CREATE but with deterministic address
621+
*/
622+
CREATE2(0xf5, 4, 1, OpCode.Tier.SpecialTier),
623+
619624
/**
620625
* opcode that can be used to call another contract (or itself) while disallowing any
621626
* modifications to the state during the call (and its subcalls, if present).
@@ -624,8 +629,6 @@ public enum OpCode {
624629
*/
625630
STATICCALL(0xfa, 6, 1, OpCode.Tier.SpecialTier, CallFlags.Call, CallFlags.Static),
626631

627-
CREATE2(0xf5, 4, 1, OpCode.Tier.SpecialTier),
628-
629632
/**
630633
* (0xfd) The `REVERT` instruction will stop execution, roll back all state changes done so far
631634
* and provide a pointer to a memory section, which can be interpreted as an error code or message.

src/main/java/org/tron/core/Wallet.java

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -288,11 +288,6 @@ public static byte[] generateContractAddress2(byte[] address, byte[] code, byte[
288288
return Hash.sha3omit12(mergedData);
289289
}
290290

291-
// for test
292-
public static byte[] generateContractAddress2(byte[] address, byte[] code, long salt) {
293-
return generateContractAddress2(address, code, new DataWord(salt).getData());
294-
}
295-
296291
// for `CREATE`
297292
public static byte[] generateContractAddress(byte[] transactionRootId, long nonce) {
298293
byte[] nonceBytes = Longs.toByteArray(nonce);

src/test/java/org/tron/common/runtime/vm/Create2Test.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
import org.tron.core.exception.VMIllegalException;
1818
import org.tron.protos.Protocol.Transaction;
1919
import stest.tron.wallet.common.client.utils.AbiUtil;
20+
import stest.tron.wallet.common.client.utils.DataWord;
2021

2122
@Slf4j
2223
public class Create2Test extends VMTestBase {
@@ -91,7 +92,6 @@ public void testCreate2()
9192

9293

9394
// Trigger contract method: deploy(bytes,uint)
94-
long salt = 100L;
9595
String hexInput = AbiUtil.parseMethod(methodSign, Arrays.asList(testCode, salt));
9696
TVMTestResult result = TVMTestUtils
9797
.triggerContractAndReturnTVMTestResult(Hex.decode(OWNER_ADDRESS),
@@ -100,7 +100,7 @@ public void testCreate2()
100100

101101
byte[] returnValue = result.getRuntime().getResult().getHReturn();
102102
byte[] actualContract = MUtil.convertToTronAddress(Arrays.copyOfRange(returnValue, 12, 32));
103-
byte[] expectedContract = Wallet.generateContractAddress2(address, Hex.decode(testCode), salt);
103+
byte[] expectedContract = Wallet.generateContractAddress2(address, Hex.decode(testCode), new DataWord(100L).getData());
104104
// check deployed contract
105105
Assert.assertEquals(actualContract, expectedContract);
106106

0 commit comments

Comments
 (0)