Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions blockdata/blockdata.asm
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
;; BLOCKDATA module

;; The BLOCKDATA module is responsible for storing block-constant values:
;; 1. COINBASE
;; 2. TIMESTAMP
;; 3. NUMBER
;; 4. PREVRANDAO
;; 5. GASLIMIT
;; 6. CHAINID
;; 7. BASEFEE
;; 8. BLOBBASEFEE

pub fn bin(INST=0x43 u8, BLOCK_NUMBER u32, VALUE u256, ARGUMENT_1 u256) -> (VALUE_NEXT_BLOCK u256) {
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Duplicate function name bin causes naming conflict

The function is named bin, but there's already a pub fn bin defined in bin/bin.zkasm. This creates a naming collision that could cause conflicts when both modules are used together. The function in the blockdata module likely intended a different name such as blockdata.

Fix in Cursor Fix in Web


if INST==EVM_INST_COINBASE goto coinbase
if INST==EVM_INST_TIMESTAMP goto timestamp ;;TODO
if INST==EVM_INST_NUMBER goto number
if INST==EVM_INST_PREVRANDAO goto prevrandao
if INST==EVM_INST_GASLIMIT goto gaslimit
if INST==EVM_INST_CHAINID goto chainid
if INST==EVM_INST_BASEFEE goto basefee
if INST==EVM_INST_BLOBBASEFEE goto blobbasefee
goto exit_f

var b u1

exit_f:
fail
coinbase:
;; nothing to do
return
timestamp:
;; need to prove a (strict) increase of timestamp
var tmp u256
b, tmp = VALUE_NEXT_BLOCK - VALUE - 1
if b == 1 exit_f
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Missing goto keyword in conditional jump statements

The conditional jump statements are missing the goto keyword. Throughout the codebase, the established pattern is if CONDITION goto TARGET (e.g., in bin/bin.zkasm, euc/euc.zkasm). Lines 36, 40, and 54 use if CONDITION exit_f without goto, which is inconsistent and likely incorrect syntax that may cause parsing errors or unintended behavior.

Additional Locations (2)

Fix in Cursor Fix in Web

return
number:
;; prove the value of BLOCK_NUMBER
if BLOCK_NUMBER != VALUE exit_f
;; block number increases by 1
b, VALUE_NEXT_BLOCK = VALUE + 1
if b != 0
exit_f
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Bug: Conditional statement incorrectly split across two lines

The conditional statement if b != 0 on line 43 is separated from exit_f on line 44. In this assembly language, conditionals appear on a single line as if CONDITION goto TARGET. The current formatting likely causes exit_f to execute unconditionally (or cause a parse error), meaning the number handler will always fail even when valid, or the if statement has no effect.

Fix in Cursor Fix in Web

return
prevrandao:
;; nothing to prove
return
gaslimit:
;; TODO
return
chainid:
;; prove constancy
if VALUE_NEXT_BLOCK != VALUE exit_f
return
basefee:
;; TODO
return
blobbasefee:
;; TODO
return
}

9 changes: 9 additions & 0 deletions constants/evm.zkasm
Original file line number Diff line number Diff line change
Expand Up @@ -20,11 +20,20 @@ const EVM_INST_SHL = 0x1b
const EVM_INST_SHR = 0x1c
const EVM_INST_SAR = 0x1d
const EVM_INST_CLZ = 0x1e
const EVM_INST_COINBASE = 0x41
const EVM_INST_TIMESTAMP = 0x42
const EVM_INST_NUMBER = 0x43
const EVM_INST_PREVRANDAO = 0x44
const EVM_INST_GASLIMIT = 0x45
const EVM_INST_CHAINID = 0x46
const EVM_INST_BASEFEE = 0x48
const EVM_INST_BLOBBASEFEE = 0x4A
const EVM_INST_CREATE = 0xF0
const EVM_INST_CALL = 0xF1
const EVM_INST_CALLCODE = 0xF2
const EVM_INST_CREATE2 = 0xF5


;; =============================================================================
;; Wcp
;; =============================================================================
Expand Down
Loading