mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-29 13:35:38 +00:00
fix EIP-4844: txpool missing dataGasUsed when generate block header
This commit is contained in:
parent
7229bca033
commit
f02c20c1f9
@ -253,6 +253,7 @@ proc vmExecCommit(pst: TxPackerStateRef)
|
|||||||
# EIP-4844
|
# EIP-4844
|
||||||
let excessDataGas = calcExcessDataGas(vmState.parent)
|
let excessDataGas = calcExcessDataGas(vmState.parent)
|
||||||
xp.chain.excessDataGas = some(excessDataGas)
|
xp.chain.excessDataGas = some(excessDataGas)
|
||||||
|
xp.chain.dataGasUsed = some(pst.dataGasUsed)
|
||||||
|
|
||||||
proc balanceDelta: UInt256 =
|
proc balanceDelta: UInt256 =
|
||||||
let postBalance = vmState.readOnlyStateDB.getBalance(xp.chain.feeRecipient)
|
let postBalance = vmState.readOnlyStateDB.getBalance(xp.chain.feeRecipient)
|
||||||
|
@ -900,6 +900,7 @@ when isMainModule:
|
|||||||
|
|
||||||
runTxPoolCliqueTest()
|
runTxPoolCliqueTest()
|
||||||
runTxPoolPosTest()
|
runTxPoolPosTest()
|
||||||
|
runTxPoolBlobhashTest()
|
||||||
noisy.runTxHeadDelta
|
noisy.runTxHeadDelta
|
||||||
|
|
||||||
#noisy.runTxLoader(dir = ".")
|
#noisy.runTxLoader(dir = ".")
|
||||||
|
@ -70,7 +70,7 @@ proc makeTx*(t: var TestEnv, recipient: EthAddress, amount: UInt256, payload: op
|
|||||||
inc t.nonce
|
inc t.nonce
|
||||||
signTransaction(tx, t.vaultKey, t.chainId, eip155 = true)
|
signTransaction(tx, t.vaultKey, t.chainId, eip155 = true)
|
||||||
|
|
||||||
proc initEnv(ttd: Option[UInt256] = none(UInt256)): TestEnv =
|
proc initEnv(envFork: HardFork): TestEnv =
|
||||||
var
|
var
|
||||||
conf = makeConfig(@[
|
conf = makeConfig(@[
|
||||||
"--engine-signer:658bdf435d810c91414ec09147daa6db62406379",
|
"--engine-signer:658bdf435d810c91414ec09147daa6db62406379",
|
||||||
@ -81,8 +81,14 @@ proc initEnv(ttd: Option[UInt256] = none(UInt256)): TestEnv =
|
|||||||
code: contractCode
|
code: contractCode
|
||||||
)
|
)
|
||||||
|
|
||||||
if ttd.isSome:
|
if envFork >= MergeFork:
|
||||||
conf.networkParams.config.terminalTotalDifficulty = ttd
|
conf.networkParams.config.terminalTotalDifficulty = some(100.u256)
|
||||||
|
|
||||||
|
if envFork >= Shanghai:
|
||||||
|
conf.networkParams.config.shanghaiTime = some(0.fromUnix)
|
||||||
|
|
||||||
|
if envFork >= Cancun:
|
||||||
|
conf.networkParams.config.cancunTime = some(0.fromUnix)
|
||||||
|
|
||||||
let
|
let
|
||||||
com = CommonRef.new(
|
com = CommonRef.new(
|
||||||
@ -112,7 +118,7 @@ const
|
|||||||
|
|
||||||
proc runTxPoolCliqueTest*() =
|
proc runTxPoolCliqueTest*() =
|
||||||
var
|
var
|
||||||
env = initEnv()
|
env = initEnv(London)
|
||||||
|
|
||||||
var
|
var
|
||||||
tx = env.makeTx(recipient, amount)
|
tx = env.makeTx(recipient, amount)
|
||||||
@ -173,7 +179,6 @@ proc runTxPoolCliqueTest*() =
|
|||||||
check rr == ValidationResult.OK
|
check rr == ValidationResult.OK
|
||||||
|
|
||||||
test "Do not kick the signer out of list":
|
test "Do not kick the signer out of list":
|
||||||
let timestamp = blk.header.timestamp
|
|
||||||
check xp.smartHead(blk.header)
|
check xp.smartHead(blk.header)
|
||||||
|
|
||||||
let tx = env.makeTx(recipient, amount)
|
let tx = env.makeTx(recipient, amount)
|
||||||
@ -207,7 +212,7 @@ proc runTxPoolCliqueTest*() =
|
|||||||
|
|
||||||
proc runTxPoolPosTest*() =
|
proc runTxPoolPosTest*() =
|
||||||
var
|
var
|
||||||
env = initEnv(some(100.u256))
|
env = initEnv(MergeFork)
|
||||||
|
|
||||||
var
|
var
|
||||||
tx = env.makeTx(recipient, amount)
|
tx = env.makeTx(recipient, amount)
|
||||||
@ -260,13 +265,69 @@ proc runTxPoolPosTest*() =
|
|||||||
let bal = sdb.getBalance(feeRecipient)
|
let bal = sdb.getBalance(feeRecipient)
|
||||||
check not bal.isZero
|
check not bal.isZero
|
||||||
|
|
||||||
|
proc runTxPoolBlobhashTest*() =
|
||||||
|
var
|
||||||
|
env = initEnv(Cancun)
|
||||||
|
|
||||||
|
var
|
||||||
|
tx = env.makeTx(recipient, amount)
|
||||||
|
xp = env.xp
|
||||||
|
com = env.com
|
||||||
|
chain = env.chain
|
||||||
|
body: BlockBody
|
||||||
|
blk: EthBlock
|
||||||
|
|
||||||
|
suite "Test TxPool with blobhash block":
|
||||||
|
test "TxPool addLocal":
|
||||||
|
let res = xp.addLocal(tx, force = true)
|
||||||
|
check res.isOk
|
||||||
|
if res.isErr:
|
||||||
|
debugEcho res.error
|
||||||
|
return
|
||||||
|
|
||||||
|
test "TxPool jobCommit":
|
||||||
|
check xp.nItems.total == 1
|
||||||
|
|
||||||
|
test "TxPool ethBlock":
|
||||||
|
com.pos.prevRandao = prevRandao
|
||||||
|
com.pos.feeRecipient = feeRecipient
|
||||||
|
com.pos.timestamp = getTime()
|
||||||
|
|
||||||
|
blk = xp.ethBlock()
|
||||||
|
|
||||||
|
check com.isBlockAfterTtd(blk.header)
|
||||||
|
|
||||||
|
body = BlockBody(
|
||||||
|
transactions: blk.txs,
|
||||||
|
uncles: blk.uncles,
|
||||||
|
withdrawals: some[seq[Withdrawal]](@[])
|
||||||
|
)
|
||||||
|
check blk.txs.len == 1
|
||||||
|
|
||||||
|
test "Blobhash persistBlocks":
|
||||||
|
let rr = chain.persistBlocks([blk.header], [body])
|
||||||
|
check rr == ValidationResult.OK
|
||||||
|
|
||||||
|
test "validate TxPool prevRandao setter":
|
||||||
|
var sdb = newAccountStateDB(com.db.db, blk.header.stateRoot, pruneTrie = false)
|
||||||
|
let (val, ok) = sdb.getStorage(recipient, slot)
|
||||||
|
let randao = Hash256(data: val.toBytesBE)
|
||||||
|
check ok
|
||||||
|
check randao == prevRandao
|
||||||
|
|
||||||
|
test "feeRecipient rewarded":
|
||||||
|
check blk.header.coinbase == feeRecipient
|
||||||
|
var sdb = newAccountStateDB(com.db.db, blk.header.stateRoot, pruneTrie = false)
|
||||||
|
let bal = sdb.getBalance(feeRecipient)
|
||||||
|
check not bal.isZero
|
||||||
|
|
||||||
proc runTxHeadDelta*(noisy = true) =
|
proc runTxHeadDelta*(noisy = true) =
|
||||||
## see github.com/status-im/nimbus-eth1/issues/1031
|
## see github.com/status-im/nimbus-eth1/issues/1031
|
||||||
|
|
||||||
suite "TxPool: Synthesising blocks (covers issue #1031)":
|
suite "TxPool: Synthesising blocks (covers issue #1031)":
|
||||||
test "Packing and adding multiple blocks to chain":
|
test "Packing and adding multiple blocks to chain":
|
||||||
var
|
var
|
||||||
env = initEnv(some(100.u256))
|
env = initEnv(MergeFork)
|
||||||
xp = env.xp
|
xp = env.xp
|
||||||
com = env.com
|
com = env.com
|
||||||
chain = env.chain
|
chain = env.chain
|
||||||
@ -336,7 +397,8 @@ when isMainModule:
|
|||||||
setErrorLevel() # mute logger
|
setErrorLevel() # mute logger
|
||||||
|
|
||||||
runTxPoolCliqueTest()
|
runTxPoolCliqueTest()
|
||||||
#runTxPoolPosTest()
|
runTxPoolPosTest()
|
||||||
#noisy.runTxHeadDelta
|
runTxPoolBlobhashTest()
|
||||||
|
noisy.runTxHeadDelta
|
||||||
|
|
||||||
# End
|
# End
|
||||||
|
Loading…
x
Reference in New Issue
Block a user