fixes regression caused by #962

This commit is contained in:
jangko 2022-02-14 21:22:39 +07:00
parent 215e9856d3
commit 6374c9f66d
No known key found for this signature in database
GPG Key ID: 31702AE10541E6B9
4 changed files with 6 additions and 6 deletions

View File

@ -30,7 +30,7 @@ proc genesisToTrie(filePath: string): HexaryTrie =
)
# TODO: this actually also creates a HexaryTrie and AccountStateDB, which we
# could skip
let header = toBlock(cn.genesis, chainDB)
let header = toGenesisHeader(chainDB)
# Trie exists already in flat db, but need to provide the root
initHexaryTrie(chainDB.db, header.stateRoot, chainDB.pruneTrie)

View File

@ -90,11 +90,11 @@ proc initDbAccounts(db: BaseChainDB): BlockHeader
# Public functions
# ------------------------------------------------------------------------------
proc toGenesisHeader*(params: NetworkParams): BlockHeader
proc toGenesisHeader*(params: NetworkParams, db = newMemoryDb()): BlockHeader
{.raises: [Defect, RlpError].} =
## Generate the genesis block header from the `params` argument value.
newBaseChainDB(
newMemoryDb(),
db = db,
id = params.config.chainID.NetworkId,
params = params,
pruneTrie = true).initDbAccounts
@ -105,7 +105,7 @@ proc toGenesisHeader*(db: BaseChainDB): BlockHeader
## fields of the argument `db` descriptor.
NetworkParams(
config: db.config,
genesis: db.genesis).toGenesisHeader
genesis: db.genesis).toGenesisHeader(db.db)
proc initializeEmptyDb*(db: BaseChainDB)
{.raises: [Defect, CatchableError].} =

View File

@ -341,7 +341,7 @@ method baseFee*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
when defined(geth):
import db/geth_db
method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base, gcsafe, raises: [Defect,CatchableError].} =
method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base, gcsafe, raises: [Defect,CatchableError,Exception].} =
var ancestorDepth = vmState.blockNumber - blockNumber - 1
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH:
return

View File

@ -328,7 +328,7 @@ method baseFee*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
when defined(geth):
import db/geth_db
method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base, gcsafe, raises: [Defect,CatchableError].} =
method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base, gcsafe, raises: [Defect,CatchableError,Exception].} =
var ancestorDepth = vmState.blockNumber - blockNumber - 1
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH:
return