Skip to content

Commit

Permalink
rename data gas to blob gas (Consensys#7398)
Browse files Browse the repository at this point in the history
* rename data gas to blob gas
  • Loading branch information
mehdi-aouadi authored Jul 28, 2023
1 parent 94542e0 commit 0cba9ef
Show file tree
Hide file tree
Showing 28 changed files with 131 additions and 132 deletions.
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title" : "ExecutionPayloadDeneb",
"type" : "object",
"required" : [ "parent_hash", "fee_recipient", "state_root", "receipts_root", "logs_bloom", "prev_randao", "block_number", "gas_limit", "gas_used", "timestamp", "extra_data", "base_fee_per_gas", "block_hash", "transactions", "withdrawals", "data_gas_used", "excess_data_gas" ],
"required" : [ "parent_hash", "fee_recipient", "state_root", "receipts_root", "logs_bloom", "prev_randao", "block_number", "gas_limit", "gas_used", "timestamp", "extra_data", "base_fee_per_gas", "block_hash", "transactions", "withdrawals", "blob_gas_used", "excess_blob_gas" ],
"properties" : {
"parent_hash" : {
"type" : "string",
Expand Down Expand Up @@ -96,13 +96,13 @@
"$ref" : "#/components/schemas/Withdrawal"
}
},
"data_gas_used" : {
"blob_gas_used" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
"format" : "uint64"
},
"excess_data_gas" : {
"excess_blob_gas" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"title" : "ExecutionPayloadHeaderDeneb",
"type" : "object",
"required" : [ "parent_hash", "fee_recipient", "state_root", "receipts_root", "logs_bloom", "prev_randao", "block_number", "gas_limit", "gas_used", "timestamp", "extra_data", "base_fee_per_gas", "block_hash", "transactions_root", "withdrawals_root", "data_gas_used", "excess_data_gas" ],
"required" : [ "parent_hash", "fee_recipient", "state_root", "receipts_root", "logs_bloom", "prev_randao", "block_number", "gas_limit", "gas_used", "timestamp", "extra_data", "base_fee_per_gas", "block_hash", "transactions_root", "withdrawals_root", "blob_gas_used", "excess_blob_gas" ],
"properties" : {
"parent_hash" : {
"type" : "string",
Expand Down Expand Up @@ -93,13 +93,13 @@
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"format" : "byte"
},
"data_gas_used" : {
"blob_gas_used" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
"format" : "uint64"
},
"excess_data_gas" : {
"excess_blob_gas" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,11 +32,11 @@

public class ExecutionPayloadDeneb extends ExecutionPayloadCapella implements ExecutionPayload {

@JsonProperty("data_gas_used")
public final UInt64 dataGasUsed;
@JsonProperty("blob_gas_used")
public final UInt64 blobGasUsed;

@JsonProperty("excess_data_gas")
public final UInt64 excessDataGas;
@JsonProperty("excess_blob_gas")
public final UInt64 excessBlobGas;

@JsonCreator
public ExecutionPayloadDeneb(
Expand All @@ -55,8 +55,8 @@ public ExecutionPayloadDeneb(
@JsonProperty("block_hash") final Bytes32 blockHash,
@JsonProperty("transactions") final List<Bytes> transactions,
@JsonProperty("withdrawals") final List<Withdrawal> withdrawals,
@JsonProperty("data_gas_used") final UInt64 dataGasUsed,
@JsonProperty("excess_data_gas") final UInt64 excessDataGas) {
@JsonProperty("blob_gas_used") final UInt64 blobGasUsed,
@JsonProperty("excess_blob_gas") final UInt64 excessBlobGas) {
super(
parentHash,
feeRecipient,
Expand All @@ -73,24 +73,24 @@ public ExecutionPayloadDeneb(
blockHash,
transactions,
withdrawals);
this.dataGasUsed = dataGasUsed;
this.excessDataGas = excessDataGas;
this.blobGasUsed = blobGasUsed;
this.excessBlobGas = excessBlobGas;
}

public ExecutionPayloadDeneb(
final tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload executionPayload) {
super(executionPayload);
this.dataGasUsed = executionPayload.toVersionDeneb().orElseThrow().getDataGasUsed();
this.excessDataGas = executionPayload.toVersionDeneb().orElseThrow().getExcessDataGas();
this.blobGasUsed = executionPayload.toVersionDeneb().orElseThrow().getBlobGasUsed();
this.excessBlobGas = executionPayload.toVersionDeneb().orElseThrow().getExcessBlobGas();
}

@Override
protected ExecutionPayloadBuilder applyToBuilder(
final ExecutionPayloadSchema<?> executionPayloadSchema,
final ExecutionPayloadBuilder builder) {
return super.applyToBuilder(executionPayloadSchema, builder)
.dataGasUsed(() -> dataGasUsed)
.excessDataGas(() -> excessDataGas);
.blobGasUsed(() -> blobGasUsed)
.excessBlobGas(() -> excessBlobGas);
}

@Override
Expand All @@ -110,13 +110,13 @@ public boolean equals(final Object o) {
return false;
}
final ExecutionPayloadDeneb that = (ExecutionPayloadDeneb) o;
return Objects.equals(dataGasUsed, that.dataGasUsed)
&& Objects.equals(excessDataGas, that.excessDataGas);
return Objects.equals(blobGasUsed, that.blobGasUsed)
&& Objects.equals(excessBlobGas, that.excessBlobGas);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), dataGasUsed, excessDataGas);
return Objects.hash(super.hashCode(), blobGasUsed, excessBlobGas);
}

@Override
Expand All @@ -137,8 +137,8 @@ public String toString() {
.add("blockHash", blockHash)
.add("transactions", transactions)
.add("withdrawals", withdrawals)
.add("dataGasUsed", dataGasUsed)
.add("excessDataGas", excessDataGas)
.add("blobGasUsed", blobGasUsed)
.add("excessBlobGas", excessBlobGas)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,11 +29,11 @@

public class ExecutionPayloadHeaderDeneb extends ExecutionPayloadHeaderCapella {

@JsonProperty("data_gas_used")
public final UInt64 dataGasUsed;
@JsonProperty("blob_gas_used")
public final UInt64 blobGasUsed;

@JsonProperty("excess_data_gas")
public final UInt64 excessDataGas;
@JsonProperty("excess_blob_gas")
public final UInt64 excessBlobGas;

@JsonCreator
public ExecutionPayloadHeaderDeneb(
Expand All @@ -52,8 +52,8 @@ public ExecutionPayloadHeaderDeneb(
@JsonProperty("block_hash") final Bytes32 blockHash,
@JsonProperty("transactions_root") final Bytes32 transactionsRoot,
@JsonProperty("withdrawals_root") final Bytes32 withdrawalsRoot,
@JsonProperty("data_gas_used") final UInt64 dataGasUsed,
@JsonProperty("excess_data_gas") final UInt64 excessDataGas) {
@JsonProperty("blob_gas_used") final UInt64 blobGasUsed,
@JsonProperty("excess_blob_gas") final UInt64 excessBlobGas) {
super(
parentHash,
feeRecipient,
Expand All @@ -70,8 +70,8 @@ public ExecutionPayloadHeaderDeneb(
blockHash,
transactionsRoot,
withdrawalsRoot);
this.dataGasUsed = dataGasUsed;
this.excessDataGas = excessDataGas;
this.blobGasUsed = blobGasUsed;
this.excessBlobGas = excessBlobGas;
}

public ExecutionPayloadHeaderDeneb(final ExecutionPayloadHeader executionPayloadHeader) {
Expand All @@ -91,8 +91,8 @@ public ExecutionPayloadHeaderDeneb(final ExecutionPayloadHeader executionPayload
executionPayloadHeader.getBlockHash(),
executionPayloadHeader.getTransactionsRoot(),
executionPayloadHeader.getOptionalWithdrawalsRoot().orElseThrow());
this.dataGasUsed = executionPayloadHeader.toVersionDeneb().orElseThrow().getDataGasUsed();
this.excessDataGas = executionPayloadHeader.toVersionDeneb().orElseThrow().getExcessDataGas();
this.blobGasUsed = executionPayloadHeader.toVersionDeneb().orElseThrow().getBlobGasUsed();
this.excessBlobGas = executionPayloadHeader.toVersionDeneb().orElseThrow().getExcessBlobGas();
}

@Override
Expand All @@ -116,8 +116,8 @@ public ExecutionPayloadHeader asInternalExecutionPayloadHeader(
.blockHash(blockHash)
.transactionsRoot(transactionsRoot)
.withdrawalsRoot(() -> withdrawalsRoot)
.dataGasUsed(() -> dataGasUsed)
.excessDataGas(() -> excessDataGas));
.blobGasUsed(() -> blobGasUsed)
.excessBlobGas(() -> excessBlobGas));
}

@Override
Expand All @@ -137,13 +137,13 @@ public boolean equals(final Object o) {
return false;
}
final ExecutionPayloadHeaderDeneb that = (ExecutionPayloadHeaderDeneb) o;
return Objects.equals(dataGasUsed, that.dataGasUsed)
&& Objects.equals(excessDataGas, that.excessDataGas);
return Objects.equals(blobGasUsed, that.blobGasUsed)
&& Objects.equals(excessBlobGas, that.excessBlobGas);
}

@Override
public int hashCode() {
return Objects.hash(super.hashCode(), dataGasUsed, excessDataGas);
return Objects.hash(super.hashCode(), blobGasUsed, excessBlobGas);
}

@Override
Expand All @@ -164,8 +164,8 @@ public String toString() {
.add("blockHash", blockHash)
.add("transactionsRoot", transactionsRoot)
.add("withdrawalsRoot", withdrawalsRoot)
.add("dataGasUsed", dataGasUsed)
.add("excessDataGas", excessDataGas)
.add("blobGasUsed", blobGasUsed)
.add("excessBlobGas", excessBlobGas)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -29,8 +29,7 @@ public class ReferenceTestFinder {
private static final Path TEST_PATH_FROM_MODULE =
Path.of("src", "referenceTest", "resources", "consensus-spec-tests", "tests");
private static final List<String> SUPPORTED_FORKS =
List.of(
TestFork.PHASE0, TestFork.ALTAIR, TestFork.BELLATRIX, TestFork.CAPELLA, TestFork.DENEB);
List.of(TestFork.PHASE0, TestFork.ALTAIR, TestFork.BELLATRIX, TestFork.CAPELLA);

@MustBeClosed
public static Stream<TestDefinition> findReferenceTests() throws IOException {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -247,12 +247,12 @@ public void newPayloadV3_shouldBuildRequestAndResponseSuccessfully() {
assertThat(executionPayloadV3Parameter.get("parentHash"))
.isEqualTo(executionPayloadV3.parentHash.toHexString());

assertThat(executionPayloadV3Parameter.get("dataGasUsed"))
assertThat(executionPayloadV3Parameter.get("blobGasUsed"))
.isEqualTo(
Bytes.ofUnsignedLong(executionPayloadV3.dataGasUsed.longValue()).toQuantityHexString());
assertThat(executionPayloadV3Parameter.get("excessDataGas"))
Bytes.ofUnsignedLong(executionPayloadV3.blobGasUsed.longValue()).toQuantityHexString());
assertThat(executionPayloadV3Parameter.get("excessBlobGas"))
.isEqualTo(
Bytes.ofUnsignedLong(executionPayloadV3.excessDataGas.longValue())
Bytes.ofUnsignedLong(executionPayloadV3.excessBlobGas.longValue())
.toQuantityHexString());
assertThat(((List<Object>) requestData.get("params")).get(1))
.asInstanceOf(LIST)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -210,8 +210,8 @@
"block_hash": "0xc02310cdcc9e8ddc40b9aee79e425463dc4f04209a2159c781a4d8fdebee62f6",
"transactions_root": "0xd3440acd6cea6c2135fc151371cb6830e25203b250ea8181ae251cc6c54f1a81",
"withdrawals_root": "0x18cf2fce2e25d0ad50e8ea981c126622aabb342eb3b68a25beeaeca81f654969",
"data_gas_used": "14779654655076927372",
"excess_data_gas": "14778002167565275948"
"blob_gas_used": "14779654655076927372",
"excess_blob_gas": "14778002167565275948"
},
"bls_to_execution_changes": [
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,8 @@
"timestamp": "1",
"extra_data": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"base_fee_per_gas": "1",
"data_gas_used": "1",
"excess_data_gas": "1",
"blob_gas_used": "1",
"excess_blob_gas": "1",
"block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"transactions_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"withdrawals_root": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
"timestamp": "1",
"extra_data": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"base_fee_per_gas": "1",
"data_gas_used": "1",
"excess_data_gas": "1",
"blob_gas_used": "1",
"excess_blob_gas": "1",
"block_hash": "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"transactions": [
"0x02f878831469668303f51d843b9ac9f9843b9aca0082520894c93269b73096998db66be0441e836d873535cb9c8894a19041886f000080c001a031cc29234036afbf9a1fb9476b463367cb1f957ac0b919b69bbc798436e604aaa018c4e9c3914eb27aadd0b91e10b18655739fcf8c1fc398763a9f1beecb8ddc86"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@
public class ExecutionPayloadV3 extends ExecutionPayloadV2 {
@JsonSerialize(using = UInt64AsHexSerializer.class)
@JsonDeserialize(using = UInt64AsHexDeserializer.class)
public final UInt64 dataGasUsed;
public final UInt64 blobGasUsed;

@JsonSerialize(using = UInt64AsHexSerializer.class)
@JsonDeserialize(using = UInt64AsHexDeserializer.class)
public final UInt64 excessDataGas;
public final UInt64 excessBlobGas;

public ExecutionPayloadV3(
@JsonProperty("parentHash") Bytes32 parentHash,
Expand All @@ -58,8 +58,8 @@ public ExecutionPayloadV3(
@JsonProperty("blockHash") Bytes32 blockHash,
@JsonProperty("transactions") List<Bytes> transactions,
@JsonProperty("withdrawals") List<WithdrawalV1> withdrawals,
@JsonProperty("dataGasUsed") UInt64 dataGasUsed,
@JsonProperty("excessDataGas") UInt64 excessDataGas) {
@JsonProperty("blobGasUsed") UInt64 blobGasUsed,
@JsonProperty("excessBlobGas") UInt64 excessBlobGas) {
super(
parentHash,
feeRecipient,
Expand All @@ -76,8 +76,8 @@ public ExecutionPayloadV3(
blockHash,
transactions,
withdrawals);
this.dataGasUsed = dataGasUsed;
this.excessDataGas = excessDataGas;
this.blobGasUsed = blobGasUsed;
this.excessBlobGas = excessBlobGas;
}

public static ExecutionPayloadV3 fromInternalExecutionPayload(
Expand All @@ -102,10 +102,10 @@ public static ExecutionPayloadV3 fromInternalExecutionPayload(
.map(SszByteListImpl::getBytes)
.collect(Collectors.toList()),
withdrawalsList,
executionPayload.toVersionDeneb().map(ExecutionPayloadDeneb::getDataGasUsed).orElse(null),
executionPayload.toVersionDeneb().map(ExecutionPayloadDeneb::getBlobGasUsed).orElse(null),
executionPayload
.toVersionDeneb()
.map(ExecutionPayloadDeneb::getExcessDataGas)
.map(ExecutionPayloadDeneb::getExcessBlobGas)
.orElse(null));
}

Expand All @@ -114,8 +114,8 @@ protected ExecutionPayloadBuilder applyToBuilder(
final ExecutionPayloadSchema<?> executionPayloadSchema,
final ExecutionPayloadBuilder builder) {
return super.applyToBuilder(executionPayloadSchema, builder)
.dataGasUsed(() -> checkNotNull(dataGasUsed, "dataGasUsed not provided when required"))
.excessDataGas(
() -> checkNotNull(excessDataGas, "excessDataGas not provided when required"));
.blobGasUsed(() -> checkNotNull(blobGasUsed, "blobGasUsed not provided when required"))
.excessBlobGas(
() -> checkNotNull(excessBlobGas, "excessBlobGas not provided when required"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -301,7 +301,7 @@ private ExecutionPayloadHeader createExecutionPayloadHeaderWithGasLimit(
.blockHash(Bytes32.random())
.transactionsRoot(Bytes32.ZERO)
.withdrawalsRoot(() -> Bytes32.ZERO)
.dataGasUsed(() -> UInt64.ONE)
.excessDataGas(() -> UInt64.ONE));
.blobGasUsed(() -> UInt64.ONE)
.excessBlobGas(() -> UInt64.ONE));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -53,9 +53,9 @@ public interface ExecutionPayloadBuilder {

ExecutionPayloadBuilder withdrawals(Supplier<List<Withdrawal>> withdrawalsSupplier);

ExecutionPayloadBuilder dataGasUsed(Supplier<UInt64> dataGasUsedSupplier);
ExecutionPayloadBuilder blobGasUsed(Supplier<UInt64> blobGasUsedSupplier);

ExecutionPayloadBuilder excessDataGas(Supplier<UInt64> excessDataGasSupplier);
ExecutionPayloadBuilder excessBlobGas(Supplier<UInt64> excessBlobGasSupplier);

ExecutionPayload build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -34,8 +34,8 @@ public enum ExecutionPayloadFields implements SszFieldName {
WITHDRAWALS,
TRANSACTIONS_ROOT,
WITHDRAWALS_ROOT,
DATA_GAS_USED,
EXCESS_DATA_GAS;
BLOB_GAS_USED,
EXCESS_BLOB_GAS;

private final String sszFieldName;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,9 +51,9 @@ public interface ExecutionPayloadHeaderBuilder {

ExecutionPayloadHeaderBuilder withdrawalsRoot(Supplier<Bytes32> withdrawalsRootSupplier);

ExecutionPayloadHeaderBuilder dataGasUsed(Supplier<UInt64> dataGasUsedSupplier);
ExecutionPayloadHeaderBuilder blobGasUsed(Supplier<UInt64> blobGasUsedSupplier);

ExecutionPayloadHeaderBuilder excessDataGas(Supplier<UInt64> excessDataGasSupplier);
ExecutionPayloadHeaderBuilder excessBlobGas(Supplier<UInt64> excessBlobGasSupplier);

ExecutionPayloadHeader build();
}
Loading

0 comments on commit 0cba9ef

Please sign in to comment.