Skip to content
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

Implementation of TX_INIT and TX_FINL fix #517

Open
wants to merge 25 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
25 commits
Select commit Hold shift + click to select a range
2fc0725
wip
OlivierBBB Nov 29, 2024
d9fa89a
feat: update of initialization phase
OlivierBBB Dec 1, 2024
ab1e32e
fix: make it compile
OlivierBBB Dec 1, 2024
d1240cd
feat: finalization phase update
OlivierBBB Dec 1, 2024
dcb72af
fix: make it compile
OlivierBBB Dec 1, 2024
d6cb294
fix: added lisp files for TX_FINL
OlivierBBB Dec 2, 2024
c2d3c88
Merge branch 'master' into 516-implementation-of-initialization-and-f…
OlivierBBB Dec 2, 2024
d9d41d3
Merge branch 'master' into 516-implementation-of-initialization-and-f…
OlivierBBB Dec 5, 2024
5537726
Merge branch 'master' into 516-implementation-of-initialization-and-f…
lorenzogentile404 Dec 12, 2024
c44de00
Merge branch 'master' into 516-implementation-of-initialization-and-f…
lorenzogentile404 Dec 18, 2024
76704eb
Merge branch 'master' into 516-implementation-of-initialization-and-f…
OlivierBBB Dec 20, 2024
609e56d
fix: the COINBASE address may require trimming in the TX_FINL phase
OlivierBBB Dec 20, 2024
08fda87
fix: using DOM-SUB-stamps---standard and deprecating ---finalization
OlivierBBB Dec 21, 2024
6366c43
fix: typos in row offset constants (tx-init => tx-finl)
OlivierBBB Dec 21, 2024
1f3a0ac
fix: removed redundant (old) TX_FINL constraints file
OlivierBBB Dec 21, 2024
1668ddc
fix: typos
OlivierBBB Dec 21, 2024
b173f2b
fix: parenthesis error
OlivierBBB Dec 21, 2024
155416f
fix: typo (sender-pay-for-gas -> recipient-value-reception)
OlivierBBB Dec 21, 2024
369e81c
fix: TX_INIT undoing constraints conditional to transaction failure
OlivierBBB Dec 21, 2024
d3a9d4c
fix: TX_INIT undoing constraints conditional to transaction failure
OlivierBBB Dec 21, 2024
44ced1d
fix: when to raise HUB_STAMP during TX_SKIP, TX_INIT, TX_FINL
OlivierBBB Dec 21, 2024
5b838e3
fix: TX_INIT terminates on a constraint row
OlivierBBB Dec 21, 2024
30f2283
fix: type constraints for GAS related BLOCKDATA columns
OlivierBBB Dec 21, 2024
3198995
fix: use maxUint64 as max value of ETHEREUM_GAS_LIMIT
OlivierBBB Dec 21, 2024
6c3aae0
fix: typo in SSTORAGE's r_dirtyreset definition
OlivierBBB Dec 23, 2024
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
2 changes: 2 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,9 @@ HUB := $(wildcard hub/columns/*lisp) \
$(wildcard hub/constraints/tx_skip/*lisp) \
$(wildcard hub/constraints/tx_prewarm/*lisp) \
$(wildcard hub/constraints/tx_init/*lisp) \
$(wildcard hub/constraints/tx_init/rows/*lisp) \
$(wildcard hub/constraints/tx_finl/*lisp) \
$(wildcard hub/constraints/tx_finl/rows/*lisp) \
$(wildcard hub/constraints/*lisp) \
$(wildcard hub/lookups/*lisp) \
hub/constants.lisp
Expand Down
8 changes: 4 additions & 4 deletions blockdata/columns.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -14,11 +14,11 @@
(INST :byte :display :opcode)
(COINBASE_HI :i32)
(COINBASE_LO :i128)
(BLOCK_GAS_LIMIT :i48)
(BASEFEE :i48)
(BLOCK_GAS_LIMIT :i64)
(BASEFEE :i64)
(FIRST_BLOCK_NUMBER :i48)
(REL_BLOCK :i8)
(REL_TX_NUM_MAX :i10)
(REL_BLOCK :i16)
(REL_TX_NUM_MAX :i16)
(DATA_HI :i128)
(DATA_LO :i128)
(ARG_1_HI :i128)
Expand Down
2 changes: 1 addition & 1 deletion constants/constants.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@
LINEA_DIFFICULTY 2
LINEA_MAX_NUMBER_OF_TRANSACTIONS_IN_BATCH 200
ETHEREUM_GAS_LIMIT_MINIMUM 5000
ETHEREUM_GAS_LIMIT_MAXIMUM 0xffffffffffffffffffffffffffffffff ;; maxUint64
ETHEREUM_GAS_LIMIT_MAXIMUM 0xffffffffffffffff ;; maxUint64
LINEA_GAS_LIMIT_MINIMUM 61000000
LINEA_GAS_LIMIT_MAXIMUM 2000000000
GAS_LIMIT_ADJUSTMENT_FACTOR 1024
Expand Down
7 changes: 4 additions & 3 deletions hub/constants.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@

(defconst
MULTIPLIER___STACK_STAMP 8 ;; \hubTau
MULTIPLIER___DOM_SUB_STAMPS 8 ;; \hubLambda
DOM_SUB_STAMP_OFFSET___REVERT 6 ;; \revertEpsilon
DOM_SUB_STAMP_OFFSET___SELFDESTRUCT 7 ;; \selfdestructEpsilon
MULTIPLIER___DOM_SUB_STAMPS 16 ;; \hubLambda
DOM_SUB_STAMP_OFFSET___REVERT 8 ;; \revertEpsilon
DOM_SUB_STAMP_OFFSET___FINALIZATION 9 ;; \finalizationEpsilon
DOM_SUB_STAMP_OFFSET___SELFDESTRUCT 10 ;; \selfdestructEpsilon
)
9 changes: 8 additions & 1 deletion hub/constraints/generalities/revert_data_specific.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defun (self_revert_trigger) (- (+ XAHOY (* stack/HALT_FLAG [stack/DEC_FLAG 2]))
(* XAHOY stack/HALT_FLAG [stack/DEC_FLAG 2])))
(* XAHOY stack/HALT_FLAG [stack/DEC_FLAG 2]))) ;; ""

(defconstraint recording-self-induced-revert (:perspective stack)
(if-not-zero (force-bool (self_revert_trigger))
Expand Down Expand Up @@ -112,6 +112,13 @@
sub_stamp_offset
))

;; (defun (DOM-SUB-stamps---finalization rel_offset
;; sub_offset)
;; (undoing-dom-sub-stamps rel_offset
;; TX_END_STAMP
;; DOM_SUB_STAMP_OFFSET___FINALIZATION
;; sub_offset))

(defun (selfdestruct-dom-sub-stamps relOffset) (undoing-dom-sub-stamps
relOffset
TX_END_STAMP
Expand Down
10 changes: 9 additions & 1 deletion hub/constraints/heartbeat/hub_stamp.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,15 @@
(will-inc! HUB_STAMP 1))))

(defconstraint heartbeat---hub-stamp---constancy-during-skipping-phase ()
(if-not-zero (+ TX_SKIP TX_INIT TX_FINL)
(if-not-zero TX_SKIP
(will-eq! HUB_STAMP (+ HUB_STAMP PEEK_AT_TRANSACTION))))

(defconstraint heartbeat---hub-stamp---constancy-during-initialization-phase ()
(if-not-zero TX_INIT
(will-eq! HUB_STAMP (+ HUB_STAMP PEEK_AT_CONTEXT))))

(defconstraint heartbeat---hub-stamp---constancy-during-finalization-phase ()
(if-not-zero TX_FINL
(will-eq! HUB_STAMP (+ HUB_STAMP PEEK_AT_TRANSACTION))))

(defconstraint heartbeat---hub-stamp---jumps-at-transaction-boundaries ()
Expand Down
2 changes: 1 addition & 1 deletion hub/constraints/heartbeat/transaction_phase_flags.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
(if-not-zero TX_WARM
(eq! (next (+ TX_WARM TX_INIT)) 1))
(if-not-zero TX_INIT
(if-zero PEEK_AT_TRANSACTION
(if-zero PEEK_AT_CONTEXT
(eq! (next TX_INIT) 1)
(eq! (next TX_EXEC) 1)))
(if-not-zero TX_EXEC
Expand Down
4 changes: 2 additions & 2 deletions hub/constraints/instruction-handling/sto.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -190,8 +190,8 @@
(defun (r-dirty-reset) (* (next-not-curr)
(curr-not-orig)
(next-is-orig)
(+ (* (orig-is-zero) (- GAS_CONST_G_SSET GAS_CONST_G_WARM_ACCESS))
(* (orig-not-zero) (- GAS_CONST_G_WARM_ACCESS GAS_CONST_G_SRESET)))))
(+ (* (orig-is-zero) (- GAS_CONST_G_SSET GAS_CONST_G_WARM_ACCESS))
(* (orig-not-zero) (- GAS_CONST_G_SRESET GAS_CONST_G_WARM_ACCESS)))))

(defconstraint storage-instruction---setting-the-refund (:guard (storage-instruction---no-stack-exceptions))
(eq!
Expand Down
17 changes: 17 additions & 0 deletions hub/constraints/tx_finl/peeking.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(module hub)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; X TX_FINL phase ;;
;; X.Y Introduction ;;
;; X.Y Setting the peeking flags ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defconstraint tx-finl---setting-peeking-flags
(:guard (tx-finl---standard-precondition))
(eq! 3
(+ (shift PEEK_AT_ACCOUNT tx-finl---row-offset---ACC---sender-gas-refund)
(shift PEEK_AT_ACCOUNT tx-finl---row-offset---ACC---coinbase-reward)
(shift PEEK_AT_TRANSACTION tx-finl---row-offset---TXN))))
28 changes: 28 additions & 0 deletions hub/constraints/tx_finl/rows/acc_coinbase_reward.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
(module hub)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; X TX_FINL phase ;;
;; X.Y Common constraints ;;
;; X.Y.Z Coinbase reward ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defconstraint tx-finl---account-row---coinbase-reward
(:guard (tx-finl---standard-precondition))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(begin
(account-trim-address tx-finl---row-offset---ACC---coinbase-reward ;; row offset
(tx-finl---coinbase-address-hi) ;; high part of raw, potentially untrimmed address
(tx-finl---coinbase-address-lo)) ;; low part of raw, potentially untrimmed address
;; (eq! (shift account/ADDRESS_HI tx-finl---row-offset---ACC---coinbase-reward) (tx-finl---coinbase-address-hi))
;; (eq! (shift account/ADDRESS_LO tx-finl---row-offset---ACC---coinbase-reward) (tx-finl---coinbase-address-lo))
(account-increment-balance-by tx-finl---row-offset---ACC---coinbase-reward (tx-finl---coinbase-reward))
(account-same-nonce tx-finl---row-offset---ACC---coinbase-reward)
(account-same-code tx-finl---row-offset---ACC---coinbase-reward)
(account-same-deployment-number-and-status tx-finl---row-offset---ACC---coinbase-reward)
(account-same-warmth tx-finl---row-offset---ACC---coinbase-reward)
(account-same-marked-for-selfdestruct tx-finl---row-offset---ACC---coinbase-reward)
(DOM-SUB-stamps---standard tx-finl---row-offset---ACC---coinbase-reward
1)))
25 changes: 25 additions & 0 deletions hub/constraints/tx_finl/rows/acc_sender_gas_refund.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
(module hub)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; X TX_FINL phase ;;
;; X.Y Common constraints ;;
;; X.Y.Z Sender gas refund ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;


(defconstraint tx-finl---account-row---sender-gas-refund
(:guard (tx-finl---standard-precondition))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(begin
(eq! (shift account/ADDRESS_HI tx-finl---row-offset---ACC---sender-gas-refund) (tx-finl---sender-address-hi))
(eq! (shift account/ADDRESS_LO tx-finl---row-offset---ACC---sender-gas-refund) (tx-finl---sender-address-lo))
(account-increment-balance-by tx-finl---row-offset---ACC---sender-gas-refund (tx-finl---sender-gas-refund))
(account-same-nonce tx-finl---row-offset---ACC---sender-gas-refund)
(account-same-code tx-finl---row-offset---ACC---sender-gas-refund)
(account-same-deployment-number-and-status tx-finl---row-offset---ACC---sender-gas-refund)
(account-same-warmth tx-finl---row-offset---ACC---sender-gas-refund)
(account-same-marked-for-selfdestruct tx-finl---row-offset---ACC---sender-gas-refund)
(DOM-SUB-stamps---standard tx-finl---row-offset---ACC---sender-gas-refund
0)))
17 changes: 17 additions & 0 deletions hub/constraints/tx_finl/rows/transaction.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
(module hub)

;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; X TX_FINL phase ;;
;; X.Y Common constraints ;;
;; X.Y.Z Transaction row ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconstraint tx-finl---transaction-row---justifying-TXN_DATA-predictions
(:guard (tx-finl---standard-precondition))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(begin
(eq! (shift transaction/STATUS_CODE tx-finl---row-offset---TXN) (tx-finl---transaction-success))
(eq! (shift transaction/REFUND_COUNTER_INFINITY tx-finl---row-offset---TXN) (shift REFUND_COUNTER_NEW tx-finl---row-offset---row-preceding-the-finl-phase))
(eq! (shift transaction/GAS_LEFTOVER tx-finl---row-offset---TXN) (shift GAS_NEXT tx-finl---row-offset---row-preceding-the-finl-phase))))
34 changes: 34 additions & 0 deletions hub/constraints/tx_finl/shorthands.lisp
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
(module hub)

;;;;;;;;;;;;;;;;;;;;;;;;;;;
;; ;;
;; X TX_FINL phase ;;
;; X.Y Introduction ;;
;; X.Y Shorthands ;;
;; ;;
;;;;;;;;;;;;;;;;;;;;;;;;;;;

(defconst
tx-finl---row-offset---row-preceding-the-finl-phase -1
tx-finl---row-offset---ACC---sender-gas-refund 0
tx-finl---row-offset---ACC---coinbase-reward 1
tx-finl---row-offset---TXN 2
)



(defun (tx-finl---standard-precondition) (* (shift TX_EXEC tx-finl---row-offset---row-preceding-the-finl-phase) TX_FINL))
(defun (tx-finl---transaction-success) (- 1 (shift CONTEXT_WILL_REVERT tx-finl---row-offset---row-preceding-the-finl-phase)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun (tx-finl---sender-address-hi) (shift transaction/FROM_ADDRESS_HI tx-finl---row-offset---TXN))
(defun (tx-finl---sender-address-lo) (shift transaction/FROM_ADDRESS_LO tx-finl---row-offset---TXN))
(defun (tx-finl---coinbase-address-hi) (shift transaction/COINBASE_ADDRESS_HI tx-finl---row-offset---TXN))
(defun (tx-finl---coinbase-address-lo) (shift transaction/COINBASE_ADDRESS_LO tx-finl---row-offset---TXN))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun (tx-finl---effective-gas-price) (shift transaction/GAS_PRICE tx-finl---row-offset---TXN))
(defun (tx-finl---effective-gas-refund) (shift transaction/REFUND_EFFECTIVE tx-finl---row-offset---TXN))
(defun (tx-finl---sender-gas-refund) (* (tx-finl---effective-gas-price) (tx-finl---effective-gas-refund)))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun (tx-finl---priority-fee-per-gas) (shift transaction/PRIORITY_FEE_PER_GAS tx-finl---row-offset---TXN))
(defun (tx-finl---gas-limit) (shift transaction/GAS_LIMIT tx-finl---row-offset---TXN))
(defun (tx-finl---coinbase-reward) (* (- (tx-finl---gas-limit) (tx-finl---effective-gas-refund)) (tx-finl---priority-fee-per-gas)))
Loading
Loading