@@ -219,9 +219,16 @@ func (s *SystemContract) VerifyUncles(chain consensus.ChainReader, block *types.
219
219
// Prepare initializes the consensus fields of a block header according to the
220
220
// rules of a particular engine. Update only timestamp and prepare ExtraData for Signature
221
221
func (s * SystemContract ) Prepare (chain consensus.ChainHeaderReader , header * types.Header ) error {
222
+ // Make sure unused fields are empty
223
+ header .Coinbase = common.Address {}
224
+ header .Nonce = types.BlockNonce {}
225
+ header .MixDigest = common.Hash {}
226
+
227
+ // Prepare EuclidV2-related fields
222
228
header .BlockSignature = make ([]byte , extraSeal )
223
229
header .IsEuclidV2 = true
224
230
header .Extra = nil
231
+
225
232
// Ensure the timestamp has the correct delay
226
233
parent := chain .GetHeader (header .ParentHash , header .Number .Uint64 ()- 1 )
227
234
if parent == nil {
@@ -233,14 +240,19 @@ func (s *SystemContract) Prepare(chain consensus.ChainHeaderReader, header *type
233
240
if s .config .RelaxedPeriod || header .Time < uint64 (time .Now ().Unix ()) {
234
241
header .Time = uint64 (time .Now ().Unix ())
235
242
}
243
+
244
+ // Difficulty must be 1
236
245
header .Difficulty = big .NewInt (1 )
246
+
237
247
return nil
238
248
}
239
249
240
250
// Finalize implements consensus.Engine. There is no post-transaction
241
251
// No rules here
242
252
func (s * SystemContract ) Finalize (chain consensus.ChainHeaderReader , header * types.Header , state * state.StateDB , txs []* types.Transaction , uncles []* types.Header ) {
243
253
// No block rewards in PoA, so the state remains as is
254
+ header .Root = state .IntermediateRoot (chain .Config ().IsEIP158 (header .Number ))
255
+ header .UncleHash = types .CalcUncleHash (nil )
244
256
}
245
257
246
258
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
@@ -249,9 +261,6 @@ func (s *SystemContract) FinalizeAndAssemble(chain consensus.ChainHeaderReader,
249
261
// Finalize block
250
262
s .Finalize (chain , header , state , txs , uncles )
251
263
252
- // Assign the final state root to header.
253
- header .Root = state .IntermediateRoot (chain .Config ().IsEIP158 (header .Number ))
254
-
255
264
// Assemble and return the final block for sealing.
256
265
return types .NewBlock (header , txs , nil , receipts , trie .NewStackTrie (nil )), nil
257
266
}
0 commit comments