Skip to content

Commit

Permalink
Add type field to eth_getTransactionReceipt (hyperledger#4713)
Browse files Browse the repository at this point in the history
Signed-off-by: garyschulte <garyschulte@gmail.com>
  • Loading branch information
Gabriel-Trintinalia authored and garyschulte committed Nov 21, 2022
1 parent 4f1ddfb commit 8b537c6
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 4 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@
- Shanghai implementation of EIP-3855 Push0 [#4660](https://github.com/hyperledger/besu/pull/4660)
- Shanghai implementation of EIP-3540 and EIP-3670 Ethereum Object Format and Code Validation [#4644](https://github.com/hyperledger/besu/pull/4644)
- Remove some log statements that are keeping some objects live in heap for a long time, to reduce the amount of memory required during initial sync [#4705](https://github.com/hyperledger/besu/pull/4705)
- Add field `type` to Transaction receipt object (eth_getTransactionReceipt) [#4505](https://github.com/hyperledger/besu/issues/4505)

### Bug Fixes

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.core.TransactionReceipt;
import org.hyperledger.besu.evm.log.Log;
import org.hyperledger.besu.plugin.data.TransactionType;

import java.util.ArrayList;
import java.util.List;
Expand All @@ -44,7 +45,8 @@
"to",
"transactionHash",
"transactionIndex",
"revertReason"
"revertReason",
"type"
})
public abstract class TransactionReceiptResult {

Expand All @@ -63,6 +65,7 @@ public abstract class TransactionReceiptResult {
private final String revertReason;

protected final TransactionReceipt receipt;
protected final String type;

protected TransactionReceiptResult(final TransactionReceiptWithMetadata receiptWithMetadata) {
final Transaction txn = receiptWithMetadata.getTransaction();
Expand All @@ -88,6 +91,10 @@ protected TransactionReceiptResult(final TransactionReceiptWithMetadata receiptW
this.transactionHash = txn.getHash().toString();
this.transactionIndex = Quantity.create(receiptWithMetadata.getTransactionIndex());
this.revertReason = receipt.getRevertReason().map(Bytes::toString).orElse(null);
this.type =
txn.getType().equals(TransactionType.FRONTIER)
? Quantity.create(0)
: Quantity.create(txn.getType().getSerializedType());
}

@JsonGetter(value = "blockHash")
Expand Down Expand Up @@ -150,6 +157,11 @@ public String getTransactionIndex() {
return transactionIndex;
}

@JsonGetter(value = "type")
public String getType() {
return type;
}

@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonGetter(value = "revertReason")
public String getRevertReason() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -164,6 +164,7 @@ public void shouldCreateAStatusTransactionReceiptWhenStatusTypeProtocol() {
final TransactionReceiptStatusResult result =
(TransactionReceiptStatusResult) response.getResult();

assertThat(result.getType()).isEqualTo("0x0");
assertThat(result.getStatus()).isEqualTo("0x1");
}

Expand All @@ -178,6 +179,7 @@ public void shouldCreateARootTransactionReceiptWhenRootTypeProtocol() {
(JsonRpcSuccessResponse) ethGetTransactionReceipt.response(request);
final TransactionReceiptRootResult result = (TransactionReceiptRootResult) response.getResult();

assertThat(result.getType()).isEqualTo("0x0");
assertThat(result.getRoot()).isEqualTo(stateRoot.toString());
}

Expand All @@ -200,6 +202,7 @@ public void shouldWorkFor1559Txs() {
(TransactionReceiptStatusResult) response.getResult();

assertThat(result.getStatus()).isEqualTo("0x1");
assertThat(result.getType()).isEqualTo("0x2");
assertThat(Wei.fromHexString(result.getEffectiveGasPrice()))
.isEqualTo(
UInt256s.min(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"root": "0x6a59608add7cee26032d1c5c3923b91d0b50e6103f61b2137b68229bcdc87395",
"to": null,
"transactionHash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed",
"transactionIndex": "0x0"
"transactionIndex": "0x0",
"type" : "0x0"
}
},
"statusCode": 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
"root": "0xb55d027526b3f56953584db678b5c3d1a418812c0106b0cfbc3c912c7898dfe5",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"transactionHash": "0x185a9154a0acc4e0ffc84029aee0f3dbf57ff0b84ec7624cb80e7373a03e8aeb",
"transactionIndex": "0x0"
"transactionIndex": "0x0",
"type" : "0x0"
}
},
"statusCode": 200
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@
"root": "0x947228066df6272aac99931a1a639621d4ac7dc461ce9fd93dfcaad933e299ee",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"transactionHash": "0xb1a62356d1433202cdef0ef9030f8abdfbb3aef549fab0867cf0eaee70b09d81",
"transactionIndex": "0x0"
"transactionIndex": "0x0",
"type" : "0x0"
}
},
"statusCode": 200
Expand Down

0 comments on commit 8b537c6

Please sign in to comment.