This repository was archived by the owner on Jan 9, 2025. It is now read-only.
This repository was archived by the owner on Jan 9, 2025. It is now read-only.
bug: blockHash()
reverts with error for block.number-1
#1605
Closed
Description
Bug Report
Kakarot version
v0.9.6
Current behavior
Calculating blockHash
for previous block reverts with error:
execution reverted: Provider errror StarknetError(ContractError(ContractErrorData { revert_error: "Error at pc=0:49:\nGot an exception while executing a hint: Execution failed. Failure reason: 0x426c6f636b206e756d626572206f7574206f662072616e6765 ('Block number out of range').\nCairo traceback (most recent call last):\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23794)\nUnknown location (pc=0:22982)\nUnknown location (pc=0:9986)\nUnknown location (pc=0:10171)\nUnknown location (pc=0:5927)\n" })).
Expected behavior
It should return blockhash in bytes32
Steps to reproduce
- Copy and paste the following contract in Remix or any contract tooling of your choice:
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;
contract TestBlockNumber {
function getPreviousBlockHash() public view returns (bytes32) {
return blockhash(block.number - 1);
}
function getCurrentBlockHash() public view returns (bytes32) {
return blockhash(block.number);
}
}
- Deploy the contract on kakarot starknet sepolia
- Call
getCurrentBlockHash()
--- it will return valid hash - Call
getPreviousBlockHash()
--- it will revert with error:
execution reverted: Provider errror StarknetError(ContractError(ContractErrorData { revert_error: "Error at pc=0:49:\nGot an exception while executing a hint: Execution failed. Failure reason: 0x426c6f636b206e756d626572206f7574206f662072616e6765 ('Block number out of range').\nCairo traceback (most recent call last):\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23796)\nUnknown location (pc=0:23794)\nUnknown location (pc=0:22982)\nUnknown location (pc=0:9986)\nUnknown location (pc=0:10171)\nUnknown location (pc=0:5927)\n" })).
Metadata
Metadata
Assignees
Labels
No labels