mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-24 19:19:21 +00:00
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:
|
for x in payload.transactions:
|
||||||
let tx = rlp.decode(distinctBase(x), Transaction)
|
let tx = rlp.decode(distinctBase(x), Transaction)
|
||||||
versionedHashes.add tx.versionedHashes
|
versionedHashes.add tx.versionedHashes
|
||||||
|
|
||||||
|
if versionedHashes.len != expected.len:
|
||||||
|
return false
|
||||||
|
|
||||||
for i, x in expected:
|
for i, x in expected:
|
||||||
if distinctBase(x) != versionedHashes[i].data:
|
if distinctBase(x) != versionedHashes[i].data:
|
||||||
return false
|
return false
|
||||||
|
@ -123,7 +123,7 @@ proc newPayload*(ben: BeaconEngineRef,
|
|||||||
|
|
||||||
trace "Inserting block without sethead",
|
trace "Inserting block without sethead",
|
||||||
hash = blockHash, number = header.blockNumber
|
hash = blockHash, number = header.blockNumber
|
||||||
let body = blockBody(payload)
|
let body = blockBody(payload, removeBlobs = true)
|
||||||
let vres = ben.chain.insertBlockWithoutSetHead(header, body)
|
let vres = ben.chain.insertBlockWithoutSetHead(header, body)
|
||||||
if vres != ValidationResult.OK:
|
if vres != ValidationResult.OK:
|
||||||
let blockHash = latestValidHash(db, parent, ttd)
|
let blockHash = latestValidHash(db, parent, ttd)
|
||||||
|
@ -105,20 +105,21 @@ func blockHeader*(p: ExecutionPayload,
|
|||||||
parentBeaconBlockRoot: beaconRoot
|
parentBeaconBlockRoot: beaconRoot
|
||||||
)
|
)
|
||||||
|
|
||||||
func blockBody*(p: ExecutionPayload):
|
func blockBody*(p: ExecutionPayload, removeBlobs: bool):
|
||||||
common.BlockBody {.gcsafe, raises:[RlpError].} =
|
common.BlockBody {.gcsafe, raises:[RlpError].} =
|
||||||
common.BlockBody(
|
common.BlockBody(
|
||||||
uncles : @[],
|
uncles : @[],
|
||||||
transactions: ethTxs p.transactions,
|
transactions: ethTxs(p.transactions, removeBlobs),
|
||||||
withdrawals : ethWithdrawals p.withdrawals,
|
withdrawals : ethWithdrawals p.withdrawals,
|
||||||
)
|
)
|
||||||
|
|
||||||
func ethBlock*(p: ExecutionPayload,
|
func ethBlock*(p: ExecutionPayload,
|
||||||
|
removeBlobs: bool,
|
||||||
beaconRoot: Option[common.Hash256]):
|
beaconRoot: Option[common.Hash256]):
|
||||||
common.EthBlock {.gcsafe, raises:[CatchableError].} =
|
common.EthBlock {.gcsafe, raises:[CatchableError].} =
|
||||||
common.Ethblock(
|
common.Ethblock(
|
||||||
header : blockHeader(p, beaconRoot),
|
header : blockHeader(p, beaconRoot),
|
||||||
uncles : @[],
|
uncles : @[],
|
||||||
txs : ethTxs p.transactions,
|
txs : ethTxs(p.transactions, removeBlobs),
|
||||||
withdrawals: ethWithdrawals p.withdrawals,
|
withdrawals: ethWithdrawals p.withdrawals,
|
||||||
)
|
)
|
||||||
|
@ -84,8 +84,8 @@ const
|
|||||||
MIN_BLOB_GASPRICE* = 1'u64
|
MIN_BLOB_GASPRICE* = 1'u64
|
||||||
BLOB_GASPRICE_UPDATE_FRACTION* = 3338477'u64
|
BLOB_GASPRICE_UPDATE_FRACTION* = 3338477'u64
|
||||||
MAX_BLOB_GAS_PER_BLOCK* = 786432
|
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
|
# EIP-4788 addresses
|
||||||
# BEACON_ROOTS_ADDRESS is the address where historical beacon roots are stored as per EIP-4788
|
# BEACON_ROOTS_ADDRESS is the address where historical beacon roots are stored as per EIP-4788
|
||||||
BEACON_ROOTS_ADDRESS* = hexToByteArray[20]("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02")
|
BEACON_ROOTS_ADDRESS* = hexToByteArray[20]("0x000F3df6D732807Ef1319fB7B8bB8522d0Beac02")
|
||||||
|
@ -274,8 +274,8 @@ proc validateTxBasic*(
|
|||||||
if tx.versionedHashes.len == 0:
|
if tx.versionedHashes.len == 0:
|
||||||
return err("invalid tx: there must be at least one blob")
|
return err("invalid tx: there must be at least one blob")
|
||||||
|
|
||||||
if tx.versionedHashes.len > MAX_ALLOWED_BLOB.int:
|
if tx.versionedHashes.len > MAX_BLOBS_PER_BLOCK:
|
||||||
return err("invalid tx: versioned hashes len exceeds MAX_ALLOWED_BLOB=" & $MAX_ALLOWED_BLOB &
|
return err("invalid tx: versioned hashes len exceeds MAX_BLOBS_PER_BLOCK=" & $MAX_BLOBS_PER_BLOCK &
|
||||||
". get=" & $tx.versionedHashes.len)
|
". get=" & $tx.versionedHashes.len)
|
||||||
|
|
||||||
for i, bv in tx.versionedHashes:
|
for i, bv in tx.versionedHashes:
|
||||||
|
@ -139,7 +139,7 @@ proc validateTxEip4844(tx: Transaction) =
|
|||||||
(acl.storageKeys.len <= MAX_ACCESS_LIST_STORAGE_KEYS)
|
(acl.storageKeys.len <= MAX_ACCESS_LIST_STORAGE_KEYS)
|
||||||
|
|
||||||
isValid = isValid and
|
isValid = isValid and
|
||||||
tx.versionedHashes.len <= MAX_ALLOWED_BLOB.int
|
tx.versionedHashes.len <= MAX_BLOBS_PER_BLOCK
|
||||||
|
|
||||||
for bv in tx.versionedHashes:
|
for bv in tx.versionedHashes:
|
||||||
isValid = isValid and
|
isValid = isValid and
|
||||||
|
Loading…
x
Reference in New Issue
Block a user