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 9 commits into
base: master
Choose a base branch
from
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
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
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))))
25 changes: 25 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,25 @@
(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
(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---finalization tx-finl---row-offset---ACC---coinbase-reward
0)))
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---finalization tx-finl---row-offset---ACC---sender-gas-refund
1)))
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-init---row-offset---TXN))
(defun (tx-finl---sender-address-lo) (shift transaction/FROM_ADDRESS_LO tx-init---row-offset---TXN))
(defun (tx-finl---coinbase-address-hi) (shift transaction/COINBASE_ADDRESS_HI tx-init---row-offset---TXN))
(defun (tx-finl---coinbase-address-lo) (shift transaction/COINBASE_ADDRESS_LO tx-init---row-offset---TXN))
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;
(defun (tx-finl---effective-gas-price) (shift transaction/GAS_PRICE tx-init---row-offset---TXN))
(defun (tx-finl---effective-gas-refund) (shift transaction/REFUND_EFFECTIVE tx-init---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-init---row-offset---TXN))
(defun (tx-finl---gas-limit) (shift transaction/GAS_LIMIT tx-init---row-offset---TXN))
(defun (tx-finl---coinbase-reward) (* (- (tx-finl---gas-limit) (tx-finl---effective-gas-price)) (tx-finl---priority-fee-per-gas)))
Loading
Loading