-
Notifications
You must be signed in to change notification settings - Fork 75
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-284] Pay no money to coinbase address when processing checkpoint blocks #767
Conversation
* | ||
* @param block the block being processed | ||
* @param worldStateProxy the initial state | ||
* @return the state after paying the appropriate reward to who corresponds | ||
*/ | ||
// scalastyle:off method.length |
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.
Will we ever grow the balls to remove this useless tool altogether?
val (blocks, error) = blockExecution.executeBlocks(List(blockWithCheckpoint), defaultBlockHeader.difficulty) | ||
|
||
blocks.size shouldBe 1 | ||
blocks.head.block shouldBe blockWithCheckpoint |
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.
Should we check that world state is unchanged? Can we do that here?
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.
we can't as all intermediate world states are created and hidden inside components.
But we know that state is unchanged because the previous failing state root validation is running and passing normally (it is not mocked, MockValidatorsAlwaysSucceed
is the validator of header and body)
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.
we can't as all intermediate world states are created and hidden inside components.
But blockchain is not mocked and accessible here. Could we use that?
But we know that state is unchanged because the previous failing state root validation is running and passing normally (it is not mocked,
MockValidatorsAlwaysSucceed
is the validator of header and body)
I'm not quite sure which part of the code you are referring to
response should haveResult(expectedBlockResponse) | ||
} | ||
|
||
it should "handle eth_getBlockByHash request (block with treasuryOut)" in new JsonRpcControllerFixture { |
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.
I'd prefer to be consistent with our naming so treasuryOptOut
(besides treasuryOut
sounds weird). This relates to several val names and string occurrences.
) | ||
worldAfterTreasuryReward | ||
} | ||
if (block.hasCheckpoint) worldStateProxy |
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.
-
I wonder if we should move this condition outside to the
prepareBlock
method, so as to avoid runningpersist
on an unchanged world state? -
Since
BlockExecutionSpec
is possibly not the best place to test that the account is unchanged, can we add an appropriate test toBlockPreparatorSpec
?
28ed295
to
104775c
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.
Minor changes and LGTM!
@@ -56,6 +56,7 @@ class BlockPreparator( | |||
* @param worldStateProxy the initial state | |||
* @return the state after paying the appropriate reward to who corresponds | |||
*/ | |||
// scalastyle:off method.length |
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.
Should we remove this now this method remains unchanged?
@@ -113,6 +115,11 @@ class JsonRpcControllerFixture(implicit system: ActorSystem) | |||
unixTimestamp = 0 | |||
) | |||
|
|||
val checkpoint = ObjectGenerators.fakeCheckpointGen(2, 5).sample.get | |||
val blockWithCheckpoint = CheckpointingTestHelpers.createBlockWithCheckpoint(Fixtures.Blocks.Block3125369.header, checkpoint) |
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.
I thought we had removed this as it's duplicated with CheckpointBlockGenerator
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.
I think it's my bad that it wasn't removed in the end. But most of its usages have been replaced with CheckpointBlockGenerator so it should be easy to remove now
val blockExecution = | ||
new BlockExecution(blockchain, blockchainConfig, newConsensus.blockPreparator, blockValidation) | ||
|
||
val (blocks, error) = blockExecution.executeBlocks(List(blockWithCheckpoint), defaultBlockHeader.difficulty) |
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.
Should we rename this method to executeAndValidateBlocks
for consistency?
response should haveResult(expectedBlockResponse) | ||
} | ||
|
||
it should "handle eth_getBlockByHash request (block with treasuryOptOut)" in new JsonRpcControllerFixture { |
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's odd that the test from this file are integration tests, instead of the usual per service and jrc
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's because we have only one huge JRC service and here we have ~EthJRC tests
32768dc
to
da3b169
Compare
checkpoint: Checkpoint | ||
): Block = { | ||
Block(createBlockHeaderWithCheckpoint(parentHeader, checkpoint), BlockBody(Nil, Nil)) | ||
} |
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.
Could we also remove the one below?
da3b169
to
2a457a9
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.
LGTM! Was able to generate checkpoint blocks without any problem
.\\ //.
. \ \ / /.
.\ ,\ /` /,.-
-. \ /'/ / .
` - `-' \ -
'. /.\`
- .-
:`//.'
.`.'
.' BP
Description
All checkpoint blocks will currently be marked as invalid, as:
the block state root is set as the same as the parent
the resulting state root includes money provided to the coinbase address
Proposed Solution
The solution is a small optimization - block with checkpoint is skipping execution of transactions and paying the reward
Important Changes Introduced
Testing
unit tests + local tests with mocked miner and QA endpoints