mirror of
https://github.com/status-im/nimbus-eth1.git
synced 2025-02-22 08:48:24 +00:00
Fix tools helper and allow GST to parse new eest devnet-6 test vectors (#3045)
* Fix tools helper * Allow GST to parse new eest devnet-6 test vectors
This commit is contained in:
parent
d4266dc186
commit
825cc4c242
@ -1,5 +1,5 @@
|
|||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2019-2024 Status Research & Development GmbH
|
# Copyright (c) 2019-2025 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -28,7 +28,7 @@ type
|
|||||||
index*: Opt[int]
|
index*: Opt[int]
|
||||||
trace*: bool
|
trace*: bool
|
||||||
legacy*: bool
|
legacy*: bool
|
||||||
pruning*: bool
|
subFixture*: Opt[int]
|
||||||
json*: bool
|
json*: bool
|
||||||
|
|
||||||
var testConfig {.threadvar.}: Configuration
|
var testConfig {.threadvar.}: Configuration
|
||||||
@ -36,7 +36,6 @@ var testConfig {.threadvar.}: Configuration
|
|||||||
proc initConfiguration(): Configuration =
|
proc initConfiguration(): Configuration =
|
||||||
result = new Configuration
|
result = new Configuration
|
||||||
result.trace = true
|
result.trace = true
|
||||||
result.pruning = true
|
|
||||||
|
|
||||||
proc getConfiguration*(): Configuration {.gcsafe.} =
|
proc getConfiguration*(): Configuration {.gcsafe.} =
|
||||||
if isNil(testConfig):
|
if isNil(testConfig):
|
||||||
@ -59,7 +58,7 @@ proc processArguments*(msg: var string): ConfigStatus =
|
|||||||
of "index": config.index = Opt.some(parseInt(value))
|
of "index": config.index = Opt.some(parseInt(value))
|
||||||
of "trace": config.trace = parseBool(value)
|
of "trace": config.trace = parseBool(value)
|
||||||
of "legacy": config.legacy = parseBool(value)
|
of "legacy": config.legacy = parseBool(value)
|
||||||
of "pruning": config.pruning = parseBool(value)
|
of "sub": config.subFixture = Opt.some(parseInt(value))
|
||||||
of "json": config.json = parseBool(value)
|
of "json": config.json = parseBool(value)
|
||||||
else:
|
else:
|
||||||
msg = "Unknown option " & key
|
msg = "Unknown option " & key
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2018-2024 Status Research & Development GmbH
|
# Copyright (c) 2018-2025 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
# * MIT license ([LICENSE-MIT](LICENSE-MIT) or http://opensource.org/licenses/MIT)
|
||||||
@ -37,6 +37,7 @@ type
|
|||||||
debugMode: bool
|
debugMode: bool
|
||||||
trace: bool
|
trace: bool
|
||||||
index: int
|
index: int
|
||||||
|
subFixture: int
|
||||||
fork: string
|
fork: string
|
||||||
|
|
||||||
var
|
var
|
||||||
@ -73,7 +74,8 @@ proc dumpDebugData(ctx: TestCtx, vmState: BaseVMState, gasUsed: GasInt, success:
|
|||||||
}
|
}
|
||||||
let status = if success: "_success" else: "_failed"
|
let status = if success: "_success" else: "_failed"
|
||||||
let fileName = normalizeFileName(ctx.name)
|
let fileName = normalizeFileName(ctx.name)
|
||||||
writeFile(fileName & "_" & ctx.fork & "_" & $ctx.index & status & ".json", debugData.pretty())
|
writeFile(fileName & "_" & $ctx.subFixture & "_" &
|
||||||
|
ctx.fork & "_" & $ctx.index & status & ".json", debugData.pretty())
|
||||||
|
|
||||||
proc testFixtureIndexes(ctx: var TestCtx, testStatusIMPL: var TestStatus) =
|
proc testFixtureIndexes(ctx: var TestCtx, testStatusIMPL: var TestStatus) =
|
||||||
let
|
let
|
||||||
@ -129,15 +131,8 @@ proc testFixtureIndexes(ctx: var TestCtx, testStatusIMPL: var TestStatus) =
|
|||||||
let success = ctx.expectedLogs == actualLogsHash and obtainedHash == ctx.expectedHash
|
let success = ctx.expectedLogs == actualLogsHash and obtainedHash == ctx.expectedHash
|
||||||
ctx.dumpDebugData(vmState, gasUsed, success)
|
ctx.dumpDebugData(vmState, gasUsed, success)
|
||||||
|
|
||||||
proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
|
proc testSubFixture(ctx: var TestCtx, fixture: JsonNode, testStatusIMPL: var TestStatus,
|
||||||
trace = false, debugMode = false) =
|
trace = false, debugMode = false) =
|
||||||
var ctx: TestCtx
|
|
||||||
var fixture: JsonNode
|
|
||||||
for label, child in fixtures:
|
|
||||||
fixture = child
|
|
||||||
ctx.name = label
|
|
||||||
break
|
|
||||||
|
|
||||||
ctx.pre = fixture["pre"]
|
ctx.pre = fixture["pre"]
|
||||||
ctx.parent = parseParentHeader(fixture["env"])
|
ctx.parent = parseParentHeader(fixture["env"])
|
||||||
ctx.header = parseHeader(fixture["env"])
|
ctx.header = parseHeader(fixture["env"])
|
||||||
@ -193,12 +188,28 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
|
|||||||
runSubTest(subTest)
|
runSubTest(subTest)
|
||||||
inc ctx.index
|
inc ctx.index
|
||||||
|
|
||||||
|
proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus,
|
||||||
|
trace = false, debugMode = false) =
|
||||||
|
let
|
||||||
|
conf = getConfiguration()
|
||||||
|
|
||||||
|
var
|
||||||
|
ctx: TestCtx
|
||||||
|
subFixture = 0
|
||||||
|
|
||||||
|
for label, child in fixtures:
|
||||||
|
ctx.name = label
|
||||||
|
ctx.subFixture = subFixture
|
||||||
|
inc subFixture
|
||||||
|
if conf.subFixture.isSome and conf.subFixture.get != ctx.subFixture:
|
||||||
|
continue
|
||||||
|
testSubFixture(ctx, child, testStatusIMPL, trace, debugMode)
|
||||||
|
|
||||||
proc generalStateJsonMain*(debugMode = false) =
|
proc generalStateJsonMain*(debugMode = false) =
|
||||||
const
|
const
|
||||||
legacyFolder = "eth_tests/LegacyTests/Constantinople/GeneralStateTests"
|
legacyFolder = "eth_tests/LegacyTests/Constantinople/GeneralStateTests"
|
||||||
newFolder = "eth_tests/GeneralStateTests"
|
newFolder = "eth_tests/GeneralStateTests"
|
||||||
#newFolder = "eth_tests/EIPTests/StateTests"
|
|
||||||
|
|
||||||
let config = getConfiguration()
|
let config = getConfiguration()
|
||||||
if config.testSubject == "" or not debugMode:
|
if config.testSubject == "" or not debugMode:
|
||||||
# run all test fixtures
|
# run all test fixtures
|
||||||
|
@ -62,10 +62,13 @@ proc assignTime(c: ChainConfig, transitionFork: HardFork, t: EthTime) =
|
|||||||
c.terminalTotalDifficulty = Opt.some(0.u256)
|
c.terminalTotalDifficulty = Opt.some(0.u256)
|
||||||
|
|
||||||
func getChainConfig*(network: string, c: ChainConfig) =
|
func getChainConfig*(network: string, c: ChainConfig) =
|
||||||
|
const DEPOSIT_CONTRACT_ADDRESS = address"0x00000000219ab540356cbb839cbe05303d7705fa"
|
||||||
|
|
||||||
c.daoForkSupport = false
|
c.daoForkSupport = false
|
||||||
c.chainId = 1.ChainId
|
c.chainId = 1.ChainId
|
||||||
c.terminalTotalDifficulty = Opt.none(UInt256)
|
c.terminalTotalDifficulty = Opt.none(UInt256)
|
||||||
c.blobSchedule = defaultBlobSchedule()
|
c.blobSchedule = defaultBlobSchedule()
|
||||||
|
c.depositContractAddress = Opt.some(DEPOSIT_CONTRACT_ADDRESS)
|
||||||
|
|
||||||
case network
|
case network
|
||||||
of $TestFork.Frontier:
|
of $TestFork.Frontier:
|
||||||
@ -126,6 +129,8 @@ func getChainConfig*(network: string, c: ChainConfig) =
|
|||||||
c.assignTime(HardFork.Cancun, EthTime(15000))
|
c.assignTime(HardFork.Cancun, EthTime(15000))
|
||||||
of $TestFork.Prague:
|
of $TestFork.Prague:
|
||||||
c.assignTime(HardFork.Prague, TimeZero)
|
c.assignTime(HardFork.Prague, TimeZero)
|
||||||
|
of $TestFork.CancunToPragueAtTime15k:
|
||||||
|
c.assignTime(HardFork.Prague, EthTime(15000))
|
||||||
else:
|
else:
|
||||||
raise newException(ValueError, "unsupported network " & network)
|
raise newException(ValueError, "unsupported network " & network)
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
# Nimbus
|
# Nimbus
|
||||||
# Copyright (c) 2022-2024 Status Research & Development GmbH
|
# Copyright (c) 2022-2025 Status Research & Development GmbH
|
||||||
# Licensed under either of
|
# Licensed under either of
|
||||||
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
# * Apache License, version 2.0, ([LICENSE-APACHE](LICENSE-APACHE) or
|
||||||
# http://www.apache.org/licenses/LICENSE-2.0)
|
# http://www.apache.org/licenses/LICENSE-2.0)
|
||||||
@ -38,6 +38,7 @@ type
|
|||||||
Cancun
|
Cancun
|
||||||
ShanghaiToCancunAtTime15k
|
ShanghaiToCancunAtTime15k
|
||||||
Prague
|
Prague
|
||||||
|
CancunToPragueAtTime15k
|
||||||
|
|
||||||
LogLevel* = enum
|
LogLevel* = enum
|
||||||
Silent
|
Silent
|
||||||
|
Loading…
x
Reference in New Issue
Block a user