Skip to content

perf(consensus): align calls to ValidateBlock, ProcessProposal and isTimely#2960

Merged
sergio-mena merged 6 commits intomainfrom
sergio/2854-align-validateblock-to-procprop
May 13, 2024
Merged

perf(consensus): align calls to ValidateBlock, ProcessProposal and isTimely#2960
sergio-mena merged 6 commits intomainfrom
sergio/2854-align-validateblock-to-procprop

Conversation

@sergio-mena
Copy link
Collaborator

@sergio-mena sergio-mena commented May 1, 2024

This change is an implementation of the alignment of ValidateBlock to ProcessProposal explained here.

We need to:

  • Check if that helps, perf-wise
  • Carefully make sure we're not compromising algorithm's correctness

EDIT:

In the end, we are implementing this as agreed here

EDIT2:

This PR will just deal with alignment of ValidateBlock, ProcessProposal and isTimely (so it's no longer closing #2854)


PR checklist

  • Tests written/updated
  • Changelog entry added in .changelog (we use unclog to manage our changelog)
  • Updated relevant documentation (docs/ or spec/) and code comments
  • Title follows the Conventional Commits spec

@sergio-mena sergio-mena requested a review from a team as a code owner May 1, 2024 10:32
@sergio-mena sergio-mena requested a review from a team May 1, 2024 10:32
@sergio-mena sergio-mena self-assigned this May 1, 2024
@sergio-mena sergio-mena added this to the 2024-Q2 milestone May 1, 2024
@sergio-mena sergio-mena changed the title Align calls to ValidateBlock to ProcessProposal perf(consensus): align calls to ValidateBlock to ProcessProposal May 1, 2024
@adizere adizere removed this from the 2024-Q2 milestone May 1, 2024
@adizere
Copy link
Contributor

adizere commented May 1, 2024

Removed from project board & Milestone b/c it's tracked already under #2854

Copy link

@cason cason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am not 100% positive about this approach, as it would allow nodes to commit a block they deem invalid if 2/3+ validators have voted for the block, where in some scenarios we could have more than 1/3 validators that are faulty (e.g., with a validation bug).

@sergio-mena
Copy link
Collaborator Author

See this comment for an explanation of the latest commits

Copy link

@cason cason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This PR now has 3 contributions:

  1. On prevote step, only validate blocks when they are new (POLRound == -1) and we are not locked
  2. The same for the timely validation performed as part of PBTS
  3. Minimal chaching mechanism for block validation

I think the PR should implement 1. and 2., with description updated to reflect this change. In this case it is not really a performance improvement, as there is no change or benefit in the good case (single round).

I would leave 3. for another PR.

@sergio-mena sergio-mena changed the title perf(consensus): align calls to ValidateBlock to ProcessProposal perf(consensus): align calls to ValidateBlock, ProcessProposal and isTimely + add simplistic block validation cache May 13, 2024
@sergio-mena
Copy link
Collaborator Author

This PR now has 3 contributions:

1. On prevote step, only validate blocks when they are new (`POLRound == -1`) and we are not locked

2. The same for the timely validation performed as part of PBTS

3. Minimal chaching mechanism for block validation

I think the PR should implement 1. and 2., with description updated to reflect this change. In this case it is not really a performance improvement, as there is no change or benefit in the good case (single round).

I would leave 3. for another PR.

This PR now has 3 contributions:

1. On prevote step, only validate blocks when they are new (`POLRound == -1`) and we are not locked

2. The same for the timely validation performed as part of PBTS

3. Minimal chaching mechanism for block validation

I think the PR should implement 1. and 2., with description updated to reflect this change. In this case it is not really a performance improvement, as there is no change or benefit in the good case (single round).

I would leave 3. for another PR.

@cason OK, I'll split this into two PRs. An extra PR is cheap

@sergio-mena sergio-mena changed the title perf(consensus): align calls to ValidateBlock, ProcessProposal and isTimely + add simplistic block validation cache perf(consensus): align calls to ValidateBlock, ProcessProposal and isTimely May 13, 2024
Copy link

@cason cason left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good refactoring :)

@sergio-mena sergio-mena added this pull request to the merge queue May 13, 2024
Merged via the queue into main with commit f8c369d May 13, 2024
@sergio-mena sergio-mena deleted the sergio/2854-align-validateblock-to-procprop branch May 13, 2024 13:23
github-merge-queue bot pushed a commit that referenced this pull request May 14, 2024
Closes #2854

Follow up from #2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of #2854

---

#### PR checklist

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
ValarDragon pushed a commit to osmosis-labs/cometbft that referenced this pull request May 25, 2024
Closes cometbft#2854

Follow up from cometbft#2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of cometbft#2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
mergify bot pushed a commit to osmosis-labs/cometbft that referenced this pull request May 28, 2024
Closes cometbft#2854

Follow up from cometbft#2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of cometbft#2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
(cherry picked from commit 2dd4e03)
PaddyMc pushed a commit to osmosis-labs/cometbft that referenced this pull request May 28, 2024
#78)

Closes cometbft#2854

Follow up from cometbft#2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of cometbft#2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
(cherry picked from commit 2dd4e03)

Co-authored-by: Sergio Mena <sergio@informal.systems>
PaddyMc pushed a commit to osmosis-labs/cometbft that referenced this pull request Aug 19, 2024
Closes cometbft#2854

Follow up from cometbft#2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of cometbft#2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
ValarDragon pushed a commit to osmosis-labs/cometbft that referenced this pull request Aug 19, 2024
#133)

Closes cometbft#2854

Follow up from cometbft#2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of cometbft#2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Sergio Mena <sergio@informal.systems>
Co-authored-by: Andy Nogueira <me@andynogueira.dev>
mattac21 pushed a commit that referenced this pull request Sep 9, 2025
Closes #2854

Follow up from #2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of #2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
mattac21 pushed a commit that referenced this pull request Sep 10, 2025
Closes #2854

Follow up from #2960

This PR adds a simplistic 1-element block validation cache in
`BlockExecutor`. This addresses a performance bottleneck raised as part
of #2854

---

- [ ] Tests written/updated
- [ ] Changelog entry added in `.changelog` (we use
[unclog](https://github.com/informalsystems/unclog) to manage our
changelog)
- [ ] Updated relevant documentation (`docs/` or `spec/`) and code
comments
- [ ] Title follows the [Conventional
Commits](https://www.conventionalcommits.org/en/v1.0.0/) spec

---------

Co-authored-by: Andy Nogueira <me@andynogueira.dev>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants