Skip to content

Commit c0126f0

Browse files
committed
feat(vm): check CREATE2 max depth under Osaka
1 parent 4b5d37d commit c0126f0

2 files changed

Lines changed: 31 additions & 1 deletion

File tree

‎actuator/src/main/java/org/tron/core/vm/program/Program.java‎

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1621,7 +1621,8 @@ public void createContract2(DataWord value, DataWord memStart, DataWord memSize,
16211621
}
16221622

16231623
byte[] senderAddress;
1624-
if (VMConfig.allowTvmCompatibleEvm() && getCallDeep() == MAX_DEPTH) {
1624+
if ((VMConfig.allowTvmCompatibleEvm() || VMConfig.allowTvmOsaka())
1625+
&& getCallDeep() == MAX_DEPTH) {
16251626
stackPushZero();
16261627
return;
16271628
}

‎framework/src/test/java/org/tron/common/runtime/vm/OperationsTest.java‎

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -788,6 +788,35 @@ Op.CALL, new DataWord(10000),
788788
VMConfig.initAllowTvmSelfdestructRestriction(0);
789789
}
790790

791+
@Test
792+
public void testCreate2MaxDepthWithOsakaOnly() throws ContractValidateException {
793+
boolean allowTvmCompatibleEvm = VMConfig.allowTvmCompatibleEvm();
794+
boolean allowTvmOsaka = VMConfig.allowTvmOsaka();
795+
VMConfig.initAllowTvmCompatibleEvm(0);
796+
VMConfig.initAllowTvmOsaka(1);
797+
try {
798+
invoke = new ProgramInvokeMockImpl() {
799+
@Override
800+
public int getCallDeep() {
801+
return 64;
802+
}
803+
};
804+
Protocol.Transaction trx = Protocol.Transaction.getDefaultInstance();
805+
InternalTransaction interTrx =
806+
new InternalTransaction(trx, InternalTransaction.TrxType.TRX_UNKNOWN_TYPE);
807+
program = new Program(new byte[0], new byte[0], invoke, interTrx);
808+
program.setRootTransactionId(new byte[32]);
809+
810+
program.createContract2(DataWord.ZERO(), DataWord.ZERO(), DataWord.ZERO(), DataWord.ZERO());
811+
812+
Assert.assertEquals(DataWord.ZERO(), program.getStack().pop());
813+
Assert.assertTrue(program.getResult().getInternalTransactions().isEmpty());
814+
} finally {
815+
VMConfig.initAllowTvmCompatibleEvm(allowTvmCompatibleEvm ? 1 : 0);
816+
VMConfig.initAllowTvmOsaka(allowTvmOsaka ? 1 : 0);
817+
}
818+
}
819+
791820
// TIP-854 outer-frame containment: a CALL to validateMultiSign or
792821
// batchValidateSign with malformed calldata must (a) push 0 onto the outer
793822
// stack, (b) leave the outer frame free of any propagated exception, and

0 commit comments

Comments
 (0)