Fix txPool: excessBlobGas should be calculated before entering EVM, not after (#2149)

This commit is contained in:
andri lim 2024-04-24 07:50:50 +07:00 committed by GitHub
parent b9187e0493
commit 47605dbdf3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 11 additions and 10 deletions

View File

@ -116,8 +116,8 @@ proc newPayload*(ben: BeaconEngineRef,
timestamp = ethTime payload.timestamp timestamp = ethTime payload.timestamp
version = payload.version version = payload.version
validateVersion(com, timestamp, version, apiVersion)
validatePayload(apiVersion, version, payload) validatePayload(apiVersion, version, payload)
validateVersion(com, timestamp, version, apiVersion)
var header = blockHeader(payload, removeBlobs = true, beaconRoot = ethHash beaconRoot) var header = blockHeader(payload, removeBlobs = true, beaconRoot = ethHash beaconRoot)

View File

@ -19,6 +19,7 @@ import
../../utils/utils, ../../utils/utils,
../../vm_state, ../../vm_state,
../../vm_types, ../../vm_types,
../eip4844,
../clique/[clique_sealer, clique_desc, clique_cfg], ../clique/[clique_sealer, clique_desc, clique_cfg],
../pow/difficulty, ../pow/difficulty,
../executor, ../executor,
@ -131,12 +132,13 @@ proc resetTxEnv(dh: TxChainRef; parent: BlockHeader; fee: Option[UInt256])
# we don't consider PoS difficulty here # we don't consider PoS difficulty here
# because that is handled in vmState # because that is handled in vmState
let blockCtx = BlockContext( let blockCtx = BlockContext(
timestamp : dh.prepHeader.timestamp, timestamp : dh.prepHeader.timestamp,
gasLimit : (if dh.maxMode: dh.limits.maxLimit else: dh.limits.trgLimit), gasLimit : (if dh.maxMode: dh.limits.maxLimit else: dh.limits.trgLimit),
fee : fee, fee : fee,
prevRandao: dh.prepHeader.prevRandao, prevRandao : dh.prepHeader.prevRandao,
difficulty: dh.prepHeader.difficulty, difficulty : dh.prepHeader.difficulty,
coinbase : dh.feeRecipient, coinbase : dh.feeRecipient,
excessBlobGas: calcExcessBlobGas(parent),
) )
dh.txEnv.vmState = BaseVMState.new( dh.txEnv.vmState = BaseVMState.new(

View File

@ -275,8 +275,7 @@ proc vmExecCommit(pst: TxPackerStateRef)
if vmState.com.forkGTE(Cancun): if vmState.com.forkGTE(Cancun):
# EIP-4844 # EIP-4844
let excessBlobGas = calcExcessBlobGas(vmState.parent) xp.chain.excessBlobGas = some(vmState.blockCtx.excessBlobGas)
xp.chain.excessBlobGas = some(excessBlobGas)
xp.chain.blobGasUsed = some(pst.blobGasUsed) xp.chain.blobGasUsed = some(pst.blobGasUsed)
proc balanceDelta: UInt256 = proc balanceDelta: UInt256 =