@Test void shouldNotifyEth1DataCacheOfDepositBlocks() { final tech.pegasys.teku.pow.event.Deposit deposit = dataStructureUtil.randomDepositEvent(UInt64.ZERO); final DepositsFromBlockEvent event = DepositsFromBlockEvent.create( dataStructureUtil.randomUInt64(), dataStructureUtil.randomBytes32(), dataStructureUtil.randomUInt64(), Stream.of(deposit)); depositProvider.onDepositsFromBlock(event); depositMerkleTree.add( DepositUtil.convertDepositEventToOperationDeposit(deposit).getData().hash_tree_root()); verify(eth1DataCache) .onBlockWithDeposit( event.getBlockTimestamp(), new Eth1Data(depositMerkleTree.getRoot(), UInt64.ONE, event.getBlockHash())); }
@Override public synchronized void onDepositsFromBlock(DepositsFromBlockEvent event) { event.getDeposits().stream() .map(DepositUtil::convertDepositEventToOperationDeposit) .forEach( deposit -> { if (!recentChainData.isPreGenesis()) { LOG.debug("About to process deposit: {}", deposit.getIndex()); } depositNavigableMap.put(deposit.getIndex(), deposit); depositMerkleTree.add(deposit.getData().hash_tree_root()); }); eth1DataCache.onBlockWithDeposit( event.getBlockTimestamp(), new Eth1Data( depositMerkleTree.getRoot(), UInt64.valueOf(depositMerkleTree.getNumberOfLeaves()), event.getBlockHash())); }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { @Override public synchronized void onDepositsFromBlock(DepositsFromBlockEvent event) { event.getDeposits().stream() .map(DepositUtil::convertDepositEventToOperationDeposit) .forEach( deposit -> { if (!recentChainData.isPreGenesis()) { LOG.debug("About to process deposit: {}", deposit.getIndex()); } depositNavigableMap.put(deposit.getIndex(), deposit); depositMerkleTree.add(deposit.getData().hash_tree_root()); }); eth1DataCache.onBlockWithDeposit( event.getBlockTimestamp(), new Eth1Data( depositMerkleTree.getRoot(), UInt64.valueOf(depositMerkleTree.getNumberOfLeaves()), event.getBlockHash())); } }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { @Override public synchronized void onDepositsFromBlock(DepositsFromBlockEvent event) { event.getDeposits().stream() .map(DepositUtil::convertDepositEventToOperationDeposit) .forEach( deposit -> { if (!recentChainData.isPreGenesis()) { LOG.debug("About to process deposit: {}", deposit.getIndex()); } depositNavigableMap.put(deposit.getIndex(), deposit); depositMerkleTree.add(deposit.getData().hash_tree_root()); }); eth1DataCache.onBlockWithDeposit( event.getBlockTimestamp(), new Eth1Data( depositMerkleTree.getRoot(), UInt64.valueOf(depositMerkleTree.getNumberOfLeaves()), event.getBlockHash())); } DepositProvider(RecentChainData recentChainData, final Eth1DataCache eth1DataCache); }
DepositProvider implements Eth1EventsChannel, FinalizedCheckpointChannel { @Override public synchronized void onDepositsFromBlock(DepositsFromBlockEvent event) { event.getDeposits().stream() .map(DepositUtil::convertDepositEventToOperationDeposit) .forEach( deposit -> { if (!recentChainData.isPreGenesis()) { LOG.debug("About to process deposit: {}", deposit.getIndex()); } depositNavigableMap.put(deposit.getIndex(), deposit); depositMerkleTree.add(deposit.getData().hash_tree_root()); }); eth1DataCache.onBlockWithDeposit( event.getBlockTimestamp(), new Eth1Data( depositMerkleTree.getRoot(), UInt64.valueOf(depositMerkleTree.getNumberOfLeaves()), event.getBlockHash())); } 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 { @Override public synchronized void onDepositsFromBlock(DepositsFromBlockEvent event) { event.getDeposits().stream() .map(DepositUtil::convertDepositEventToOperationDeposit) .forEach( deposit -> { if (!recentChainData.isPreGenesis()) { LOG.debug("About to process deposit: {}", deposit.getIndex()); } depositNavigableMap.put(deposit.getIndex(), deposit); depositMerkleTree.add(deposit.getData().hash_tree_root()); }); eth1DataCache.onBlockWithDeposit( event.getBlockTimestamp(), new Eth1Data( depositMerkleTree.getRoot(), UInt64.valueOf(depositMerkleTree.getNumberOfLeaves()), event.getBlockHash())); } 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();  }