-
Notifications
You must be signed in to change notification settings - Fork 775
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fork choice modifications and cleanup (#3962)
## Issue Addressed NA ## Proposed Changes - Implements ethereum/consensus-specs#3290 - Bumps `ef-tests` to [v1.3.0-rc.4](https://github.com/ethereum/consensus-spec-tests/releases/tag/v1.3.0-rc.4). The `CountRealizedFull` concept has been removed and the `--count-unrealized-full` and `--count-unrealized` BN flags now do nothing but log a `WARN` when used. ## Database Migration Debt This PR removes the `best_justified_checkpoint` from fork choice. This field is persisted on-disk and the correct way to go about this would be to make a DB migration to remove the field. However, in this PR I've simply stubbed out the value with a junk value. I've taken this approach because if we're going to do a DB migration I'd love to remove the `Option`s around the justified and finalized checkpoints on `ProtoNode` whilst we're at it. Those options were added in #2822 which was included in Lighthouse v2.1.0. The options were only put there to handle the migration and they've been set to `Some` ever since v2.1.0. There's no reason to keep them as options anymore. I started adding the DB migration to this branch but I started to feel like I was bloating this rather critical PR with nice-to-haves. I've kept the partially-complete migration [over in my repo](https://github.com/paulhauner/lighthouse/tree/fc-pr-18-migration) so we can pick it up after this PR is merged.
- Loading branch information
1 parent
3ac5583
commit 1f8c17b
Showing
29 changed files
with
216 additions
and
413 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
46 changes: 46 additions & 0 deletions
46
beacon_node/beacon_chain/src/schema_change/migration_schema_v16.rs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
use crate::beacon_chain::{BeaconChainTypes, FORK_CHOICE_DB_KEY}; | ||
use crate::persisted_fork_choice::PersistedForkChoiceV11; | ||
use slog::{debug, Logger}; | ||
use std::sync::Arc; | ||
use store::{Error, HotColdDB, KeyValueStoreOp, StoreItem}; | ||
|
||
pub fn upgrade_to_v16<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
drop_balances_cache::<T>(db, log) | ||
} | ||
|
||
pub fn downgrade_from_v16<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
drop_balances_cache::<T>(db, log) | ||
} | ||
|
||
/// Drop the balances cache from the fork choice store. | ||
/// | ||
/// There aren't any type-level changes in this schema migration, however the | ||
/// way that we compute the `JustifiedBalances` has changed due to: | ||
/// https://github.com/sigp/lighthouse/pull/3962 | ||
pub fn drop_balances_cache<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
let mut persisted_fork_choice = db | ||
.get_item::<PersistedForkChoiceV11>(&FORK_CHOICE_DB_KEY)? | ||
.ok_or_else(|| Error::SchemaMigrationError("fork choice missing from database".into()))?; | ||
|
||
debug!( | ||
log, | ||
"Dropping fork choice balances cache"; | ||
"item_count" => persisted_fork_choice.fork_choice_store.balances_cache.items.len() | ||
); | ||
|
||
// Drop all items in the balances cache. | ||
persisted_fork_choice.fork_choice_store.balances_cache = <_>::default(); | ||
|
||
let kv_op = persisted_fork_choice.as_kv_store_op(FORK_CHOICE_DB_KEY); | ||
|
||
Ok(vec![kv_op]) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.