Skip to content
This repository has been archived by the owner on Dec 5, 2024. It is now read-only.

Commit

Permalink
Merge pull request #928 from ethereum/eip-658
Browse files Browse the repository at this point in the history
Eip 658: Embedding transaction return data in receipts
  • Loading branch information
mkalinin authored Aug 31, 2017
2 parents ae95aa6 + 656301b commit b2c203b
Show file tree
Hide file tree
Showing 8 changed files with 48 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -152,4 +152,10 @@ String validateTransactionChanges(BlockStore blockStore, Block curBlock, Transac
* EIP214: https://github.com/ethereum/EIPs/pull/214
*/
boolean eip214();

/**
* EIP658: https://github.com/ethereum/EIPs/pull/658
* Replaces the intermediate state root field of the receipt with the status
*/
boolean eip658();
}
Original file line number Diff line number Diff line change
Expand Up @@ -183,6 +183,11 @@ public boolean eip214() {
return false;
}

@Override
public boolean eip658() {
return false;
}

@Override
public String toString() {
return getClass().getSimpleName();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -103,4 +103,9 @@ public boolean eip213() {
public boolean eip214() {
return true;
}

@Override
public boolean eip658() {
return true;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -171,4 +171,9 @@ public boolean eip213() {
public boolean eip214() {
return false;
}

@Override
public boolean eip658() {
return false;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
package org.ethereum.core;

import com.google.common.util.concurrent.ThreadFactoryBuilder;
import org.ethereum.config.BlockchainConfig;
import org.ethereum.config.CommonConfig;
import org.ethereum.config.SystemProperties;
import org.ethereum.crypto.HashUtil;
Expand Down Expand Up @@ -861,7 +862,8 @@ private BlockSummary applyBlock(Repository track, Block block) {

logger.debug("applyBlock: block: [{}] tx.list: [{}]", block.getNumber(), block.getTransactionsList().size());

config.getBlockchainConfig().getConfigForBlock(block.getNumber()).hardForkTransfers(block, track);
BlockchainConfig blockchainConfig = config.getBlockchainConfig().getConfigForBlock(block.getNumber());
blockchainConfig.hardForkTransfers(block, track);

long saveTime = System.nanoTime();
int i = 1;
Expand All @@ -887,7 +889,11 @@ private BlockSummary applyBlock(Repository track, Block block) {
txTrack.commit();
final TransactionReceipt receipt = executor.getReceipt();

receipt.setPostTxState(track.getRoot());
if (blockchainConfig.eip658()) {
receipt.setTxStatus(receipt.isSuccessful());
} else {
receipt.setPostTxState(track.getRoot());
}

stateLogger.info("block: [{}] executed tx: [{}] \n state: [{}]", block.getNumber(), i,
Hex.toHexString(track.getRoot()));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,8 @@ public void go() {

if (result.getException() != null) {
throw result.getException();
} else {
execError("REVERT opcode executed");
}
} else {
touchedAccounts.addAll(result.getTouchedAccounts());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -204,6 +204,19 @@ public void setPostTxState(byte[] postTxState) {
rlpEncoded = null;
}

public void setTxStatus(boolean success) {
this.postTxState = success ? new byte[]{1} : new byte[0];
rlpEncoded = null;
}

public boolean hasTxStatus() {
return postTxState != null && postTxState.length <= 1;
}

public boolean isTxStatusOK() {
return postTxState != null && postTxState.length == 1 && postTxState[0] == 1;
}

public void setCumulativeGas(long cumulativeGas) {
this.cumulativeGas = BigIntegers.asUnsignedByteArray(BigInteger.valueOf(cumulativeGas));
rlpEncoded = null;
Expand Down Expand Up @@ -258,7 +271,8 @@ public String toString() {
// todo: fix that

return "TransactionReceipt[" +
"\n , postTxState=" + Hex.toHexString(postTxState) +
"\n , " + (hasTxStatus() ? ("txStatus=" + (isTxStatusOK() ? "OK" : "FAILED"))
: ("postTxState=" + Hex.toHexString(postTxState))) +
"\n , cumulativeGas=" + Hex.toHexString(cumulativeGas) +
"\n , gasUsed=" + Hex.toHexString(gasUsed) +
"\n , error=" + error +
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
@FixMethodOrder(MethodSorters.NAME_ASCENDING)
public class GitHubBlockTest {

static String commitSHA = "74431cab7b8e8a0ccf457ad2fbc4b25f6c3e1f7f";
static String commitSHA = "d098a00a4e7108f7965d1ca81e2fd51fc5b1e11b";
static String treeSHA = "f957bebb5d163da11656e7a18d0b95ee025e4ca2"; // https://github.com/ethereum/tests/tree/develop/BlockchainTests/
static GitHubJSONTestSuite.Network[] targetNets = {
GitHubJSONTestSuite.Network.Frontier,
Expand All @@ -53,7 +53,7 @@ public static void setup() {
// do not initialize BlockchainTestSuite to avoid unnecessary GitHub API hits
public void bcSingleTest() throws IOException {
BlockchainTestSuite.runSingle(
"bcBlockGasLimitTest/BlockGasLimit2p63m1.json", commitSHA, GitHubJSONTestSuite.Network.Frontier);
"bcWalletTest/wallet2outOf3txs2.json", commitSHA, GitHubJSONTestSuite.Network.Byzantium);
}


Expand Down

0 comments on commit b2c203b

Please sign in to comment.