Signed-off-by: stefan.pingel@consensys.net <stefan.pingel@consensys.net>
pull/7651/head
stefan.pingel@consensys.net 2 months ago
parent 854d063229
commit f62d15f99d
  1. 21
      ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/TransactionReceipt.java
  2. 2
      ethereum/rlp/src/main/java/org/hyperledger/besu/ethereum/rlp/AbstractRLPInput.java

@ -208,8 +208,10 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
public void writeToForReceiptTrie(
final RLPOutput rlpOutput, final boolean withRevertReason, final boolean compacted) {
if (rlp != null) {
rlpOutput.writeBytes(rlp);
if (rlp != null && !compacted) {
// at this point we can ignore withRevertReason, because we would only have the rlp if the
// receipt was received via p2p, which means the receipt does not contain the revert reason.
rlpOutput.writeRaw(rlp);
return;
}
@ -285,13 +287,14 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
LogsBloomFilter bloomFilter = null;
final boolean hasLogs = !input.nextIsList() && input.nextSize() == LogsBloomFilter.BYTE_SIZE;
if (hasLogs) {
final boolean hasBloomFilter =
!input.nextIsList() && input.nextSize() == LogsBloomFilter.BYTE_SIZE;
if (!hasBloomFilter) {
// The logs below will populate the bloom filter upon construction.
bloomFilter = LogsBloomFilter.readFrom(input);
}
// TODO consider validating that the logs and bloom filter match.
final boolean compacted = !hasLogs;
final boolean compacted = !hasBloomFilter;
final List<Log> logs = input.readList(logInput -> Log.readFrom(logInput, compacted));
if (compacted) {
bloomFilter = LogsBloomFilter.builder().insertLogs(logs).build();
@ -307,9 +310,9 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
revertReason = Optional.of(input.readBytes());
}
Bytes raw = null;
Bytes rlpBytes = null;
if (keepRlp) {
raw = input.raw();
rlpBytes = rlpInput.raw();
}
// Status code-encoded transaction receipts have a single
@ -318,12 +321,12 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
final int status = firstElement.readIntScalar();
input.leaveList();
return new TransactionReceipt(
transactionType, status, cumulativeGas, logs, bloomFilter, revertReason, raw);
transactionType, status, cumulativeGas, logs, bloomFilter, revertReason, rlpBytes);
} else {
final Hash stateRoot = Hash.wrap(firstElement.readBytes32());
input.leaveList();
return new TransactionReceipt(
transactionType, stateRoot, cumulativeGas, logs, bloomFilter, revertReason, raw);
transactionType, stateRoot, cumulativeGas, logs, bloomFilter, revertReason, rlpBytes);
}
}

@ -476,7 +476,7 @@ abstract class AbstractRLPInput implements RLPInput {
*
* @see #enterList()
* @param skipCount true if the element count is not required.
* @return -1 if skipCount==true, otherwise, the number of item of the entered list.
* @return -1 if skipCount==true, otherwise, the number of items of the entered list.
*/
public int enterList(final boolean skipCount) {
if (currentItem >= size) {

Loading…
Cancel
Save