Skip to content

Conversation

shane-moore
Copy link

@shane-moore shane-moore commented Jul 29, 2025

Changes

  • added Constants / Misc / Preset / Containers from consensus specs while cross-referencing the old epbs branch, which already had some of the containers built out and just needed some minor tweaks per updates to the spec

Note: I made a couple fixes to the gloas boilerplate to get cargo build to compile and cargo test -p types to be all passing in a separate PR

Todo for Containers (didn't want this PR to get too big)

  • BeaconBlockBody
  • BeaconState

Copy link

cla-assistant bot commented Jul 29, 2025

CLA assistant check
All committers have signed the CLA.

@@ -585,6 +612,8 @@ impl EthSpec for GnosisEthSpec {
type BytesPerCell = U2048;
type KzgCommitmentsInclusionProofDepth = U4;
type ProposerLookaheadSlots = U32; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
type PTCSize = U64; // todo: verify if needs to be U512 for some reason like in Mark's OG implementation
Copy link
Author

@shane-moore shane-moore Jul 29, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethDreamer, just wanted to check with you on this. pretty sure all good now but wanted to flag it anyways (https://ethereum.github.io/consensus-specs/specs/_features/eip7732/beacon-chain/#misc_1)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you must have gotten confused because the spec you linked also has this as 512?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@ethDreamer, I'm reading
image
as saying: PTCSize should be of type uint64 with a constant value of 512. so I think we're ok to uses U64 instead of U512 in the eth_spec.rs?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ohhhh no these types are special. The type is actually its value, not the number of bits in the type. Look at the typenum crate in rust.

Copy link
Author

@shane-moore shane-moore Jul 30, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ahh, I see! typenum lets you express that the type represents 512 in this case, nice

updated in latest commit 76f9f83

pub parent_block_root: Hash256,
pub block_hash: ExecutionBlockHash,
#[serde(with = "serde_utils::address_hex")]
pub fee_recipient: Address, // todo(eip-7732): verify if this needs address_hex serialization
Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we seem to serialize to 0xABC instead of byte array when sending json over the wire

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So.. when gossiping payloads we always serialize with SSZ which is unaffected by the serde configuration. SSZ serialization/deserialization is achieved from Encode and Decode traits while JSON serialization/deserialization is done with the Serialize and Deserialize traits via serde.

There are two ways that consensus objects get serialized into JSON:

  1. The beacon API (which while use these objects directly)
  2. The engine API (where the objects are first converted to JSONVariant so that the serialization matches the engine API.. side note.. perhaps I should rename all instances from JSON to Engine as that would make more sense..

I don't believe this object ever enters the Engine API so it would only need to conform to the beacon API standards for JSON encoding.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

for sure! I was familiar with Encode and Decode being for ssz, and Serialize/Deserialize being for json, but I did not know about the engine api having to convert to JSONVariant for serialization. Will keep this in mind

@michaelsproul michaelsproul added gloas consensus An issue/PR that touches consensus code, such as state_processing or block verification. work-in-progress PR is a work-in-progress labels Jul 29, 2025
@michaelsproul michaelsproul requested a review from ethDreamer July 29, 2025 01:53
Copy link
Member

@ethDreamer ethDreamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great start! Only small changes and I need to go clarify some stuff about the spec I now realize.

@@ -75,6 +75,7 @@ pub trait EthSpec: 'static + Default + Sync + Send + Clone + Debug + PartialEq +
type EpochsPerSlashingsVector: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type HistoricalRootsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type ValidatorRegistryLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
type BuilderPendingWithdrawalsLimit: Unsigned + Clone + Sync + Send + Debug + PartialEq;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

small nit here - this is a state list length but this list appears as all phase0 state list lengths - others have been put along with their respective fork (see Electra's PendingDepositsLimit and PendingPartialWithdrawalsLimit)

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

makes total sense, updated in 76f9f83

@@ -585,6 +612,8 @@ impl EthSpec for GnosisEthSpec {
type BytesPerCell = U2048;
type KzgCommitmentsInclusionProofDepth = U4;
type ProposerLookaheadSlots = U32; // Derived from (MIN_SEED_LOOKAHEAD + 1) * SLOTS_PER_EPOCH
type PTCSize = U64; // todo: verify if needs to be U512 for some reason like in Mark's OG implementation
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you must have gotten confused because the spec you linked also has this as 512?

pub parent_block_root: Hash256,
pub block_hash: ExecutionBlockHash,
#[serde(with = "serde_utils::address_hex")]
pub fee_recipient: Address, // todo(eip-7732): verify if this needs address_hex serialization
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So.. when gossiping payloads we always serialize with SSZ which is unaffected by the serde configuration. SSZ serialization/deserialization is achieved from Encode and Decode traits while JSON serialization/deserialization is done with the Serialize and Deserialize traits via serde.

There are two ways that consensus objects get serialized into JSON:

  1. The beacon API (which while use these objects directly)
  2. The engine API (where the objects are first converted to JSONVariant so that the serialization matches the engine API.. side note.. perhaps I should rename all instances from JSON to Engine as that would make more sense..

I don't believe this object ever enters the Engine API so it would only need to conform to the beacon API standards for JSON encoding.

#[serde(bound = "E: EthSpec", deny_unknown_fields)]
#[cfg_attr(feature = "arbitrary", arbitrary(bound = "E: EthSpec"))]
#[context_deserialize(ForkName)]
pub struct IndexedPayloadAttestation<E: EthSpec> {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

okay so i was under the impression that the PayloadAttestations never go on chain but the existence of this object (and the latest spec) has them in the BeaconBlock.. i need to go figure out why..

pub data: PayloadAttestationData,
pub signature: AggregateSignature,
}

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similarly here the PayloadAttestations are aggregated by the proposer.. this was the opposite of what I had understood.. I wonder if this was accidentally left in.. going to go check.

@shane-moore shane-moore force-pushed the eip-7732-containers branch from ebf949f to a9c297e Compare July 30, 2025 03:22
@shane-moore shane-moore force-pushed the eip-7732-containers branch from 76f9f83 to b7bdd9c Compare July 30, 2025 20:05
@Clay-1010
Copy link

@ethDreamer ethDreamer mentioned this pull request Aug 11, 2025
87 tasks
Copy link
Member

@ethDreamer ethDreamer left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good! just a couple of changes now

#[cfg_attr(feature = "arbitrary", derive(arbitrary::Arbitrary))]
#[derivative(PartialEq, Hash)]
#[context_deserialize(ForkName)]
// This is what Potuz' spec calls an `ExecutionPayload` even though it's clearly a bid.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
// This is what Potuz' spec calls an `ExecutionPayload` even though it's clearly a bid.
// This is what Potuz' spec calls an `ExecutionPayloadHeader` even though it's clearly a bid.
// https://github.com/ethereum/consensus-specs/blob/bba2c7be148d6d921d2ca5e1cc528f5daaf456d9/specs/gloas/beacon-chain.md#executionpayloadheader

@ethDreamer ethDreamer closed this Aug 22, 2025
@ethDreamer ethDreamer reopened this Aug 22, 2025
@ethDreamer
Copy link
Member

continuing this work in #7923

@ethDreamer ethDreamer closed this Aug 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
consensus An issue/PR that touches consensus code, such as state_processing or block verification. gloas work-in-progress PR is a work-in-progress
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants