newUncleEnv¶
| Source (upstream pre-purge) | Current | |
|---|---|---|
| File | miner/worker.go |
uncles_pow.go |
| Symbol | worker.makeEnv |
powWorker.newUncleEnv |
| Ref | dde2da0ef~1 |
etc/v1.17.3-full-node |
Seeds the ancestor/family sets. Extracted from the pre-purge makeEnv, keeping only the GetBlocksFromHash seeding loop; state/prefetcher setup stays in Miner.prepareWork.
3-way merge — purge → getc ← upstream¶
pre-purge≈ adapted (origin inferred by similarity)fork-only
// newUncleEnv seeds the ancestor and family sets for a block being sealed on
// top of the given header.
func (w *powWorker) newUncleEnv(header *types.Header) *uncleEnv {
env := &uncleEnv{
↗ header: header,
uncles: make(map[common.Hash]*types.Header),
≈ ancestors: mapset.NewSet[common.Hash](),
family: mapset.NewSet[common.Hash](),
↗ }
// when 08 is processed ancestors contain 07 (quick block)
≈ for _, ancestor := range w.chain.GetBlocksFromHash(header.ParentHash, 7) {
↗ for _, uncle := range ancestor.Uncles() {
env.family.Add(uncle.Hash())
}
env.family.Add(ancestor.Hash())
env.ancestors.Add(ancestor.Hash())
}
≈ return env
↗}
core-geth validation — +8 -21
| | | |---|---| | File | [`worker.go`](https://github.com/etclabscore/core-geth/blob/v1.12.20/miner/worker.go) | | Symbol | `worker.makeEnv` | | Ref | `v1.12.20` |--- a/core-geth/miner/worker.go
+++ b/etc/miner/uncles_pow.go
@@ -1,32 +1,19 @@
-// makeEnv creates a new environment for the sealing block.
-func (w *worker) makeEnv(parent *types.Header, header *types.Header, coinbase common.Address) (*environment, error) {
- // Retrieve the parent state to execute on top and start a prefetcher for
- // the miner to speed block sealing up a bit.
- state, err := w.chain.StateAt(parent.Root)
- if err != nil {
- return nil, err
- }
- state.StartPrefetcher("miner")
-
- // Note the passed coinbase may be different with header.Coinbase.
- env := &environment{
- signer: types.MakeSigner(w.chainConfig, header.Number, header.Time),
- state: state,
- coinbase: coinbase,
- ancestors: mapset.NewSet[common.Hash](),
- family: mapset.NewSet[common.Hash](),
+// newUncleEnv seeds the ancestor and family sets for a block being sealed on
+// top of the given header.
+func (w *powWorker) newUncleEnv(header *types.Header) *uncleEnv {
+ env := &uncleEnv{
header: header,
uncles: make(map[common.Hash]*types.Header),
+ ancestors: mapset.NewSet[common.Hash](),
+ family: mapset.NewSet[common.Hash](),
}
// when 08 is processed ancestors contain 07 (quick block)
- for _, ancestor := range w.chain.GetBlocksFromHash(parent.Hash(), 7) {
+ for _, ancestor := range w.chain.GetBlocksFromHash(header.ParentHash, 7) {
for _, uncle := range ancestor.Uncles() {
env.family.Add(uncle.Hash())
}
env.family.Add(ancestor.Hash())
env.ancestors.Add(ancestor.Hash())
}
- // Keep track of transactions which return errors so they can be removed
- env.tcount = 0
- return env, nil
+ return env
}