-
Notifications
You must be signed in to change notification settings - Fork 2.2k
fix NoProof block signature #5219
Conversation
Codecov Report
@@ Coverage Diff @@
## master #5219 +/- ##
==========================================
- Coverage 60.84% 60.76% -0.09%
==========================================
Files 338 338
Lines 27570 27420 -150
Branches 3195 3183 -12
==========================================
- Hits 16776 16662 -114
+ Misses 9669 9640 -29
+ Partials 1125 1118 -7 |
@@ -273,6 +273,14 @@ void TestBlock::mine(TestBlockChain const& _bc) | |||
} | |||
else | |||
recalcBlockHeaderBytes(); | |||
|
|||
// Create dummy signature for NoProof blocks | |||
if (Ethash::mixHash(m_blockHeader) == h256(0)) |
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.
h256{0}
.
// Create dummy signature for NoProof blocks | ||
if (Ethash::mixHash(m_blockHeader) == h256(0)) | ||
{ | ||
m_blockHeader.setSeal(Ethash::NonceField, h64(42)); |
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.
Maybe make it null?
if (Ethash::mixHash(m_blockHeader) == h256{0}) | ||
{ | ||
m_blockHeader.setSeal(Ethash::NonceField, h64{0}); | ||
m_blockHeader.setSeal(Ethash::MixHashField, h256{0}); |
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 do you assign it here if you just checked that it's 0?
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.
because it returns 0 also when there is no signature set.
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 could implenent a method hasSignature() if you woukd like. That will change libethereum. By default I try not to touch libethereum for test related logic
5703784
to
a168110
Compare
I don't get - if there's a change to |
It will generate correct blocks but without any signature. no nonce and mixhash in blockheader. |
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 we should make aleth generate the blocks with zero signature in NoProof
mode
Do you mean both blocks without any signature and blocks with zero signature are "correct"? |
Correct in what context? |
There is no consensus on blocks without signature cause NoProof is smth that we use for testing purposes. So we define what a block on NoProof should look like (with zero signature / random signature or no signature at all) |
So I understood that intention of this PR is to establish that NoProof blocks have zero signature.
Right, so I'm saying we should generate blocks with signature everywhere.
Why should blocks without signature be valid? |
Blocks without signature are valid on NoProof |
But you say they are not valid for other clients |
Other clients parsing state test format expect signature in blocks. Only in test format. They dont have NoProof defenition. We could make it anything. |
We could, but why would we want two different block formats in tests and out of the tests? This will only lead to confusion and possible incompatibilities between parts of the codebase. |
Thats why this pr adding a zero signature to the blocks without signature |
But you don't change NoProof design, just hack the final test output. I'm also a bit into the solution to make NoProof more strict and do not allow block headers without signature fields. |
By default I try not to touch core libraries logic for testing purposes. To summarize the discussion: |
Yes, if that makes the whole system more consistent and simple to understand. Can someone check if Clique is adding/remove any fields to the block hash? |
@chfast It does not change the format, just changes the meaning of some fields ethereum/EIPs#225 |
updatet this PR. now 0 signature is set by default inside sealEngineBase generateSeal method. |
|
removed generateSeal from SealEngineBase There should be an error throwing in case no callback is called from BasicAuthority::generateSeal. |
Where is the endless loop? |
libethcore/SealEngine.cpp
Outdated
void NoProof::generateSeal(BlockHeader const& _bi) | ||
{ | ||
BlockHeader header(_bi); | ||
header.setSeal(1, h64{0}); // NonceField |
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.
Maybe move enum { MixHashField = 0, NonceField = 1 };
to SealEngineBase
and use it 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.
this is a good question. what if with sealEngine = Ethash2 there will be 3 or 1 fields for signature?
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'll see then, let's not try to guess the future
Endless loop somewhere where it waits for a callback of m_onSealGenerated |
libethcore/BasicAuthority.cpp
Outdated
bi.streamRLP(ret); | ||
if (m_onSealGenerated) | ||
m_onSealGenerated(ret.out()); | ||
// Else throw an error!!! |
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 say it's a problem of the calling code if it would not set this handler and then wait somehow (how?) for it to be called.
So I don't think anything needs to be done here.
fixed your last comments |
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.
This PR looks very nice in the end.
Other devs report that It is better if NoProof blocks still have the signature. but the signature is just ignored.
Rather then absence of signature as it is now.