mirror of
https://github.com/sigp/lighthouse.git
synced 2026-03-03 00:31:50 +00:00
Pass blobs into ValidatorStore::sign_block (#7497)
While the Lighthouse implementation of the `ValidatorStore` does not really care about blobs, Anchor needs to be able to return different blobs from `sign_blocks` than what was passed into it, in case it decides to sign another Anchor node's block. Only passing the unsigned block into `sign_block` and only returning a signed block from it (without any blobs and proofs) was an oversight in #6705. - Replace `validator_store::{Uns,S}ignedBlock` with `validator_store::block_service::{Uns,S}ignedBlock`, as we need all data in there. - In `lighthouse_validator_store`, just add the received blobs back to the signed block after signing it.
This commit is contained in:
@@ -10,6 +10,7 @@ edition = { workspace = true }
|
||||
account_utils = { workspace = true }
|
||||
async-channel = { workspace = true }
|
||||
environment = { workspace = true }
|
||||
eth2 = { workspace = true }
|
||||
eth2_keystore = { workspace = true }
|
||||
eth2_network_config = { workspace = true }
|
||||
futures = { workspace = true }
|
||||
|
||||
@@ -20,6 +20,7 @@ mod tests {
|
||||
use account_utils::validator_definitions::{
|
||||
SigningDefinition, ValidatorDefinition, ValidatorDefinitions, Web3SignerDefinition,
|
||||
};
|
||||
use eth2::types::FullBlockContents;
|
||||
use eth2_keystore::KeystoreBuilder;
|
||||
use eth2_network_config::Eth2NetworkConfig;
|
||||
use initialized_validators::{
|
||||
@@ -45,7 +46,9 @@ mod tests {
|
||||
use tokio::time::sleep;
|
||||
use types::{attestation::AttestationBase, *};
|
||||
use url::Url;
|
||||
use validator_store::{Error as ValidatorStoreError, SignedBlock, ValidatorStore};
|
||||
use validator_store::{
|
||||
Error as ValidatorStoreError, SignedBlock, UnsignedBlock, ValidatorStore,
|
||||
};
|
||||
|
||||
/// If the we are unable to reach the Web3Signer HTTP API within this time out then we will
|
||||
/// assume it failed to start.
|
||||
@@ -595,8 +598,9 @@ mod tests {
|
||||
async move {
|
||||
let block = BeaconBlock::<E>::Base(BeaconBlockBase::empty(&spec));
|
||||
let block_slot = block.slot();
|
||||
let unsigned_block = UnsignedBlock::Full(FullBlockContents::Block(block));
|
||||
validator_store
|
||||
.sign_block(pubkey, block.into(), block_slot)
|
||||
.sign_block(pubkey, unsigned_block, block_slot)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
@@ -665,12 +669,10 @@ mod tests {
|
||||
async move {
|
||||
let mut altair_block = BeaconBlockAltair::empty(&spec);
|
||||
altair_block.slot = altair_fork_slot;
|
||||
let unsigned_block =
|
||||
UnsignedBlock::Full(FullBlockContents::Block(altair_block.into()));
|
||||
validator_store
|
||||
.sign_block(
|
||||
pubkey,
|
||||
BeaconBlock::<E>::Altair(altair_block).into(),
|
||||
altair_fork_slot,
|
||||
)
|
||||
.sign_block(pubkey, unsigned_block, altair_fork_slot)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
@@ -752,12 +754,10 @@ mod tests {
|
||||
async move {
|
||||
let mut bellatrix_block = BeaconBlockBellatrix::empty(&spec);
|
||||
bellatrix_block.slot = bellatrix_fork_slot;
|
||||
let unsigned_block =
|
||||
UnsignedBlock::Full(FullBlockContents::Block(bellatrix_block.into()));
|
||||
validator_store
|
||||
.sign_block(
|
||||
pubkey,
|
||||
BeaconBlock::<E>::Bellatrix(bellatrix_block).into(),
|
||||
bellatrix_fork_slot,
|
||||
)
|
||||
.sign_block(pubkey, unsigned_block, bellatrix_fork_slot)
|
||||
.await
|
||||
.unwrap()
|
||||
}
|
||||
@@ -876,8 +876,9 @@ mod tests {
|
||||
.assert_signatures_match("first_block", |pubkey, validator_store| async move {
|
||||
let block = first_block();
|
||||
let slot = block.slot();
|
||||
let unsigned_block = UnsignedBlock::Full(FullBlockContents::Block(block));
|
||||
validator_store
|
||||
.sign_block(pubkey, block.into(), slot)
|
||||
.sign_block(pubkey, unsigned_block, slot)
|
||||
.await
|
||||
.unwrap()
|
||||
})
|
||||
@@ -887,8 +888,9 @@ mod tests {
|
||||
move |pubkey, validator_store| async move {
|
||||
let block = double_vote_block();
|
||||
let slot = block.slot();
|
||||
let unsigned_block = UnsignedBlock::Full(FullBlockContents::Block(block));
|
||||
validator_store
|
||||
.sign_block(pubkey, block.into(), slot)
|
||||
.sign_block(pubkey, unsigned_block, slot)
|
||||
.await
|
||||
.map(|_| ())
|
||||
},
|
||||
|
||||
Reference in New Issue
Block a user