File tree Expand file tree Collapse file tree
src/main/java/org/tron/common/runtime/vm Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -220,7 +220,10 @@ public void step(Program program) {
220220 // here, contract call an other contract, or a library, and so on
221221 // todo: check the callvalue here
222222 gasCost = gasCosts .getCALL ();
223+
223224 DataWord callGasWord = stack .get (stack .size () - 1 );
225+ // DataWord callGasWord = new DataWord(1000000);
226+
224227 DataWord callAddressWord = stack .get (stack .size () - 2 );
225228 DataWord value = op .callHasValue () ?
226229 stack .get (stack .size () - 3 ) : DataWord .ZERO ;
@@ -248,6 +251,7 @@ public void step(Program program) {
248251 }
249252 DataWord getGasLimitLeft = program .getGasLimitLeft ().clone ();
250253 getGasLimitLeft .sub (new DataWord (gasCost ));
254+
251255 adjustedCallGas = program .getCallGas (op , callGasWord , getGasLimitLeft );
252256 gasCost += adjustedCallGas .longValueSafe ();
253257 break ;
@@ -1128,8 +1132,7 @@ public void step(Program program) {
11281132 }
11291133 break ;
11301134 case GAS : {
1131- DataWord gas = new DataWord (0 );
1132-
1135+ DataWord gas = program .getGasLimitLeft ();
11331136 if (logger .isInfoEnabled ()) {
11341137 hint = "" + gas ;
11351138 }
Original file line number Diff line number Diff line change @@ -1420,13 +1420,14 @@ public StackTooLargeException(String message) {
14201420
14211421 public DataWord getCallGas (OpCode op , DataWord requestedGas , DataWord availableGas ) {
14221422
1423- if (requestedGas .compareTo (availableGas ) > 0 ) {
1424- throw new Program .OutOfGasException (
1425- "Not enough gas for '%s' operation executing: opGas[%d], programGas[%d]" , op .name (),
1426- requestedGas , availableGas );
1427- }
1428-
1429- return requestedGas .clone ();
1423+ // if (requestedGas.compareTo(availableGas) > 0) {
1424+ // throw new Program.OutOfGasException(
1425+ // "Not enough gas for '%s' operation executing: opGas[%d], programGas[%d]", op.name(),
1426+ // requestedGas, availableGas);
1427+ // }
1428+ //
1429+ // return requestedGas.clone();
1430+ return requestedGas .compareTo (availableGas ) > 0 ? availableGas : requestedGas ;
14301431 }
14311432
14321433 public DataWord getCreateGas (DataWord availableGas ) {
You can’t perform that action at this time.
0 commit comments