-
Notifications
You must be signed in to change notification settings - Fork 125
Add invalid signature support #104
base: main
Are you sure you want to change the base?
Conversation
This reverts commit 7179baa.
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.
Generally looks very good!
make test
failed on some commented code (wat) but easy fix, just add this in bus-mapping/src/lib.rs
:
+//! invalid: false,
Afterwards make test
works but I guess these errors that are tx table lookup related so seems like there's an issue there:
test super_circuit::test::serial_test_super_circuit_1tx_1max_tx ... [2023-06-13T18:07:46Z ERROR zkevm_circuits::super_circuit::test] Verification failures: [
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 218,
name: "State transition (delta) constraint of rw_counter",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 219,
name: "State transition (to) constraint of call_id",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 220,
name: "State transition (to) constraint of is_root",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 222,
name: "State transition (to) constraint of code_hash",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 224,
name: "State transition (to) constraint of stack_pointer",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 225,
name: "State transition (to) constraint of gas_left",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 230,
name: "num_rows_until_next_step_next := height - 1",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 19,
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 2,
Lookup Tx(index: 208) is not satisfied in Region 25 ('Execution step') at offset 1,
]
FAILED
test super_circuit::test::serial_test_super_circuit_1tx_2max_tx ... [2023-06-13T18:08:35Z ERROR zkevm_circuits::super_circuit::test] Verification failures: [
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 218,
name: "State transition (delta) constraint of rw_counter",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 219,
name: "State transition (to) constraint of call_id",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 220,
name: "State transition (to) constraint of is_root",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 222,
name: "State transition (to) constraint of code_hash",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 224,
name: "State transition (to) constraint of stack_pointer",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 225,
name: "State transition (to) constraint of gas_left",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 230,
name: "num_rows_until_next_step_next := height - 1",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 19,
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 2,
Lookup Tx(index: 208) is not satisfied in Region 25 ('Execution step') at offset 1,
]
FAILED
test super_circuit::test::serial_test_super_circuit_2tx_2max_tx ... [2023-06-13T18:09:25Z ERROR zkevm_circuits::super_circuit::test] Verification failures: [
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 218,
name: "State transition (delta) constraint of rw_counter",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 219,
name: "State transition (to) constraint of call_id",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 220,
name: "State transition (to) constraint of is_root",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 222,
name: "State transition (to) constraint of code_hash",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 224,
name: "State transition (to) constraint of stack_pointer",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 225,
name: "State transition (to) constraint of gas_left",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 230,
name: "num_rows_until_next_step_next := height - 1",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 0,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 218,
name: "State transition (delta) constraint of rw_counter",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 219,
name: "State transition (to) constraint of call_id",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 220,
name: "State transition (to) constraint of is_root",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 222,
name: "State transition (to) constraint of code_hash",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 224,
name: "State transition (to) constraint of stack_pointer",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 225,
name: "State transition (to) constraint of gas_left",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
ConstraintCaseDebug {
constraint: Constraint {
gate: Gate {
index: 2531,
name: "BeginTx",
},
index: 230,
name: "num_rows_until_next_step_next := height - 1",
},
location: InRegion {
region: Region 25 ('Execution step'),
offset: 26,
},
cell_values: [
(
DebugVirtualCell {
name: "",
column: DebugColumn {
column_type: Advice,
index: 353,
annotation: "EVM_q_step",
},
rotation: 0,
},
"1",
),
],
},
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 19,
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 45,
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 2,
Lookup Tx(index: 205) is not satisfied in Region 25 ('Execution step') at offset 28,
Lookup Tx(index: 208) is not satisfied in Region 25 ('Execution step') at offset 1,
Lookup Tx(index: 208) is not satisfied in Region 25 ('Execution step') at offset 27,
]
FAILED
failures:
---- super_circuit::test::serial_test_super_circuit_1tx_1max_tx stdout ----
thread 'super_circuit::test::serial_test_super_circuit_1tx_1max_tx' panicked at 'Failed verification', zkevm-circuits/src/super_circuit/test.rs:33:9
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
---- super_circuit::test::serial_test_super_circuit_1tx_2max_tx stdout ----
thread 'super_circuit::test::serial_test_super_circuit_1tx_2max_tx' panicked at 'Failed verification', zkevm-circuits/src/super_circuit/test.rs:33:9
---- super_circuit::test::serial_test_super_circuit_2tx_2max_tx stdout ----
thread 'super_circuit::test::serial_test_super_circuit_2tx_2max_tx' panicked at 'Failed verification', zkevm-circuits/src/super_circuit/test.rs:33:9
failures:
super_circuit::test::serial_test_super_circuit_1tx_1max_tx
super_circuit::test::serial_test_super_circuit_1tx_2max_tx
super_circuit::test::serial_test_super_circuit_2tx_2max_tx
test result: FAILED. 1 passed; 3 failed; 0 ignored; 0 measured; 414 filtered out; finished in 145.80s
zkevm-circuits/Cargo.toml
Outdated
ecdsa = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", tag = "v2023_04_20" } | ||
ecc = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", tag = "v2023_04_20" } | ||
maingate = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", tag = "v2023_04_20" } | ||
integer = { git = "https://github.com/privacy-scaling-explorations/halo2wrong", tag = "v2023_04_20" } | ||
ecdsa = { git = "https://github.com/xiaodino/halo2wrong", rev = "24a7880c259f19cc6cf786ca47cfda34433ee9fb" } | ||
ecc = { git = "https://github.com/xiaodino/halo2wrong", rev = "24a7880c259f19cc6cf786ca47cfda34433ee9fb" } | ||
maingate = { git = "https://github.com/xiaodino/halo2wrong", rev = "24a7880c259f19cc6cf786ca47cfda34433ee9fb" } | ||
integer = { git = "https://github.com/xiaodino/halo2wrong", rev = "24a7880c259f19cc6cf786ca47cfda34433ee9fb" } | ||
libsecp256k1 = "0.7" | ||
num-bigint = { version = "0.4" } | ||
rand_chacha = "0.3" | ||
snark-verifier = { git = "https://github.com/privacy-scaling-explorations/snark-verifier", tag = "v2023_04_20", default-features = false, features = ["loader_halo2", "system_halo2"] } | ||
snark-verifier = { git = "https://github.com/xiaodino/snark-verifier", rev = "6131ee5d6c7126e608f798e5037b102ca3cbd406", default-features = false, features = ["loader_halo2", "system_halo2"] } |
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.
How hard would it be to still use the pse forks for now (for when we create a PR on the PSE repo which won't want to update these dependencies just yet)? So this would simply set if the signature is valid or not without any in-circuit checks.
let balance_not_enough = | ||
LtWordGadget::construct(cb, sender_balance_prev, total_eth_cost.sum()); | ||
|
||
// A transaction is invalid when |
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.
Need to add invalid signature case here as well no?
TxFieldTag::TxInvalid, | ||
assigned_sig_verif.is_invalid.value().copied(), |
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.
The tx may also be invalid because of invalid nonce/etc... So if we just set the value here to if the tx signature is valid, how can we support the other invalid cases? I think we may need a separate tag for just TxSignatureInvalid
so we can lookup this value in the EVM circuit and then check if TxInvalid
is indeed the correct value taking into account all possible invalid tx cases. Or do I miss something?
Description
Support skipping the following invalid transations:
Issue Link
#70
Type of change
Contents