From c3623c83fcc9c781636b5fcc64bc70a25592dfdc Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Olivier=20B=C3=A9gassat?= Date: Mon, 2 Dec 2024 12:55:59 +0700 Subject: [PATCH] fix: CREATE pricing in scenario/CREATE_FAILURE cases --- .../create/constraints/generalities.lisp | 33 ++++++++++--------- 1 file changed, 17 insertions(+), 16 deletions(-) diff --git a/hub/constraints/instruction-handling/create/constraints/generalities.lisp b/hub/constraints/instruction-handling/create/constraints/generalities.lisp index 437eaf10..1b4d2cb3 100644 --- a/hub/constraints/instruction-handling/create/constraints/generalities.lisp +++ b/hub/constraints/instruction-handling/create/constraints/generalities.lisp @@ -165,26 +165,27 @@ (if-not-zero (scenario-shorthand---CREATE---no-context-change) (next-context-is-current)) (if-not-zero (scenario-shorthand---CREATE---not-rebuffed-nonempty-init-code) (next-context-is-new)))) +(defun (create-instruction---upfront-gas-cost) (+ GAS_CONST_G_CREATE + (create-instruction---MXP-gas))) +(defun (create-instruction---full-gas-cost) (+ (create-instruction---upfront-gas-cost) + (create-instruction---STP-gas-paid-out-of-pocket))) + + (defconstraint create-instruction---setting-GAS_COST (:guard (create-instruction---generic-precondition)) (begin - (if-not-zero (+ (create-instruction---STACK-staticx) (create-instruction---STACK-mxpx)) - (vanishes! GAS_COST)) - (if-not-zero (+ (create-instruction---STACK-oogx) (scenario-shorthand---CREATE---unexceptional)) - (eq! GAS_COST (+ GAS_CONST_G_CREATE - (create-instruction---MXP-gas)))) + (if-not-zero (+ (create-instruction---STACK-staticx) + (create-instruction---STACK-mxpx)) + (eq! GAS_COST 0)) + (if-not-zero (+ (create-instruction---STACK-oogx) + (scenario-shorthand---CREATE---unexceptional)) + (eq! GAS_COST (create-instruction---upfront-gas-cost))) )) (defconstraint create-instruction---setting-GAS_NEXT (:guard (create-instruction---generic-precondition)) (begin - (if-not-zero scenario/CREATE_EXCEPTION - (vanishes! GAS_NEXT)) - (if-not-zero (scenario-shorthand---CREATE---no-context-change) - (eq! GAS_NEXT - (- GAS_ACTUAL - GAS_COST))) - (if-not-zero (scenario-shorthand---CREATE---not-rebuffed-nonempty-init-code) - (eq! GAS_NEXT - (- GAS_ACTUAL - GAS_COST - (create-instruction---STP-gas-paid-out-of-pocket)))) + (if-not-zero scenario/CREATE_EXCEPTION (eq! GAS_NEXT 0)) + (if-not-zero scenario/CREATE_ABORT (eq! GAS_NEXT (- GAS_ACTUAL (create-instruction---upfront-gas-cost)))) + (if-not-zero (scenario-shorthand---CREATE---failure-condition) (eq! GAS_NEXT (- GAS_ACTUAL (create-instruction---full-gas-cost)))) + (if-not-zero (scenario-shorthand---CREATE---not-rebuffed-empty-init-code) (eq! GAS_NEXT (- GAS_ACTUAL (create-instruction---upfront-gas-cost)))) + (if-not-zero (scenario-shorthand---CREATE---not-rebuffed-nonempty-init-code) (eq! GAS_NEXT (- GAS_ACTUAL (create-instruction---full-gas-cost)))) ))