Skip to content

Commit

Permalink
Add max_fee_per_data_gas field to transaction (#4970)
Browse files Browse the repository at this point in the history
Signed-off-by: Fabio Di Fabio <fabio.difabio@consensys.net>
  • Loading branch information
fab-10 authored Jan 24, 2023
1 parent 7d04ed2 commit 617c14a
Show file tree
Hide file tree
Showing 21 changed files with 301 additions and 97 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
- Support for new DATAHASH opcode as part of EIP-4844 [#4823](https://github.com/hyperledger/besu/issues/4823)
- Send only hash announcement for blob transaction type [#4940](https://github.com/hyperledger/besu/pull/4940)
- Add `excess_data_gas` field to block header [#4958](https://github.com/hyperledger/besu/pull/4958)
- Add `max_fee_per_data_gas` field to transaction [#4970](https://github.com/hyperledger/besu/pull/4970)

### Bug Fixes
- Mitigation fix for stale bonsai code storage leading to log rolling issues on contract recreates [#4906](https://github.com/hyperledger/besu/pull/4906)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -172,29 +172,26 @@ public TransactionResult transaction(
final String s) {

final Transaction transaction =
new Transaction(
transactionType,
unsignedLong(nonce),
Optional.of(Wei.fromHexString(gasPrice)),
Optional.empty(),
Optional.empty(),
unsignedLong(gas),
Optional.ofNullable(address(toAddress)),
wei(value),
SignatureAlgorithmFactory.getInstance()
.createSignature(
Bytes.fromHexString(r).toUnsignedBigInteger(),
Bytes.fromHexString(s).toUnsignedBigInteger(),
Bytes.fromHexString(v)
.toUnsignedBigInteger()
.subtract(Transaction.REPLAY_UNPROTECTED_V_BASE)
.byteValueExact()),
bytes(input),
Optional.empty(),
address(fromAddress),
Optional.empty(),
Optional.of(bigInteger(v)),
Optional.empty());
Transaction.builder()
.type(transactionType)
.nonce(unsignedLong(nonce))
.gasPrice(Wei.fromHexString(gasPrice))
.gasLimit(unsignedLong(gas))
.to(address(toAddress))
.value(wei(value))
.signature(
SignatureAlgorithmFactory.getInstance()
.createSignature(
Bytes.fromHexString(r).toUnsignedBigInteger(),
Bytes.fromHexString(s).toUnsignedBigInteger(),
Bytes.fromHexString(v)
.toUnsignedBigInteger()
.subtract(Transaction.REPLAY_UNPROTECTED_V_BASE)
.byteValueExact()))
.payload(bytes(input))
.sender(address(fromAddress))
.v(bigInteger(v))
.build();

return new TransactionCompleteResult(
new TransactionWithMetadata(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ private TransactionAdapter updatePrivatePayload(final Transaction transaction) {
transaction.getGasPrice(),
transaction.getMaxPriorityFeePerGas(),
transaction.getMaxFeePerGas(),
transaction.getMaxFeePerDataGas(),
transaction.getGasLimit(),
transaction.getTo(),
transaction.getValue(),
Expand All @@ -351,6 +352,6 @@ private TransactionAdapter updatePrivatePayload(final Transaction transaction) {
transaction.getSender(),
transaction.getChainId(),
Optional.ofNullable(transaction.getV()),
Optional.empty())));
transaction.getVersionedHashes())));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.results;

import org.hyperledger.besu.datatypes.Address;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.core.Transaction;
import org.hyperledger.besu.ethereum.rlp.BytesValueRLPOutput;
Expand All @@ -33,8 +34,9 @@
"from",
"gas",
"gasPrice",
"maxPriortyFeePerGas",
"maxPriorityFeePerGas",
"maxFeePerGas",
"maxFeePerDataGas",
"hash",
"input",
"nonce",
Expand All @@ -43,7 +45,8 @@
"value",
"v",
"r",
"s"
"s",
"blobVersionedHashes"
})
public class TransactionPendingResult implements TransactionResult {

Expand All @@ -62,6 +65,9 @@ public class TransactionPendingResult implements TransactionResult {
@JsonInclude(JsonInclude.Include.NON_NULL)
private final String maxFeePerGas;

@JsonInclude(JsonInclude.Include.NON_NULL)
private final String maxFeePerDataGas;

private final String hash;
private final String input;
private final String nonce;
Expand All @@ -74,6 +80,9 @@ public class TransactionPendingResult implements TransactionResult {
private final String r;
private final String s;

@JsonInclude(JsonInclude.Include.NON_NULL)
private final List<Hash> versionedHashes;

public TransactionPendingResult(final Transaction transaction) {
final TransactionType transactionType = transaction.getType();
this.accessList = transaction.getAccessList().orElse(null);
Expand All @@ -83,6 +92,8 @@ public TransactionPendingResult(final Transaction transaction) {
this.maxPriorityFeePerGas =
transaction.getMaxPriorityFeePerGas().map(Wei::toShortHexString).orElse(null);
this.maxFeePerGas = transaction.getMaxFeePerGas().map(Wei::toShortHexString).orElse(null);
this.maxFeePerDataGas =
transaction.getMaxFeePerDataGas().map(Wei::toShortHexString).orElse(null);
this.gasPrice = transaction.getGasPrice().map(Quantity::create).orElse(maxFeePerGas);
this.hash = transaction.getHash().toString();
this.input = transaction.getPayload().toString();
Expand All @@ -100,6 +111,7 @@ public TransactionPendingResult(final Transaction transaction) {
this.v = Quantity.create(transaction.getV());
this.r = Quantity.create(transaction.getR());
this.s = Quantity.create(transaction.getS());
this.versionedHashes = transaction.getVersionedHashes().orElse(null);
}

@JsonGetter(value = "accessList")
Expand Down Expand Up @@ -137,6 +149,11 @@ public String getMaxFeePerGas() {
return maxFeePerGas;
}

@JsonGetter(value = "maxFeePerDataGas")
public String getMaxFeePerDataGas() {
return maxFeePerDataGas;
}

@JsonGetter(value = "hash")
public String getHash() {
return hash;
Expand Down Expand Up @@ -206,4 +223,9 @@ public String getBlockNumber() {
public String getTransactionIndex() {
return null;
}

@JsonGetter(value = "blobVersionedHashes")
public List<Hash> getVersionedHashes() {
return versionedHashes;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,7 @@ public void setupTest() throws Exception {
.type(TransactionType.FRONTIER)
.nonce(42)
.gasLimit(654321)
.gasPrice(Wei.ONE)
.build(),
true,
Instant.ofEpochSecond(Integer.MAX_VALUE))));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -175,6 +175,7 @@ private Object createFakeBlock(final Long height) {
null,
Bytes.EMPTY,
Address.ZERO,
Optional.empty(),
Optional.empty())),
List.of())));
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ public class BaseEeaSendRawTransaction {
Byte.parseByte("1")),
Bytes.fromBase64String(MOCK_ORION_KEY),
Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")),
Optional.empty(),
Optional.empty());

final Transaction PUBLIC_PLUGIN_TRANSACTION =
Expand All @@ -103,6 +104,7 @@ public class BaseEeaSendRawTransaction {
Byte.parseByte("0")),
Bytes.fromBase64String(MOCK_ORION_KEY),
Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")),
Optional.empty(),
Optional.empty());

final Transaction PUBLIC_OFF_CHAIN_TRANSACTION =
Expand All @@ -122,6 +124,7 @@ public class BaseEeaSendRawTransaction {
Byte.parseByte("1")),
Bytes.fromBase64String(MOCK_ORION_KEY),
Address.wrap(Bytes.fromHexString("0x8411b12666f68ef74cace3615c9d5a377729d03f")),
Optional.empty(),
Optional.empty());

final JsonRpcRequestContext validPrivateForTransactionRequest =
Expand Down
Loading

0 comments on commit 617c14a

Please sign in to comment.