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

[Blockchain] Simplify block verification #544

Merged
merged 23 commits into from
Jun 1, 2022
Merged
Show file tree
Hide file tree
Changes from 13 commits
Commits
Show all changes
23 commits
Select commit Hold shift + click to select a range
9694a84
Add the initial block verification separation
zivkovicmilos May 9, 2022
ae3b3b4
Separate out consensus and other module verification methods
zivkovicmilos May 9, 2022
29aaa36
Add better naming to block verification methods
zivkovicmilos May 9, 2022
58b46da
Standardize block result errors
zivkovicmilos May 9, 2022
12f6f6a
Add receipts extraction
zivkovicmilos May 9, 2022
8620ea5
Add additional documentation for the usage of the receipts cache
zivkovicmilos May 10, 2022
80e3155
Add delegators for testing the blockchain module
zivkovicmilos May 10, 2022
e317917
Add mock support for the blockchain and storage modules
zivkovicmilos May 10, 2022
33d351e
Add coverage tests
zivkovicmilos May 10, 2022
92bdeca
Simplify the gas verification
zivkovicmilos May 10, 2022
c5dfbbc
Rearrange code blocks
zivkovicmilos May 11, 2022
0194cf9
Rename some helper methods to be more clear
zivkovicmilos May 11, 2022
0a69882
Make the mock testing structure public, refactor a simple test
zivkovicmilos May 11, 2022
a7c2300
Remove redundant comment
zivkovicmilos May 16, 2022
fa47659
Simplify the error variable in initCaches
zivkovicmilos May 16, 2022
87386b7
Eliminate magic numbers
zivkovicmilos May 16, 2022
80954f3
Rearrange the checks in VerifySealedBlock
zivkovicmilos May 16, 2022
18f3f87
Remove reference block type when verifying
zivkovicmilos May 17, 2022
a74f79a
Add explainer for WriteBlock
zivkovicmilos May 17, 2022
92f8113
Verify the header seals before inserting the block
zivkovicmilos May 19, 2022
ddc3480
Merge branch 'develop' into bugfix/simplify-block-verification
zivkovicmilos May 20, 2022
dc73808
Rename interface methods to be more implementation agnostic
zivkovicmilos May 31, 2022
6a4763a
Merge branch 'develop' into bugfix/simplify-block-verification
zivkovicmilos May 31, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions archive/restore.go
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ type blockchainInterface interface {
GetBlockByNumber(uint64, bool) (*types.Block, bool)
GetHashByNumber(uint64) types.Hash
WriteBlock(*types.Block) error
VerifySealedBlock(*types.Block) error
}

// RestoreChain reads blocks from the archive and write to the chain
Expand Down Expand Up @@ -73,6 +74,10 @@ func importBlocks(chain blockchainInterface, blockStream *blockStream, progressi
nextBlock := firstBlock

for {
if err := chain.VerifySealedBlock(nextBlock); err != nil {
return err
}

if err := chain.WriteBlock(nextBlock); err != nil {
return err
}
Expand Down
4 changes: 4 additions & 0 deletions archive/restore_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,10 @@ func (m *mockChain) WriteBlock(block *types.Block) error {
return nil
}

func (m *mockChain) VerifySealedBlock(block *types.Block) error {
return nil
}

func (m *mockChain) SubscribeEvents() blockchain.Subscription {
return protocol.NewMockSubscription()
}
Expand Down
Loading