mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-16 03:12:41 +00:00
Tweak signature verifier handling of proposer
This commit is contained in:
@@ -119,6 +119,7 @@ pub fn per_block_processing<T: EthSpec, Payload: ExecPayload<T>>(
|
||||
|pk_bytes| pk_bytes.decompress().ok().map(Cow::Owned),
|
||||
signed_block,
|
||||
block_root,
|
||||
false,
|
||||
spec
|
||||
)
|
||||
.is_ok(),
|
||||
@@ -249,6 +250,7 @@ pub fn verify_block_signature<T: EthSpec, Payload: ExecPayload<T>>(
|
||||
|i| get_pubkey_from_state(state, i),
|
||||
block,
|
||||
block_root,
|
||||
false,
|
||||
spec
|
||||
)?
|
||||
.verify(),
|
||||
|
||||
@@ -123,10 +123,11 @@ where
|
||||
decompressor: D,
|
||||
block: &'a SignedBeaconBlock<T, Payload>,
|
||||
block_root: Option<Hash256>,
|
||||
check_proposer_index: bool,
|
||||
spec: &'a ChainSpec,
|
||||
) -> Result<()> {
|
||||
let mut verifier = Self::new(state, get_pubkey, decompressor, spec);
|
||||
verifier.include_all_signatures(block, block_root)?;
|
||||
verifier.include_all_signatures(block, block_root, check_proposer_index)?;
|
||||
verifier.verify()
|
||||
}
|
||||
|
||||
@@ -135,8 +136,9 @@ where
|
||||
&mut self,
|
||||
block: &'a SignedBeaconBlock<T, Payload>,
|
||||
block_root: Option<Hash256>,
|
||||
check_proposer_index: bool,
|
||||
) -> Result<()> {
|
||||
self.include_block_proposal(block, block_root)?;
|
||||
self.include_block_proposal(block, block_root, check_proposer_index)?;
|
||||
self.include_all_signatures_except_proposal(block)?;
|
||||
|
||||
Ok(())
|
||||
@@ -164,12 +166,14 @@ where
|
||||
&mut self,
|
||||
block: &'a SignedBeaconBlock<T, Payload>,
|
||||
block_root: Option<Hash256>,
|
||||
check_proposer_index: bool,
|
||||
) -> Result<()> {
|
||||
let set = block_proposal_signature_set(
|
||||
self.state,
|
||||
self.get_pubkey.clone(),
|
||||
block,
|
||||
block_root,
|
||||
check_proposer_index,
|
||||
self.spec,
|
||||
)?;
|
||||
self.sets.push(set);
|
||||
|
||||
@@ -76,6 +76,7 @@ pub fn block_proposal_signature_set<'a, T, F, Payload: ExecPayload<T>>(
|
||||
get_pubkey: F,
|
||||
signed_block: &'a SignedBeaconBlock<T, Payload>,
|
||||
block_root: Option<Hash256>,
|
||||
check_proposer_index: bool,
|
||||
spec: &'a ChainSpec,
|
||||
) -> Result<SignatureSet<'a>>
|
||||
where
|
||||
@@ -83,14 +84,20 @@ where
|
||||
F: Fn(usize) -> Option<Cow<'a, PublicKey>>,
|
||||
{
|
||||
let block = signed_block.message();
|
||||
let proposer_index = state.get_beacon_proposer_index(block.slot(), spec)? as u64;
|
||||
|
||||
if proposer_index != block.proposer_index() {
|
||||
return Err(Error::IncorrectBlockProposer {
|
||||
block: block.proposer_index(),
|
||||
local_shuffling: proposer_index,
|
||||
});
|
||||
}
|
||||
let proposer_index = if check_proposer_index {
|
||||
let proposer_index = state.get_beacon_proposer_index(block.slot(), spec)? as u64;
|
||||
|
||||
if proposer_index != block.proposer_index() {
|
||||
return Err(Error::IncorrectBlockProposer {
|
||||
block: block.proposer_index(),
|
||||
local_shuffling: proposer_index,
|
||||
});
|
||||
}
|
||||
proposer_index
|
||||
} else {
|
||||
block.proposer_index()
|
||||
};
|
||||
|
||||
block_proposal_signature_set_from_parts(
|
||||
signed_block,
|
||||
@@ -162,7 +169,9 @@ where
|
||||
T: EthSpec,
|
||||
F: Fn(usize) -> Option<Cow<'a, PublicKey>>,
|
||||
{
|
||||
let proposer_index = state.get_beacon_proposer_index(block.slot(), spec)?;
|
||||
// FIXME(sproul): ensure this is checked elsewhere
|
||||
let proposer_index = block.proposer_index() as usize;
|
||||
// let proposer_index = state.get_beacon_proposer_index(block.slot(), spec)?;
|
||||
|
||||
let domain = spec.get_domain(
|
||||
block.slot().epoch(T::slots_per_epoch()),
|
||||
|
||||
@@ -330,6 +330,7 @@ impl ParticipationCache {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::indexing_slicing)]
|
||||
if is_eligible || is_active_current_epoch {
|
||||
let effective_balance = val.effective_balance;
|
||||
let base_reward =
|
||||
|
||||
Reference in New Issue
Block a user