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

New definition for "out of sync" #1996

Merged
merged 2 commits into from Apr 1, 2022

Conversation

michaelsutton
Copy link
Collaborator

@michaelsutton michaelsutton commented Mar 31, 2022

This PR modifies "out of sync" definition such that miners will mine under all possible circumstances.

app/protocol/flowcontext/should_mine.go Show resolved Hide resolved
@@ -35,13 +26,15 @@ func (f *FlowContext) ShouldMine() (bool, error) {
}

now := mstime.Now().UnixMilliseconds()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The queries to virtual selected parent info are relatively expensive. It might make sense to maintain the virtual selected parent timestamp by pushing virtual changes and only querying the current time against it with out acquiring the consensus lock.

@@ -50,7 +50,12 @@ func (flow *handleRelayedTransactionsFlow) start() error {
return err
}

if flow.IsIBDRunning() {
isNearlySynced, err := flow.IsNearlySynced()
Copy link
Collaborator Author

Choose a reason for hiding this comment

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

This might be a performance-sensitive location, if we don't optimize IsNearlySynced using push updates as suggested above.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it's fine to keep using IsIBDRunning in here

if err != nil {
return err
}
if !isNearlySynced && flow.IsIBDRunning() {
Copy link
Collaborator

Choose a reason for hiding this comment

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

IsIBDRunning should be pretty fast, so I think it's better to check it first

@@ -50,7 +50,12 @@ func (flow *handleRelayedTransactionsFlow) start() error {
return err
}

if flow.IsIBDRunning() {
isNearlySynced, err := flow.IsNearlySynced()
Copy link
Collaborator

Choose a reason for hiding this comment

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

Maybe it's fine to keep using IsIBDRunning in here

@codecov
Copy link

codecov bot commented Apr 1, 2022

Codecov Report

Merging #1996 (9f7c2fd) into dev (cb65dae) will increase coverage by 0.02%.
The diff coverage is 35.71%.

@@            Coverage Diff             @@
##              dev    #1996      +/-   ##
==========================================
+ Coverage   57.19%   57.22%   +0.02%     
==========================================
  Files         685      685              
  Lines       32982    32995      +13     
==========================================
+ Hits        18865    18881      +16     
+ Misses      11439    11436       -3     
  Partials     2678     2678              
Impacted Files Coverage Δ
.../protocol/flows/v4/blockrelay/handle_relay_invs.go 0.00% <0.00%> (ø)
.../protocol/flows/v5/blockrelay/handle_relay_invs.go 52.76% <0.00%> (-0.05%) ⬇️
...v4/transactionrelay/handle_relayed_transactions.go 47.66% <25.00%> (-0.42%) ⬇️
...v5/transactionrelay/handle_relayed_transactions.go 64.48% <25.00%> (-0.90%) ⬇️
app/protocol/flowcontext/flow_context.go 93.54% <100.00%> (+0.44%) ⬆️
app/protocol/flowcontext/should_mine.go 80.95% <100.00%> (+22.61%) ⬆️
app/protocol/manager.go 86.36% <100.00%> (ø)
app/protocol/flows/v5/blockrelay/block_locator.go 52.94% <0.00%> (-11.77%) ⬇️
infrastructure/network/netadapter/router/route.go 88.57% <0.00%> (-5.72%) ⬇️
...k/netadapter/server/grpcserver/connection_loops.go 56.89% <0.00%> (-5.18%) ⬇️
... and 9 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 cb65dae...9f7c2fd. Read the comment docs.

@michaelsutton michaelsutton merged commit 95fa045 into kaspanet:dev Apr 1, 2022
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

2 participants