Engine API simulator: pass first Cancun test (#1838)

This commit is contained in:
andri lim 2023-10-22 14:05:20 +07:00 committed by GitHub
parent f32419c81f
commit 4f6cdab641
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 17 additions and 26 deletions

View File

@ -81,7 +81,7 @@ func verifyBlob*(blobId: BlobID, blob: kzg.KzgBlob): bool =
return true
proc fillBlob(blobid: BlobID): KzgBlob =
proc fillBlob(blobId: BlobID): KzgBlob =
if blobId == 0:
# Blob zero is empty blob, so leave as is
return

View File

@ -133,7 +133,7 @@ proc verifyBlobBundle(step: NewPayloads,
return false
if len(blobBundle.blobs) != step.expectedIncludedBlobCount:
error "expected",
error "expected blobs",
expect=step.expectedIncludedBlobCount,
get=len(blobBundle.blobs)
return false
@ -168,9 +168,7 @@ proc verifyBlobBundle(step: NewPayloads,
for expectedBlob in step.expectedBlobs:
var found = false
for blobData in blobDataInPayload:
if not expectedBlob.verifyBlob(blobData.blob):
return false
else:
if expectedBlob.verifyBlob(blobData.blob):
found = true
break

View File

@ -19,7 +19,7 @@ import
# Precalculate the first data gas cost increase
const
DATA_GAS_COST_INCREMENT_EXCEED_BLOBS = getMinExcessBlobsForBlobGasPrice(2)
DATA_GAS_COST_INCREMENT_EXCEED_BLOBS = getMinExcessBlobsForBlobGasPrice(2).int
TARGET_BLOBS_PER_BLOCK = int(TARGET_BLOB_GAS_PER_BLOCK div GAS_PER_BLOB)
proc getGenesis(param: NetworkParams) =
@ -100,7 +100,7 @@ let cancunTestList* = [
# We create the first payload, and verify that the blob transactions
# are included in the payload.
# We also verify that the blob transactions are included in the blobs bundle.
#[NewPayloads(
NewPayloads(
expectedIncludedBlobCount: TARGET_BLOBS_PER_BLOCK,
expectedBlobs: getBlobList(0, TARGET_BLOBS_PER_BLOCK),
),
@ -128,7 +128,7 @@ let cancunTestList* = [
# But it will be included in the next payload
NewPayloads(
expectedIncludedBlobCount: MAX_BLOBS_PER_BLOCK,
),]#
),
]
)
),

View File

@ -332,26 +332,19 @@ proc getNextPayload(cl: CLMocker): bool =
return true
func versionedHashes(bb: BlobsBundleV1): seq[Web3Hash] =
#doAssert(bb.commitments.len > 0)
result = newSeqOfCap[BlockHash](bb.commitments.len)
for com in bb.commitments:
var h = keccakHash(com.bytes)
h.data[0] = VERSIONED_HASH_VERSION_KZG
result.add w3Hash h
func versionedHashes(payload: ExecutionPayload): seq[Web3Hash] =
result = newSeqOfCap[BlockHash](payload.transactions.len)
for x in payload.transactions:
let tx = rlp.decode(distinctBase(x), Transaction)
for vs in tx.versionedHashes:
result.add w3Hash vs
proc broadcastNewPayload(cl: CLMocker, payload: ExecutionPayload): Result[PayloadStatusV1, string] =
var versionedHashes: seq[Web3Hash]
if cl.latestBlobsBundle.isSome:
# Broadcast the blob bundle to all clients
versionedHashes = versionedHashes(cl.latestBlobsBundle.get)
case payload.version
of Version.V1: return cl.client.newPayloadV1(payload.V1)
of Version.V2: return cl.client.newPayloadV2(payload.V2)
of Version.V3: return cl.client.newPayloadV3(payload.V3,
versionedHashes,
versionedHashes(payload),
cl.latestPayloadAttributes.parentBeaconBlockRoot.get)
proc broadcastNextNewPayload(cl: CLMocker): bool =

View File

@ -97,7 +97,7 @@ proc newEngineEnv*(conf: var NimbusConf, chainFile: string, enableAuth: bool): E
let
hooks = if enableAuth: @[httpJwtAuth(key)]
else: @[]
server = newRpcHttpServer(["127.0.0.1:" & $conf.rpcPort], hooks)
server = newRpcHttpServerWithParams("127.0.0.1:" & $conf.rpcPort, hooks)
sealer = SealingEngineRef.new(
chain, ctx, conf.engineSigner,
txPool, EngineStopped)

View File

@ -248,7 +248,7 @@ proc makeTx*(params: MakeTxParams, tc: BlobTx): Transaction =
else: gasTipPrice
let unsignedTx = Transaction(
txType : TxEIP4844,
txType : TxEip4844,
chainId : params.chainId,
nonce : params.nonce,
maxPriorityFee: gasTipCap,