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