Amend which transactions to put into the next block proposal.
(
&self,
request: request::PrepareProposal,
)
| 790 | |
| 791 | /// Amend which transactions to put into the next block proposal. |
| 792 | async fn prepare_proposal( |
| 793 | &self, |
| 794 | request: request::PrepareProposal, |
| 795 | ) -> AbciResult<response::PrepareProposal> { |
| 796 | tracing::debug!( |
| 797 | height = request.height.value(), |
| 798 | time = request.time.to_string(), |
| 799 | "prepare proposal" |
| 800 | ); |
| 801 | let mut cetf_tx = vec![]; |
| 802 | match request.local_last_commit { |
| 803 | Some(info) => { |
| 804 | // TODO: Better error handling |
| 805 | let votes = info |
| 806 | .votes |
| 807 | .into_iter() |
| 808 | .map(|vote| { |
| 809 | if vote.vote_extension.is_empty() { |
| 810 | vec![] |
| 811 | } else { |
| 812 | from_slice::<SignedTags>(&vote.vote_extension).unwrap().0 |
| 813 | } |
| 814 | }) |
| 815 | .flatten() |
| 816 | .collect::<Vec<_>>(); |
| 817 | |
| 818 | let cetf_sigs = votes |
| 819 | .iter() |
| 820 | .filter(|t| matches!(t, SignatureKind::Cetf(_))) |
| 821 | .map(SignatureKind::as_slice) |
| 822 | .map(bls_signatures::Signature::from_bytes) |
| 823 | .collect::<Result<Vec<_>, bls_signatures::Error>>() |
| 824 | .unwrap(); |
| 825 | let height_sigs = votes |
| 826 | .iter() |
| 827 | .filter(|t| matches!(t, SignatureKind::BlockHeight(_))) |
| 828 | .map(SignatureKind::as_slice) |
| 829 | .map(bls_signatures::Signature::from_bytes) |
| 830 | .collect::<Result<Vec<_>, bls_signatures::Error>>() |
| 831 | .unwrap(); |
| 832 | |
| 833 | let agg_cetf_sig = if !cetf_sigs.is_empty() { |
| 834 | Some(bls_signatures::aggregate(&cetf_sigs).unwrap()) |
| 835 | } else { |
| 836 | None |
| 837 | }; |
| 838 | let agg_height_sig = if !height_sigs.is_empty() { |
| 839 | Some(bls_signatures::aggregate(&height_sigs).unwrap()) |
| 840 | } else { |
| 841 | None |
| 842 | }; |
| 843 | |
| 844 | tracing::debug!( |
| 845 | r#"prepare proposal signature aggregation result (TM Height: {})): |
| 846 | agg_cetf_sig: {:?} |
| 847 | agg_height_sig: {:?} |
| 848 | "#, |
| 849 | request.height.value(), |
nothing calls this directly
no test coverage detected