mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-10 11:06:49 +00:00
remove unused coinbase from sealing engine
header.coinbase is handled by txpool, clique, and engine api. so the sealing engine no need to touch it anymore.
This commit is contained in:
parent
3f0994f80b
commit
8827e04bc0
@ -78,7 +78,6 @@ proc isLondon(c: ChainConfig, number: BlockNumber): bool {.inline.} =
|
|||||||
number >= c.londonBlock
|
number >= c.londonBlock
|
||||||
|
|
||||||
proc prepareBlock(engine: SealingEngineRef,
|
proc prepareBlock(engine: SealingEngineRef,
|
||||||
coinbase: EthAddress,
|
|
||||||
parent: BlockHeader,
|
parent: BlockHeader,
|
||||||
time: Time,
|
time: Time,
|
||||||
prevRandao: Hash256): Result[EthBlock, string] =
|
prevRandao: Hash256): Result[EthBlock, string] =
|
||||||
@ -122,7 +121,6 @@ proc prepareBlock(engine: SealingEngineRef,
|
|||||||
ok(blk)
|
ok(blk)
|
||||||
|
|
||||||
proc generateBlock(engine: SealingEngineRef,
|
proc generateBlock(engine: SealingEngineRef,
|
||||||
coinbase: EthAddress,
|
|
||||||
parentBlockHeader: BlockHeader,
|
parentBlockHeader: BlockHeader,
|
||||||
outBlock: var EthBlock,
|
outBlock: var EthBlock,
|
||||||
timestamp = getTime(),
|
timestamp = getTime(),
|
||||||
@ -133,7 +131,7 @@ proc generateBlock(engine: SealingEngineRef,
|
|||||||
# - no DAO hard fork
|
# - no DAO hard fork
|
||||||
# - no local and remote uncles inclusion
|
# - no local and remote uncles inclusion
|
||||||
|
|
||||||
let res = prepareBlock(engine, coinbase, parentBlockHeader, timestamp, prevRandao)
|
let res = prepareBlock(engine, parentBlockHeader, timestamp, prevRandao)
|
||||||
if res.isErr:
|
if res.isErr:
|
||||||
return err("error prepare header")
|
return err("error prepare header")
|
||||||
|
|
||||||
@ -151,30 +149,28 @@ proc generateBlock(engine: SealingEngineRef,
|
|||||||
ok()
|
ok()
|
||||||
|
|
||||||
proc generateBlock(engine: SealingEngineRef,
|
proc generateBlock(engine: SealingEngineRef,
|
||||||
coinbase: EthAddress,
|
|
||||||
parentHash: Hash256,
|
parentHash: Hash256,
|
||||||
outBlock: var EthBlock,
|
outBlock: var EthBlock,
|
||||||
timestamp = getTime(),
|
timestamp = getTime(),
|
||||||
prevRandao = Hash256()): Result[void, string] =
|
prevRandao = Hash256()): Result[void, string] =
|
||||||
var parentBlockHeader: BlockHeader
|
var parentBlockHeader: BlockHeader
|
||||||
if engine.chain.db.getBlockHeader(parentHash, parentBlockHeader):
|
if engine.chain.db.getBlockHeader(parentHash, parentBlockHeader):
|
||||||
generateBlock(engine, coinbase, parentBlockHeader, outBlock, timestamp, prevRandao)
|
generateBlock(engine, parentBlockHeader, outBlock, timestamp, prevRandao)
|
||||||
else:
|
else:
|
||||||
# TODO:
|
# TODO:
|
||||||
# This hack shouldn't be necessary if the database can find
|
# This hack shouldn't be necessary if the database can find
|
||||||
# the genesis block hash in `getBlockHeader`.
|
# the genesis block hash in `getBlockHeader`.
|
||||||
let maybeGenesisBlock = engine.chain.currentBlock()
|
let maybeGenesisBlock = engine.chain.currentBlock()
|
||||||
if parentHash == maybeGenesisBlock.blockHash:
|
if parentHash == maybeGenesisBlock.blockHash:
|
||||||
generateBlock(engine, coinbase, maybeGenesisBlock, outBlock, timestamp, prevRandao)
|
generateBlock(engine, maybeGenesisBlock, outBlock, timestamp, prevRandao)
|
||||||
else:
|
else:
|
||||||
return err "parent block not found"
|
return err "parent block not found"
|
||||||
|
|
||||||
proc generateBlock(engine: SealingEngineRef,
|
proc generateBlock(engine: SealingEngineRef,
|
||||||
coinbase: EthAddress,
|
|
||||||
outBlock: var EthBlock,
|
outBlock: var EthBlock,
|
||||||
timestamp = getTime(),
|
timestamp = getTime(),
|
||||||
prevRandao = Hash256()): Result[void, string] =
|
prevRandao = Hash256()): Result[void, string] =
|
||||||
generateBlock(engine, coinbase, engine.chain.currentBlock(),
|
generateBlock(engine, engine.chain.currentBlock(),
|
||||||
outBlock, timestamp, prevRandao)
|
outBlock, timestamp, prevRandao)
|
||||||
|
|
||||||
proc sealingLoop(engine: SealingEngineRef): Future[void] {.async.} =
|
proc sealingLoop(engine: SealingEngineRef): Future[void] {.async.} =
|
||||||
@ -192,9 +188,6 @@ proc sealingLoop(engine: SealingEngineRef): Future[void] {.async.} =
|
|||||||
|
|
||||||
clique.authorize(engine.signer, signerFunc)
|
clique.authorize(engine.signer, signerFunc)
|
||||||
|
|
||||||
# TODO: This should be configurable
|
|
||||||
var coinbase: EthAddress
|
|
||||||
|
|
||||||
# convert times.Duration to chronos.Duration
|
# convert times.Duration to chronos.Duration
|
||||||
let period = chronos.seconds(clique.cfg.period.inSeconds)
|
let period = chronos.seconds(clique.cfg.period.inSeconds)
|
||||||
|
|
||||||
@ -209,7 +202,7 @@ proc sealingLoop(engine: SealingEngineRef): Future[void] {.async.} =
|
|||||||
# - no queue for chain reorgs
|
# - no queue for chain reorgs
|
||||||
# - no async lock/guard against race with sync algo
|
# - no async lock/guard against race with sync algo
|
||||||
var blk: EthBlock
|
var blk: EthBlock
|
||||||
let blkRes = engine.generateBlock(coinbase, blk)
|
let blkRes = engine.generateBlock(blk)
|
||||||
if blkRes.isErr:
|
if blkRes.isErr:
|
||||||
error "sealing engine generateBlock error", msg=blkRes.error
|
error "sealing engine generateBlock error", msg=blkRes.error
|
||||||
break
|
break
|
||||||
@ -246,7 +239,6 @@ proc generateExecutionPayload*(engine: SealingEngineRef,
|
|||||||
engine.txPool.feeRecipient = coinbase
|
engine.txPool.feeRecipient = coinbase
|
||||||
|
|
||||||
let blkRes = engine.generateBlock(
|
let blkRes = engine.generateBlock(
|
||||||
coinbase,
|
|
||||||
headBlock,
|
headBlock,
|
||||||
blk,
|
blk,
|
||||||
timestamp,
|
timestamp,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user