@@ -219,9 +219,16 @@ func (s *SystemContract) VerifyUncles(chain consensus.ChainReader, block *types.
219219// Prepare initializes the consensus fields of a block header according to the
220220// rules of a particular engine. Update only timestamp and prepare ExtraData for Signature
221221func (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
222228 header .BlockSignature = make ([]byte , extraSeal )
223229 header .IsEuclidV2 = true
224230 header .Extra = nil
231+
225232 // Ensure the timestamp has the correct delay
226233 parent := chain .GetHeader (header .ParentHash , header .Number .Uint64 ()- 1 )
227234 if parent == nil {
@@ -233,14 +240,19 @@ func (s *SystemContract) Prepare(chain consensus.ChainHeaderReader, header *type
233240 if s .config .RelaxedPeriod || header .Time < uint64 (time .Now ().Unix ()) {
234241 header .Time = uint64 (time .Now ().Unix ())
235242 }
243+
244+ // Difficulty must be 1
236245 header .Difficulty = big .NewInt (1 )
246+
237247 return nil
238248}
239249
240250// Finalize implements consensus.Engine. There is no post-transaction
241251// No rules here
242252func (s * SystemContract ) Finalize (chain consensus.ChainHeaderReader , header * types.Header , state * state.StateDB , txs []* types.Transaction , uncles []* types.Header ) {
243253 // 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 )
244256}
245257
246258// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
@@ -249,9 +261,6 @@ func (s *SystemContract) FinalizeAndAssemble(chain consensus.ChainHeaderReader,
249261 // Finalize block
250262 s .Finalize (chain , header , state , txs , uncles )
251263
252- // Assign the final state root to header.
253- header .Root = state .IntermediateRoot (chain .Config ().IsEIP158 (header .Number ))
254-
255264 // Assemble and return the final block for sealing.
256265 return types .NewBlock (header , txs , nil , receipts , trie .NewStackTrie (nil )), nil
257266}
0 commit comments