Skip to content

Commit

Permalink
run contract code storage routines only in case when no exceptions or…
Browse files Browse the repository at this point in the history
… revert occurs before (ethereum#1271)
  • Loading branch information
zilm13 authored and mkalinin committed Apr 1, 2019
1 parent e54131f commit 6bfb6fe
Showing 1 changed file with 3 additions and 10 deletions.
13 changes: 3 additions & 10 deletions ethereumj-core/src/main/java/org/ethereum/vm/program/Program.java
Original file line number Diff line number Diff line change
Expand Up @@ -549,16 +549,9 @@ private void createContractImpl(DataWord value, byte[] programCode, byte[] newAd
}

// 4. CREATE THE CONTRACT OUT OF RETURN
byte[] code = result.getHReturn();

long storageCost = getLength(code) * getBlockchainConfig().getGasCost().getCREATE_DATA();
if (result.isRevert()) {
long afterSpend = programInvoke.getGas().longValue() - result.getGasUsed();
if (afterSpend < 0) {
result.setException(Program.Exception.notEnoughSpendingGas("No gas to return just created contract",
storageCost, this));
}
} else {
if (!result.isRevert() && result.getException() == null) {
byte[] code = result.getHReturn();
long storageCost = getLength(code) * getBlockchainConfig().getGasCost().getCREATE_DATA();
long afterSpend = programInvoke.getGas().longValue() - result.getGasUsed() - storageCost;
if (afterSpend < 0) {
if (!blockchainConfig.getConstants().createEmptyContractOnOOG()) {
Expand Down

0 comments on commit 6bfb6fe

Please sign in to comment.