parent
52a2ba4bd7
commit
7381ee8ff9
|
@ -1,10 +1,10 @@
|
|||
import
|
||||
std/[options, os, strutils],
|
||||
confutils,
|
||||
confutils, stint,
|
||||
./types
|
||||
|
||||
export
|
||||
options
|
||||
options, stint
|
||||
|
||||
func combineForks(): string =
|
||||
for x in low(TestFork)..high(TestFork):
|
||||
|
@ -83,9 +83,10 @@ type
|
|||
name: "input.txs" }: string
|
||||
|
||||
stateReward* {.
|
||||
desc: "Mining reward. Set to 0 to disable"
|
||||
defaultValue: 0
|
||||
name: "state.reward" }: HexOrInt
|
||||
desc: "Mining reward. Set to -1 to disable"
|
||||
defaultValue: none(UInt256)
|
||||
defaultValueDesc: "-1"
|
||||
name: "state.reward" }: Option[UInt256]
|
||||
|
||||
stateChainId* {.
|
||||
desc: "ChainID to use"
|
||||
|
@ -105,6 +106,17 @@ type
|
|||
defaultValue: 3
|
||||
name: "verbosity" }: int
|
||||
|
||||
proc parseCmdArg*(T: type Option[UInt256], p: TaintedString): T =
|
||||
if p.string == "-1":
|
||||
none(UInt256)
|
||||
elif startsWith(p.string, "0x"):
|
||||
some(parse(p.string, UInt256, 16))
|
||||
else:
|
||||
some(parse(p.string, UInt256, 10))
|
||||
|
||||
proc completeCmdArg*(T: type Option[UInt256], val: TaintedString): seq[string] =
|
||||
return @[]
|
||||
|
||||
proc parseCmdArg*(T: type HexOrInt, p: TaintedString): T =
|
||||
if startsWith(p.string, "0x"):
|
||||
parseHexInt(p.string).T
|
||||
|
@ -116,6 +128,13 @@ proc completeCmdArg*(T: type HexOrInt, val: TaintedString): seq[string] =
|
|||
|
||||
proc notCmd(x: string): bool =
|
||||
if x.len == 0: return true
|
||||
|
||||
# negative number
|
||||
if x.len >= 2 and
|
||||
x[0] == '-' and
|
||||
x[1].isDigit: return true
|
||||
|
||||
# else
|
||||
x[0] != '-'
|
||||
|
||||
proc convertToNimStyle(cmds: openArray[string]): seq[string] =
|
||||
|
|
|
@ -286,6 +286,15 @@ const
|
|||
output: T8nOutput(alloc: false, result: false),
|
||||
expExitCode: ErrorConfig.int,
|
||||
),
|
||||
TestSpec(
|
||||
name : "Test state-reward -1",
|
||||
base : "testdata/3",
|
||||
input : t8nInput(
|
||||
"alloc.json", "txs.json", "env.json", "Berlin", "-1"
|
||||
),
|
||||
output: T8nOutput(alloc: true, result: true),
|
||||
expOut: "exp.json",
|
||||
),
|
||||
]
|
||||
|
||||
proc main() =
|
||||
|
|
|
@ -128,7 +128,7 @@ proc dumpTrace(txIndex: int, txHash: Hash256, traceResult: JsonNode) =
|
|||
|
||||
proc exec(ctx: var TransContext,
|
||||
vmState: BaseVMState,
|
||||
blockReward: UInt256,
|
||||
stateReward: Option[UInt256],
|
||||
header: BlockHeader): ExecOutput =
|
||||
|
||||
var
|
||||
|
@ -174,7 +174,8 @@ proc exec(ctx: var TransContext,
|
|||
)
|
||||
includedTx.add tx
|
||||
|
||||
if blockReward > 0.u256:
|
||||
if stateReward.isSome:
|
||||
let blockReward = stateReward.get()
|
||||
var mainReward = blockReward
|
||||
for uncle in ctx.env.ommers:
|
||||
var uncleReward = 8.u256 - uncle.delta.u256
|
||||
|
@ -355,7 +356,7 @@ proc transitionAction*(ctx: var TransContext, conf: T8NConf) =
|
|||
db.setupAlloc(ctx.alloc)
|
||||
db.persist(clearCache = false)
|
||||
|
||||
let res = exec(ctx, vmState, conf.stateReward.uint64.u256, header)
|
||||
let res = exec(ctx, vmState, conf.stateReward, header)
|
||||
|
||||
if vmState.hashError.len > 0:
|
||||
raise newError(ErrorMissingBlockhash, vmState.hashError)
|
||||
|
|
Loading…
Reference in New Issue