Skip to content

Commit

Permalink
[Merge] add extra_data field in ExecutionPayload and `ExecutionPa…
Browse files Browse the repository at this point in the history
…yloadHeader` Ssz (#4392)

* Updated `ExecutionPayload` and `ExecutionPayloadHeader` Ssz (#4346)

* rename miner->coinbase in client schema and zeroed extra_data in GenesisGenerator  (#4346)
  • Loading branch information
tbenr authored Sep 27, 2021
1 parent 05ae79a commit 8381c48
Show file tree
Hide file tree
Showing 13 changed files with 148 additions and 34 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ public BeaconBlockBodyMerge(
() ->
new tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload(
executionPayload.parent_hash,
executionPayload.miner,
executionPayload.coinbase,
executionPayload.state_root,
executionPayload.receipt_root,
executionPayload.logs_bloom,
Expand All @@ -85,6 +85,7 @@ public BeaconBlockBodyMerge(
executionPayload.gas_limit,
executionPayload.gas_used,
executionPayload.timestamp,
executionPayload.extra_data,
executionPayload.base_fee_per_gas,
executionPayload.block_hash,
executionPayload.transactions)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -168,6 +168,7 @@ protected void applyAdditionalFields(final MutableBeaconState state) {
latest_execution_payload_header.gas_limit,
latest_execution_payload_header.gas_used,
latest_execution_payload_header.timestamp,
latest_execution_payload_header.extra_data,
latest_execution_payload_header.base_fee_per_gas,
latest_execution_payload_header.block_hash,
latest_execution_payload_header.transactions_root));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
public class ExecutionPayload {

public final Bytes32 parent_hash;
public final Bytes20 miner;
public final Bytes20 coinbase;
public final Bytes32 state_root;
public final Bytes32 receipt_root;
public final Bytes logs_bloom;
Expand All @@ -38,13 +38,14 @@ public class ExecutionPayload {
public final UInt64 gas_limit;
public final UInt64 gas_used;
public final UInt64 timestamp;
public final Bytes extra_data;
public final Bytes32 base_fee_per_gas;
public final Bytes32 block_hash;
public final List<Bytes> transactions;

public ExecutionPayload(
@JsonProperty("parent_hash") Bytes32 parent_hash,
@JsonProperty("miner") Bytes20 miner,
@JsonProperty("coinbase") Bytes20 coinbase,
@JsonProperty("state_root") Bytes32 state_root,
@JsonProperty("receipt_root") Bytes32 receipt_root,
@JsonProperty("logs_bloom") Bytes logs_bloom,
Expand All @@ -53,11 +54,12 @@ public ExecutionPayload(
@JsonProperty("gas_limit") UInt64 gas_limit,
@JsonProperty("gas_used") UInt64 gas_used,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extra_data") Bytes extra_data,
@JsonProperty("base_fee_per_gas") Bytes32 base_fee_per_gas,
@JsonProperty("block_hash") Bytes32 block_hash,
@JsonProperty("transactions") List<Bytes> transactions) {
this.parent_hash = parent_hash;
this.miner = miner;
this.coinbase = coinbase;
this.state_root = state_root;
this.receipt_root = receipt_root;
this.logs_bloom = logs_bloom;
Expand All @@ -66,6 +68,7 @@ public ExecutionPayload(
this.gas_limit = gas_limit;
this.gas_used = gas_used;
this.timestamp = timestamp;
this.extra_data = extra_data;
this.base_fee_per_gas = base_fee_per_gas;
this.block_hash = block_hash;
this.transactions = transactions != null ? transactions : Collections.emptyList();
Expand All @@ -74,7 +77,7 @@ public ExecutionPayload(
public ExecutionPayload(
tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload executionPayload) {
this.parent_hash = executionPayload.getParent_hash();
this.miner = executionPayload.getCoinbase();
this.coinbase = executionPayload.getCoinbase();
this.state_root = executionPayload.getState_root();
this.receipt_root = executionPayload.getReceipt_root();
this.logs_bloom = executionPayload.getLogs_bloom();
Expand All @@ -83,6 +86,7 @@ public ExecutionPayload(
this.gas_limit = executionPayload.getGas_limit();
this.gas_used = executionPayload.getGas_used();
this.timestamp = executionPayload.getTimestamp();
this.extra_data = executionPayload.getExtraData();
this.base_fee_per_gas = executionPayload.getBaseFeePerGas();
this.block_hash = executionPayload.getBlock_hash();
this.transactions =
Expand All @@ -96,7 +100,7 @@ public ExecutionPayload(
asInternalExecutionPayload() {
return new tech.pegasys.teku.spec.datastructures.execution.ExecutionPayload(
parent_hash,
miner,
coinbase,
state_root,
receipt_root,
logs_bloom,
Expand All @@ -105,6 +109,7 @@ public ExecutionPayload(
gas_limit,
gas_used,
timestamp,
extra_data,
base_fee_per_gas,
block_hash,
transactions);
Expand All @@ -120,7 +125,7 @@ public boolean equals(final Object o) {
}
final ExecutionPayload that = (ExecutionPayload) o;
return Objects.equals(parent_hash, that.parent_hash)
&& Objects.equals(miner, that.miner)
&& Objects.equals(coinbase, that.coinbase)
&& Objects.equals(state_root, that.state_root)
&& Objects.equals(receipt_root, that.receipt_root)
&& Objects.equals(logs_bloom, that.logs_bloom)
Expand All @@ -129,6 +134,7 @@ public boolean equals(final Object o) {
&& Objects.equals(gas_limit, that.gas_limit)
&& Objects.equals(gas_used, that.gas_used)
&& Objects.equals(timestamp, that.timestamp)
&& Objects.equals(extra_data, that.extra_data)
&& Objects.equals(base_fee_per_gas, that.base_fee_per_gas)
&& Objects.equals(block_hash, that.block_hash)
&& Objects.equals(transactions, that.transactions);
Expand All @@ -138,7 +144,7 @@ public boolean equals(final Object o) {
public int hashCode() {
return Objects.hash(
parent_hash,
miner,
coinbase,
state_root,
receipt_root,
logs_bloom,
Expand All @@ -147,6 +153,7 @@ public int hashCode() {
gas_limit,
gas_used,
timestamp,
extra_data,
base_fee_per_gas,
block_hash,
transactions);
Expand All @@ -156,7 +163,7 @@ public int hashCode() {
public String toString() {
return MoreObjects.toStringHelper(this)
.add("parent_hash", parent_hash)
.add("miner", miner)
.add("coinbase", coinbase)
.add("state_root", state_root)
.add("receipt_root", receipt_root)
.add("logs_bloom", logs_bloom)
Expand All @@ -165,6 +172,7 @@ public String toString() {
.add("gas_limit", gas_limit)
.add("gas_used", gas_used)
.add("timestamp", timestamp)
.add("extra_data", extra_data)
.add("base_fee_per_gas", base_fee_per_gas)
.add("block_hash", block_hash)
.add("transactions", transactions)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ public class ExecutionPayloadHeader {
public final UInt64 gas_limit;
public final UInt64 gas_used;
public final UInt64 timestamp;
public final Bytes extra_data;
public final Bytes32 base_fee_per_gas;
public final Bytes32 block_hash;
public final Bytes32 transactions_root;
Expand All @@ -48,6 +49,7 @@ public ExecutionPayloadHeader(
@JsonProperty("gas_limit") UInt64 gas_limit,
@JsonProperty("gas_used") UInt64 gas_used,
@JsonProperty("timestamp") UInt64 timestamp,
@JsonProperty("extra_data") Bytes extra_data,
@JsonProperty("base_fee_per_gas") Bytes32 base_fee_per_gas,
@JsonProperty("block_hash") Bytes32 block_hash,
@JsonProperty("transactions_root") Bytes32 transactions_root) {
Expand All @@ -61,6 +63,7 @@ public ExecutionPayloadHeader(
this.gas_limit = gas_limit;
this.gas_used = gas_used;
this.timestamp = timestamp;
this.extra_data = extra_data;
this.base_fee_per_gas = base_fee_per_gas;
this.block_hash = block_hash;
this.transactions_root = transactions_root;
Expand All @@ -79,6 +82,7 @@ public ExecutionPayloadHeader(
this.gas_limit = executionPayloadHeader.getGas_limit();
this.gas_used = executionPayloadHeader.getGas_used();
this.timestamp = executionPayloadHeader.getTimestamp();
this.extra_data = executionPayloadHeader.getExtraData();
this.base_fee_per_gas = executionPayloadHeader.getBaseFeePerGas();
this.block_hash = executionPayloadHeader.getBlock_hash();
this.transactions_root = executionPayloadHeader.getTransactions_root();
Expand All @@ -97,6 +101,7 @@ public ExecutionPayloadHeader(
gas_limit,
gas_used,
timestamp,
extra_data,
base_fee_per_gas,
block_hash,
transactions_root);
Expand All @@ -121,6 +126,7 @@ public boolean equals(final Object o) {
&& Objects.equals(gas_limit, that.gas_limit)
&& Objects.equals(gas_used, that.gas_used)
&& Objects.equals(timestamp, that.timestamp)
&& Objects.equals(extra_data, that.extra_data)
&& Objects.equals(base_fee_per_gas, that.base_fee_per_gas)
&& Objects.equals(block_hash, that.block_hash)
&& Objects.equals(transactions_root, that.transactions_root);
Expand All @@ -139,6 +145,7 @@ public int hashCode() {
gas_limit,
gas_used,
timestamp,
extra_data,
base_fee_per_gas,
block_hash,
transactions_root);
Expand All @@ -157,6 +164,7 @@ public String toString() {
.add("gas_limit", gas_limit)
.add("gas_used", gas_used)
.add("timestamp", timestamp)
.add("extra_data", extra_data)
.add("base_fee_per_gas", base_fee_per_gas)
.add("block_hash", block_hash)
.add("transactions_root", transactions_root)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ public interface SpecConfig {
int BYTES_PER_LOGS_BLOOM = 256;
int MAX_BYTES_PER_OPAQUE_TRANSACTION = 1048576;
int MAX_EXECUTION_TRANSACTIONS = 16384;
int MAX_EXTRA_DATA_BYTES = 32;

static SpecConfigBuilder builder() {
return new SpecConfigBuilder();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,19 +19,21 @@
import tech.pegasys.teku.infrastructure.unsigned.UInt64;
import tech.pegasys.teku.spec.config.SpecConfig;
import tech.pegasys.teku.ssz.SszList;
import tech.pegasys.teku.ssz.collections.SszByteList;
import tech.pegasys.teku.ssz.collections.SszByteVector;
import tech.pegasys.teku.ssz.containers.Container13;
import tech.pegasys.teku.ssz.containers.ContainerSchema13;
import tech.pegasys.teku.ssz.containers.Container14;
import tech.pegasys.teku.ssz.containers.ContainerSchema14;
import tech.pegasys.teku.ssz.primitive.SszBytes32;
import tech.pegasys.teku.ssz.primitive.SszUInt64;
import tech.pegasys.teku.ssz.schema.SszListSchema;
import tech.pegasys.teku.ssz.schema.SszPrimitiveSchemas;
import tech.pegasys.teku.ssz.schema.collections.SszByteListSchema;
import tech.pegasys.teku.ssz.schema.collections.SszByteVectorSchema;
import tech.pegasys.teku.ssz.tree.TreeNode;
import tech.pegasys.teku.ssz.type.Bytes20;

public class ExecutionPayload
extends Container13<
extends Container14<
ExecutionPayload,
SszBytes32,
SszByteVector,
Expand All @@ -43,12 +45,13 @@ public class ExecutionPayload
SszUInt64,
SszUInt64,
SszUInt64,
SszByteList,
SszBytes32,
SszBytes32,
SszList<Transaction>> {

public static class ExecutionPayloadSchema
extends ContainerSchema13<
extends ContainerSchema14<
ExecutionPayload,
SszBytes32,
SszByteVector,
Expand All @@ -60,6 +63,7 @@ public static class ExecutionPayloadSchema
SszUInt64,
SszUInt64,
SszUInt64,
SszByteList,
SszBytes32,
SszBytes32,
SszList<Transaction>> {
Expand All @@ -77,6 +81,7 @@ public ExecutionPayloadSchema() {
namedSchema("gas_limit", SszPrimitiveSchemas.UINT64_SCHEMA),
namedSchema("gas_used", SszPrimitiveSchemas.UINT64_SCHEMA),
namedSchema("timestamp", SszPrimitiveSchemas.UINT64_SCHEMA),
namedSchema("extra_data", SszByteListSchema.create(SpecConfig.MAX_EXTRA_DATA_BYTES)),
namedSchema("base_fee_per_gas", SszPrimitiveSchemas.BYTES32_SCHEMA),
namedSchema("block_hash", SszPrimitiveSchemas.BYTES32_SCHEMA),
namedSchema(
Expand All @@ -86,7 +91,7 @@ public ExecutionPayloadSchema() {

@SuppressWarnings("unchecked")
public SszListSchema<Transaction, ?> getTransactionsSchema() {
return (SszListSchema<Transaction, ?>) getFieldSchema12();
return (SszListSchema<Transaction, ?>) getFieldSchema13();
}

@Override
Expand All @@ -102,7 +107,7 @@ public ExecutionPayload() {
}

ExecutionPayload(
ContainerSchema13<
ContainerSchema14<
ExecutionPayload,
SszBytes32,
SszByteVector,
Expand All @@ -114,6 +119,7 @@ public ExecutionPayload() {
SszUInt64,
SszUInt64,
SszUInt64,
SszByteList,
SszBytes32,
SszBytes32,
SszList<Transaction>>
Expand All @@ -133,6 +139,7 @@ public ExecutionPayload(
UInt64 gas_limit,
UInt64 gas_used,
UInt64 timestamp,
Bytes extra_data,
Bytes32 baseFeePerGas,
Bytes32 block_hash,
List<Bytes> transactions) {
Expand All @@ -148,6 +155,7 @@ public ExecutionPayload(
SszUInt64.of(gas_limit),
SszUInt64.of(gas_used),
SszUInt64.of(timestamp),
SszByteList.fromBytes(extra_data),
SszBytes32.of(baseFeePerGas),
SszBytes32.of(block_hash),
transactions.stream()
Expand Down Expand Up @@ -201,15 +209,19 @@ public UInt64 getTimestamp() {
return getField9().get();
}

public Bytes getExtraData() {
return getField10().getBytes();
}

public Bytes32 getBaseFeePerGas() {
return getField10().get();
return getField11().get();
}

public Bytes32 getBlock_hash() {
return getField11().get();
return getField12().get();
}

public SszList<Transaction> getTransactions() {
return getField12();
return getField13();
}
}
Loading

0 comments on commit 8381c48

Please sign in to comment.