Skip to content

fix(tvm): revert tstore in staticcall #6214

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions actuator/src/main/java/org/tron/core/vm/OperationActions.java
Original file line number Diff line number Diff line change
Expand Up @@ -656,6 +656,9 @@ public static void tLoadAction(Program program) {
}

public static void tStoreAction(Program program) {
if (program.isStaticCall()) {
throw new Program.StaticCallModificationException();
}
DataWord key = program.stackPop();
DataWord value = program.stackPop();
DataWord address = program.getContractAddress();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,6 +210,10 @@ public void setOwnerAddress(byte[] ownerAddress) {
this.ownerAddress = Arrays.clone(ownerAddress);
}

public void setStaticCall(boolean isStatic) {
isStaticCall = isStatic;
}

@Override
public boolean isStaticCall() {
return isStaticCall;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -953,6 +953,15 @@ public void testTransientStorageOperations() throws ContractValidateException {

// TSTORE = 0x5d;
op = new byte[] {0x60, 0x01, 0x60, 0x01, 0x5d};

invoke.setStaticCall(true);
program = new Program(op, op, invoke, interTrx);
testOperations(program);
Assert.assertEquals(20000, program.getResult().getEnergyUsed());
Assert.assertTrue(program.getResult().getException()
instanceof Program.StaticCallModificationException);

invoke.setStaticCall(false);
program = new Program(op, op, invoke, interTrx);
testOperations(program);
Assert.assertEquals(106, program.getResult().getEnergyUsed());
Expand Down