diff --git a/nimbus/db/db_chain.nim b/nimbus/db/db_chain.nim index bba3a3c6f..706a87c8c 100644 --- a/nimbus/db/db_chain.nim +++ b/nimbus/db/db_chain.nim @@ -107,7 +107,7 @@ proc persistTransactions*(self: BaseChainDB, blockNumber: BlockNumber, transacti for idx, tx in transactions: let encodedTx = rlp.encode(tx).toRange - txHash = keccak(encodedTx.toOpenArray) + txHash = keccakHash(encodedTx.toOpenArray) txKey: TransactionKey = (blockNumber, idx) trie.put(rlp.encode(idx).toRange, encodedTx) self.db.put(transactionHashToBlockKey(txHash).toOpenArray, rlp.encode(txKey)) @@ -127,7 +127,7 @@ iterator getBlockTransactionHashes(self: BaseChainDB, blockHeader: BlockHeader): ## Returns an iterable of the transaction hashes from th block specified ## by the given block header. for encodedTx in self.getBlockTransactionData(blockHeader.txRoot): - yield keccak(encodedTx.toOpenArray) + yield keccakHash(encodedTx.toOpenArray) proc getBlockBody*(self: BaseChainDB, blockHash: Hash256, output: var BlockBody): bool = var header: BlockHeader @@ -247,7 +247,7 @@ proc persistUncles*(self: BaseChainDB, uncles: openarray[BlockHeader]): Hash256 ## Persists the list of uncles to the database. ## Returns the uncles hash. let enc = rlp.encode(uncles) - result = keccak(enc) + result = keccakHash(enc) self.db.put(genericHashKey(result).toOpenArray, enc) #proc persistBlockToDb*(self: BaseChainDB; blk: Block): ValidationResult = diff --git a/nimbus/db/state_db.nim b/nimbus/db/state_db.nim index 3bf8fb110..b65da25dc 100644 --- a/nimbus/db/state_db.nim +++ b/nimbus/db/state_db.nim @@ -115,7 +115,7 @@ proc setStorage*(db: var AccountStateDB, var triedb = HexaryTrie(db.trie).db # slotHash can be obtained from accountTrie.put? - slotHash = keccak(slot.toByteArrayBE) + slotHash = keccakHash(slot.toByteArrayBE) triedb.put(slotHashToSlotKey(slotHash.data).toOpenArray, rlp.encode(slot)) account.storageRoot = accountTrie.rootHash @@ -165,7 +165,7 @@ proc setCode*(db: AccountStateDB, address: EthAddress, code: ByteRange) = # also use JournalDB to revert state trie let - newCodeHash = keccak code.toOpenArray + newCodeHash = keccakHash(code.toOpenArray) triedb = HexaryTrie(db.trie).db if code.len != 0: diff --git a/nimbus/rpc/p2p.nim b/nimbus/rpc/p2p.nim index 1795fc8a6..024fada9c 100644 --- a/nimbus/rpc/p2p.nim +++ b/nimbus/rpc/p2p.nim @@ -376,7 +376,7 @@ proc setupEthRpc*(node: EthereumNode, chain: BaseChainDB, rpcsrv: RpcServer) = for i in 0 ..< blockBody.uncles.len: rawData[startIdx .. startIdx + 32] = blockBody.uncles[i].hash.data startIdx += 32 - result.sha3Uncles = keccak(rawData) + result.sha3Uncles = keccakHash(rawData) result.logsBloom = some(header.bloom) result.transactionsRoot = header.txRoot diff --git a/nimbus/utils.nim b/nimbus/utils.nim index 6ee50d693..9adc756b0 100644 --- a/nimbus/utils.nim +++ b/nimbus/utils.nim @@ -14,11 +14,11 @@ template calcTxRoot*(transactions: openArray[Transaction]): Hash256 = template calcReceiptRoot*(receipts: openArray[Receipt]): Hash256 = calcRootHash(receipts) -func keccak*(value: openarray[byte]): Hash256 {.inline.} = +func keccakHash*(value: openarray[byte]): Hash256 {.inline.} = keccak256.digest value func generateAddress*(address: EthAddress, nonce: AccountNonce): EthAddress = - result[0..19] = keccak(rlp.encodeList(address, nonce)).data.toOpenArray(12, 31) + result[0..19] = keccakHash(rlp.encodeList(address, nonce)).data.toOpenArray(12, 31) func hash*(b: BlockHeader): Hash256 {.inline.} = rlpHash(b) diff --git a/premix/hunter.nim b/premix/hunter.nim index f7b31ffca..3ae4dd778 100644 --- a/premix/hunter.nim +++ b/premix/hunter.nim @@ -11,7 +11,7 @@ const proc store(memoryDB: TrieDatabaseRef, branch: JsonNode) = for p in branch: let rlp = hexToSeqByte(p.getStr) - let hash = keccak(rlp) + let hash = keccakHash(rlp) memoryDB.put(hash.data, rlp) proc parseAddress(address: string): EthAddress = diff --git a/tests/test_generalstate_json.nim b/tests/test_generalstate_json.nim index eb30c662e..5f741c9aa 100644 --- a/tests/test_generalstate_json.nim +++ b/tests/test_generalstate_json.nim @@ -16,7 +16,7 @@ import ../nimbus/db/[db_chain, state_db] proc hashLogEntries(logs: seq[Log]): string = - toLowerAscii("0x" & $keccak(rlp.encode(logs))) + toLowerAscii("0x" & $keccakHash(rlp.encode(logs))) proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) diff --git a/tests/test_vm_json.nim b/tests/test_vm_json.nim index f951f5a23..64a666c84 100644 --- a/tests/test_vm_json.nim +++ b/tests/test_vm_json.nim @@ -17,7 +17,7 @@ import ../nimbus/db/[db_chain, state_db] proc hashLogEntries(logs: seq[Log]): string = - toLowerAscii("0x" & $keccak(rlp.encode(logs))) + toLowerAscii("0x" & $keccakHash(rlp.encode(logs))) proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) @@ -32,7 +32,7 @@ proc testFixture(fixtures: JsonNode, testStatusIMPL: var TestStatus) = break let fenv = fixture["env"] - var emptyRlpHash = keccak(rlp.encode("")) + var emptyRlpHash = keccakHash(rlp.encode("")) let header = BlockHeader( coinbase: fenv{"currentCoinbase"}.getStr.parseAddress, difficulty: fromHex(UInt256, fenv{"currentDifficulty"}.getStr),