Attestation superstruct changes for EIP 7549 (#5644)

* update

* experiment

* superstruct changes

* revert

* superstruct changes

* fix tests

* indexed attestation

* indexed attestation superstruct

* updated TODOs
This commit is contained in:
Eitan Seri-Levi
2024-04-30 19:49:08 +03:00
committed by GitHub
parent 4a48d7b546
commit 3b7132bc0d
56 changed files with 943 additions and 429 deletions

View File

@@ -226,12 +226,12 @@ impl TargetArrayChunk for MinTargetChunk {
) -> Result<AttesterSlashingStatus<E>, Error> {
let min_target =
self.chunk
.get_target(validator_index, attestation.data.source.epoch, config)?;
if attestation.data.target.epoch > min_target {
.get_target(validator_index, attestation.data().source.epoch, config)?;
if attestation.data().target.epoch > min_target {
let existing_attestation =
db.get_attestation_for_validator(txn, validator_index, min_target)?;
if attestation.data.source.epoch < existing_attestation.data.source.epoch {
if attestation.data().source.epoch < existing_attestation.data().source.epoch {
Ok(AttesterSlashingStatus::SurroundsExisting(Box::new(
existing_attestation,
)))
@@ -329,12 +329,12 @@ impl TargetArrayChunk for MaxTargetChunk {
) -> Result<AttesterSlashingStatus<E>, Error> {
let max_target =
self.chunk
.get_target(validator_index, attestation.data.source.epoch, config)?;
if attestation.data.target.epoch < max_target {
.get_target(validator_index, attestation.data().source.epoch, config)?;
if attestation.data().target.epoch < max_target {
let existing_attestation =
db.get_attestation_for_validator(txn, validator_index, max_target)?;
if existing_attestation.data.source.epoch < attestation.data.source.epoch {
if existing_attestation.data().source.epoch < attestation.data().source.epoch {
Ok(AttesterSlashingStatus::SurroundedByExisting(Box::new(
existing_attestation,
)))
@@ -428,7 +428,7 @@ pub fn apply_attestation_for_validator<E: EthSpec, T: TargetArrayChunk>(
current_epoch: Epoch,
config: &Config,
) -> Result<AttesterSlashingStatus<E>, Error> {
let mut chunk_index = config.chunk_index(attestation.data.source.epoch);
let mut chunk_index = config.chunk_index(attestation.data().source.epoch);
let mut current_chunk = get_chunk_for_update(
db,
txn,
@@ -446,7 +446,7 @@ pub fn apply_attestation_for_validator<E: EthSpec, T: TargetArrayChunk>(
}
let Some(mut start_epoch) =
T::first_start_epoch(attestation.data.source.epoch, current_epoch, config)
T::first_start_epoch(attestation.data().source.epoch, current_epoch, config)
else {
return Ok(slashing_status);
};
@@ -465,7 +465,7 @@ pub fn apply_attestation_for_validator<E: EthSpec, T: TargetArrayChunk>(
chunk_index,
validator_index,
start_epoch,
attestation.data.target.epoch,
attestation.data().target.epoch,
current_epoch,
config,
)?;
@@ -492,7 +492,7 @@ pub fn update<E: EthSpec>(
let mut chunk_attestations = BTreeMap::new();
for attestation in batch {
chunk_attestations
.entry(config.chunk_index(attestation.indexed.data.source.epoch))
.entry(config.chunk_index(attestation.indexed.data().source.epoch))
.or_insert_with(Vec::new)
.push(attestation);
}