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 70b22d5869..0000000000 --- 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 3ccffa485e..0000000000 --- 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 224d2c9d5a..c7bc673ec1 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 @@ -49,6 +49,7 @@ import java.util.stream.Collectors; 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; @@ -1015,25 +1016,30 @@ public class Transaction 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 d0bdfe90dd..7189ac3490 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 @@ -21,6 +21,7 @@ import static org.hyperledger.besu.ethereum.core.Transaction.REPLAY_PROTECTED_V_ 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.config.GoQuorumOptions; import org.hyperledger.besu.crypto.SECPSignature; @@ -47,11 +48,14 @@ import org.apache.tuweni.bytes.Bytes; 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); @@ -90,6 +94,7 @@ public class TransactionDecoder { TransactionNetworkPayload.SingedBlobTransaction signedBlobTransaction; if (firstOffset.equals(BLOB_TRANSACTION_OFFSET)) { + LOG.trace("Decoding TransactionNetworkPayload"); TransactionNetworkPayload payload = new TransactionNetworkPayload(); payload.populateFromReader(input); @@ -97,6 +102,7 @@ public class TransactionDecoder { 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 bb956f431f..ab257b7796 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.bytes.Bytes; 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 @@ public class TransactionEncoder { 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 class TransactionEncoder { } 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);