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( public void writeToForReceiptTrie(
final RLPOutput rlpOutput, final boolean withRevertReason, final boolean compacted) { final RLPOutput rlpOutput, final boolean withRevertReason, final boolean compacted) {
if (rlp != null) { if (rlp != null && !compacted) {
rlpOutput.writeBytes(rlp); // 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; return;
} }
@ -285,13 +287,14 @@ public class TransactionReceipt implements org.hyperledger.besu.plugin.data.Tran
LogsBloomFilter bloomFilter = null; LogsBloomFilter bloomFilter = null;
final boolean hasLogs = !input.nextIsList() && input.nextSize() == LogsBloomFilter.BYTE_SIZE; final boolean hasBloomFilter =
if (hasLogs) { !input.nextIsList() && input.nextSize() == LogsBloomFilter.BYTE_SIZE;
if (!hasBloomFilter) {
// The logs below will populate the bloom filter upon construction. // The logs below will populate the bloom filter upon construction.
bloomFilter = LogsBloomFilter.readFrom(input); bloomFilter = LogsBloomFilter.readFrom(input);
} }
// TODO consider validating that the logs and bloom filter match. // 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)); final List<Log> logs = input.readList(logInput -> Log.readFrom(logInput, compacted));
if (compacted) { if (compacted) {
bloomFilter = LogsBloomFilter.builder().insertLogs(logs).build(); 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()); revertReason = Optional.of(input.readBytes());
} }
Bytes raw = null; Bytes rlpBytes = null;
if (keepRlp) { if (keepRlp) {
raw = input.raw(); rlpBytes = rlpInput.raw();
} }
// Status code-encoded transaction receipts have a single // 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(); final int status = firstElement.readIntScalar();
input.leaveList(); input.leaveList();
return new TransactionReceipt( return new TransactionReceipt(
transactionType, status, cumulativeGas, logs, bloomFilter, revertReason, raw); transactionType, status, cumulativeGas, logs, bloomFilter, revertReason, rlpBytes);
} else { } else {
final Hash stateRoot = Hash.wrap(firstElement.readBytes32()); final Hash stateRoot = Hash.wrap(firstElement.readBytes32());
input.leaveList(); input.leaveList();
return new TransactionReceipt( 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() * @see #enterList()
* @param skipCount true if the element count is not required. * @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) { public int enterList(final boolean skipCount) {
if (currentItem >= size) { if (currentItem >= size) {

Loading…
Cancel
Save