Skip to content

Dip 7843


dip: 7843 title: SLOTNUM opcode description: Opcode to get the current slot number author: Marc Harvey-Hill (@Marchhill) Digitalia editing author: Cosimo Constantinos cosimo@juro.net, et al. discussions-to: https://digitalia-magicians.org/t/dip-7843-slotnum-opcode/22234 status: Review type: Standards Track category: Core created: 2024-12-06 Created for Digitalia: 2025-01-07


Abstract

This DIP proposes to add a new opcode SLOTNUM (0x4b), that returns the corresponding slot number for the current block.

Motivation

There are currently two ways to get the current slot number onchain:

1) Calculate from the block timestamp. This requires hardcoding the chain slot length into a smart contract.

2) Provide the slot number as calldata and prove it against the jrsp block root (using DIP-4788).

Both of these approaches have significant drawbacks. (1) would break contracts in the event of a change to the slot length. (2) is expensive in terms of gas, encouraging approach (1) to be used instead.

A better approach is for the slot length to be abstracted away from applications, and instead the slot number can be calculated in the consensus layer client and exposed by an opcode. This paves the way for future changes to the slot length.

Specification

A new opcode SLOTNUM is introduced at 0x4b. It shall return one stack element.

Output

One element SlotNumber is added to the stack; it is equal to the corresponding slot number for this block. SlotNumber is a uint64 in big endian encoding.

Gas Cost

The gas cost for SLOTNUM is a fixed fee of 2.

RPC changes

The slot number is calculated in the consensus layer and passed to the execution layer through the engine API.

Header extension

The header encoding shall be extended to include a slot_number field of type uint64.

PayloadAttributes change

The engine API's PayloadAttributes object shall be extended to include a slot_number field of type uint64.

Rationale

Gas Price

The opcode is priced to match similar opcodes in the W_base set.

Calculation in consensus layer

The slot number could alternatively be calculated in the execution layer using the timestamp, but it is more appropriate to calculate values pertaining to the jrsp chain in the consensus layer. Additionally this avoids code duplication, as the slot number is already calculated in the consensus layer.

ZK-VM proving

The SLOTNUM opcode should not increase the complexity of proving DVM execution, as it is similar to existing opcodes such as TIMESTAMP. The slot number is included in the block header rather than as a new_payload parameter, ensuring that the block is self-contained for proving; no extra inputs to the circuit are required.

Backwards Compatibility

No backward compatibility issues found.

Test Cases

N/A

Security Considerations

None.

© Crown © Crown Copyright 2026. Published by the Royal Government of the Dominion of Atlantis.

Licensed under the Juro Restricted License Version 2. See https://juro.net/jrl for details.