mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-01-11 21:04:11 +00:00
Fix t8n: Calculate excessBlobGas from parent if not supplied (#2432)
* Fix t8n: Calculate excessBlobGas from parent if not supplied * Fix comment
This commit is contained in:
parent
c24affadee
commit
403b93104b
@ -17,10 +17,10 @@ import
|
||||
../../nimbus/beacon/web3_eth_conv
|
||||
|
||||
const
|
||||
#testFile = "tests/fixtures/eth_tests/BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip4844_blobs/fork_transition_excess_blob_gas.json"
|
||||
testFile = "tests/fixtures/eth_tests/BlockchainTests/GeneralStateTests/Pyspecs/cancun/eip4844_blobs/fork_transition_excess_blob_gas.json"
|
||||
#testFile = "tests/fixtures/eth_tests/BlockchainTests/ValidBlocks/bcRandomBlockhashTest/randomStatetest224BC.json"
|
||||
#testFile = "tests/fixtures/eth_tests/BlockchainTests/ValidBlocks/bcRandomBlockhashTest/randomStatetest631BC.json"
|
||||
testFile = "tests/fixtures/eth_tests/BlockchainTests/ValidBlocks/bcStateTests/blockhashTests.json"
|
||||
#testFile = "tests/fixtures/eth_tests/BlockchainTests/ValidBlocks/bcStateTests/blockhashTests.json"
|
||||
|
||||
type
|
||||
BCTConv* = JrpcConv
|
||||
@ -122,10 +122,12 @@ proc toBctEnv(parentBlock, currentBlock: EthBlock, hashes: BCTHashes): BCTEnv =
|
||||
result.currentTimestamp = Opt.some w3Qty(current.timestamp)
|
||||
result.currentDifficulty = current.difficulty
|
||||
result.currentRandom = Opt.some w3Hash(current.mixHash)
|
||||
result.currentBaseFee = current.baseFeePerGas
|
||||
|
||||
result.currentBlobGasUsed = w3Qty(current.blobGasUsed)
|
||||
result.currentExcessBlobGas = w3Qty(current.excessBlobGas)
|
||||
# t8n should able to calculate these values itself if not supplied
|
||||
#result.currentBaseFee = current.baseFeePerGas
|
||||
#result.currentBlobGasUsed = w3Qty(current.blobGasUsed)
|
||||
#result.currentExcessBlobGas = w3Qty(current.excessBlobGas)
|
||||
|
||||
result.parentBeaconBlockRoot = w3Hash(current.parentBeaconBlockRoot)
|
||||
result.parentDifficulty = Opt.some parent.difficulty
|
||||
result.parentTimestamp = Opt.some w3Qty(parent.timestamp)
|
||||
|
@ -113,9 +113,23 @@ proc cmp(jsc: var JsonComparator; a, b: JsonNode, path: string): bool =
|
||||
of JObject:
|
||||
# we cannot use OrderedTable's equality here as
|
||||
# the order does not matter for equality here.
|
||||
if a.fields.len != b.fields.len:
|
||||
jsc.exit("OBJ LEN A($1) != B($2)" % [$a.fields.len, $b.fields.len])
|
||||
var
|
||||
aFields = newSeqOfCap[string](a.fields.len)
|
||||
bFields = newSeqOfCap[string](b.fields.len)
|
||||
|
||||
for key, val in a.fields:
|
||||
if val.kind != JNull:
|
||||
aFields.add key
|
||||
|
||||
for key, val in b.fields:
|
||||
if val.kind != JNull:
|
||||
bFields.add key
|
||||
|
||||
if aFields.len != bFields.len:
|
||||
jsc.exit("OBJ LEN A($1) != B($2)" % [$aFields.len, $bFields.len])
|
||||
|
||||
for key in aFields:
|
||||
let val = a.fields[key]
|
||||
if not b.fields.hasKey(key):
|
||||
jsc.exit("OBJ FIELD A($1) != B(none)" % [key])
|
||||
if not jsc.cmp(val, b.fields[key], path & "/" & key):
|
||||
@ -578,6 +592,15 @@ const
|
||||
output: T8nOutput(result: true),
|
||||
expOut: "exp.json",
|
||||
),
|
||||
TestSpec(
|
||||
name : "Calculate excessBlobGas if not supplied",
|
||||
base : "testdata/00-524",
|
||||
input : t8nInput(
|
||||
"alloc.json", "txs.rlp", "env.json", "Cancun", "0",
|
||||
),
|
||||
output: T8nOutput(result: true),
|
||||
expOut: "exp.json",
|
||||
),
|
||||
]
|
||||
|
||||
proc main() =
|
||||
|
36
tools/t8n/testdata/00-524/alloc.json
vendored
Normal file
36
tools/t8n/testdata/00-524/alloc.json
vendored
Normal file
@ -0,0 +1,36 @@
|
||||
{
|
||||
"0x0000000000000000000000000000000000000100" : {
|
||||
"code" : "0x",
|
||||
"nonce" : "0x00",
|
||||
"balance" : "0x06",
|
||||
"storage" : {
|
||||
}
|
||||
},
|
||||
"0x000f3df6d732807ef1319fb7b8bb8522d0beac02" : {
|
||||
"code" : "0x3373fffffffffffffffffffffffffffffffffffffffe14604d57602036146024575f5ffd5b5f35801560495762001fff810690815414603c575f5ffd5b62001fff01545f5260205ff35b5f5ffd5b62001fff42064281555f359062001fff015500",
|
||||
"nonce" : "0x01",
|
||||
"balance" : "0x00",
|
||||
"storage" : {
|
||||
"0x1aa4" : "0x3aa3",
|
||||
"0x1ab0" : "0x3aaf",
|
||||
"0x1abc" : "0x3abb",
|
||||
"0x1ac8" : "0x3ac7",
|
||||
"0x1ad4" : "0x3ad3",
|
||||
"0x1ae0" : "0x3adf"
|
||||
}
|
||||
},
|
||||
"0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba" : {
|
||||
"code" : "0x",
|
||||
"nonce" : "0x00",
|
||||
"balance" : "0x1339e0",
|
||||
"storage" : {
|
||||
}
|
||||
},
|
||||
"0xa94f5374fce5edbc8e2a8697c15331677e6ebf0b" : {
|
||||
"code" : "0x",
|
||||
"nonce" : "0x06",
|
||||
"balance" : "0x1d6329f1c35ca4bfabb9f560ffff9750ca",
|
||||
"storage" : {
|
||||
}
|
||||
}
|
||||
}
|
45
tools/t8n/testdata/00-524/env.json
vendored
Normal file
45
tools/t8n/testdata/00-524/env.json
vendored
Normal file
@ -0,0 +1,45 @@
|
||||
{
|
||||
"blockHashes": {
|
||||
"0": "0x62a3952bff0f4c551280e37529f7262e943728565d381f8b3809a8a2d6894b62",
|
||||
"1": "0xa6b5ec5f9e31f19ecedc1e3ff9199171d685d1eb37578a9d9f15ff79774116c6",
|
||||
"10": "0x50f68c4b975d4177f6b8d5856a1464478879fe08910bbadad8a4d53e4960adbc",
|
||||
"11": "0x3080eec1bc3fc3b43dd898dc428fd2421aee116770a77601f236db01b01e6463",
|
||||
"12": "0xce8c807d8e8d0e62bf3fb80ddfb18cb0a3892245b3adc0d073a426b3ab650025",
|
||||
"13": "0x876080a31785b5cb13aec8a9f2a8377eeba7b9a495ea9e01a0144c3c80eb6b36",
|
||||
"14": "0x7ae2e4b82775c956911581694c6ba462b6a04380af8a34cb56708ab2cb650c8e",
|
||||
"15": "0x64177ba1942c915cc9c4d95a69b27befb29a3e0c2a56882fba4fb8c5bf367fea",
|
||||
"16": "0x1cb941b201a51e6790c31d1e9b6b422f71929519438720f8e0450142b9c3b20a",
|
||||
"17": "0x28f137df5e136b5bdce159a9d6b7a68b5cb53df13b16a34542cdc9b5592eacd5",
|
||||
"18": "0xd789fa5ee86edd732984820d8255707cb1bf546cc23048b67a65cdd3f12f9bd5",
|
||||
"19": "0x267cdfcc322b89a1198c6ee7d11e14a156e36c083de3fe6866d5f7e842cf6206",
|
||||
"2": "0x14af96433f42dd247f32441ab6718a0cd2c360d1aad6020e7f61d0ee87f54959",
|
||||
"20": "0x62b544f6ecb297d832a0a5bef5246ffb6ee9fad24106e3b3bdb5599eee90c18c",
|
||||
"21": "0x969e23ee6e6a5a2e9beee708c6a48a3f3016fd17222990c3cc7a16adc17a2090",
|
||||
"22": "0xa2f1f2ced0aa92a99f866e9eb3f0f924eb13abe0f6a09b203068c145b0e17bbe",
|
||||
"23": "0x1b3409441366238b60c36aa4b1fe384a6710f72c7d40c5b721c36ff540d9761d",
|
||||
"3": "0x82654f9384ce991af3fc90f2f8b2a10bb63d02d27b9c8a67cd2c520c120548da",
|
||||
"4": "0x32de784a12e4d2cdddac24390786361378087191283973a40894bdf0a23b8754",
|
||||
"5": "0x1f6a293ff31771a4c9b221f9cb3af7b4121ef73768c2e676561d079c54c414cf",
|
||||
"6": "0xade0b651d2d0f69590cb7212d48132094aaf38b5e168a4a0081240f6b268ffaa",
|
||||
"7": "0x26aadcec2b641feba29608cb4e156ecebae90f2b3dc58b9b120d675eb068e691",
|
||||
"8": "0x67542942696328ef3f0347ffcda91b73512041c6b3ba8257edce7680d2f8003c",
|
||||
"9": "0xa64eddafd629ba0f1cd7555a5558b3537978738ffbd9eb2459a8778fc2f104f1"
|
||||
},
|
||||
"currentCoinbase": "0x2adc25665018aa1fe0e6bc666dac8fc2697ff9ba",
|
||||
"currentDifficulty": "0x0",
|
||||
"currentGasLimit": "0x16345785d8a0000",
|
||||
"currentNumber": "0x16",
|
||||
"currentRandom": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"currentTimestamp": "0x3aeb",
|
||||
"parentBaseFee": "0x7",
|
||||
"parentBeaconBlockRoot": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"parentBlobGasUsed": "0xc0000",
|
||||
"parentDifficulty": "0x0",
|
||||
"parentExcessBlobGas": "0x1e0000",
|
||||
"parentGasLimit": "0x16345785d8a0000",
|
||||
"parentGasUsed": "0x5208",
|
||||
"parentTimestamp": "0x3adf",
|
||||
"parentUncleHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
"withdrawals": [
|
||||
]
|
||||
}
|
31
tools/t8n/testdata/00-524/exp.json
vendored
Normal file
31
tools/t8n/testdata/00-524/exp.json
vendored
Normal file
@ -0,0 +1,31 @@
|
||||
{
|
||||
"result": {
|
||||
"stateRoot": "0x0488e5f75205c63570c7e448aaab098076ebebde078f50f46c3b5216ebaba1f5",
|
||||
"txRoot": "0x12b9a15e00d03fef9edafa164d7b72a74af4ed7722bfa9eb366ed81e408f1202",
|
||||
"receiptsRoot": "0xeaa8c40899a61ae59615cf9985f5e2194f8fd2b57d273be63bde6733e89b12ab",
|
||||
"logsHash": "0x1dcc4de8dec75d7aab85b567b6ccd41ad312451b948a7413f0a142fd40d49347",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"receipts": [
|
||||
{
|
||||
"type": "0x3",
|
||||
"root": "0x",
|
||||
"status": "0x1",
|
||||
"cumulativeGasUsed": "0x5208",
|
||||
"logsBloom": "0x00000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000",
|
||||
"logs": null,
|
||||
"transactionHash": "0x130c501dcf86fb04c76470b074f523d1c7c04bf1d68534ddc204343d145a2b31",
|
||||
"contractAddress": "0x0000000000000000000000000000000000000000",
|
||||
"gasUsed": "0x5208",
|
||||
"effectiveGasPrice": null,
|
||||
"blockHash": "0x0000000000000000000000000000000000000000000000000000000000000000",
|
||||
"transactionIndex": "0x0"
|
||||
}
|
||||
],
|
||||
"currentDifficulty": null,
|
||||
"gasUsed": "0x5208",
|
||||
"currentBaseFee": "0x7",
|
||||
"withdrawalsRoot": "0x56e81f171bcc55a6ff8345e692c0f86e5b48e01b996cadc001622fb5e363b421",
|
||||
"currentExcessBlobGas": "0x240000",
|
||||
"blobGasUsed": "0xc0000"
|
||||
}
|
||||
}
|
1
tools/t8n/testdata/00-524/txs.rlp
vendored
Normal file
1
tools/t8n/testdata/00-524/txs.rlp
vendored
Normal file
@ -0,0 +1 @@
|
||||
"0xf90136b9013303f9012f01060a830f4240832dc6c09400000000000000000000000000000000000001000180c064f8c6a00100000000000000000000000000000000000000000000000000000000000000a00100000000000000000000000000000000000000000000000000000000000001a00100000000000000000000000000000000000000000000000000000000000002a00100000000000000000000000000000000000000000000000000000000000003a00100000000000000000000000000000000000000000000000000000000000004a0010000000000000000000000000000000000000000000000000000000000000501a00e24c94730c203be893635cba0cacc17271a48e7ea79a38cef681817e094ad1fa04d319fda237eb0219df9ad9de0f16af61cc0ff0cdebcee3ec3deda2d2245a5e6"
|
@ -482,6 +482,13 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) =
|
||||
ctx.env.currentDifficulty = Opt.some(calcDifficulty(com,
|
||||
ctx.env.currentTimestamp, parent))
|
||||
|
||||
# Calculate the excessBlobGas
|
||||
if ctx.env.currentExcessBlobGas.isNone:
|
||||
# If it is not explicitly defined, but we have the parent values, we try
|
||||
# to calculate it ourselves.
|
||||
if parent.excessBlobGas.isSome and parent.blobGasUsed.isSome:
|
||||
ctx.env.currentExcessBlobGas = Opt.some calcExcessBlobGas(parent)
|
||||
|
||||
let header = envToHeader(ctx.env)
|
||||
|
||||
let vmState = TestVMState(
|
||||
|
Loading…
x
Reference in New Issue
Block a user