Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Minimize signature verification when bootstrapping #3255

Merged
merged 6 commits into from
Aug 2, 2024

Conversation

yacovm
Copy link
Contributor

@yacovm yacovm commented Jul 31, 2024

Why this should be merged

When bootstrapping blocks of the P-chain, the node verifies blocks when it replicates them from remote nodes,
and afterwards it executes them.

When executing them, it verifies the blocks once again via parsing them.
This is redundant, as it has already parsed them before while replicating them.

When testing a chunk of 1000 blocks, parsing the blocks without verifying the signature shaves off 93% of the runtime
in comparison to just appraising them.

How this works

This change introduces a concept called "local parsing", which similar to the parser
found in snow/engine/snowman/block/vm.go, converts the bytes of a block to a snowman.Block.

However, unlike the Parser, it is only implemented at the proposerVM, and doesn't verify the signature
of the block, reducing the CPU cycles it costs to execute the blocks when bootstrapping.

How this was tested

Regular CI tests

vms/proposervm/vm.go Outdated Show resolved Hide resolved
vms/proposervm/vm.go Outdated Show resolved Hide resolved
chains/manager.go Outdated Show resolved Hide resolved
@yacovm yacovm force-pushed the fasterBootstrap branch 3 times, most recently from 5d95957 to e3ad23c Compare July 31, 2024 19:11
chains/manager.go Outdated Show resolved Hide resolved
chains/manager.go Show resolved Hide resolved
snow/engine/snowman/bootstrap/acceptor.go Outdated Show resolved Hide resolved
vms/platformvm/vm_test.go Outdated Show resolved Hide resolved
vms/proposervm/vm.go Outdated Show resolved Hide resolved
vms/proposervm/vm.go Show resolved Hide resolved
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

small suggestions

snow/engine/snowman/bootstrap/config.go Outdated Show resolved Hide resolved
vms/platformvm/vm_test.go Outdated Show resolved Hide resolved
snow/engine/snowman/block/test_vm.go Outdated Show resolved Hide resolved
chains/manager.go Outdated Show resolved Hide resolved
vms/proposervm/vm_test.go Outdated Show resolved Hide resolved
Copy link
Contributor

@StephenButtolph StephenButtolph left a comment

Choose a reason for hiding this comment

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

1 last naming nit then lgtm

snow/engine/snowman/bootstrap/bootstrapper.go Show resolved Hide resolved
@StephenButtolph StephenButtolph added this to the v1.11.11 milestone Aug 1, 2024
@StephenButtolph StephenButtolph added this pull request to the merge queue Aug 1, 2024
@github-merge-queue github-merge-queue bot removed this pull request from the merge queue due to failed status checks Aug 1, 2024
When bootstrapping blocks of the P-chain, the node verifies blocks when it replicates them from remote nodes,
and afterwards it executes them.

When executing them, it verifies the blocks once again via parsing them.
This is redundant, as it has already parsed them before while replicating them.

This change introduces an interface called Appraiser, which similar to the parser
found in snow/engine/snowman/block/vm.go, converts the bytes of a block to a snowman.Block.

However, unlike the Parser, it is only implemented at the proposerVM, and doesn't verify the signature
of the block, reducing the CPU cycles it costs to execute the blocks when bootstrapping.

When testing a chunk of 1000 blocks, parsing the blocks without verifying the signature shaves off 93% of the runtime
in comparison to just appraising them.

Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
Signed-off-by: Yacov Manevich <yacov.manevich@avalabs.org>
@StephenButtolph StephenButtolph added this pull request to the merge queue Aug 2, 2024
Merged via the queue into ava-labs:master with commit c202c5a Aug 2, 2024
20 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

4 participants