Skip to content

Commit

Permalink
Migrate DataGas to BlobGas (hyperledger#5759)
Browse files Browse the repository at this point in the history
In all places move from DataGas to BlobGas when talking about 4844 gas.

Signed-off-by: Danno Ferrin <danno.ferrin@swirldslabs.com>
  • Loading branch information
shemnon authored and garyschulte committed Aug 28, 2023
1 parent 5357f75 commit 07dcef6
Show file tree
Hide file tree
Showing 83 changed files with 668 additions and 657 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4073,6 +4073,6 @@
"gasUsed": "0x0",
"parentHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
"baseFeePerGas": null,
"dataGasUsed": null,
"excessDataGas": null
"blobGasUsed": null,
"excessBlobGas": null
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"blockHash": "0x50c02dc77082fe2060b600cba0e6ce5a491af6d5323b2a90a7bc6359dd18e97b",
"transactions": [],
"withdrawals": [],
"dataGasUsed": null,
"excessDataGas": null
"blobGasUsed": null,
"excessBlobGas": null
}
]
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"blockHash": "0x50c02dc77082fe2060b600cba0e6ce5a491af6d5323b2a90a7bc6359dd18e97b",
"transactions": [],
"withdrawals": [],
"dataGasUsed": null,
"excessDataGas": null
"blobGasUsed": null,
"excessBlobGas": null
},
null
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@
"timestamp": "0x1236",
"extraData": "0x",
"baseFeePerGas": "0x2da282a8",
"excessDataGas": "0x0",
"excessBlobGas": "0x0",
"transactions": [],
"withdrawals": [],
"blockNumber": "0x2",
"dataGasUsed": "0x0",
"blobGasUsed": "0x0",
"receiptsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
"blockHash": "0xc33d43425366d661ef70df12faf8ccd66ed7d0c6718d16d14868ba49e6786927"
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
"blockHash": "0xc33d43425366d661ef70df12faf8ccd66ed7d0c6718d16d14868ba49e6786927",
"transactions": [],
"withdrawals": [],
"dataGasUsed": "0x0",
"excessDataGas": "0x0"
"blobGasUsed": "0x0",
"excessBlobGas": "0x0"
},
[]
]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,9 +15,9 @@
package org.hyperledger.besu.services;

import static com.google.common.base.Preconditions.checkArgument;
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessDataGasCalculator.calculateExcessDataGasForParent;
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;

import org.hyperledger.besu.datatypes.DataGas;
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Hash;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods.TraceBlock.ChainUpdater;
Expand Down Expand Up @@ -111,15 +111,15 @@ private void trace(final Block block, final BlockAwareOperationTracer tracer) {
transaction -> {
final Optional<BlockHeader> maybeParentHeader =
blockchain.getBlockHeader(header.getParentHash());
final Wei dataGasPrice =
final Wei blobGasPrice =
protocolSpec
.getFeeMarket()
.dataPricePerGas(
.blobGasPricePerGas(
maybeParentHeader
.map(
parent ->
calculateExcessDataGasForParent(protocolSpec, parent))
.orElse(DataGas.ZERO));
calculateExcessBlobGasForParent(protocolSpec, parent))
.orElse(BlobGas.ZERO));

tracer.traceStartTransaction(transaction);

Expand All @@ -133,7 +133,7 @@ private void trace(final Block block, final BlockAwareOperationTracer tracer) {
tracer,
new CachingBlockHashLookup(header, blockchain),
false,
dataGasPrice);
blobGasPrice);

long transactionGasUsed = transaction.getGasLimit() - result.getGasRemaining();
tracer.traceEndTransaction(result.getOutput(), transactionGasUsed, 0);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,21 +248,21 @@ public String getNonce() {
}

/**
* Gets excess data gas.
* Gets excess blob gas.
*
* @return the excess data gas
* @return the excess blob gas
*/
public String getExcessDataGas() {
return JsonUtil.getValueAsString(configRoot, "excessdatagas", "0x0");
public String getExcessBlobGas() {
return JsonUtil.getValueAsString(configRoot, "excessblobgas", "0x0");
}

/**
* Gets data gas used.
* Gets blob gas used.
*
* @return the data gas used
* @return the blob gas used
*/
public String getDataGasUsed() {
return JsonUtil.getValueAsString(configRoot, "datagasused", "0x0");
public String getBlobGasUsed() {
return JsonUtil.getValueAsString(configRoot, "blobgasused", "0x0");
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,97 +20,97 @@
import org.apache.tuweni.units.bigints.BaseUInt64Value;
import org.apache.tuweni.units.bigints.UInt64;

/** A particular quantity of DataGas */
public final class DataGas extends BaseUInt64Value<DataGas> implements Quantity {
/** A particular quantity of BlobGas */
public final class BlobGas extends BaseUInt64Value<BlobGas> implements Quantity {

/** The constant ZERO. */
public static final DataGas ZERO = of(0);
public static final BlobGas ZERO = of(0);

/** The constant ONE. */
public static final DataGas ONE = of(1);
public static final BlobGas ONE = of(1);

/** The constant MAX_DATA_GAS. */
public static final DataGas MAX_DATA_GAS = of(UInt64.MAX_VALUE);
/** The constant MAX_BLOB_GAS. */
public static final BlobGas MAX_BLOB_GAS = of(UInt64.MAX_VALUE);

/**
* Instantiates a new DataGas.
* Instantiates a new BlobGas.
*
* @param value the value
*/
DataGas(final UInt64 value) {
super(value, DataGas::new);
BlobGas(final UInt64 value) {
super(value, BlobGas::new);
}

private DataGas(final long v) {
private BlobGas(final long v) {
this(UInt64.valueOf(v));
}

private DataGas(final BigInteger v) {
private BlobGas(final BigInteger v) {
this(UInt64.valueOf(v));
}

private DataGas(final String hexString) {
private BlobGas(final String hexString) {
this(UInt64.fromHexString(hexString));
}

/**
* data gas of value.
* blob gas of value.
*
* @param value the value
* @return the data gas
* @return the blob gas
*/
public static DataGas of(final long value) {
return new DataGas(value);
public static BlobGas of(final long value) {
return new BlobGas(value);
}

/**
* data gas of value.
* blob gas of value.
*
* @param value the value
* @return the data gas
* @return the blob gas
*/
public static DataGas of(final BigInteger value) {
return new DataGas(value);
public static BlobGas of(final BigInteger value) {
return new BlobGas(value);
}

/**
* data gas of value.
* blob gas of value.
*
* @param value the value
* @return the data gas
* @return the blob gas
*/
public static DataGas of(final UInt64 value) {
return new DataGas(value);
public static BlobGas of(final UInt64 value) {
return new BlobGas(value);
}

/**
* data gas of value.
* blob gas of value.
*
* @param value the value
* @return the data gas
* @return the blob gas
*/
public static DataGas ofNumber(final Number value) {
return new DataGas((BigInteger) value);
public static BlobGas ofNumber(final Number value) {
return new BlobGas((BigInteger) value);
}

/**
* Wrap data gas.
* Wrap blob gas.
*
* @param value the value
* @return the data gas
* @return the blob gas
*/
public static DataGas wrap(final Bytes value) {
return new DataGas(UInt64.fromBytes(value));
public static BlobGas wrap(final Bytes value) {
return new BlobGas(UInt64.fromBytes(value));
}

/**
* From hex string to data gas.
* From hex string to blob gas.
*
* @param str the str
* @return the data gas
* @return the blob gas
*/
public static DataGas fromHexString(final String str) {
return new DataGas(str);
public static BlobGas fromHexString(final String str) {
return new BlobGas(str);
}

@Override
Expand All @@ -134,12 +134,12 @@ public String toShortHexString() {
}

/**
* From quantity to data gas.
* From quantity to blob gas.
*
* @param quantity the quantity
* @return the data gas
* @return the blob gas
*/
public static DataGas fromQuantity(final Quantity quantity) {
return DataGas.wrap((Bytes) quantity);
public static BlobGas fromQuantity(final Quantity quantity) {
return BlobGas.wrap((Bytes) quantity);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -73,12 +73,12 @@ default Optional<? extends Quantity> getMaxFeePerGas() {
}

/**
* A scalar value equal to the max number of Wei to be paid for data gas, as specified in
* A scalar value equal to the max number of Wei to be paid for blob gas, as specified in
* EIP-4844.
*
* @return the quantity of Wei for fee per data gas.
* @return the quantity of Wei for fee per blob gas.
*/
default Optional<? extends Quantity> getMaxFeePerDataGas() {
default Optional<? extends Quantity> getMaxFeePerBlobGas() {
return Optional.empty();
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -127,8 +127,8 @@ public JsonRpcResponse response(
mixHash,
nonce,
withdrawalsRoot,
null, // ToDo 4844: set with the value of data_gas_used field
null, // ToDo 4844: set with the value of excess_data_gas field
null, // ToDo 4844: set with the value of blob_gas_used field
null, // ToDo 4844: set with the value of excess_blob_gas field
depositsRoot,
blockHeaderFunctions);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,8 @@ public static RpcErrorType convertTransactionInvalidReason(
return RpcErrorType.NONCE_TOO_FAR_IN_FUTURE_FOR_SENDER;
case LOWER_NONCE_INVALID_TRANSACTION_EXISTS:
return RpcErrorType.LOWER_NONCE_INVALID_TRANSACTION_EXISTS;
case TOTAL_DATA_GAS_TOO_HIGH:
return RpcErrorType.TOTAL_DATA_GAS_TOO_HIGH;
case TOTAL_BLOB_GAS_TOO_HIGH:
return RpcErrorType.TOTAL_BLOB_GAS_TOO_HIGH;
case TX_POOL_DISABLED:
return RpcErrorType.TX_POOL_DISABLED;
default:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@
*/
package org.hyperledger.besu.ethereum.api.jsonrpc.internal.methods;

import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessDataGasCalculator.calculateExcessDataGasForParent;
import static org.hyperledger.besu.ethereum.mainnet.feemarket.ExcessBlobGasCalculator.calculateExcessBlobGasForParent;

import org.hyperledger.besu.datatypes.DataGas;
import org.hyperledger.besu.datatypes.BlobGas;
import org.hyperledger.besu.datatypes.Wei;
import org.hyperledger.besu.ethereum.api.jsonrpc.internal.processor.TransactionTrace;
import org.hyperledger.besu.ethereum.chain.Blockchain;
Expand Down Expand Up @@ -88,13 +88,13 @@ public TransactionTrace apply(final TransactionTrace transactionTrace) {
BlockHeader header = block.getHeader();
final Optional<BlockHeader> maybeParentHeader =
blockchain.getBlockHeader(header.getParentHash());
final Wei dataGasPrice =
final Wei blobGasPrice =
protocolSpec
.getFeeMarket()
.dataPricePerGas(
.blobGasPricePerGas(
maybeParentHeader
.map(parent -> calculateExcessDataGasForParent(protocolSpec, parent))
.orElse(DataGas.ZERO));
.map(parent -> calculateExcessBlobGasForParent(protocolSpec, parent))
.orElse(BlobGas.ZERO));
final BlockHashLookup blockHashLookup = new CachingBlockHashLookup(header, blockchain);
result =
transactionProcessor.processTransaction(
Expand All @@ -106,7 +106,7 @@ public TransactionTrace apply(final TransactionTrace transactionTrace) {
tracer,
blockHashLookup,
false,
dataGasPrice);
blobGasPrice);

traceFrames = tracer.copyTraceFrames();
tracer.reset();
Expand Down
Loading

0 comments on commit 07dcef6

Please sign in to comment.