mirror of
https://github.com/ethereum/go-ethereum.git
synced 2026-07-23 21:26:42 +00:00
fix(system-contract): Ensure header.coinbase is not set (#1127)
This commit is contained in:
parent
1dedddbffb
commit
1ceb1ba496
2 changed files with 13 additions and 4 deletions
|
|
@ -219,9 +219,16 @@ func (s *SystemContract) VerifyUncles(chain consensus.ChainReader, block *types.
|
||||||
// Prepare initializes the consensus fields of a block header according to the
|
// Prepare initializes the consensus fields of a block header according to the
|
||||||
// rules of a particular engine. Update only timestamp and prepare ExtraData for Signature
|
// rules of a particular engine. Update only timestamp and prepare ExtraData for Signature
|
||||||
func (s *SystemContract) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
|
func (s *SystemContract) Prepare(chain consensus.ChainHeaderReader, header *types.Header) error {
|
||||||
|
// Make sure unused fields are empty
|
||||||
|
header.Coinbase = common.Address{}
|
||||||
|
header.Nonce = types.BlockNonce{}
|
||||||
|
header.MixDigest = common.Hash{}
|
||||||
|
|
||||||
|
// Prepare EuclidV2-related fields
|
||||||
header.BlockSignature = make([]byte, extraSeal)
|
header.BlockSignature = make([]byte, extraSeal)
|
||||||
header.IsEuclidV2 = true
|
header.IsEuclidV2 = true
|
||||||
header.Extra = nil
|
header.Extra = nil
|
||||||
|
|
||||||
// Ensure the timestamp has the correct delay
|
// Ensure the timestamp has the correct delay
|
||||||
parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
|
parent := chain.GetHeader(header.ParentHash, header.Number.Uint64()-1)
|
||||||
if parent == nil {
|
if parent == nil {
|
||||||
|
|
@ -233,7 +240,10 @@ func (s *SystemContract) Prepare(chain consensus.ChainHeaderReader, header *type
|
||||||
if s.config.RelaxedPeriod || header.Time < uint64(time.Now().Unix()) {
|
if s.config.RelaxedPeriod || header.Time < uint64(time.Now().Unix()) {
|
||||||
header.Time = uint64(time.Now().Unix())
|
header.Time = uint64(time.Now().Unix())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Difficulty must be 1
|
||||||
header.Difficulty = big.NewInt(1)
|
header.Difficulty = big.NewInt(1)
|
||||||
|
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -241,6 +251,8 @@ func (s *SystemContract) Prepare(chain consensus.ChainHeaderReader, header *type
|
||||||
// No rules here
|
// No rules here
|
||||||
func (s *SystemContract) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
|
func (s *SystemContract) Finalize(chain consensus.ChainHeaderReader, header *types.Header, state *state.StateDB, txs []*types.Transaction, uncles []*types.Header) {
|
||||||
// No block rewards in PoA, so the state remains as is
|
// No block rewards in PoA, so the state remains as is
|
||||||
|
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
||||||
|
header.UncleHash = types.CalcUncleHash(nil)
|
||||||
}
|
}
|
||||||
|
|
||||||
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
|
// FinalizeAndAssemble implements consensus.Engine, ensuring no uncles are set,
|
||||||
|
|
@ -249,9 +261,6 @@ func (s *SystemContract) FinalizeAndAssemble(chain consensus.ChainHeaderReader,
|
||||||
// Finalize block
|
// Finalize block
|
||||||
s.Finalize(chain, header, state, txs, uncles)
|
s.Finalize(chain, header, state, txs, uncles)
|
||||||
|
|
||||||
// Assign the final state root to header.
|
|
||||||
header.Root = state.IntermediateRoot(chain.Config().IsEIP158(header.Number))
|
|
||||||
|
|
||||||
// Assemble and return the final block for sealing.
|
// Assemble and return the final block for sealing.
|
||||||
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)), nil
|
return types.NewBlock(header, txs, nil, receipts, trie.NewStackTrie(nil)), nil
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import (
|
||||||
const (
|
const (
|
||||||
VersionMajor = 5 // Major version component of the current release
|
VersionMajor = 5 // Major version component of the current release
|
||||||
VersionMinor = 8 // Minor version component of the current release
|
VersionMinor = 8 // Minor version component of the current release
|
||||||
VersionPatch = 15 // Patch version component of the current release
|
VersionPatch = 16 // Patch version component of the current release
|
||||||
VersionMeta = "mainnet" // Version metadata to append to the version string
|
VersionMeta = "mainnet" // Version metadata to append to the version string
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue