fix t8n 0-touch reward on pre EIP150 networks
This commit is contained in:
parent
505091597a
commit
05584a21b9
|
@ -84,7 +84,7 @@ type
|
|||
|
||||
stateReward* {.
|
||||
desc: "Mining reward. Set to -1 to disable"
|
||||
defaultValue: none(UInt256)
|
||||
defaultValue: some(0.u256)
|
||||
defaultValueDesc: "-1"
|
||||
name: "state.reward" }: Option[UInt256]
|
||||
|
||||
|
|
|
@ -56,7 +56,7 @@ The following options are available:
|
|||
extension is '.rlp', then the data is interpreted as an RLP list of signed
|
||||
transactions. The '.rlp' format is identical to the output.body format.
|
||||
[=txs.json].
|
||||
--state.reward Mining reward. Set to 0 to disable [=0].
|
||||
--state.reward Mining reward. Set to -1 to disable [=0].
|
||||
--state.chainid ChainID to use [=1].
|
||||
--state.fork Name of ruleset to use. [=GrayGlacier].
|
||||
- Frontier.
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
import
|
||||
std/[json, strutils, times, tables, os],
|
||||
std/[json, strutils, times, tables, os, sets],
|
||||
eth/[rlp, trie],
|
||||
stint, chronicles, stew/results,
|
||||
"."/[config, types, helpers],
|
||||
|
@ -176,7 +176,7 @@ proc exec(ctx: var TransContext,
|
|||
)
|
||||
includedTx.add tx
|
||||
|
||||
if stateReward.isSome:
|
||||
if stateReward.isSome and stateReward.get >= 0:
|
||||
let blockReward = stateReward.get()
|
||||
var mainReward = blockReward
|
||||
for uncle in ctx.env.ommers:
|
||||
|
@ -191,6 +191,18 @@ proc exec(ctx: var TransContext,
|
|||
db.addBalance(ctx.env.currentCoinbase, mainReward)
|
||||
db.persist(clearCache = false)
|
||||
|
||||
let miner = ctx.env.currentCoinbase
|
||||
vmState.mutateStateDB:
|
||||
if miner in vmState.selfDestructs:
|
||||
db.deleteAccount miner
|
||||
if vmState.com.forkGTE(Spurious):
|
||||
# EIP158/161 state clearing
|
||||
if db.accountExists(miner) and db.isEmptyAccount(miner):
|
||||
db.deleteAccount(miner)
|
||||
# do not clear cache, we need the cache when constructing
|
||||
# post state
|
||||
db.persist(clearCache = false)
|
||||
|
||||
let stateDB = vmState.stateDB
|
||||
stateDB.postState(result.alloc)
|
||||
result.result = ExecutionResult(
|
||||
|
@ -232,7 +244,6 @@ proc setupAlloc(stateDB: AccountsCache, alloc: GenesisAlloc) =
|
|||
method getAncestorHash(vmState: TestVMState; blockNumber: BlockNumber): Hash256 {.gcsafe.} =
|
||||
# we can't raise exception here, it'll mess with EVM exception handler.
|
||||
# so, store the exception for later using `hashError`
|
||||
|
||||
let num = blockNumber.truncate(uint64)
|
||||
var h = Hash256()
|
||||
if vmState.blockHashes.len == 0:
|
||||
|
|
Loading…
Reference in New Issue