-
Notifications
You must be signed in to change notification settings - Fork 910
Electra attestation changes rm decode impl #5856
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
realbigsean
merged 4 commits into
sigp:electra_attestation_changes
from
ethDreamer:electra_attestation_changes_rm_decode_impl
May 30, 2024
Merged
Changes from 3 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
c996bc0
Remove Crappy Decode impl for Attestation
ethDreamer 6f9a8a9
Remove Inefficient Attestation Decode impl
ethDreamer 5a72c14
Implement Schema Upgrade / Downgrade
ethDreamer 973cbee
Update beacon_node/beacon_chain/src/schema_change/migration_schema_v2…
ethDreamer File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or 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
103 changes: 103 additions & 0 deletions
103
beacon_node/beacon_chain/src/schema_change/migration_schema_v20.rs
This file contains hidden or 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,103 @@ | ||
use crate::beacon_chain::{BeaconChainTypes, OP_POOL_DB_KEY}; | ||
use operation_pool::{ | ||
PersistedOperationPool, PersistedOperationPoolV15, PersistedOperationPoolV20, | ||
}; | ||
use slog::{debug, info, Logger}; | ||
use std::sync::Arc; | ||
use store::{Error, HotColdDB, KeyValueStoreOp, StoreItem}; | ||
use types::Attestation; | ||
|
||
pub fn upgrade_to_v20<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
// Load a V14 op pool and transform it to V15. | ||
let Some(PersistedOperationPoolV15::<T::EthSpec> { | ||
attestations_v15, | ||
sync_contributions, | ||
attester_slashings_v15, | ||
proposer_slashings, | ||
voluntary_exits, | ||
bls_to_execution_changes, | ||
capella_bls_change_broadcast_indices, | ||
}) = db.get_item(&OP_POOL_DB_KEY)? | ||
else { | ||
debug!(log, "Nothing to do, no operation pool stored"); | ||
return Ok(vec![]); | ||
}; | ||
|
||
let attestations = attestations_v15 | ||
.into_iter() | ||
.map(|(attestation, indices)| (Attestation::Base(attestation).into(), indices)) | ||
.collect(); | ||
|
||
let attester_slashings = attester_slashings_v15 | ||
.into_iter() | ||
.map(|slashing| slashing.into()) | ||
.collect(); | ||
|
||
let v20 = PersistedOperationPool::V20(PersistedOperationPoolV20 { | ||
attestations, | ||
sync_contributions, | ||
attester_slashings, | ||
proposer_slashings, | ||
voluntary_exits, | ||
bls_to_execution_changes, | ||
capella_bls_change_broadcast_indices, | ||
}); | ||
Ok(vec![v20.as_kv_store_op(OP_POOL_DB_KEY)]) | ||
} | ||
|
||
pub fn downgrade_from_v20<T: BeaconChainTypes>( | ||
db: Arc<HotColdDB<T::EthSpec, T::HotStore, T::ColdStore>>, | ||
log: Logger, | ||
) -> Result<Vec<KeyValueStoreOp>, Error> { | ||
// Load a V20 op pool and transform it to V15. | ||
let Some(PersistedOperationPoolV20::<T::EthSpec> { | ||
attestations, | ||
sync_contributions, | ||
attester_slashings, | ||
proposer_slashings, | ||
voluntary_exits, | ||
bls_to_execution_changes, | ||
capella_bls_change_broadcast_indices, | ||
}) = db.get_item(&OP_POOL_DB_KEY)? | ||
else { | ||
debug!(log, "Nothing to do, no operation pool stored"); | ||
return Ok(vec![]); | ||
}; | ||
|
||
let attestations_v15 = attestations | ||
.into_iter() | ||
.filter_map(|(attestation, indices)| { | ||
if let Attestation::Base(attestation) = attestation.into() { | ||
Some((attestation, indices)) | ||
} else { | ||
info!(log, "Dropping attestation during downgrade"; "reason" => "not a base attestation"); | ||
None | ||
} | ||
}) | ||
.collect(); | ||
|
||
let attester_slashings_v15 = attester_slashings | ||
.into_iter() | ||
.filter_map(|slashing| match slashing.try_into() { | ||
Ok(slashing) => Some(slashing), | ||
Err(_) => { | ||
info!(log, "Dropping attester slashing during downgrade"; "reason" => "not a base attester slashing"); | ||
None | ||
} | ||
}) | ||
.collect(); | ||
|
||
let v15 = PersistedOperationPool::V15(PersistedOperationPoolV15 { | ||
attestations_v15, | ||
sync_contributions, | ||
attester_slashings_v15, | ||
proposer_slashings, | ||
voluntary_exits, | ||
bls_to_execution_changes, | ||
capella_bls_change_broadcast_indices, | ||
}); | ||
Ok(vec![v15.as_kv_store_op(OP_POOL_DB_KEY)]) | ||
} |
This file contains hidden or 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 hidden or 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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.