-
Notifications
You must be signed in to change notification settings - Fork 21
Debug BLS
#773
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
Debug BLS
#773
Changes from all commits
109161c
7d1ca1f
f83d3f0
064e86c
532f5d6
6c4127d
fa34d51
a9247c7
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,5 +20,5 @@ | |
|
||
(defconstraint pair-of-inputs-constancy () | ||
(if-not-zero ACC_INPUTS | ||
(if (will-remain-constant! ACC_INPUTS) | ||
(if-zero (- (next ACC_INPUTS) ACC_INPUTS) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Is this rejected by go-corset ? The original version looked ok to me. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. no, they are probably equivalent, but I believe this way is more clear |
||
(will-remain-constant! NONTRIVIAL_POP_BIT)))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
oob.ADD_FLAG) | ||
|
||
(defclookup | ||
oob-into-add | ||
(oob-into-add :unchecked) | ||
;; target columns | ||
( | ||
add.ARG_1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
oob.MOD_FLAG) | ||
|
||
(defclookup | ||
oob-into-mod | ||
(oob-into-mod :unchecked) | ||
;; target columns | ||
( | ||
mod.ARG_1_HI | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,35 +1,39 @@ | ||
(module oob) | ||
|
||
|
||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; ;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
;; ;; | ||
;; For BLS_G1_MSM and BLS_G2_MSM ;; | ||
;; ;; | ||
;; ;; | ||
;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;; | ||
|
||
(defun (prc-g1msm-prc-g2msm---standard-precondition) | ||
(+ IS_BLS_G1_MSM | ||
(defun (prc-g1msm-prc-g2msm---standard-precondition) | ||
(+ IS_BLS_G1_MSM | ||
IS_BLS_G2_MSM)) | ||
(defun (msm-pair-size) | ||
(+ (* PRECOMPILE_CALL_DATA_UNIT_SIZE___BLS_G1_MSM IS_BLS_G1_MSM) | ||
(defun (msm-pair-size) | ||
(+ (* PRECOMPILE_CALL_DATA_UNIT_SIZE___BLS_G1_MSM IS_BLS_G1_MSM) | ||
(* PRECOMPILE_CALL_DATA_UNIT_SIZE___BLS_G2_MSM IS_BLS_G2_MSM))) | ||
(defun (max-discount) | ||
(+ (* PRC_BLS_G1_MSM_MAX_DISCOUNT IS_BLS_G1_MSM) | ||
(defun (max-discount) | ||
(+ (* PRC_BLS_G1_MSM_MAX_DISCOUNT IS_BLS_G1_MSM) | ||
(* PRC_BLS_G2_MSM_MAX_DISCOUNT IS_BLS_G2_MSM))) | ||
(defun (msm-multiplication-cost) | ||
(+ (* PRC_BLS_G1_MSM_MULTIPLICATION_COST IS_BLS_G1_MSM) | ||
(defun (msm-multiplication-cost) | ||
(+ (* PRC_BLS_G1_MSM_MULTIPLICATION_COST IS_BLS_G1_MSM) | ||
(* PRC_BLS_G2_MSM_MULTIPLICATION_COST IS_BLS_G2_MSM))) | ||
(defun (prc-g1msm-prc-g2msm---remainder) (shift OUTGOING_RES_LO 2)) | ||
(defun (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) (shift OUTGOING_RES_LO 3)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (prc---cds)) | ||
(defun (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) (shift OUTGOING_RES_LO 3)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (prc---cds)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs-gt-128) (shift OUTGOING_RES_LO 4)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs-leq-128) (- 1 (prc-g1msm-prc-g2msm---num-inputs-gt-128))) | ||
(defun (prc-g1msm-prc-g2msm---discount) (shift OUTGOING_RES_LO 5)) | ||
(defun (prc-g1msm-prc-g2msm---insufficient-gas) (shift OUTGOING_RES_LO 6)) | ||
(defun (prc-g1msm-prc-g2msm---reference-table-discount) (shift OUTGOING_RES_LO 5)) | ||
(defun (prc-g1msm-prc-g2msm---discount) | ||
(if-not-zero (prc-g1msm-prc-g2msm---num-inputs-leq-128) | ||
(prc-g1msm-prc-g2msm---reference-table-discount) | ||
(max-discount))) | ||
(defun (prc-g1msm-prc-g2msm---msm-cost-numerator_msm-pair-size) | ||
(* (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (msm-multiplication-cost) (prc-g1msm-prc-g2msm---discount))) | ||
(defun (prc-g1msm-prc-g2msm---precompile-cost) (shift OUTGOING_RES_LO 6)) | ||
(defun (prc-g1msm-prc-g2msm---insufficient-gas) (shift OUTGOING_RES_LO 7)) | ||
(defun (prc-g1msm-prc-g2msm---sufficient-gas) (- 1 (prc-g1msm-prc-g2msm---insufficient-gas))) | ||
(defun (prc-g1msm-prc-g2msm---precompile-cost_msm-pair-size_PRC_BLS_MULTIPLICATION_MULTIPLIER) (* (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (msm-multiplication-cost) (prc-g1msm-prc-g2msm---discount))) | ||
|
||
|
||
|
||
(defconstraint prc-g1msm-prc-g2msm---mod-cds-by-msm-pair-size (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(call-to-MOD 2 0 (prc---cds) 0 (msm-pair-size))) | ||
|
@@ -63,27 +67,38 @@ | |
(vanishes! (shift [OUTGOING_DATA 2] 5)) | ||
(vanishes! (shift [OUTGOING_DATA 3] 5)) | ||
(vanishes! (shift [OUTGOING_DATA 4] 5))) | ||
(begin (noCall 5) | ||
(eq! (prc-g1msm-prc-g2msm---discount) (max-discount)))))) | ||
|
||
(defconstraint prc-g1msm-prc-g2msm---compare-call-gas-against-precompile-cost (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(begin (noCall 5))))) | ||
|
||
(defconstraint prc-g1msm-prc-g2msm---compute-precompile-cost-integer-division (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(if-zero (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) | ||
(noCall 6) | ||
(begin (vanishes! (shift ADD_FLAG 6)) | ||
(vanishes! (shift MOD_FLAG 6)) | ||
(eq! (shift WCP_FLAG 6) 1) | ||
(eq! (shift MOD_FLAG 6) 1) | ||
(vanishes! (shift WCP_FLAG 6)) | ||
(vanishes! (shift BLS_REF_TABLE_FLAG 6)) | ||
(eq! (shift OUTGOING_INST 6) EVM_INST_LT) | ||
(eq! (shift OUTGOING_INST 6) EVM_INST_DIV) | ||
(vanishes! (shift [OUTGOING_DATA 1] 6)) | ||
(eq! (shift [OUTGOING_DATA 2] 6) (prc---callee-gas)) | ||
(eq! (* (shift [OUTGOING_DATA 2] 6) (msm-pair-size)) (prc-g1msm-prc-g2msm---msm-cost-numerator_msm-pair-size)) | ||
(vanishes! (shift [OUTGOING_DATA 3] 6)) | ||
(eq! (* (shift [OUTGOING_DATA 4] 6) (msm-pair-size) PRC_BLS_MULTIPLICATION_MULTIPLIER) | ||
(prc-g1msm-prc-g2msm---precompile-cost_msm-pair-size_PRC_BLS_MULTIPLICATION_MULTIPLIER))))) | ||
(eq! (shift [OUTGOING_DATA 4] 6) PRC_BLS_MULTIPLICATION_MULTIPLIER)))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Cost Calculation Error in Precompile ConstraintThe |
||
|
||
(defconstraint prc-g1msm-prc-g2msm---compare-call-gas-against-precompile-cost (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(if-zero (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) | ||
(noCall 7) | ||
(begin (vanishes! (shift ADD_FLAG 7)) | ||
(vanishes! (shift MOD_FLAG 7)) | ||
(eq! (shift WCP_FLAG 7) 1) | ||
(vanishes! (shift BLS_REF_TABLE_FLAG 7)) | ||
(eq! (shift OUTGOING_INST 7) EVM_INST_LT) | ||
(vanishes! (shift [OUTGOING_DATA 1] 7)) | ||
(eq! (shift [OUTGOING_DATA 2] 7) (prc---callee-gas)) | ||
(vanishes! (shift [OUTGOING_DATA 3] 7)) | ||
(eq! (shift [OUTGOING_DATA 4] 7) (prc-g1msm-prc-g2msm---precompile-cost))))) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Could we replace all the There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yes, but I would prefer in a separated PR. |
||
|
||
(defconstraint prc-g1msm-prc-g2msm---justify-hub-predictions (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(begin (eq! (prc---hub-success) | ||
(* (prc---cds-is-non-zero) (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) (prc-g1msm-prc-g2msm---sufficient-gas))) | ||
(if-zero (prc---hub-success) | ||
(vanishes! (prc---return-gas)) | ||
(eq! (* (prc---return-gas) (msm-pair-size) PRC_BLS_MULTIPLICATION_MULTIPLIER) | ||
(- (* (prc---callee-gas) (msm-pair-size) PRC_BLS_MULTIPLICATION_MULTIPLIER) (prc-g1msm-prc-g2msm---precompile-cost_msm-pair-size_PRC_BLS_MULTIPLICATION_MULTIPLIER)))))) | ||
(eq! (prc---return-gas) | ||
(- (prc---callee-gas) (prc-g1msm-prc-g2msm---precompile-cost)))))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
oob.ADD_FLAG) | ||
|
||
(defclookup | ||
oob-into-add | ||
(oob-into-add :unchecked) | ||
;; target columns | ||
( | ||
add.ARG_1 | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ | |
oob.MOD_FLAG) | ||
|
||
(defclookup | ||
oob-into-mod | ||
(oob-into-mod :unchecked) | ||
;; target columns | ||
( | ||
mod.ARG_1_HI | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -20,16 +20,20 @@ | |
(+ (* PRC_BLS_G1_MSM_MULTIPLICATION_COST IS_BLS_G1_MSM) | ||
(* PRC_BLS_G2_MSM_MULTIPLICATION_COST IS_BLS_G2_MSM))) | ||
(defun (prc-g1msm-prc-g2msm---remainder) (shift OUTGOING_RES_LO 2)) | ||
(defun (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) (shift OUTGOING_RES_LO 3)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (prc---cds)) | ||
(defun (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) (shift OUTGOING_RES_LO 3)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (prc---cds)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs-gt-128) (shift OUTGOING_RES_LO 4)) | ||
(defun (prc-g1msm-prc-g2msm---num-inputs-leq-128) (- 1 (prc-g1msm-prc-g2msm---num-inputs-gt-128))) | ||
(defun (prc-g1msm-prc-g2msm---discount) (shift OUTGOING_RES_LO 5)) | ||
(defun (prc-g1msm-prc-g2msm---insufficient-gas) (shift OUTGOING_RES_LO 6)) | ||
(defun (prc-g1msm-prc-g2msm---reference-table-discount) (shift OUTGOING_RES_LO 5)) | ||
(defun (prc-g1msm-prc-g2msm---discount) | ||
(if-not-zero (prc-g1msm-prc-g2msm---num-inputs-leq-128) | ||
(prc-g1msm-prc-g2msm---reference-table-discount) | ||
(max-discount))) | ||
(defun (prc-g1msm-prc-g2msm---msm-cost-numerator_msm-pair-size) | ||
(* (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (msm-multiplication-cost) (prc-g1msm-prc-g2msm---discount))) | ||
(defun (prc-g1msm-prc-g2msm---precompile-cost) (shift OUTGOING_RES_LO 6)) | ||
(defun (prc-g1msm-prc-g2msm---insufficient-gas) (shift OUTGOING_RES_LO 7)) | ||
(defun (prc-g1msm-prc-g2msm---sufficient-gas) (- 1 (prc-g1msm-prc-g2msm---insufficient-gas))) | ||
(defun (prc-g1msm-prc-g2msm---precompile-cost_msm-pair-size_PRC_BLS_MULTIPLICATION_MULTIPLIER) (* (prc-g1msm-prc-g2msm---num-inputs_msm-pair-size) (msm-multiplication-cost) (prc-g1msm-prc-g2msm---discount))) | ||
|
||
|
||
|
||
(defconstraint prc-g1msm-prc-g2msm---mod-cds-by-msm-pair-size (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(call-to-MOD 2 0 (prc---cds) 0 (msm-pair-size))) | ||
|
@@ -63,27 +67,38 @@ | |
(vanishes! (shift [OUTGOING_DATA 2] 5)) | ||
(vanishes! (shift [OUTGOING_DATA 3] 5)) | ||
(vanishes! (shift [OUTGOING_DATA 4] 5))) | ||
(begin (noCall 5) | ||
(eq! (prc-g1msm-prc-g2msm---discount) (max-discount)))))) | ||
(begin (noCall 5))))) | ||
|
||
(defconstraint prc-g1msm-prc-g2msm---compare-call-gas-against-precompile-cost (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(defconstraint prc-g1msm-prc-g2msm---compute-precompile-cost-integer-division (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(if-zero (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) | ||
(noCall 6) | ||
(begin (vanishes! (shift ADD_FLAG 6)) | ||
(vanishes! (shift MOD_FLAG 6)) | ||
(eq! (shift WCP_FLAG 6) 1) | ||
(eq! (shift MOD_FLAG 6) 1) | ||
(vanishes! (shift WCP_FLAG 6)) | ||
(vanishes! (shift BLS_REF_TABLE_FLAG 6)) | ||
(eq! (shift OUTGOING_INST 6) EVM_INST_LT) | ||
(eq! (shift OUTGOING_INST 6) EVM_INST_DIV) | ||
(vanishes! (shift [OUTGOING_DATA 1] 6)) | ||
(eq! (shift [OUTGOING_DATA 2] 6) (prc---callee-gas)) | ||
(eq! (* (shift [OUTGOING_DATA 2] 6) (msm-pair-size)) (prc-g1msm-prc-g2msm---msm-cost-numerator_msm-pair-size)) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: EVM Division Precompile Constraint ErrorThe |
||
(vanishes! (shift [OUTGOING_DATA 3] 6)) | ||
(eq! (* (shift [OUTGOING_DATA 4] 6) (msm-pair-size) PRC_BLS_MULTIPLICATION_MULTIPLIER) | ||
(prc-g1msm-prc-g2msm---precompile-cost_msm-pair-size_PRC_BLS_MULTIPLICATION_MULTIPLIER))))) | ||
(eq! (shift [OUTGOING_DATA 4] 6) PRC_BLS_MULTIPLICATION_MULTIPLIER)))) | ||
|
||
(defconstraint prc-g1msm-prc-g2msm---compare-call-gas-against-precompile-cost (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(if-zero (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) | ||
(noCall 7) | ||
(begin (vanishes! (shift ADD_FLAG 7)) | ||
(vanishes! (shift MOD_FLAG 7)) | ||
(eq! (shift WCP_FLAG 7) 1) | ||
(vanishes! (shift BLS_REF_TABLE_FLAG 7)) | ||
(eq! (shift OUTGOING_INST 7) EVM_INST_LT) | ||
(vanishes! (shift [OUTGOING_DATA 1] 7)) | ||
(eq! (shift [OUTGOING_DATA 2] 7) (prc---callee-gas)) | ||
(vanishes! (shift [OUTGOING_DATA 3] 7)) | ||
(eq! (shift [OUTGOING_DATA 4] 7) (prc-g1msm-prc-g2msm---precompile-cost))))) | ||
|
||
(defconstraint prc-g1msm-prc-g2msm---justify-hub-predictions (:guard (* (assumption---fresh-new-stamp) (prc-g1msm-prc-g2msm---standard-precondition))) | ||
(begin (eq! (prc---hub-success) | ||
(* (prc---cds-is-non-zero) (prc-g1msm-prc-g2msm---cds-is-multiple-of-msm-pair-size) (prc-g1msm-prc-g2msm---sufficient-gas))) | ||
(if-zero (prc---hub-success) | ||
(vanishes! (prc---return-gas)) | ||
(eq! (* (prc---return-gas) (msm-pair-size) PRC_BLS_MULTIPLICATION_MULTIPLIER) | ||
(- (* (prc---callee-gas) (msm-pair-size) PRC_BLS_MULTIPLICATION_MULTIPLIER) (prc-g1msm-prc-g2msm---precompile-cost_msm-pair-size_PRC_BLS_MULTIPLICATION_MULTIPLIER)))))) | ||
(eq! (prc---return-gas) | ||
(- (prc---callee-gas) (prc-g1msm-prc-g2msm---precompile-cost)))))) |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,7 @@ | ||
(module blsreftable) | ||
|
||
(defcolumns | ||
(PRC_NAME :byte) | ||
(PRC_NAME :i16) | ||
(NUM_INPUTS :i8) ;; greatest value is 128 | ||
(DISCOUNT :i10) ;; greatest value is 1000 | ||
) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Bug: Constancy Constraint Scope Narrowing
The
pair-of-inputs-constancy
constraint now checksACC_INPUTS
constancy only between adjacent rows. This replaces awill-remain-constant!
call that likely validated it over a broader context, narrowing the validation scope. This change could allowACC_INPUTS
to vary in later steps, potentially leading to invalid state.Additional Locations (1)
blsdata/prague/generalities/constancy_conditions.lisp#L22-L23