Skip to content

Commit

Permalink
Copy also computed fields, when doing a Transaction detached copy (hy…
Browse files Browse the repository at this point in the history
…perledger#6329)

Signed-off-by: Fabio Di Fabio <[email protected]>
  • Loading branch information
fab-10 authored Jan 10, 2024
1 parent 331833b commit d636e7f
Showing 1 changed file with 27 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1007,24 +1007,33 @@ public Transaction detachedCopy() {
withCommitments ->
blobsWithCommitmentsDetachedCopy(withCommitments, detachedVersionedHashes.get()));

return new Transaction(
true,
transactionType,
nonce,
gasPrice,
maxPriorityFeePerGas,
maxFeePerGas,
maxFeePerBlobGas,
gasLimit,
detachedTo,
value,
signature,
payload.copy(),
detachedAccessList,
sender,
chainId,
detachedVersionedHashes,
detachedBlobsWithCommitments);
final var copiedTx =
new Transaction(
true,
transactionType,
nonce,
gasPrice,
maxPriorityFeePerGas,
maxFeePerGas,
maxFeePerBlobGas,
gasLimit,
detachedTo,
value,
signature,
payload.copy(),
detachedAccessList,
sender,
chainId,
detachedVersionedHashes,
detachedBlobsWithCommitments);

// copy also the computed fields, to avoid to recompute them
copiedTx.sender = this.sender;
copiedTx.hash = this.hash;
copiedTx.hashNoSignature = this.hashNoSignature;
copiedTx.size = this.size;

return copiedTx;
}

private AccessListEntry accessListDetachedCopy(final AccessListEntry accessListEntry) {
Expand Down

0 comments on commit d636e7f

Please sign in to comment.