Skip to content

feat: BLOBHASH opcode #672

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
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
3 changes: 3 additions & 0 deletions constants/constants.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@
EVM_INST_CHAINID 0x46
EVM_INST_SELFBALANCE 0x47
EVM_INST_BASEFEE 0x48
EVM_INST_BLOBHASH 0x49 ;; appears in Canun EIP-4844
EVM_INST_BLOBBASEFEE 0x4A ;; appears in Cancun
;; Stack, Memory, Storage and Flow Operations
EVM_INST_POP 0x50
Expand Down Expand Up @@ -230,6 +231,7 @@
GAS_CONST_ECPAIRING_PAIR 34000
GAS_CONST_BLAKE2_PER_ROUND 1
GAS_CONST_INIT_CODE_WORD 2 ;; post Shanghai EIP-3860
GAS_CONST_HASH_OPCODE_GAS 3 ;; gas cost of BLOBHASH, EIP-4844 in Cancun
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; EVM MISC ;;
Expand Down Expand Up @@ -262,6 +264,7 @@
LINEA_GAS_LIMIT_MAXIMUM 2000000000
LINEA_BLOCK_GAS_LIMIT LINEA_GAS_LIMIT_MAXIMUM
LINEA_BLOB_BASE_FEE MIN_BASE_FEE_PER_BLOB_GAS
LINEA_BLOB_PER_TRANSACTION_MAXIMUM 0
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; SIZE / LENGTH ;;
Expand Down
3 changes: 1 addition & 2 deletions hub/cancun/constraints/instruction-handling/btc.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,7 @@
(defconstraint block-data-instruction-setting-the-stack-pattern (:guard (block-data-standard-hypothesis))
(begin
(if-eq [stack/DEC_FLAG 1] 1 (stack-pattern-1-1))
(if-eq [stack/DEC_FLAG 2] 1 (stack-pattern-0-1))
(if-eq [stack/DEC_FLAG 3] 1 (stack-pattern-1-1)))) ;;TODO: this is for BLOBHASH, will be recategorize TXN family
(if-eq [stack/DEC_FLAG 2] 1 (stack-pattern-0-1))))

(defconstraint block-data-instruction-setting-NSR (:guard (block-data-standard-hypothesis))
(eq! NON_STACK_ROWS
Expand Down
21 changes: 14 additions & 7 deletions hub/cancun/constraints/instruction-handling/txn.lisp
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
(module hub)

(defun (txn-instruction---standard-precondition) (* PEEK_AT_STACK stack/TXN_FLAG (- 1 stack/SUX stack/SOX)))
(defun (txn-instruction---is-ORIGIN) [ stack/DEC_FLAG 1 ])
(defun (txn-instruction---is-GASPRICE) [ stack/DEC_FLAG 2 ])
(defun (txn-instruction---standard-precondition) (force-bin (* PEEK_AT_STACK stack/TXN_FLAG (- 1 stack/SUX stack/SOX))))
(defun (txn-instruction---is-ORIGIN) (force-bin [ stack/DEC_FLAG 1 ]))
(defun (txn-instruction---is-GASPRICE) (force-bin [ stack/DEC_FLAG 2 ]))
(defun (txn-instruction---is-BLOBHASH) (force-bin [ stack/DEC_FLAG 3 ]))
(defun (txn-instruction---result-hi) [ stack/STACK_ITEM_VALUE_HI 4 ])
(defun (txn-instruction---result-lo) [ stack/STACK_ITEM_VALUE_LO 4 ]) ;; ""

Expand All @@ -14,7 +15,10 @@
(defconstraint txn-instruction---setting-the-stack-pattern
(:guard (txn-instruction---standard-precondition))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(stack-pattern-0-1))
(begin
(if-eq (txn-instruction---is-ORIGIN) 1 (stack-pattern-0-1))
(if-eq (txn-instruction---is-GASPRICE) 1 (stack-pattern-0-1))
(if-eq (txn-instruction---is-BLOBHASH) 1 (stack-pattern-1-1))))

(defconstraint txn-instruction---setting-NSR
(:guard (txn-instruction---standard-precondition))
Expand All @@ -39,9 +43,12 @@
(begin
(if-zero XAHOY
(begin
(if-not-zero (txn-instruction---is-ORIGIN)
(if-eq (txn-instruction---is-ORIGIN) 1
(begin (eq! (txn-instruction---result-hi) (shift transaction/FROM_ADDRESS_HI roff---txn-instruction---transaction-row))
(eq! (txn-instruction---result-lo) (shift transaction/FROM_ADDRESS_LO roff---txn-instruction---transaction-row))))
(if-not-zero (txn-instruction---is-GASPRICE)
(if-eq (txn-instruction---is-GASPRICE) 1
(begin (eq! (txn-instruction---result-hi) 0)
(eq! (txn-instruction---result-lo) (shift transaction/GAS_PRICE roff---txn-instruction---transaction-row))))))))
(eq! (txn-instruction---result-lo) (shift transaction/GAS_PRICE roff---txn-instruction---transaction-row))))
(if-eq (txn-instruction---is-BLOBHASH) 1
(begin (eq! (txn-instruction---result-hi) 0)
(eq! (txn-instruction---result-lo) 0)))))))
Loading