Skip to content

Commit

Permalink
only increment the state deposit index on old deposit flow
Browse files Browse the repository at this point in the history
  • Loading branch information
realbigsean committed Jun 25, 2024
1 parent ff847f8 commit 6275e04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 5 deletions.
2 changes: 1 addition & 1 deletion beacon_node/genesis/src/eth1_genesis_service.rs
Original file line number Diff line number Diff line change
Expand Up @@ -439,7 +439,7 @@ impl Eth1GenesisService {
None
};

apply_deposit(&mut state, data, proof, spec)
apply_deposit(&mut state, data, proof, true, spec)
.map_err(|e| format!("Error whilst processing deposit: {:?}", e))
})?;

Expand Down
2 changes: 1 addition & 1 deletion consensus/state_processing/src/genesis.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ pub fn initialize_beacon_state_from_eth1<E: EthSpec>(
.map_err(BlockProcessingError::MerkleTreeError)?;
state.eth1_data_mut().deposit_root = deposit_tree.root();
let Deposit { proof, data } = deposit;
apply_deposit(&mut state, data, Some(proof), spec)?;
apply_deposit(&mut state, data, Some(proof), true, spec)?;
}

process_activations(&mut state, spec)?;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -417,7 +417,7 @@ pub fn process_deposits<E: EthSpec>(

// Update the state in series.
for deposit in deposits {
apply_deposit(state, deposit.data.clone(), None, spec)?;
apply_deposit(state, deposit.data.clone(), None, true, spec)?;
}

Ok(())
Expand All @@ -428,6 +428,7 @@ pub fn apply_deposit<E: EthSpec>(
state: &mut BeaconState<E>,
deposit_data: DepositData,
proof: Option<FixedVector<Hash256, U33>>,
increment_eth1_deposit_index: bool,
spec: &ChainSpec,
) -> Result<(), BlockProcessingError> {
let deposit_index = state.eth1_deposit_index() as usize;
Expand All @@ -440,7 +441,9 @@ pub fn apply_deposit<E: EthSpec>(
.map_err(|e| e.into_with_index(deposit_index))?;
}

state.eth1_deposit_index_mut().safe_add_assign(1)?;
if increment_eth1_deposit_index {
state.eth1_deposit_index_mut().safe_add_assign(1)?;
}

// Get an `Option<u64>` where `u64` is the validator index if this deposit public key
// already exists in the beacon_state.
Expand Down Expand Up @@ -641,7 +644,7 @@ pub fn process_deposit_receipts<E: EthSpec>(
amount: receipt.amount,
signature: receipt.signature.clone().into(),
};
apply_deposit(state, deposit_data, None, spec)?
apply_deposit(state, deposit_data, None, false, spec)?
}

Ok(())
Expand Down

0 comments on commit 6275e04

Please sign in to comment.