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

enable margin #1622

Merged
merged 4 commits into from
Jul 7, 2020
Merged

enable margin #1622

merged 4 commits into from
Jul 7, 2020

Conversation

InoMurko
Copy link
Contributor

@InoMurko InoMurko commented Jul 6, 2020

📋 Add associated issues, tickets, docs URL here.

Overview

Describe what your Pull Request is about in a few sentences.

Changes

Describe your changes and implementation choices. More details make PRs easier to review.

  • Change 1
  • Change 2
  • ...

Testing

Describe how to test your new feature/bug fix and if possible, a step by step guide on how to demo this.

@achiurizo achiurizo requested review from T-Dnzt and unnawut July 6, 2020 21:09
@InoMurko InoMurko removed the request for review from kasima July 6, 2020 21:29
@boolafish
Copy link
Contributor

boolafish commented Jul 7, 2020

hmmm, I think the real bug is in this line:

It should be using min instead of max? The sync_height would take wait_for into account:

next_sync_height =
config
|> Keyword.get(:waits_for, [])
|> get_height_of_awaited(state)
|> consider_finality(configs[service_name], root_chain_height)
|> min(current_sync_height + @maximum_leap_forward)
|> min(root_chain_height)
|> max(0)

However, since we are using max here, it will use the "root_chain_height" instead of the sync height that should be the real guidance.

The PR here is fixing this issue in an abusing way of how implementation works I think. It will solve the issue because the "root_chain_height" would take the finality margin into account.

finality_bearing_root = max(0, root_chain_height - finality_margin_for(config))

@InoMurko
Copy link
Contributor Author

InoMurko commented Jul 7, 2020

@boolafish you might be right, and fixing this probably makes sense. But since I looked into it, it would have a bigger impact then the approach in this PR.
This PR is actually verified - since that's how Watcher syncs.

So I suggest we go with what we have here and address/simplify Root Chain Coordinator at a later stage. WDYT

@pgebal
Copy link
Contributor

pgebal commented Jul 7, 2020

hmmm, I think the real bug is in this line:

It should be using min instead of max? The sync_height would take wait_for into account:

next_sync_height =
config
|> Keyword.get(:waits_for, [])
|> get_height_of_awaited(state)
|> consider_finality(configs[service_name], root_chain_height)
|> min(current_sync_height + @maximum_leap_forward)
|> min(root_chain_height)
|> max(0)

However, since we are using max here, it will use the "root_chain_height" instead of the sync height that should be the real guidance.

The PR here is fixing this issue in an abusing way of how implementation works I think. It will solve the issue because the "root_chain_height" would take the finality margin into account.

finality_bearing_root = max(0, root_chain_height - finality_margin_for(config))

@boolafish If we want to do that this way, we could remove root_chain_height from SyncGuide, since sync height is never greater than root_chain_height.

Copy link
Contributor

@unnawut unnawut left a comment

Choose a reason for hiding this comment

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

The fix lgtm and we can continue the longer term fix in parallel 👍

@InoMurko
Copy link
Contributor Author

InoMurko commented Jul 7, 2020

The fix lgtm and we can continue the longer term fix in parallel 👍

#1624

@InoMurko InoMurko merged commit d666cd0 into master Jul 7, 2020
@InoMurko InoMurko deleted the inomurko/reorg branch July 7, 2020 10:29
@unnawut unnawut added the chore Technical work that does not affect service behaviour label Aug 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
chore Technical work that does not affect service behaviour
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants