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

[General] Root snapshot QC validation #2038

Merged
merged 7 commits into from
Feb 28, 2022

Conversation

durkmurder
Copy link
Member

https://github.com/dapperlabs/flow-go/issues/6145

Context

This PR implements validation of QCs that are part of the root snapshot.
A few important points that were implemented in different way comparing to what is described in ticket:

  • Implemented validation for both root QC and cluster QCs
  • Implemented the check as separate function, not as part of IsValidRootSnapshot. (IsValidRootSnapshot is used in ~130 tests which breaks all of them since we use fixtures for root snapshot).
  • Extra check were added in FlowNodeBuilder and finalize tool.

Copy link
Member

@zhangchiqing zhangchiqing left a comment

Choose a reason for hiding this comment

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

Looks good. Some minor suggestions.

Comment on lines 344 to 351
clusterRootBlock := &model.Block{
BlockID: clusterBlock.ID(),
View: clusterBlock.Header.View,
ProposerID: clusterBlock.Header.ProposerID,
QC: nil,
PayloadHash: clusterBlock.Header.PayloadHash,
Timestamp: clusterBlock.Header.Timestamp,
}
Copy link
Member

Choose a reason for hiding this comment

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

could we extract it into a function, and reuse here?

@@ -212,6 +212,12 @@ func finalize(cmd *cobra.Command, args []string) {
log.Fatal().Err(err).Msg("the generated root snapshot is invalid")
}

// validate the generated root snapshot QCs
err = badger.IsValidRootSnapshotQCs(snapshot)
Copy link
Member

Choose a reason for hiding this comment

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

could we move IsValidRootSnapshotQCs into IsValidRootSnapshot?

Copy link
Member Author

Choose a reason for hiding this comment

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

We cannot because IsValidRootSnapshot is used in ~130 tests, moving it will break every test or require us to generate a completely valid QC instead of fixtures.

@codecov-commenter
Copy link

Codecov Report

Merging #2038 (4212e37) into master (0bd50cf) will decrease coverage by 0.14%.
The diff coverage is 4.91%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #2038      +/-   ##
==========================================
- Coverage   57.63%   57.49%   -0.15%     
==========================================
  Files         631      631              
  Lines       36233    36285      +52     
==========================================
- Hits        20884    20861      -23     
- Misses      12732    12807      +75     
  Partials     2617     2617              
Flag Coverage Δ
unittests 57.49% <4.91%> (-0.15%) ⬇️

Flags with carried forward coverage won't be shown. Click here to find out more.

Impacted Files Coverage Δ
cmd/scaffold.go 8.56% <0.00%> (-0.03%) ⬇️
consensus/hotstuff/committees/static.go 0.00% <0.00%> (ø)
state/protocol/badger/validity.go 46.25% <0.00%> (-19.83%) ⬇️
cmd/bootstrap/cmd/finalize.go 64.76% <33.33%> (-0.62%) ⬇️
cmd/bootstrap/run/cluster_qc.go 53.84% <100.00%> (-5.25%) ⬇️
ledger/common/hash/hash.go 18.18% <0.00%> (-21.82%) ⬇️
consensus/hotstuff/eventloop/event_loop.go 68.29% <0.00%> (-6.10%) ⬇️
...s/hotstuff/votecollector/staking_vote_processor.go 89.47% <0.00%> (-3.51%) ⬇️
fvm/handler/contract.go 75.32% <0.00%> (-2.60%) ⬇️
...tstuff/votecollector/combined_vote_processor_v2.go 85.60% <0.00%> (-1.61%) ⬇️
... and 7 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0bd50cf...4212e37. Read the comment docs.

Copy link
Member

@jordanschalm jordanschalm left a comment

Choose a reason for hiding this comment

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

Just one comment, other LGTM. Thanks for this

state/protocol/badger/validity.go Outdated Show resolved Hide resolved
@durkmurder
Copy link
Member Author

bors merge

@bors
Copy link
Contributor

bors bot commented Feb 28, 2022

@bors bors bot merged commit 285d111 into master Feb 28, 2022
@bors bors bot deleted the yurii/6142-cluster-qc-root-shapshot-validation branch February 28, 2022 10:52
bors bot added a commit that referenced this pull request Oct 26, 2022
3444: Add AccountKeysCount to AccountKeyReader to match changes in Cadence's runtime Interface r=turbolent a=dreamsmasher

Closes [Cadence issue 1388](onflow/cadence#1388).

Two new fields/methods have been added to `PublicAccount.keys` and `AuthAccount.keys` in [Cadence PR 2038](onflow/cadence#2038): 

`pub let count: Int`
`pub fun forEach(f: ((AccountKey): Bool))`

Both are implemented top of `AccountKeyReader.GetAccountKey` and `Accounts.GetPublicKeyCount`. As part of [#2038](onflow/cadence#2038), the core runtime `Interface` was updated to require `AccountKeysCount`, which was previously implemented as part of the FVM's `Accounts` struct but not exposed to Cadence. This PR introduces `AccountKeysCount` to the `AccountKeyReader` interface to fulfill these new upstream requirements.

Blocked by onflow/cadence#2093

Co-authored-by: Naomi Liu <naomi.liu@dapperlabs.com>
bors bot added a commit that referenced this pull request Oct 27, 2022
3444: Add AccountKeysCount to AccountKeyReader to match changes in Cadence's runtime Interface r=turbolent a=dreamsmasher

Closes [Cadence issue 1388](onflow/cadence#1388).

Two new fields/methods have been added to `PublicAccount.keys` and `AuthAccount.keys` in [Cadence PR 2038](onflow/cadence#2038): 

`pub let count: Int`
`pub fun forEach(f: ((AccountKey): Bool))`

Both are implemented top of `AccountKeyReader.GetAccountKey` and `Accounts.GetPublicKeyCount`. As part of [#2038](onflow/cadence#2038), the core runtime `Interface` was updated to require `AccountKeysCount`, which was previously implemented as part of the FVM's `Accounts` struct but not exposed to Cadence. This PR introduces `AccountKeysCount` to the `AccountKeyReader` interface to fulfill these new upstream requirements.

Blocked by onflow/cadence#2093

Co-authored-by: Naomi Liu <naomi.liu@dapperlabs.com>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
bors bot added a commit that referenced this pull request Oct 27, 2022
3444: Add AccountKeysCount to AccountKeyReader to match changes in Cadence's runtime Interface r=turbolent a=dreamsmasher

Closes [Cadence issue 1388](onflow/cadence#1388).

Two new fields/methods have been added to `PublicAccount.keys` and `AuthAccount.keys` in [Cadence PR 2038](onflow/cadence#2038): 

`pub let count: Int`
`pub fun forEach(f: ((AccountKey): Bool))`

Both are implemented top of `AccountKeyReader.GetAccountKey` and `Accounts.GetPublicKeyCount`. As part of [#2038](onflow/cadence#2038), the core runtime `Interface` was updated to require `AccountKeysCount`, which was previously implemented as part of the FVM's `Accounts` struct but not exposed to Cadence. This PR introduces `AccountKeysCount` to the `AccountKeyReader` interface to fulfill these new upstream requirements.

Blocked by onflow/cadence#2093

3450: Clean up fvm mocks r=pattyshack a=pattyshack

1. Removed dead mock directory fvm/mock
2. Updated makefile to wipe environment/mock directory before regenerating mocks
3. Updated test to stop using dead mocks

Co-authored-by: Naomi Liu <naomi.liu@dapperlabs.com>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Co-authored-by: Patrick Lee <patrick.lee@dapperlabs.com>
bors bot added a commit that referenced this pull request Oct 27, 2022
3440: Test ErrorsCollector against SplitError r=pattyshack a=pattyshack

Forgot to add test for this during the refactoring.

3444: Add AccountKeysCount to AccountKeyReader to match changes in Cadence's runtime Interface r=turbolent a=dreamsmasher

Closes [Cadence issue 1388](onflow/cadence#1388).

Two new fields/methods have been added to `PublicAccount.keys` and `AuthAccount.keys` in [Cadence PR 2038](onflow/cadence#2038): 

`pub let count: Int`
`pub fun forEach(f: ((AccountKey): Bool))`

Both are implemented top of `AccountKeyReader.GetAccountKey` and `Accounts.GetPublicKeyCount`. As part of [#2038](onflow/cadence#2038), the core runtime `Interface` was updated to require `AccountKeysCount`, which was previously implemented as part of the FVM's `Accounts` struct but not exposed to Cadence. This PR introduces `AccountKeysCount` to the `AccountKeyReader` interface to fulfill these new upstream requirements.

Blocked by onflow/cadence#2093

Co-authored-by: Patrick Lee <patrick.lee@dapperlabs.com>
Co-authored-by: Naomi Liu <naomi.liu@dapperlabs.com>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
bors bot added a commit that referenced this pull request Oct 27, 2022
3444: Add AccountKeysCount to AccountKeyReader to match changes in Cadence's runtime Interface r=turbolent a=dreamsmasher

Closes [Cadence issue 1388](onflow/cadence#1388).

Two new fields/methods have been added to `PublicAccount.keys` and `AuthAccount.keys` in [Cadence PR 2038](onflow/cadence#2038): 

`pub let count: Int`
`pub fun forEach(f: ((AccountKey): Bool))`

Both are implemented top of `AccountKeyReader.GetAccountKey` and `Accounts.GetPublicKeyCount`. As part of [#2038](onflow/cadence#2038), the core runtime `Interface` was updated to require `AccountKeysCount`, which was previously implemented as part of the FVM's `Accounts` struct but not exposed to Cadence. This PR introduces `AccountKeysCount` to the `AccountKeyReader` interface to fulfill these new upstream requirements.

Blocked by onflow/cadence#2093

Co-authored-by: Naomi Liu <naomi.liu@dapperlabs.com>
Co-authored-by: Bastian Müller <bastian@axiomzen.co>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants