Skip to content
This repository has been archived by the owner on Jan 8, 2025. It is now read-only.

feat: implement 0x40 - BlockHash Opcode #149

Closed
Eikix opened this issue Aug 22, 2023 · 3 comments · Fixed by #435
Closed

feat: implement 0x40 - BlockHash Opcode #149

Eikix opened this issue Aug 22, 2023 · 3 comments · Fixed by #435
Assignees
Labels
enhancement New feature or request opcode Implementation of an opcode smart-contract-logic A specific type of opcode that requires smart contract logic as opposed to pure cairo

Comments

@Eikix
Copy link
Member

Eikix commented Aug 22, 2023

SinceGroup
FrontierBlock Information

Index 1 is top of the stack. See PUSH.

Stack input

  1. blockNumber: block number to get the hash from. Valid range is the last 256 blocks (not including the current one). Current block number can be queried with NUMBER.

Stack output

  1. hash: hash of the chosen block, or 0 if the block number is not in the valid range.

Examples

InputOutput
15994235450x29045A592007D0C246EF02C2223570DA9522D0CF0F73282C79A1BC8F0BB2C238

Error cases

The state changes done by the current context are reverted in those cases:

  • Not enough gas.
  • Not enough values on the stack.
@Eikix Eikix added enhancement New feature or request no-stale smart-contract-logic A specific type of opcode that requires smart contract logic as opposed to pure cairo labels Aug 22, 2023
@github-project-automation github-project-automation bot moved this to 🆕 Backlog in Kakarot on Starknet Aug 22, 2023
@Eikix Eikix added opcode Implementation of an opcode and removed no-stale labels Aug 23, 2023
@Eikix Eikix added this to the Kakarot Cairo Migration milestone Aug 29, 2023
@Eikix
Copy link
Member Author

Eikix commented Sep 8, 2023

Important update: we are gathering some bugs in the Kakarot v0 codebase, we need to make sure each issue and each PR in Kakarot-ssj is aware of the lists of known bugs. Look at this link everytime you take an issue and check your issue isn't targeted by a known bug.

@Eikix
Copy link
Member Author

Eikix commented Sep 8, 2023

Important update: we are gathering some bugs in the Kakarot v0 codebase, we need to make sure each issue and each PR in Kakarot-ssj is aware of the lists of known bugs. Look at this tracking issue everytime you take an issue and check your issue isn't targeted by a known bug. Will add this reminder in many places to make sure we keep track of known bugs.

@Eikix
Copy link
Member Author

Eikix commented Oct 18, 2023

As per
https://docs.starknet.io/documentation/architecture_and_concepts/Smart_Contracts/system-calls-cairo1/#get_block_hash

What should we do for this ~10 block lag?

My proposal:
Start by implementing the function using the syscall, as it's the most straightforward way.
Then for the N-10 to N problem, we can manage using error handling and some hook calling to the sequencer (madara?) -> longer term

@Eikix Eikix self-assigned this Oct 18, 2023
@Eikix Eikix moved this from 🆕 Backlog to 🏗 In progress in Kakarot on Starknet Oct 18, 2023
@Eikix Eikix mentioned this issue Oct 18, 2023
9 tasks
@Eikix Eikix moved this from 🏗 In progress to 👀 In review in Kakarot on Starknet Oct 18, 2023
@github-project-automation github-project-automation bot moved this from 👀 In review to ✅ Done in Kakarot on Starknet Oct 19, 2023
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request opcode Implementation of an opcode smart-contract-logic A specific type of opcode that requires smart contract logic as opposed to pure cairo
Projects
No open projects
Archived in project
Development

Successfully merging a pull request may close this issue.

1 participant