diff --git a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Blob.java b/datatypes/src/main/java/org/hyperledger/besu/datatypes/Blob.java deleted file mode 100644 index 70b22d58691..00000000000 --- a/datatypes/src/main/java/org/hyperledger/besu/datatypes/Blob.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Hyperledger Besu Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.hyperledger.besu.datatypes; - -public class Blob {} diff --git a/datatypes/src/main/java/org/hyperledger/besu/datatypes/KZGCommitment.java b/datatypes/src/main/java/org/hyperledger/besu/datatypes/KZGCommitment.java deleted file mode 100644 index 3ccffa485e2..00000000000 --- a/datatypes/src/main/java/org/hyperledger/besu/datatypes/KZGCommitment.java +++ /dev/null @@ -1,18 +0,0 @@ -/* - * Copyright Hyperledger Besu Contributors. - * - * Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with - * the License. You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on - * an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the - * specific language governing permissions and limitations under the License. - * - * SPDX-License-Identifier: Apache-2.0 - */ - -package org.hyperledger.besu.datatypes; - -public class KZGCommitment {} diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java index 794b5fb64b0..3932e736d5a 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/Transaction.java @@ -48,6 +48,7 @@ import com.google.common.primitives.Longs; import org.apache.tuweni.bytes.Bytes; import org.apache.tuweni.bytes.Bytes32; +import org.apache.tuweni.ssz.SSZ; import org.apache.tuweni.ssz.SSZFixedSizeTypeList; import org.apache.tuweni.units.bigints.UInt256; import org.apache.tuweni.units.bigints.UInt256s; @@ -1008,25 +1009,30 @@ private static Bytes blobPreimage( final Optional chainId, final Optional> accessList, final List versionedHashes) { - final Bytes encoded = - RLP.encode( - rlpOutput -> { - rlpOutput.startList(); - eip1559PreimageFields( - nonce, - maxPriorityFeePerGas, - maxFeePerGas, - gasLimit, - to, - value, - payload, - chainId, - accessList, - rlpOutput); - rlpOutput.writeUInt256Scalar(maxFeePerDataGas); - TransactionEncoder.writeBlobVersionedHashes(rlpOutput, versionedHashes); - rlpOutput.endList(); - }); + + var blobTransaction = new TransactionNetworkPayload.SingedBlobTransaction.BlobTransaction(); + chainId.ifPresent(id -> blobTransaction.setChainId(UInt256.valueOf(id))); + blobTransaction.setNonce(nonce); + blobTransaction.setMaxPriorityFeePerGas(maxPriorityFeePerGas.toUInt256()); + blobTransaction.setMaxFeePerGas(maxFeePerGas.toUInt256()); + blobTransaction.setMaxFeePerDataGas(maxFeePerDataGas.toUInt256()); + blobTransaction.setGas(gasLimit); + blobTransaction.setAddress(to); + blobTransaction.setValue(value.toUInt256()); + blobTransaction.setData(payload); + accessList.ifPresent( + al -> { + var list = blobTransaction.getAccessList(); + al.forEach( + accessListEntry -> { + var tuple = new TransactionNetworkPayload.SingedBlobTransaction.AccessTuple(); + tuple.setAddress(accessListEntry.getAddress()); + tuple.setStorageKeys(accessListEntry.getStorageKeys()); + list.add(tuple); + }); + }); + blobTransaction.setBlobVersionedHashes(versionedHashes); + Bytes encoded = SSZ.encode(blobTransaction::writeTo); return Bytes.concatenate(Bytes.of(TransactionType.BLOB.getSerializedType()), encoded); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java index be8f6654bdc..25de07c065d 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionDecoder.java @@ -20,6 +20,7 @@ import static org.hyperledger.besu.ethereum.core.Transaction.REPLAY_UNPROTECTED_V_BASE; import static org.hyperledger.besu.ethereum.core.Transaction.REPLAY_UNPROTECTED_V_BASE_PLUS_1; import static org.hyperledger.besu.ethereum.core.Transaction.TWO; +import static org.slf4j.LoggerFactory.getLogger; import org.hyperledger.besu.crypto.SECPSignature; import org.hyperledger.besu.crypto.SignatureAlgorithm; @@ -44,11 +45,14 @@ import org.apache.tuweni.ssz.SSZ; import org.apache.tuweni.ssz.SSZReader; import org.apache.tuweni.units.bigints.UInt32; +import org.slf4j.Logger; public class TransactionDecoder { private static final UInt32 BLOB_TRANSACTION_OFFSET = UInt32.fromHexString("0x3c000000"); + private static final Logger LOG = getLogger(TransactionDecoder.class); + @FunctionalInterface interface Decoder { Transaction decode(final Bytes input); @@ -87,6 +91,7 @@ public static Transaction decodeBlob(final SSZReader input, final UInt32 firstOf TransactionNetworkPayload.SingedBlobTransaction signedBlobTransaction; if (firstOffset.equals(BLOB_TRANSACTION_OFFSET)) { + LOG.trace("Decoding TransactionNetworkPayload"); TransactionNetworkPayload payload = new TransactionNetworkPayload(); payload.populateFromReader(input); @@ -94,6 +99,7 @@ public static Transaction decodeBlob(final SSZReader input, final UInt32 firstOf builder.kzgBlobs(payload.getKzgCommitments(), payload.getBlobs(), payload.getKzgProof()); } else { + LOG.trace("Decoding TransactionNetworkPayload.SingedBlobTransaction"); signedBlobTransaction = new TransactionNetworkPayload.SingedBlobTransaction(); signedBlobTransaction.populateFromReader(input); } diff --git a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java index 1902b0d6a19..a50dc3b44ae 100644 --- a/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java +++ b/ethereum/core/src/main/java/org/hyperledger/besu/ethereum/core/encoding/TransactionEncoder.java @@ -15,6 +15,7 @@ package org.hyperledger.besu.ethereum.core.encoding; import static com.google.common.base.Preconditions.checkNotNull; +import static org.slf4j.LoggerFactory.getLogger; import org.hyperledger.besu.datatypes.Address; import org.hyperledger.besu.datatypes.Hash; @@ -35,8 +36,10 @@ import org.apache.tuweni.ssz.SSZ; import org.apache.tuweni.ssz.SSZWriter; import org.apache.tuweni.units.bigints.UInt256; +import org.slf4j.Logger; public class TransactionEncoder { + private static final Logger LOG = getLogger(Encoder.class); @FunctionalInterface interface Encoder { @@ -73,6 +76,7 @@ interface SSZEncoder { TransactionType.BLOB, Encoder.sszEncoder(TransactionEncoder::encodeWithBlobs)); public static void encodeWithBlobs(final Transaction transaction, final SSZWriter rlpOutput) { + LOG.trace("Encoding transaction with blobs {}", transaction); var payload = new TransactionNetworkPayload(); var blobsWithCommitments = transaction.getBlobsWithCommitments(); if (blobsWithCommitments.isPresent()) { @@ -88,6 +92,7 @@ public static void encodeWithBlobs(final Transaction transaction, final SSZWrite } public static void encodeWithoutBlobs(final Transaction transaction, final SSZWriter rlpOutput) { + LOG.trace("Encoding transaction without blobs {}", transaction); var signedBlobTransaction = new TransactionNetworkPayload.SingedBlobTransaction(); populatedSignedBlobTransaction(transaction, signedBlobTransaction); signedBlobTransaction.writeTo(rlpOutput);