Skip to content

Commit

Permalink
change order and make data_gas_used UInt64
Browse files Browse the repository at this point in the history
  • Loading branch information
StefanBratanov committed Jun 1, 2023
1 parent 4a93861 commit 38313bb
Show file tree
Hide file tree
Showing 23 changed files with 117 additions and 121 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", "excess_data_gas", "data_gas_used" ],
"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" ],
"properties" : {
"parent_hash" : {
"type" : "string",
Expand Down Expand Up @@ -96,17 +96,17 @@
"$ref" : "#/components/schemas/Withdrawal"
}
},
"excess_data_gas" : {
"data_gas_used" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
"format" : "uint64"
},
"data_gas_used" : {
"excess_data_gas" : {
"type" : "string",
"description" : "unsigned 256 bit integer",
"description" : "unsigned 64 bit integer",
"example" : "1",
"format" : "uint256"
"format" : "uint64"
}
}
}
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", "excess_data_gas", "data_gas_used" ],
"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" ],
"properties" : {
"parent_hash" : {
"type" : "string",
Expand Down Expand Up @@ -93,17 +93,17 @@
"example" : "0xcf8e0d4e9587369b2301d0790347320302cc0943d5a1884560367e8208d920f2",
"format" : "byte"
},
"excess_data_gas" : {
"data_gas_used" : {
"type" : "string",
"description" : "unsigned 64 bit integer",
"example" : "1",
"format" : "uint64"
},
"data_gas_used" : {
"excess_data_gas" : {
"type" : "string",
"description" : "unsigned 256 bit integer",
"description" : "unsigned 64 bit integer",
"example" : "1",
"format" : "uint256"
"format" : "uint64"
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,12 @@

public class ExecutionPayloadDeneb extends ExecutionPayloadCapella implements ExecutionPayload {

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

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

@JsonProperty("data_gas_used")
public final UInt256 dataGasUsed;

@JsonCreator
public ExecutionPayloadDeneb(
@JsonProperty("parent_hash") final Bytes32 parentHash,
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("excess_data_gas") final UInt64 excessDataGas,
@JsonProperty("data_gas_used") final UInt256 dataGasUsed) {
@JsonProperty("data_gas_used") final UInt64 dataGasUsed,
@JsonProperty("excess_data_gas") final UInt64 excessDataGas) {
super(
parentHash,
feeRecipient,
Expand All @@ -73,24 +73,24 @@ public ExecutionPayloadDeneb(
blockHash,
transactions,
withdrawals);
this.excessDataGas = excessDataGas;
this.dataGasUsed = dataGasUsed;
this.excessDataGas = excessDataGas;
}

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

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

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

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

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

public class ExecutionPayloadHeaderDeneb extends ExecutionPayloadHeaderCapella {

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

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

@JsonProperty("data_gas_used")
public final UInt256 dataGasUsed;

@JsonCreator
public ExecutionPayloadHeaderDeneb(
@JsonProperty("parent_hash") final Bytes32 parentHash,
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("excess_data_gas") final UInt64 excessDataGas,
@JsonProperty("data_gas_used") final UInt256 dataGasUsed) {
@JsonProperty("data_gas_used") final UInt64 dataGasUsed,
@JsonProperty("excess_data_gas") final UInt64 excessDataGas) {
super(
parentHash,
feeRecipient,
Expand All @@ -70,8 +70,8 @@ public ExecutionPayloadHeaderDeneb(
blockHash,
transactionsRoot,
withdrawalsRoot);
this.excessDataGas = excessDataGas;
this.dataGasUsed = dataGasUsed;
this.excessDataGas = excessDataGas;
}

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

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

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

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

@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("data_gas_used", dataGasUsed)
.toString();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,6 @@
import org.apache.tuweni.bytes.Bytes;
import org.apache.tuweni.bytes.Bytes32;
import org.apache.tuweni.units.bigints.UInt256;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexDeserializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt256AsHexSerializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexDeserializer;
import tech.pegasys.teku.ethereum.executionclient.serialization.UInt64AsHexSerializer;
import tech.pegasys.teku.infrastructure.bytes.Bytes20;
Expand All @@ -38,11 +36,11 @@
public class ExecutionPayloadV3 extends ExecutionPayloadV2 {
@JsonSerialize(using = UInt64AsHexSerializer.class)
@JsonDeserialize(using = UInt64AsHexDeserializer.class)
public final UInt64 excessDataGas;
public final UInt64 dataGasUsed;

@JsonSerialize(using = UInt256AsHexSerializer.class)
@JsonDeserialize(using = UInt256AsHexDeserializer.class)
public final UInt256 dataGasUsed;
@JsonSerialize(using = UInt64AsHexSerializer.class)
@JsonDeserialize(using = UInt64AsHexDeserializer.class)
public final UInt64 excessDataGas;

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

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

@Override
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"))
.dataGasUsed(() -> checkNotNull(dataGasUsed, "dataGasUsed not provided when required"));
() -> checkNotNull(excessDataGas, "excessDataGas not provided when required"));
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -298,7 +298,7 @@ private ExecutionPayloadHeader createExecutionPayloadHeaderWithGasLimit(
.blockHash(Bytes32.random())
.transactionsRoot(Bytes32.ZERO)
.withdrawalsRoot(() -> Bytes32.ZERO)
.excessDataGas(() -> UInt64.ONE)
.dataGasUsed(() -> UInt256.ONE));
.dataGasUsed(() -> UInt64.ONE)
.excessDataGas(() -> 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 excessDataGas(Supplier<UInt64> excessDataGasSupplier);
ExecutionPayloadBuilder dataGasUsed(Supplier<UInt64> dataGasUsedSupplier);

ExecutionPayloadBuilder dataGasUsed(Supplier<UInt256> dataGasUsedSupplier);
ExecutionPayloadBuilder excessDataGas(Supplier<UInt64> excessDataGasSupplier);

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,
EXCESS_DATA_GAS,
DATA_GAS_USED;
DATA_GAS_USED,
EXCESS_DATA_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 excessDataGas(Supplier<UInt64> excessDataGasSupplier);
ExecutionPayloadHeaderBuilder dataGasUsed(Supplier<UInt64> dataGasUsedSupplier);

ExecutionPayloadHeaderBuilder dataGasUsed(Supplier<UInt256> dataGasUsedSupplier);
ExecutionPayloadHeaderBuilder excessDataGas(Supplier<UInt64> excessDataGasSupplier);

ExecutionPayloadHeader build();
}
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ public ExecutionPayloadBuilder withdrawals(final Supplier<List<Withdrawal>> with
}

@Override
public ExecutionPayloadBuilder excessDataGas(final Supplier<UInt64> excessDataGasSupplier) {
public ExecutionPayloadBuilder dataGasUsed(final Supplier<UInt64> dataGasUsedSupplier) {
return this;
}

@Override
public ExecutionPayloadBuilder dataGasUsed(final Supplier<UInt256> dataGasUsedSupplier) {
public ExecutionPayloadBuilder excessDataGas(final Supplier<UInt64> excessDataGasSupplier) {
return this;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,12 +143,12 @@ public ExecutionPayloadHeaderBuilder withdrawalsRoot(
}

@Override
public ExecutionPayloadHeaderBuilder excessDataGas(final Supplier<UInt64> excessDataGasSupplier) {
public ExecutionPayloadHeaderBuilder dataGasUsed(final Supplier<UInt64> dataGasUsedSupplier) {
return this;
}

@Override
public ExecutionPayloadHeaderBuilder dataGasUsed(final Supplier<UInt256> dataGasUsedSupplier) {
public ExecutionPayloadHeaderBuilder excessDataGas(final Supplier<UInt64> excessDataGasSupplier) {
return this;
}

Expand Down
Loading

0 comments on commit 38313bb

Please sign in to comment.