-
Notifications
You must be signed in to change notification settings - Fork 15
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
RETURNDATACOPY must always load the current execution context (#449)
- Loading branch information
1 parent
7c4b705
commit 9c78cc9
Showing
9 changed files
with
399 additions
and
428 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
21 changes: 21 additions & 0 deletions
21
hub/constraints/instruction-handling/copy/calldatacopy.lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
(module hub) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; ;; | ||
;; X.Y.4 Specifics for CALLDATACOPY ;; | ||
;; ;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
(defconstraint copy-instruction---CALLDATACOPY---setting-the-gas-cost (:guard (copy-instruction---standard-CALLDATACOPY)) | ||
(begin (if-not-zero stack/MXPX | ||
(vanishes! GAS_COST)) | ||
(if-not-zero stack/OOGX | ||
(eq! GAS_COST (+ stack/STATIC_GAS (copy-instruction---MXP-memory-expansion-gas)))) | ||
(if-zero XAHOY | ||
(eq! GAS_COST (+ stack/STATIC_GAS (copy-instruction---MXP-memory-expansion-gas)))))) | ||
|
||
(defconstraint copy-instruction---CALLDATACOPY---setting-context-row---exceptional-case (:guard (copy-instruction---standard-CALLDATACOPY)) | ||
(if-not-zero XAHOY | ||
(execution-provides-empty-return-data ROW_OFFSET_CALLDATACOPY_CONTEXT_ROW) | ||
(read-context-data ROW_OFFSET_CALLDATACOPY_CONTEXT_ROW CONTEXT_NUMBER))) | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,39 @@ | ||
(module hub) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; ;; | ||
;; X.Y.6 Specifics for CODECOPY ;; | ||
;; ;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
(defconstraint copy-instruction---CODECOPY---setting-the-gas-cost (:guard (copy-instruction---standard-CODECOPY)) | ||
(begin (if-not-zero stack/MXPX | ||
(vanishes! GAS_COST)) | ||
(if-not-zero stack/OOGX | ||
(eq! GAS_COST (+ stack/STATIC_GAS (copy-instruction---MXP-memory-expansion-gas)))) | ||
(if-zero XAHOY | ||
(eq! GAS_COST (+ stack/STATIC_GAS (copy-instruction---MXP-memory-expansion-gas)))))) | ||
|
||
(defconstraint copy-instruction---CODECOPY---setting-the-context-row---exceptional-case (:guard (copy-instruction---standard-CODECOPY)) | ||
(if-not-zero XAHOY | ||
(execution-provides-empty-return-data ROW_OFFSET_CODECOPY_XAHOY_CONTEXT_ROW))) | ||
|
||
(defconstraint copy-instruction---CODECOPY---setting-the-context-row-unexceptional-case (:guard (copy-instruction---standard-CODECOPY)) | ||
(if-zero XAHOY | ||
(read-context-data ROW_OFFSET_CODECOPY_XAHOY_CONTEXT_ROW CONTEXT_NUMBER))) | ||
|
||
(defconstraint copy-instruction---CODECOPY---setting-the-account-row---unexceptional-case (:guard (copy-instruction---standard-CODECOPY)) | ||
(if-zero XAHOY | ||
(begin (eq! (shift account/ADDRESS_HI ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) (shift context/BYTE_CODE_ADDRESS_HI ROW_OFFSET_CODECOPY_NO_XAHOY_CONTEXT_ROW)) | ||
(eq! (shift account/ADDRESS_LO ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) (shift context/BYTE_CODE_ADDRESS_LO ROW_OFFSET_CODECOPY_NO_XAHOY_CONTEXT_ROW)) | ||
(eq! (shift account/DEPLOYMENT_NUMBER ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) (shift context/BYTE_CODE_CODE_FRAGMENT_INDEX ROW_OFFSET_CODECOPY_NO_XAHOY_CONTEXT_ROW)) | ||
(eq! (shift account/CODE_FRAGMENT_INDEX ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) CODE_FRAGMENT_INDEX) | ||
(eq! (shift account/ROMLEX_FLAG ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) 1) | ||
(account-same-balance ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) | ||
(account-same-nonce ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) | ||
(account-same-code ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) | ||
(account-same-deployment-number-and-status ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) | ||
(account-same-warmth ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) | ||
(account-same-marked-for-selfdestruct ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW) | ||
(DOM-SUB-stamps---standard ROW_OFFSET_CODECOPY_NO_XAHOY_ACCOUNT_ROW 0)))) | ||
|
79 changes: 79 additions & 0 deletions
79
hub/constraints/instruction-handling/copy/extcodecopy.lisp
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
(module hub) | ||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; ;; | ||
;; X.Y.7 Specifics for EXTCODECOPY ;; | ||
;; ;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
(defconstraint copy-instruction---EXTCODECOPY---setting-the-gas-cost (:guard (copy-instruction---standard-EXTCODECOPY)) | ||
(if-not-zero stack/MXPX | ||
;; MXPX ≡ 1 | ||
(vanishes! GAS_COST) | ||
;; MXPX ≡ 0 | ||
(eq! GAS_COST | ||
(+ stack/STATIC_GAS | ||
(copy-instruction---MXP-memory-expansion-gas) | ||
(* (copy-instruction---exo-address-warmth) GAS_CONST_G_WARM_ACCESS) | ||
(* (- 1 (copy-instruction---exo-address-warmth)) GAS_CONST_G_COLD_ACCOUNT_ACCESS))))) | ||
|
||
(defconstraint copy-instruction---EXTCODECOPY---the-MXPX-case (:guard (copy-instruction---standard-EXTCODECOPY)) | ||
(if-not-zero stack/MXPX | ||
(execution-provides-empty-return-data ROW_OFFSET_EXTCODECOPY_MXPX_CONTEXT_ROW))) | ||
|
||
(defconstraint copy-instruction---EXTCODECOPY---the-OOGX-case (:guard (copy-instruction---standard-EXTCODECOPY)) | ||
(if-not-zero stack/OOGX | ||
;; account-row i + 2 | ||
(begin (account-trim-address ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW (copy-instruction---raw-address-hi) (copy-instruction---raw-address-lo)) | ||
(vanishes! (shift account/ROMLEX_FLAG ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW)) | ||
(account-same-balance ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW) | ||
(account-same-nonce ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW) | ||
(account-same-code ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW) | ||
(account-same-deployment-number-and-status ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW) | ||
(account-same-warmth ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW) | ||
(account-same-marked-for-selfdestruct ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW) | ||
(DOM-SUB-stamps---standard ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW 0)) | ||
;; context-row i + 3 | ||
(execution-provides-empty-return-data ROW_OFFSET_EXTCODECOPY_OOGX_CONTEXT_ROW))) | ||
|
||
(defun (copy-instruction---trigger-CFI) | ||
(* (copy-instruction---is-EXTCODECOPY) | ||
(copy-instruction---trigger_MMU) | ||
(copy-instruction---exo-address-has-code))) | ||
|
||
(defconstraint copy-instruction---unexceptional-reverted-EXTCODECOPY---doing-account-row (:guard (copy-instruction---standard-EXTCODECOPY)) | ||
(if-not-zero (* (- 1 XAHOY) CONTEXT_WILL_REVERT) | ||
(begin (account-trim-address ROW_OFFSET_EXTCODECOPY_OOGX_ACCOUNT_ROW (copy-instruction---raw-address-hi) (copy-instruction---raw-address-lo)) | ||
(eq! (shift account/ROMLEX_FLAG ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) (copy-instruction---trigger-CFI)) | ||
(account-same-balance ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-same-nonce ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-same-code ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-same-deployment-number-and-status ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-turn-on-warmth ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-same-marked-for-selfdestruct ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(DOM-SUB-stamps---standard ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW 0)))) | ||
|
||
(defconstraint copy-instruction---unexceptional-reverted-EXTCODECOPY---undoing-account-row (:guard (copy-instruction---standard-EXTCODECOPY)) | ||
(if-not-zero (* (- 1 XAHOY) CONTEXT_WILL_REVERT) | ||
(begin (account-same-address-as ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(debug (vanishes! (shift account/ROMLEX_FLAG ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW))) | ||
(account-undo-balance-update ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-undo-nonce-update ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-undo-code-update ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-undo-deployment-status-update ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-undo-warmth-update ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_DOING_ROW) | ||
(account-same-marked-for-selfdestruct ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW) | ||
(DOM-SUB-stamps---revert-with-current ROW_OFFSET_EXTCODECOPY_NO_XAHOY_REVERT_ACCOUNT_UNDOING_ROW 1)))) | ||
|
||
(defconstraint copy-instruction---unexceptional-unreverted-EXTCODECOPY-account-row (:guard (copy-instruction---standard-EXTCODECOPY)) | ||
(if-not-zero (* (- 1 XAHOY) (- 1 CONTEXT_WILL_REVERT)) | ||
(begin (account-trim-address ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW (copy-instruction---raw-address-hi) (copy-instruction---raw-address-lo)) | ||
(eq! (shift account/ROMLEX_FLAG ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) (copy-instruction---trigger-CFI)) | ||
(account-same-balance ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) | ||
(account-same-nonce ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) | ||
(account-same-code ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) | ||
(account-same-deployment-number-and-status ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) | ||
(account-turn-on-warmth ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) | ||
(account-same-marked-for-selfdestruct ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW) | ||
(DOM-SUB-stamps---standard ROW_OFFSET_EXTCODECOPY_NO_XAHOY_NO_REVERT_ACCOUNT_ROW 0)))) | ||
|
Oops, something went wrong.