Skip to content

Commit 6acb6ff

Browse files
committed
Revert "Merge pull request ElementsProject#1409 from ElementsProject/simplicity"
This reverts commit 0397d22, reversing changes made to 24b43ea.
1 parent 9310412 commit 6acb6ff

File tree

1 file changed

+25
-12
lines changed

1 file changed

+25
-12
lines changed

src/simplicity/eval.c

Lines changed: 25 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -629,12 +629,19 @@ simplicity_err simplicity_analyseBounds( ubounded *cellsBound, ubounded *UWORDBo
629629
, bound[dag[i].child[1]].cost ));
630630
break;
631631
case DISCONNECT:
632-
bound[i].extraCellsBound[1] = type_dag[DISCONNECT_W256A(dag, type_dag, i)].bitSize;
633-
bound[i].extraCellsBound[0] = bounded_max(
634-
bounded_add( type_dag[DISCONNECT_BC(dag, type_dag, i)].bitSize
635-
, bounded_max( bounded_add(bound[i].extraCellsBound[1], bound[dag[i].child[0]].extraCellsBound[1])
636-
, bounded_max(bound[dag[i].child[0]].extraCellsBound[0], bound[dag[i].child[1]].extraCellsBound[1]))),
637-
bound[dag[i].child[1]].extraCellsBound[0]);
632+
if (UBOUNDED_MAX <= type_dag[DISCONNECT_W256A(dag, type_dag, i)].bitSize ||
633+
UBOUNDED_MAX <= type_dag[DISCONNECT_BC(dag, type_dag, i)].bitSize) {
634+
/* 'BITSIZE(WORD256 * A)' or 'BITSIZE(B * C)' has exceeded our limits. */
635+
bound[i].extraCellsBound[0] = UBOUNDED_MAX;
636+
bound[i].extraCellsBound[1] = UBOUNDED_MAX;
637+
} else {
638+
bound[i].extraCellsBound[1] = type_dag[DISCONNECT_W256A(dag, type_dag, i)].bitSize;
639+
bound[i].extraCellsBound[0] = bounded_max(
640+
bounded_add( type_dag[DISCONNECT_BC(dag, type_dag, i)].bitSize
641+
, bounded_max( bounded_add(bound[i].extraCellsBound[1], bound[dag[i].child[0]].extraCellsBound[1])
642+
, bounded_max(bound[dag[i].child[0]].extraCellsBound[0], bound[dag[i].child[1]].extraCellsBound[1]))),
643+
bound[dag[i].child[1]].extraCellsBound[0]);
644+
}
638645
bound[i].extraUWORDBound[1] = (ubounded)ROUND_UWORD(type_dag[DISCONNECT_W256A(dag, type_dag, i)].bitSize);
639646
bound[i].extraUWORDBound[0] = bounded_max(
640647
(ubounded)ROUND_UWORD(type_dag[DISCONNECT_BC(dag, type_dag, i)].bitSize) +
@@ -653,12 +660,18 @@ simplicity_err simplicity_analyseBounds( ubounded *cellsBound, ubounded *UWORDBo
653660
, bounded_add(bound[dag[i].child[0]].cost, bound[dag[i].child[1]].cost))))));
654661
break;
655662
case COMP:
656-
bound[i].extraCellsBound[0] = bounded_max( bounded_add( type_dag[COMP_B(dag, type_dag, i)].bitSize
657-
, bounded_max( bound[dag[i].child[0]].extraCellsBound[0]
658-
, bound[dag[i].child[1]].extraCellsBound[1] ))
659-
, bound[dag[i].child[1]].extraCellsBound[0] );
660-
bound[i].extraCellsBound[1] = bounded_add( type_dag[COMP_B(dag, type_dag, i)].bitSize
661-
, bound[dag[i].child[0]].extraCellsBound[1] );
663+
if (UBOUNDED_MAX <= type_dag[COMP_B(dag, type_dag, i)].bitSize) {
664+
/* 'BITSIZE(B)' has exceeded our limits. */
665+
bound[i].extraCellsBound[0] = UBOUNDED_MAX;
666+
bound[i].extraCellsBound[1] = UBOUNDED_MAX;
667+
} else {
668+
bound[i].extraCellsBound[0] = bounded_max( bounded_add( type_dag[COMP_B(dag, type_dag, i)].bitSize
669+
, bounded_max( bound[dag[i].child[0]].extraCellsBound[0]
670+
, bound[dag[i].child[1]].extraCellsBound[1] ))
671+
, bound[dag[i].child[1]].extraCellsBound[0] );
672+
bound[i].extraCellsBound[1] = bounded_add( type_dag[COMP_B(dag, type_dag, i)].bitSize
673+
, bound[dag[i].child[0]].extraCellsBound[1] );
674+
}
662675
bound[i].extraUWORDBound[0] = bounded_max( (ubounded)ROUND_UWORD(type_dag[COMP_B(dag, type_dag, i)].bitSize) +
663676
bounded_max( bound[dag[i].child[0]].extraUWORDBound[0]
664677
, bound[dag[i].child[1]].extraUWORDBound[1] )

0 commit comments

Comments
 (0)