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

[testnet1] sync head & improved fork handling #413

Merged
merged 13 commits into from
Dec 1, 2017

Conversation

antiochp
Copy link
Member

@antiochp antiochp commented Dec 1, 2017

  • introduces the new sync_head that we use to track the longest fork on the peer with most work
  • remove assumption that a new fork will never by >height+1 based on current head (see Fix block locator with long forks #402 for discussion)
  • don't call check_known in sync_block_header - we always want to (re)-process headers when syncing as we can jump from fork to fork depending on connected peers
  • don't check heights as first step in validate_block (height may jump across forks)
  • in validate_block
    • check for NotFound in get_header_by_height (height may jump across forks)
  • in setup_height
    • check for NotFound (height may jump across forks)
    • make it recursive for clarity

fix

put the 1s sleep back in...

let sync run even if the full 512 headers are all known
give sync a chance to sync against a fork that forked a long time ago
block validaton should not check for height+1 based on head
no assumptions should be made about height indices
@antiochp
Copy link
Member Author

antiochp commented Dec 1, 2017

This should be ready to go - tests were failing in chain (now fixed) and grin.
Will investigate if the grin tests continue to fail.
We were seeing errors like this in the logs on travis -

Dec 01 15:16:36.967 INFO Rejected block 77bc5f32 at 1: StoreErr(SerErr(IOErr(Error { repr: Custom(Custom { kind: UnexpectedEof, error: StringError("failed to fill whole buffer") }) })), "pipe get previous")
Dec 01 15:16:36.968 ERRO (Server ID: Port 18000) Error validating mined block: StoreErr(SerErr(IOErr(Error { repr: Custom(Custom { kind: UnexpectedEof, error: StringError("failed to fill whole buffer") }) })), "pipe get previous")

@antiochp
Copy link
Member Author

antiochp commented Dec 1, 2017

Seeing this in the test logs. Something looks wrong here as this genesis hash is for testnet1 (and cuckoo10 should use a different hash)?

running 4 tests
test a_simulate_block_propagation ... Dec 01 11:40:08.427 INFO Saved genesis block with hash: e17ea64f, nonce: 28205, pow: Cuckoo(21e 7a2 eae 144e 1b1c 1fbd 203a 214b 293b 2b74 2bfa 2c26 32bb 346a 34c7 37c5 4164 42cc 4cc3 55af 5a70 5b14 5e1c 5f76 6061 60f9 61d7 6318 63a1 63fb 649b 64e5 65a1 6b69 70f8 71c7 71cd 7492 7b11 7db8 7f29 7ff8)
Dec 01 11:40:08.427 INFO Chain init: Tip { height: 0, last_block_h: e17ea64f, prev_block_h: e17ea64f, total_difficulty: Difficulty { num: 1 } }

@antiochp
Copy link
Member Author

antiochp commented Dec 1, 2017

Should be fixed now. Waiting to see if tests pass on travis...

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.

1 participant