Skip to content

Conversation

@rakita
Copy link
Member

@rakita rakita commented Jan 21, 2026

Summary

  • Implement EIP-7843 SLOTNUM opcode (0x4B) that returns the slot number for the current block
  • The opcode is gated behind the AMSTERDAM hardfork
  • Gas cost: 2 (aligned with similar base-level opcodes like BASEFEE and BLOBBASEFEE)

Changes

  • Add SLOTNUM opcode constant at 0x4B in bytecode
  • Add slot_num: u64 field to BlockEnv struct
  • Add slot_num() method to Block trait with default returning 0
  • Add slot_num() method to Host trait returning U256
  • Implement slot_num instruction in block_info.rs
  • Add instruction to dispatch table with gas cost of 2

EIP Reference

https://eips.ethereum.org/EIPS/eip-7843

Test plan

  • All existing tests pass (362 tests)
  • Clippy passes
  • Code formatted

Add the SLOTNUM opcode (0x4B) that returns the slot number for the
current block as specified in EIP-7843. The slot number is passed
from the consensus layer via the execution payload.

Changes:
- Add SLOTNUM opcode constant at 0x4B in bytecode
- Add slot_num field to BlockEnv struct
- Add slot_num method to Block trait with default returning 0
- Add slot_num method to Host trait
- Implement slot_num instruction gated behind AMSTERDAM hardfork
- Gas cost: 2 (aligned with similar base-level opcodes)
@codspeed-hq
Copy link

codspeed-hq bot commented Jan 21, 2026

CodSpeed Performance Report

Merging this PR will not alter performance

Comparing slotnum (417a0dc) with main (7ccf633)

Summary

✅ 173 untouched benchmarks

@rakita rakita merged commit 26785fc into main Jan 21, 2026
31 checks passed
@github-actions github-actions bot mentioned this pull request Jan 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants