evmstate: make batched execution possible (#2875)

* evmstate: make batched execution possible

* Revert changes in CommonRef
This commit is contained in:
andri lim 2024-11-27 13:15:05 +07:00 committed by GitHub
parent 1721435b3c
commit 0926a2110b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 21 additions and 15 deletions

View File

@ -76,6 +76,7 @@ type
inputFile* {.
desc: "json file contains state test data"
defaultValue: ""
argument }: string
const

View File

@ -41,7 +41,6 @@ type
index: int
tracerFlags: set[TracerFlags]
error: string
trustedSetupLoaded: bool
StateResult = object
name : string
@ -113,14 +112,6 @@ proc runExecution(ctx: var StateContext, conf: StateConf, pre: JsonNode): StateR
else:
JsonTracer(nil)
if com.isCancunOrLater(ctx.header.timestamp):
if not ctx.trustedSetupLoaded:
let res = loadKzgTrustedSetup()
if res.isErr:
echo "FATAL: ", res.error
quit(QuitFailure)
ctx.trustedSetupLoaded = true
let vmState = TestVMState()
vmState.init(
parent = ctx.parent,
@ -156,8 +147,7 @@ proc runExecution(ctx: var StateContext, conf: StateConf, pre: JsonNode): StateR
if rc.isOk:
gasUsed = rc.value
let miner = ctx.header.coinbase
coinbaseStateClearing(vmState, miner)
coinbaseStateClearing(vmState, ctx.header.coinbase)
except CatchableError as ex:
echo "FATAL: ", ex.msg
quit(QuitFailure)
@ -178,9 +168,12 @@ proc toTracerFlags(conf: StateConf): set[TracerFlags] =
template hasError(ctx: StateContext): bool =
ctx.error.len > 0
proc prepareAndRun(ctx: var StateContext, conf: StateConf): bool =
proc prepareAndRun(inputFile: string, conf: StateConf): bool =
var
ctx: StateContext
let
fixture = json.parseFile(conf.inputFile)
fixture = json.parseFile(inputFile)
n = ctx.extractNameAndFixture(fixture)
txData = n["transaction"]
post = n["post"]
@ -262,8 +255,20 @@ proc main() =
let conf = StateConf.init()
when defined(chronicles_runtime_filtering):
setVerbosity(conf.verbosity)
var ctx: StateContext
if not ctx.prepareAndRun(conf):
loadKzgTrustedSetup().isOkOr:
echo "FATAL: ", error
quit(QuitFailure)
if conf.inputFile.len > 0:
if not prepareAndRun(conf.inputFile, conf):
quit(QuitFailure)
else:
var noError = true
for inputFile in lines(stdin):
let res = prepareAndRun(inputFile, conf)
noError = noError and res
if not noError:
quit(QuitFailure)
main()