-
Notifications
You must be signed in to change notification settings - Fork 75
[ETCM-1058] Replace block import by consensus #1078
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-1058] Replace block import by consensus #1078
Conversation
src/main/scala/io/iohk/ethereum/testmode/TestModeComponentsProvider.scala
Outdated
Show resolved
Hide resolved
c41b1fe
to
13bf68d
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Do have some questions but wouldn't want to block further work on this.
*/ | ||
def importBlock( | ||
override def evaluateBranchBlock( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is it called evaluate
, the term for this elsewhere is execute
, right?
Also, the comments and result type still talk of "importing", while we should probably drop that term everywhere?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The term elsewhere is execute, right
? No. Where did you get that idea from? Actually me and Aurelién are struggling to give this method a proper name, because it can have several outcomes. I removed the name import
exactly because as said in the description it Tries to import
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There is the BlockExecution
class for example. So this could be considered "branch execution"?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is not guaranteed that there will be a block or branch execution, the block may end up by just being added to the BlockQueue
) | ||
} | ||
|
||
private def returnNoBestBlock(): Task[BlockImportFailed] = { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this split out into a method? Doesn't seem to do much.
(If anything should be split out: BlockImportFailed("Couldn't find the current best block")
could be a val
.)
Perhaps we can reuse these error descriptions as log messages as well?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It was mainly to make the main method evaluateBranchBlock
more readable, by moving the detail of logging the error and creating the actual error description
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
So I would argue it is less readable now since those methods actually do so little.
import io.iohk.ethereum.mpt.MerklePatriciaTrie.MissingNodeException | ||
import io.iohk.ethereum.utils.BlockchainConfig | ||
import io.iohk.ethereum.utils.ByteStringUtils | ||
import io.iohk.ethereum.utils.Logger | ||
|
||
class BlockImport( | ||
class ConsensusImpl( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it need to be split into Consensus
and ConsensusImpl
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
One is a trait the other a class. It will help with testing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Does it though? It didn't get in the way with BlockImport
before.
This way does make code navigation a lot more annoying.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just look at the private[ledger] val blockExecution: BlockExecution
(previous line 28). That was being accessed directly in the tests.
Hopefully we can improve the tests much more in the future
1ac7040
to
ae639d1
Compare
ae639d1
to
b8a4882
Compare
Description
Replace class BlockImport by a Consensus class, reusing current code.
Important Changes Introduced
Added a new trait Consensus and class ConsensusImpl
ConsensusImpl reuses existing code (with some refactoring)
The refactoring is done is on separate commits to make it easier to evaluate
Testing
Regular Sync was tested with mainnet
Regular Sync / mining still to be tested in staging