Skip to content
This repository has been archived by the owner on Jul 1, 2021. It is now read-only.

Store union of hashes for block witness #2109

Merged
merged 4 commits into from
Nov 27, 2020

Conversation

carver
Copy link
Contributor

@carver carver commented Nov 19, 2020

What was wrong?

Fixes #2105

How was it fixed?

Store union of the witness hashes, when witness metadata comes in for the same block.

To-Do

  • Test where two persists interleave their database accesses, to force the race condition that one witness overwrites the other
  • Add a lock to pass ^ test
  • Clean up commit history

Cute Animal Picture

put a cute animal picture link inside the parentheses

@carver carver changed the title Witness hash union 2105 Store union of hashes for block witness Nov 19, 2020
@carver carver requested a review from gsalgado November 20, 2020 23:48
@carver carver marked this pull request as ready for review November 20, 2020 23:49
@gsalgado
Copy link
Contributor

Sorry, I keep forgetting to review this. Will do so tomorrow, but just thought I'd mention I found a bug that causes persist_witness_hashes() to crash with a KeyError when we call it multiple times with the same hash. This test exhibits it: d0b33b5

Is that bug present in this branch as well?

@carver
Copy link
Contributor Author

carver commented Nov 24, 2020

Yup, looks like that bug is fixed in this branch. I added the test. It's similar to another test I added, but seems good to have another explicit one. 👍

Copy link
Contributor

@gsalgado gsalgado left a comment

Choose a reason for hiding this comment

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

LGTM

"""
Repeated blocks should not consume more slots in the limited history of block witnesses
"""
wit_db = AsyncWitnessDB(AtomicDB())
Copy link
Contributor

Choose a reason for hiding this comment

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

AsyncWitnessDB was changed recently to wrap a regular DatabaseAPI instead of AtomicDatabaseAPI, so we could use a MemoryDB() here instead

Atomic is not called for, anymore
Repeated persistence with the same block should not consume history
slots. I tested the test by patching into line 59 of
trinity/protocol/wit/db.py:
+ if True or block_hash not in recent_blocks_with_witnesses:

The test fails with that change, as expected.

Also, explicitly check that DB eviction works after a block repeat is
persisted.
@carver carver merged commit 0deec1a into ethereum:master Nov 27, 2020
@carver carver deleted the witness-hash-union-2105 branch November 27, 2020 18:08
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Do not overwrite existing witness hashes for a given block in the DB
2 participants