@@ -558,7 +558,13 @@ pub(crate) struct ParentData<F> {
558
558
pub ( crate ) rlc : Cell < F > ,
559
559
pub ( crate ) is_root : Cell < F > ,
560
560
pub ( crate ) is_placeholder : Cell < F > ,
561
+ // is_extension is used only in a non-existing proof / wrong extension node case -
562
+ // in account/storage leaf to check whether the parent is an extension node
561
563
pub ( crate ) is_extension : Cell < F > ,
564
+ // is_ext_last_level is used only in a non-existing proof - in wrong extension node case the branch
565
+ // is a placeholder and the check for a branch hash being in the parent extension node needs to be ignored,
566
+ // but it needs to be ignored only in the last branch (the branch above the leaf into which the lookup is made)
567
+ pub ( crate ) is_ext_last_level : Cell < F > ,
562
568
pub ( crate ) drifted_parent_hash : WordLoHiCell < F > ,
563
569
}
564
570
@@ -569,6 +575,7 @@ pub(crate) struct ParentDataWitness<F> {
569
575
pub ( crate ) is_root : bool ,
570
576
pub ( crate ) is_placeholder : bool ,
571
577
pub ( crate ) is_extension : bool ,
578
+ pub ( crate ) is_ext_last_level : bool ,
572
579
pub ( crate ) drifted_parent_hash : WordLoHi < F > ,
573
580
}
574
581
@@ -584,6 +591,7 @@ impl<F: Field> ParentData<F> {
584
591
is_root : cb. query_cell ( ) ,
585
592
is_placeholder : cb. query_cell ( ) ,
586
593
is_extension : cb. query_cell ( ) ,
594
+ is_ext_last_level : cb. query_cell ( ) ,
587
595
drifted_parent_hash : cb. query_word_unchecked ( ) ,
588
596
} ;
589
597
circuit ! ( [ meta, cb. base] , {
@@ -597,6 +605,7 @@ impl<F: Field> ParentData<F> {
597
605
parent_data. is_root. expr( ) ,
598
606
parent_data. is_placeholder. expr( ) ,
599
607
parent_data. is_extension. expr( ) ,
608
+ parent_data. is_ext_last_level. expr( ) ,
600
609
parent_data. drifted_parent_hash. lo( ) . expr( ) ,
601
610
parent_data. drifted_parent_hash. hi( ) . expr( ) ,
602
611
] ,
@@ -613,6 +622,7 @@ impl<F: Field> ParentData<F> {
613
622
is_root : Expression < F > ,
614
623
is_placeholder : Expression < F > ,
615
624
is_extension : Expression < F > ,
625
+ is_ext_last_level : Expression < F > ,
616
626
drifted_parent_hash : WordLoHi < Expression < F > > ,
617
627
) {
618
628
memory. store (
@@ -624,6 +634,7 @@ impl<F: Field> ParentData<F> {
624
634
is_root,
625
635
is_placeholder,
626
636
is_extension,
637
+ is_ext_last_level,
627
638
drifted_parent_hash. lo ( ) ,
628
639
drifted_parent_hash. hi ( ) ,
629
640
] ,
@@ -640,6 +651,7 @@ impl<F: Field> ParentData<F> {
640
651
force_hashed : bool ,
641
652
is_placeholder : bool ,
642
653
is_extension : bool ,
654
+ is_ext_last_level : bool ,
643
655
drifted_parent_hash : WordLoHi < F > ,
644
656
) -> Result < ( ) , Error > {
645
657
memory. witness_store (
@@ -651,6 +663,7 @@ impl<F: Field> ParentData<F> {
651
663
force_hashed. scalar ( ) ,
652
664
is_placeholder. scalar ( ) ,
653
665
is_extension. scalar ( ) ,
666
+ is_ext_last_level. scalar ( ) ,
654
667
drifted_parent_hash. lo ( ) ,
655
668
drifted_parent_hash. hi ( ) ,
656
669
] ,
@@ -673,20 +686,22 @@ impl<F: Field> ParentData<F> {
673
686
self . is_root . assign ( region, offset, values[ 3 ] ) ?;
674
687
self . is_placeholder . assign ( region, offset, values[ 4 ] ) ?;
675
688
self . is_extension . assign ( region, offset, values[ 5 ] ) ?;
689
+ self . is_ext_last_level . assign ( region, offset, values[ 6 ] ) ?;
676
690
self . drifted_parent_hash
677
691
. lo ( )
678
- . assign ( region, offset, values[ 6 ] ) ?;
692
+ . assign ( region, offset, values[ 7 ] ) ?;
679
693
self . drifted_parent_hash
680
694
. hi ( )
681
- . assign ( region, offset, values[ 7 ] ) ?;
695
+ . assign ( region, offset, values[ 8 ] ) ?;
682
696
683
697
Ok ( ParentDataWitness {
684
698
hash : WordLoHi :: new ( [ values[ 0 ] , values[ 1 ] ] ) ,
685
699
rlc : values[ 2 ] ,
686
700
is_root : values[ 3 ] == 1 . scalar ( ) ,
687
701
is_placeholder : values[ 4 ] == 1 . scalar ( ) ,
688
702
is_extension : values[ 5 ] == 1 . scalar ( ) ,
689
- drifted_parent_hash : WordLoHi :: new ( [ values[ 6 ] , values[ 7 ] ] ) ,
703
+ is_ext_last_level : values[ 6 ] == 1 . scalar ( ) ,
704
+ drifted_parent_hash : WordLoHi :: new ( [ values[ 7 ] , values[ 8 ] ] ) ,
690
705
} )
691
706
}
692
707
}
@@ -1273,7 +1288,6 @@ impl<F: Field> WrongLeafGadget<F> {
1273
1288
list_bytes : & [ u8 ] ,
1274
1289
expected_item : & RLPItemWitness ,
1275
1290
for_placeholder_s : bool ,
1276
- is_parent_extension : bool ,
1277
1291
key_data : KeyDataWitness < F > ,
1278
1292
r : F ,
1279
1293
) -> Result < ( F , F ) , Error > {
0 commit comments