Add type field to eth_getTransactionReceipt (#4713)

pull/4700/head
Gabriel-Trintinalia 2 years ago committed by GitHub
parent 1fa65fb944
commit 7d374b6a1b
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 1
      CHANGELOG.md
  2. 14
      ethereum/api/src/main/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/results/TransactionReceiptResult.java
  3. 3
      ethereum/api/src/test/java/org/hyperledger/besu/ethereum/api/jsonrpc/internal/methods/EthGetTransactionReceiptTest.java
  4. 3
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionReceipt_contractAddress.json
  5. 3
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionReceipt_logs.json
  6. 3
      ethereum/api/src/test/resources/org/hyperledger/besu/ethereum/api/jsonrpc/eth/eth_getTransactionReceipt_nullContractAddress.json

@ -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

@ -20,6 +20,7 @@ import org.hyperledger.besu.ethereum.api.query.TransactionReceiptWithMetadata;
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;
@ -44,7 +45,8 @@ import org.apache.tuweni.bytes.Bytes;
"to",
"transactionHash",
"transactionIndex",
"revertReason"
"revertReason",
"type"
})
public abstract class TransactionReceiptResult {
@ -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();
@ -88,6 +91,10 @@ public abstract class TransactionReceiptResult {
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")
@ -150,6 +157,11 @@ public abstract class TransactionReceiptResult {
return transactionIndex;
}
@JsonGetter(value = "type")
public String getType() {
return type;
}
@JsonInclude(JsonInclude.Include.NON_NULL)
@JsonGetter(value = "revertReason")
public String getRevertReason() {

@ -164,6 +164,7 @@ public class EthGetTransactionReceiptTest {
final TransactionReceiptStatusResult result =
(TransactionReceiptStatusResult) response.getResult();
assertThat(result.getType()).isEqualTo("0x0");
assertThat(result.getStatus()).isEqualTo("0x1");
}
@ -178,6 +179,7 @@ public class EthGetTransactionReceiptTest {
(JsonRpcSuccessResponse) ethGetTransactionReceipt.response(request);
final TransactionReceiptRootResult result = (TransactionReceiptRootResult) response.getResult();
assertThat(result.getType()).isEqualTo("0x0");
assertThat(result.getRoot()).isEqualTo(stateRoot.toString());
}
@ -200,6 +202,7 @@ public class EthGetTransactionReceiptTest {
(TransactionReceiptStatusResult) response.getResult();
assertThat(result.getStatus()).isEqualTo("0x1");
assertThat(result.getType()).isEqualTo("0x2");
assertThat(Wei.fromHexString(result.getEffectiveGasPrice()))
.isEqualTo(
UInt256s.min(

@ -23,7 +23,8 @@
"root": "0x6a59608add7cee26032d1c5c3923b91d0b50e6103f61b2137b68229bcdc87395",
"to": null,
"transactionHash": "0x812742182a79a8e67733edc58cfa3767aa2d7ad06439d156ddbbb33e3403b4ed",
"transactionIndex": "0x0"
"transactionIndex": "0x0",
"type" : "0x0"
}
},
"statusCode": 200

@ -40,7 +40,8 @@
"root": "0xb55d027526b3f56953584db678b5c3d1a418812c0106b0cfbc3c912c7898dfe5",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"transactionHash": "0x185a9154a0acc4e0ffc84029aee0f3dbf57ff0b84ec7624cb80e7373a03e8aeb",
"transactionIndex": "0x0"
"transactionIndex": "0x0",
"type" : "0x0"
}
},
"statusCode": 200

@ -23,7 +23,8 @@
"root": "0x947228066df6272aac99931a1a639621d4ac7dc461ce9fd93dfcaad933e299ee",
"to": "0x6295ee1b4f6dd65047762f924ecd367c17eabf8f",
"transactionHash": "0xb1a62356d1433202cdef0ef9030f8abdfbb3aef549fab0867cf0eaee70b09d81",
"transactionIndex": "0x0"
"transactionIndex": "0x0",
"type" : "0x0"
}
},
"statusCode": 200

Loading…
Cancel
Save