Skip to content

Commit

Permalink
Implement QueryablePayload::transaction for Payload (#1761)
Browse files Browse the repository at this point in the history
Closes #<ISSUE_NUMBER>
<!-- These comments should help create a useful PR message, please
delete any remaining comments before opening the PR. -->
<!-- If there is no issue number make sure to describe clearly *why*
this PR is necessary. -->
<!-- Mention open questions, remaining TODOs, if any -->

### This PR:
<!-- Describe what this PR adds to this repo and why -->
<!-- E.g. -->
<!-- * Implements feature 1 -->
<!-- * Fixes bug 3 -->
Implements `QueryablePayload::transaction` for `Payload` using
`Payload::transaction`.
Until now `Payload` had only the generic `QueryablePayload::transaction`
which internally uses `transaction_with_proof`. This is not optimal as
proof calculation is cpu-intensive and it's a waste of cpu cycles in
case we only care about the transaction and not the proof.
This change greatly improves the builder's performance.

Tested with `demo-native` it looks like this solves empty blocks issue.

### This PR does not:
<!-- Describe what is out of scope for this PR, if applicable. Leave
this section blank if it's not applicable -->
<!-- This section helps avoid the reviewer having to needlessly point
out missing parts -->
<!-- * Implement feature 3 because that feature is blocked by Issue 4
-->
<!-- * Implement xyz because that is tracked in issue #123. -->
<!-- * Address xzy for which I opened issue #456 -->

### Key places to review:
<!-- Describe key places for reviewers to pay close attention to -->
<!-- * file.rs, `add_integers` function -->
<!-- Or directly comment on those files/lines to make it easier for the
reviewers -->

<!-- ### How to test this PR:  -->
<!-- Optional, uncomment the above line if this is relevant to your PR
-->
<!-- If your PR is fully tested through CI there is no need to add this
section -->
<!-- * E.g. `just test` -->

<!-- ### Things tested -->
<!-- Anything that was manually tested (that is not tested in CI). -->
<!-- E.g. building/running of docker containers. Changes to docker demo,
... -->
<!-- Especially mention anything untested, with reasoning and link an
issue to resolve this. -->

<!-- Complete the following items before creating this PR -->
<!-- [ ] Issue linked or PR description mentions why this change is
necessary. -->
<!-- [ ] PR description is clear enough for reviewers. -->
<!-- [ ] Documentation for changes (additions) has been updated (added).
-->
<!-- [ ] If this is a draft it is marked as "draft".  -->

<!-- To make changes to this template edit
https://github.com/EspressoSystems/.github/blob/main/PULL_REQUEST_TEMPLATE.md
-->
  • Loading branch information
lukaszrzasik authored Jul 22, 2024
2 parents 332a452 + bcbafc2 commit 8709a14
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions types/src/v0/impls/block/full_payload/payload.rs
Original file line number Diff line number Diff line change
Expand Up @@ -219,6 +219,14 @@ impl QueryablePayload<SeqTypes> for Payload {

TxProof::new(index, self, &common)
}

fn transaction(
&self,
_meta: &Self::Metadata,
index: &Self::TransactionIndex,
) -> Option<Self::Transaction> {
self.transaction(index)
}
}

impl std::fmt::Display for Payload {
Expand Down

0 comments on commit 8709a14

Please sign in to comment.