@Test void numberOfDepositsThatCanBeIncludedLessThanMaxDeposits() { mockStateEth1DepositIndex(5); mockEth1DataDepositCount(20); Constants.MAX_DEPOSITS = 16; mockDepositsFromEth1Block(0, 10); mockDepositsFromEth1Block(10, 20); SSZList<Deposit> deposits = depositProvider.getDeposits(state, randomEth1Data); assertThat(deposits).hasSize(15); checkThatDepositProofIsValid(deposits); }
public synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data) { UInt64 eth1DepositCount; if (isEnoughVotesToUpdateEth1Data(getVoteCount(state, eth1Data) + 1)) { eth1DepositCount = eth1Data.getDeposit_count(); } else { eth1DepositCount = state.getEth1_data().getDeposit_count(); } UInt64 eth1DepositIndex = state.getEth1_deposit_index(); checkRequiredDepositsAvailable(eth1DepositCount, eth1DepositIndex); UInt64 latestDepositIndexWithMaxBlock = eth1DepositIndex.plus(MAX_DEPOSITS); UInt64 toDepositIndex = latestDepositIndexWithMaxBlock.isGreaterThan(eth1DepositCount) ? eth1DepositCount : latestDepositIndexWithMaxBlock; return SSZList.createMutable( getDepositsWithProof(eth1DepositIndex, toDepositIndex, eth1DepositCount), MAX_DEPOSITS, Deposit.class); }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { public synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data) { UInt64 eth1DepositCount; if (isEnoughVotesToUpdateEth1Data(getVoteCount(state, eth1Data) + 1)) { eth1DepositCount = eth1Data.getDeposit_count(); } else { eth1DepositCount = state.getEth1_data().getDeposit_count(); } UInt64 eth1DepositIndex = state.getEth1_deposit_index(); checkRequiredDepositsAvailable(eth1DepositCount, eth1DepositIndex); UInt64 latestDepositIndexWithMaxBlock = eth1DepositIndex.plus(MAX_DEPOSITS); UInt64 toDepositIndex = latestDepositIndexWithMaxBlock.isGreaterThan(eth1DepositCount) ? eth1DepositCount : latestDepositIndexWithMaxBlock; return SSZList.createMutable( getDepositsWithProof(eth1DepositIndex, toDepositIndex, eth1DepositCount), MAX_DEPOSITS, Deposit.class); } }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { public synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data) { UInt64 eth1DepositCount; if (isEnoughVotesToUpdateEth1Data(getVoteCount(state, eth1Data) + 1)) { eth1DepositCount = eth1Data.getDeposit_count(); } else { eth1DepositCount = state.getEth1_data().getDeposit_count(); } UInt64 eth1DepositIndex = state.getEth1_deposit_index(); checkRequiredDepositsAvailable(eth1DepositCount, eth1DepositIndex); UInt64 latestDepositIndexWithMaxBlock = eth1DepositIndex.plus(MAX_DEPOSITS); UInt64 toDepositIndex = latestDepositIndexWithMaxBlock.isGreaterThan(eth1DepositCount) ? eth1DepositCount : latestDepositIndexWithMaxBlock; return SSZList.createMutable( getDepositsWithProof(eth1DepositIndex, toDepositIndex, eth1DepositCount), MAX_DEPOSITS, Deposit.class); } DepositProvider(RecentChainData recentChainData, final Eth1DataCache eth1DataCache); }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { public synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data) { UInt64 eth1DepositCount; if (isEnoughVotesToUpdateEth1Data(getVoteCount(state, eth1Data) + 1)) { eth1DepositCount = eth1Data.getDeposit_count(); } else { eth1DepositCount = state.getEth1_data().getDeposit_count(); } UInt64 eth1DepositIndex = state.getEth1_deposit_index(); checkRequiredDepositsAvailable(eth1DepositCount, eth1DepositIndex); UInt64 latestDepositIndexWithMaxBlock = eth1DepositIndex.plus(MAX_DEPOSITS); UInt64 toDepositIndex = latestDepositIndexWithMaxBlock.isGreaterThan(eth1DepositCount) ? eth1DepositCount : latestDepositIndexWithMaxBlock; return SSZList.createMutable( getDepositsWithProof(eth1DepositIndex, toDepositIndex, eth1DepositCount), MAX_DEPOSITS, Deposit.class); } DepositProvider(RecentChainData recentChainData, final Eth1DataCache eth1DataCache); @Override synchronized void onDepositsFromBlock(DepositsFromBlockEvent event); @Override void onNewFinalizedCheckpoint(final Checkpoint checkpoint); @Override void onEth1Block(final Bytes32 blockHash, final UInt64 blockTimestamp); @Override void onMinGenesisTimeBlock(MinGenesisTimeBlockEvent event); synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data); synchronized int getDepositMapSize(); }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { public synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data) { UInt64 eth1DepositCount; if (isEnoughVotesToUpdateEth1Data(getVoteCount(state, eth1Data) + 1)) { eth1DepositCount = eth1Data.getDeposit_count(); } else { eth1DepositCount = state.getEth1_data().getDeposit_count(); } UInt64 eth1DepositIndex = state.getEth1_deposit_index(); checkRequiredDepositsAvailable(eth1DepositCount, eth1DepositIndex); UInt64 latestDepositIndexWithMaxBlock = eth1DepositIndex.plus(MAX_DEPOSITS); UInt64 toDepositIndex = latestDepositIndexWithMaxBlock.isGreaterThan(eth1DepositCount) ? eth1DepositCount : latestDepositIndexWithMaxBlock; return SSZList.createMutable( getDepositsWithProof(eth1DepositIndex, toDepositIndex, eth1DepositCount), MAX_DEPOSITS, Deposit.class); } DepositProvider(RecentChainData recentChainData, final Eth1DataCache eth1DataCache); @Override synchronized void onDepositsFromBlock(DepositsFromBlockEvent event); @Override void onNewFinalizedCheckpoint(final Checkpoint checkpoint); @Override void onEth1Block(final Bytes32 blockHash, final UInt64 blockTimestamp); @Override void onMinGenesisTimeBlock(MinGenesisTimeBlockEvent event); synchronized SSZList<Deposit> getDeposits(BeaconState state, Eth1Data eth1Data); synchronized int getDepositMapSize();  }