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

[ETCM-177] Simplify ommers handling #745

Merged
merged 4 commits into from
Oct 23, 2020

Conversation

mirkoAlic
Copy link
Contributor

@mirkoAlic mirkoAlic commented Oct 19, 2020

Description

fix for: https://jira.iohk.io/browse/ETCM-177

Proposed solution

  • If the ommers are invalid we just create a block without any.
  • Add ommers only at resolve branch level
  • Stop manually removing ommers from pool, eventually older ones will disappear.

TODO

@mirkoAlic mirkoAlic changed the title [ETCM-177] Improve ommers handling [ETCM-177] Simplify ommers handling Oct 19, 2020
@mirkoAlic mirkoAlic requested a review from ntallar October 20, 2020 17:32
@mirkoAlic mirkoAlic marked this pull request as ready for review October 20, 2020 17:32
Copy link

@ntallar ntallar left a comment

Choose a reason for hiding this comment

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

Should we go further in the pool validation for ommers (ex. check if there were already used)

I think we are currently in the middle between 2 approaches:

  1. Keeping the ommers pool with a lot of tentative ommers query, which is why the pool response depends on the block being mined
  2. Keeping the ommers pool with only the ommers that will be valid for the block being mined, which ideally won't require any validations (neither on pool query or block generation)

Option 1. seems to be closer to what we currently have, so I'm more inclined to it as well... we could keep the removals of ommers to the bare minimum (as they are only tentative ommers), improve the validations done on the pool upon query as you said and remove validations on the block generator

val pHeader = parent.header
val blockNumber = pHeader.number + 1
val parentHash = pHeader.hash

val ommersV = validators.ommersValidator
val ommers = validators.ommersValidator.validate(parentHash, blockNumber, x, blockchain) match {
case Left(_) => emptyX
Copy link

Choose a reason for hiding this comment

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

Should we log this case?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

mmm...now i'm thinking we could log this at ommers pool level once we finally do all the validations. Btw, the amount of ommers per block is something that we measure, so we couyld produce metrics, i mean, it won't be an issue to get track of that.

@@ -227,12 +226,9 @@ class BlockImporter(

private def broadcastNewBlocks(blocks: List[NewBlock]): Unit = broadcaster ! BroadcastBlocks(blocks)

private def updateTxAndOmmerPools(blocksAdded: Seq[Block], blocksRemoved: Seq[Block]): Unit = {
blocksRemoved.headOption.foreach(block => ommersPool ! AddOmmers(block.header))
private def updateTxPool(blocksAdded: Seq[Block], blocksRemoved: Seq[Block]): Unit = {
Copy link

Choose a reason for hiding this comment

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

I don't like much the middle ground of keeping the pool and ignoring any problems when using it on the miner, but only updating the pool it half of the times, should we:

  1. Remove the pool entirely and have no support with mining blocks with ommers
  2. Keep the pool updates as on develop and use the patch for producing blocks without ommers for handling the case that it has any invalid one

@mirkoAlic
Copy link
Contributor Author

Should we go further in the pool validation for ommers (ex. check if there were already used)

I think we are currently in the middle between 2 approaches:

1. Keeping the ommers pool with a lot of tentative ommers query, which is why the pool response depends on the block being mined

2. Keeping the ommers pool with only the ommers that will be valid for the block being mined, which ideally won't require any validations (neither on pool query or block generation)

Option 1. seems to be closer to what we currently have, so I'm more inclined to it as well... we could keep the removals of ommers to the bare minimum (as they are only tentative ommers), improve the validations done on the pool upon query as you said and remove validations on the block generator

In answer to this comment and the other one too.

  • I prefer the ommers pool that works as a service, that a user can query using a given header, instead of provide a component that is relying on the current top.

  • My next step (i will create the task and add the reference) is to refactor ommers pool in order to always return valid ones (currently the missing part is to check if those where used before).

  • I strongly recommend to just filter bad ommers when someone is trying to create a new block. I mean, IMHO, including them is not a hard stop requirement for a new block.

  • i don't want to provide a way to manually remove the ommers, i mean ommers pool already have a mechanism to forget older ones. IMO, it should be a independently component that only relies on the information in the blockchain, and apply internal mechanism for deletes. The only "drawback" i saw with current approach is to require a little bit more of RAM but is in post of simplify the interaction with other components in the system.
    (disclaimer: the idea was to also keep addition to the bare minimum)

Copy link

@ntallar ntallar left a comment

Choose a reason for hiding this comment

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

LGTM!

 .\\            //.
. \ \          / /.
.\  ,\     /` /,.-
 -.   \  /'/ /  .
 ` -   `-'  \  -
   '.       /.\`
      -    .-
      :`//.'
      .`.'
      .' BP 

@mirkoAlic mirkoAlic merged commit 65b93ad into develop Oct 23, 2020
@mirkoAlic mirkoAlic deleted the etcm-177-improve-ommers-pool-handling branch October 23, 2020 19:03
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.

2 participants