-
Notifications
You must be signed in to change notification settings - Fork 995
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
Custom Block HTR #5219
Merged
Merged
Custom Block HTR #5219
Changes from all commits
Commits
Show all changes
11 commits
Select commit
Hold shift + click to select a range
1e54ee2
add custom htr
nisdas a7f934b
fix root
nisdas 4aeafcd
fix everything
nisdas b9ed31c
Apply suggestions from code review
nisdas 2e3dfcd
Update beacon-chain/state/stateutil/blocks.go
nisdas 96b6f11
Update beacon-chain/blockchain/receive_block.go
nisdas 3f3c2c8
Update beacon-chain/blockchain/process_block.go
nisdas 5b53ff4
terence's review
nisdas 8575b31
Merge branch 'customBlockHTR' of https://github.com/prysmaticlabs/get…
nisdas bf06c6d
Merge refs/heads/master into customBlockHTR
prylabs-bulldozer[bot] 686c0f8
Merge refs/heads/master into customBlockHTR
prylabs-bulldozer[bot] File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
package stateutil_benchmark | ||
|
||
import ( | ||
"testing" | ||
|
||
ethpb "github.com/prysmaticlabs/ethereumapis/eth/v1alpha1" | ||
"github.com/prysmaticlabs/go-ssz" | ||
"github.com/prysmaticlabs/prysm/beacon-chain/state/stateutil" | ||
"github.com/prysmaticlabs/prysm/shared/testutil" | ||
) | ||
|
||
func BenchmarkBlockHTR(b *testing.B) { | ||
genState, keys := testutil.DeterministicGenesisState(b, 200) | ||
conf := testutil.DefaultBlockGenConfig() | ||
blk, err := testutil.GenerateFullBlock(genState, keys, conf, 10) | ||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
atts := make([]*ethpb.Attestation, 0, 128) | ||
for i := 0; i < 128; i++ { | ||
atts = append(atts, blk.Block.Body.Attestations[0]) | ||
} | ||
deposits, _, err := testutil.DeterministicDepositsAndKeys(16) | ||
if err != nil { | ||
b.Fatal(err) | ||
} | ||
blk.Block.Body.Attestations = atts | ||
blk.Block.Body.Deposits = deposits | ||
|
||
b.Run("SSZ_HTR", func(b *testing.B) { | ||
b.ResetTimer() | ||
b.ReportAllocs() | ||
for i := 0; i < b.N; i++ { | ||
if _, err := ssz.HashTreeRoot(blk.Block); err != nil { | ||
b.Fatal(err) | ||
} | ||
} | ||
}) | ||
|
||
b.Run("Custom_SSZ_HTR", func(b *testing.B) { | ||
b.ResetTimer() | ||
b.ReportAllocs() | ||
for i := 0; i < b.N; i++ { | ||
if _, err := stateutil.BlockRoot(blk.Block); err != nil { | ||
b.Fatal(err) | ||
} | ||
} | ||
}) | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Prefer naming it
attestationsRoot
as it doesn't need to be constrained withblock
, the function can be extensible to any object that needs a hash tree root of a list of attestationsThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we use the max block attestation capacity here, so this will only apply for beacon block attestations. If we use attestations which are larger than 128 in length, this root will be incorrect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
makes sense 👍