Fix Eth1 data underflow (#977)

* Fix Eth1 data underflow #540

* Refactor: smart transformation from Option to Result

* Add tests for BeaconState::get_outstanding_deposit_len()
This commit is contained in:
Akihito Nakano
2020-04-06 14:36:34 +09:00
committed by GitHub
parent 54782d896c
commit c188227cc2
3 changed files with 59 additions and 1 deletions

View File

@@ -417,7 +417,7 @@ pub fn process_deposits<T: EthSpec>(
) -> Result<(), BlockProcessingError> {
let expected_deposit_len = std::cmp::min(
T::MaxDeposits::to_u64(),
state.eth1_data.deposit_count - state.eth1_deposit_index,
state.get_outstanding_deposit_len()?,
);
block_verify!(
deposits.len() as u64 == expected_deposit_len,