add "--threads:on" to tests and main binary

- some "funcs" were no longer considered side-effect free, so I made
  them procs
- added {.base.} to some base methods to avoid a deprecation warning
This commit is contained in:
Ștefan Talpalaru 2019-01-15 15:02:25 +01:00 committed by zah
parent 9b33aeff6b
commit a431ceed11
8 changed files with 20 additions and 16 deletions

View File

@ -533,7 +533,8 @@ proc initConfiguration(): NimbusConfiguration =
result.net.maxPendingPeers = 0 result.net.maxPendingPeers = 0
result.net.bindPort = 30303'u16 result.net.bindPort = 30303'u16
result.net.discPort = 30303'u16 result.net.discPort = 30303'u16
result.net.ident = NimbusIdent {.gcsafe.}:
result.net.ident = NimbusIdent
const dataDir = getDefaultDataDir() const dataDir = getDefaultDataDir()

View File

@ -1,4 +1,5 @@
-d:chronicles_line_numbers -d:chronicles_line_numbers
-d:"chronicles_sinks=textblocks" -d:"chronicles_sinks=textblocks"
-d:nimDebugDlOpen -d:nimDebugDlOpen
--threads:on

View File

@ -10,20 +10,20 @@ proc newChain*(db: BaseChainDB): Chain =
result.new result.new
result.db = db result.db = db
method genesisHash*(c: Chain): KeccakHash = method genesisHash*(c: Chain): KeccakHash {.gcsafe.} =
c.db.getBlockHash(0.toBlockNumber) c.db.getBlockHash(0.toBlockNumber)
method getBlockHeader*(c: Chain, b: HashOrNum, output: var BlockHeader): bool = method getBlockHeader*(c: Chain, b: HashOrNum, output: var BlockHeader): bool {.gcsafe.} =
case b.isHash case b.isHash
of true: of true:
c.db.getBlockHeader(b.hash, output) c.db.getBlockHeader(b.hash, output)
else: else:
c.db.getBlockHeader(b.number, output) c.db.getBlockHeader(b.number, output)
method getBestBlockHeader*(c: Chain): BlockHeader = method getBestBlockHeader*(c: Chain): BlockHeader {.gcsafe.} =
c.db.getCanonicalHead() c.db.getCanonicalHead()
method getSuccessorHeader*(c: Chain, h: BlockHeader, output: var BlockHeader): bool = method getSuccessorHeader*(c: Chain, h: BlockHeader, output: var BlockHeader): bool {.gcsafe.} =
let n = h.blockNumber + 1 let n = h.blockNumber + 1
c.db.getBlockHeader(n, output) c.db.getBlockHeader(n, output)

View File

@ -14,7 +14,8 @@ import
proc setupCommonRPC*(server: RpcServer) = proc setupCommonRPC*(server: RpcServer) =
server.rpc("web3_clientVersion") do() -> string: server.rpc("web3_clientVersion") do() -> string:
result = NimbusIdent {.gcsafe.}:
result = NimbusIdent
server.rpc("web3_sha3") do(data: HexDataStr) -> string: server.rpc("web3_sha3") do(data: HexDataStr) -> string:
var rawdata = nimcrypto.fromHex(data.string) var rawdata = nimcrypto.fromHex(data.string)

View File

@ -85,7 +85,7 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) =
let vmState = newBaseVMState(header, chain) let vmState = newBaseVMState(header, chain)
result = vmState.readOnlyStateDB() result = vmState.readOnlyStateDB()
func accountDbFromTag(tag: string, readOnly = true): ReadOnlyStateDB = proc accountDbFromTag(tag: string, readOnly = true): ReadOnlyStateDB =
result = getAccountDb(chain.headerFromTag(tag)) result = getAccountDb(chain.headerFromTag(tag))
proc getBlockBody(hash: KeccakHash): BlockBody = proc getBlockBody(hash: KeccakHash): BlockBody =

View File

@ -19,7 +19,7 @@ func toHash*(value: array[32, byte]): Hash256 {.inline.} =
func toHash*(value: EthHashStr): Hash256 {.inline.} = func toHash*(value: EthHashStr): Hash256 {.inline.} =
result = hexToPaddedByteArray[32](value.string).toHash result = hexToPaddedByteArray[32](value.string).toHash
func headerFromTag*(chain: BaseChainDB, blockTag: string): BlockHeader = proc headerFromTag*(chain: BaseChainDB, blockTag: string): BlockHeader =
let tag = blockTag.toLowerAscii let tag = blockTag.toLowerAscii
case tag case tag
of "latest": result = chain.getCanonicalHead() of "latest": result = chain.getCanonicalHead()
@ -31,4 +31,4 @@ func headerFromTag*(chain: BaseChainDB, blockTag: string): BlockHeader =
# Raises are trapped and wrapped in JSON when returned to the user. # Raises are trapped and wrapped in JSON when returned to the user.
tag.validateHexQuantity tag.validateHexQuantity
let blockNum = stint.fromHex(UInt256, tag) let blockNum = stint.fromHex(UInt256, tag)
result = chain.getBlockHeader(blockNum) result = chain.getBlockHeader(blockNum)

View File

@ -39,25 +39,25 @@ proc newBaseVMState*(header: BlockHeader, chainDB: BaseChainDB, tracerFlags: set
proc stateRoot*(vmState: BaseVMState): Hash256 = proc stateRoot*(vmState: BaseVMState): Hash256 =
vmState.blockHeader.stateRoot vmState.blockHeader.stateRoot
method blockhash*(vmState: BaseVMState): Hash256 = method blockhash*(vmState: BaseVMState): Hash256 {.base, gcsafe.} =
vmState.blockHeader.hash vmState.blockHeader.hash
method coinbase*(vmState: BaseVMState): EthAddress = method coinbase*(vmState: BaseVMState): EthAddress {.base, gcsafe.} =
vmState.blockHeader.coinbase vmState.blockHeader.coinbase
method timestamp*(vmState: BaseVMState): EthTime = method timestamp*(vmState: BaseVMState): EthTime {.base, gcsafe.} =
vmState.blockHeader.timestamp vmState.blockHeader.timestamp
method blockNumber*(vmState: BaseVMState): BlockNumber = method blockNumber*(vmState: BaseVMState): BlockNumber {.base, gcsafe.} =
vmState.blockHeader.blockNumber vmState.blockHeader.blockNumber
method difficulty*(vmState: BaseVMState): UInt256 = method difficulty*(vmState: BaseVMState): UInt256 {.base, gcsafe.} =
vmState.blockHeader.difficulty vmState.blockHeader.difficulty
method gasLimit*(vmState: BaseVMState): GasInt = method gasLimit*(vmState: BaseVMState): GasInt {.base, gcsafe.} =
vmState.blockHeader.gasLimit vmState.blockHeader.gasLimit
method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 = method getAncestorHash*(vmState: BaseVMState, blockNumber: BlockNumber): Hash256 {.base, gcsafe.} =
var ancestorDepth = vmState.blockHeader.blockNumber - blockNumber - 1 var ancestorDepth = vmState.blockHeader.blockNumber - blockNumber - 1
if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH or ancestorDepth < 0: if ancestorDepth >= constants.MAX_PREV_HEADER_DEPTH or ancestorDepth < 0:
return return

View File

@ -1,3 +1,4 @@
-d:chronicles_line_numbers -d:chronicles_line_numbers
-d:"chronicles_sinks=textblocks" -d:"chronicles_sinks=textblocks"
--threads:on