mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-28 04:55:33 +00:00
fix txpool + POA regression, header.coinbase should empty
This commit is contained in:
parent
a7c088843d
commit
0589d49dbc
@ -91,7 +91,6 @@ proc prepareHeader(dh: TxChainRef; parent: BlockHeader, timestamp: EthTime)
|
|||||||
# but BaseVMState.minerAddress == signerAddress
|
# but BaseVMState.minerAddress == signerAddress
|
||||||
# - minerAddress is extracted from header.extraData
|
# - minerAddress is extracted from header.extraData
|
||||||
# - header.coinbase is from clique engine
|
# - header.coinbase is from clique engine
|
||||||
dh.prepHeader.coinbase = dh.miner
|
|
||||||
of ConsensusType.POS:
|
of ConsensusType.POS:
|
||||||
dh.com.pos.prepare(dh.prepHeader)
|
dh.com.pos.prepare(dh.prepHeader)
|
||||||
|
|
||||||
@ -118,6 +117,8 @@ proc getTimestamp(dh: TxChainRef, parent: BlockHeader): EthTime =
|
|||||||
of ConsensusType.POS:
|
of ConsensusType.POS:
|
||||||
dh.com.pos.timestamp
|
dh.com.pos.timestamp
|
||||||
|
|
||||||
|
proc feeRecipient*(dh: TxChainRef): EthAddress {.gcsafe.}
|
||||||
|
|
||||||
proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
||||||
{.gcsafe,raises: [CatchableError].} =
|
{.gcsafe,raises: [CatchableError].} =
|
||||||
dh.txEnv.reset
|
dh.txEnv.reset
|
||||||
@ -138,7 +139,7 @@ proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
|
|||||||
fee = fee,
|
fee = fee,
|
||||||
prevRandao= dh.prepHeader.prevRandao,
|
prevRandao= dh.prepHeader.prevRandao,
|
||||||
difficulty= dh.prepHeader.difficulty,
|
difficulty= dh.prepHeader.difficulty,
|
||||||
miner = dh.prepHeader.coinbase,
|
miner = dh.feeRecipient,
|
||||||
com = dh.com)
|
com = dh.com)
|
||||||
|
|
||||||
dh.txEnv.txRoot = EMPTY_ROOT_HASH
|
dh.txEnv.txRoot = EMPTY_ROOT_HASH
|
||||||
@ -260,7 +261,7 @@ proc maxMode*(dh: TxChainRef): bool =
|
|||||||
## Getter
|
## Getter
|
||||||
dh.maxMode
|
dh.maxMode
|
||||||
|
|
||||||
proc feeRecipient*(dh: TxChainRef): EthAddress =
|
proc feeRecipient*(dh: TxChainRef): EthAddress {.gcsafe.} =
|
||||||
## Getter
|
## Getter
|
||||||
if dh.com.consensus == ConsensusType.POS:
|
if dh.com.consensus == ConsensusType.POS:
|
||||||
dh.com.pos.feeRecipient
|
dh.com.pos.feeRecipient
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
import
|
import
|
||||||
std/[math, tables, times],
|
std/[math, tables, times, os],
|
||||||
eth/[keys],
|
eth/[keys],
|
||||||
stew/[byteutils, results], unittest2,
|
stew/[byteutils, results], unittest2,
|
||||||
../nimbus/db/state_db,
|
../nimbus/db/state_db,
|
||||||
@ -172,6 +172,39 @@ proc runTxPoolCliqueTest*() =
|
|||||||
let rr = chain.persistBlocks([blk.header], [body])
|
let rr = chain.persistBlocks([blk.header], [body])
|
||||||
check rr == ValidationResult.OK
|
check rr == ValidationResult.OK
|
||||||
|
|
||||||
|
test "Do not kick the signer out of list":
|
||||||
|
let timestamp = blk.header.timestamp
|
||||||
|
check xp.smartHead(blk.header)
|
||||||
|
|
||||||
|
let tx = env.makeTx(recipient, amount)
|
||||||
|
let res = xp.addLocal(tx, force = true)
|
||||||
|
check res.isOk
|
||||||
|
if res.isErr:
|
||||||
|
debugEcho res.error
|
||||||
|
return
|
||||||
|
check xp.nItems.total == 1
|
||||||
|
|
||||||
|
blk = xp.ethBlock()
|
||||||
|
body = BlockBody(
|
||||||
|
transactions: blk.txs,
|
||||||
|
uncles: blk.uncles
|
||||||
|
)
|
||||||
|
check blk.txs.len == 1
|
||||||
|
|
||||||
|
let rx = clique.seal(blk)
|
||||||
|
check rx.isOk
|
||||||
|
if rx.isErr:
|
||||||
|
debugEcho rx.error
|
||||||
|
return
|
||||||
|
|
||||||
|
# prevent block from future detected in persistBlocks
|
||||||
|
os.sleep(com.cliquePeriod * 1000)
|
||||||
|
|
||||||
|
xp.chain.clearAccounts
|
||||||
|
check xp.chain.vmState.processBlock(com.poa, blk.header, body).isOK
|
||||||
|
let rr = chain.persistBlocks([blk.header], [body])
|
||||||
|
check rr == ValidationResult.OK
|
||||||
|
|
||||||
proc runTxPoolPosTest*() =
|
proc runTxPoolPosTest*() =
|
||||||
var
|
var
|
||||||
env = initEnv(some(100.u256))
|
env = initEnv(some(100.u256))
|
||||||
@ -303,7 +336,7 @@ when isMainModule:
|
|||||||
setErrorLevel() # mute logger
|
setErrorLevel() # mute logger
|
||||||
|
|
||||||
runTxPoolCliqueTest()
|
runTxPoolCliqueTest()
|
||||||
runTxPoolPosTest()
|
#runTxPoolPosTest()
|
||||||
noisy.runTxHeadDelta
|
#noisy.runTxHeadDelta
|
||||||
|
|
||||||
# End
|
# End
|
||||||
|
Loading…
x
Reference in New Issue
Block a user