Refactor for Organization

This commit is contained in:
Mark Mackey
2025-10-22 16:01:47 -05:00
parent ccb519b71c
commit 76b0330b4c
4 changed files with 474 additions and 226 deletions

View File

@@ -69,6 +69,10 @@ impl<'a, E: EthSpec> ExecutionPayloadEnvelopeRef<'a, E> {
Self::NextFork(envelope) => ExecutionPayloadRef::Gloas(&envelope.payload),
}
}
pub fn block_hash(&self) -> ExecutionBlockHash {
self.payload().block_hash()
}
}
impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for ExecutionPayloadEnvelope<E> {

View File

@@ -75,11 +75,28 @@ impl<E: EthSpec> SignedExecutionPayloadEnvelope<E> {
}
}
pub fn slot(&self) -> Slot {
self.message().slot()
}
pub fn epoch(&self) -> Epoch {
self.slot().epoch(E::slots_per_epoch())
}
pub fn beacon_block_root(&self) -> Hash256 {
self.message().beacon_block_root()
}
pub fn block_hash(&self) -> ExecutionBlockHash {
self.message().block_hash()
}
/// Verify `self.signature`.
///
/// The `parent_state` is the post-state of the beacon block with
/// block_root = self.message.beacon_block_root
pub fn verify_signature(
/// todo(gloas): maybe delete this function later
pub fn verify_signature_with_state(
&self,
parent_state: &BeaconState<E>,
spec: &ChainSpec,
@@ -104,6 +121,29 @@ impl<E: EthSpec> SignedExecutionPayloadEnvelope<E> {
Ok(self.signature().verify(&pubkey, message))
}
/// Verify `self.signature`.
///
/// If the root of `block.message` is already known it can be passed in via `object_root_opt`.
/// Otherwise, it will be computed locally.
pub fn verify_signature(
&self,
pubkey: &PublicKey,
fork: &Fork,
genesis_validators_root: Hash256,
spec: &ChainSpec,
) -> bool {
let domain = spec.get_domain(
self.epoch(),
Domain::BeaconProposer,
fork,
genesis_validators_root,
);
let message = self.message().signing_root(domain);
self.signature().verify(pubkey, message)
}
}
impl<'de, E: EthSpec> ContextDeserialize<'de, ForkName> for SignedExecutionPayloadEnvelope<E> {