Engine API: remove EIP-4844 blobs before insert header to chain (#1834)
This commit is contained in:
parent
b7d0b06e79
commit
f365e0d472
|
@ -32,6 +32,10 @@ func validateVersionedHashed*(payload: ExecutionPayload,
|
|||
for x in payload.transactions:
|
||||
let tx = rlp.decode(distinctBase(x), Transaction)
|
||||
versionedHashes.add tx.versionedHashes
|
||||
|
||||
if versionedHashes.len != expected.len:
|
||||
return false
|
||||
|
||||
for i, x in expected:
|
||||
if distinctBase(x) != versionedHashes[i].data:
|
||||
return false
|
||||
|
|
|
@ -123,7 +123,7 @@ proc newPayload*(ben: BeaconEngineRef,
|
|||
|
||||
trace "Inserting block without sethead",
|
||||
hash = blockHash, number = header.blockNumber
|
||||
let body = blockBody(payload)
|
||||
let body = blockBody(payload, removeBlobs = true)
|
||||
let vres = ben.chain.insertBlockWithoutSetHead(header, body)
|
||||
if vres != ValidationResult.OK:
|
||||
let blockHash = latestValidHash(db, parent, ttd)
|
||||
|
|
|
@ -105,20 +105,21 @@ func blockHeader*(p: ExecutionPayload,
|
|||
parentBeaconBlockRoot: beaconRoot
|
||||
)
|
||||
|
||||
func blockBody*(p: ExecutionPayload):
|
||||
func blockBody*(p: ExecutionPayload, removeBlobs: bool):
|
||||
common.BlockBody {.gcsafe, raises:[RlpError].} =
|
||||
common.BlockBody(
|
||||
uncles : @[],
|
||||
transactions: ethTxs p.transactions,
|
||||
transactions: ethTxs(p.transactions, removeBlobs),
|
||||
withdrawals : ethWithdrawals p.withdrawals,
|
||||
)
|
||||
|
||||
func ethBlock*(p: ExecutionPayload,
|
||||
removeBlobs: bool,
|
||||
beaconRoot: Option[common.Hash256]):
|
||||
common.EthBlock {.gcsafe, raises:[CatchableError].} =
|
||||
common.Ethblock(
|
||||
header : blockHeader(p, beaconRoot),
|
||||
uncles : @[],
|
||||
txs : ethTxs p.transactions,
|
||||
txs : ethTxs(p.transactions, removeBlobs),
|
||||
withdrawals: ethWithdrawals p.withdrawals,
|
||||
)
|
||||
|
|
|
@ -84,7 +84,7 @@ const
|
|||
MIN_BLOB_GASPRICE* = 1'u64
|
||||
BLOB_GASPRICE_UPDATE_FRACTION* = 3338477'u64
|
||||
MAX_BLOB_GAS_PER_BLOCK* = 786432
|
||||
MAX_ALLOWED_BLOB* = MAX_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB
|
||||
MAX_BLOBS_PER_BLOCK* = int(MAX_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB)
|
||||
|
||||
# EIP-4788 addresses
|
||||
# BEACON_ROOTS_ADDRESS is the address where historical beacon roots are stored as per EIP-4788
|
||||
|
|
|
@ -274,8 +274,8 @@ proc validateTxBasic*(
|
|||
if tx.versionedHashes.len == 0:
|
||||
return err("invalid tx: there must be at least one blob")
|
||||
|
||||
if tx.versionedHashes.len > MAX_ALLOWED_BLOB.int:
|
||||
return err("invalid tx: versioned hashes len exceeds MAX_ALLOWED_BLOB=" & $MAX_ALLOWED_BLOB &
|
||||
if tx.versionedHashes.len > MAX_BLOBS_PER_BLOCK:
|
||||
return err("invalid tx: versioned hashes len exceeds MAX_BLOBS_PER_BLOCK=" & $MAX_BLOBS_PER_BLOCK &
|
||||
". get=" & $tx.versionedHashes.len)
|
||||
|
||||
for i, bv in tx.versionedHashes:
|
||||
|
|
|
@ -139,7 +139,7 @@ proc validateTxEip4844(tx: Transaction) =
|
|||
(acl.storageKeys.len <= MAX_ACCESS_LIST_STORAGE_KEYS)
|
||||
|
||||
isValid = isValid and
|
||||
tx.versionedHashes.len <= MAX_ALLOWED_BLOB.int
|
||||
tx.versionedHashes.len <= MAX_BLOBS_PER_BLOCK
|
||||
|
||||
for bv in tx.versionedHashes:
|
||||
isValid = isValid and
|
||||
|
|
Loading…
Reference in New Issue