stacks-core icon indicating copy to clipboard operation
stacks-core copied to clipboard

[pox] assertion in -extend too late

Open friedger opened this issue 2 years ago • 0 comments

Describe the bug When using pox-3 stack-extend or delegate-stack-extent with clarinet unit tests the calls fail with an ArithmeticUnderFlow runtime error.

The check to prevent this error comes AFTER the substraction causing the runtime error.

It is not clear to me whether this can happen on mainchain. If not, the assertion below can be removed:

;; first cycle must be after the current cycle
      (asserts! (> first-extend-cycle cur-cycle) (err ERR_STACKING_INVALID_LOCK_PERIOD))

Steps To Reproduce Call stack-extend or delegate-stack-extend in a unit test See for example https://github.com/friedger/clarity-stacking-pools/blob/963ebc92cf7cba4f74f6ce14734b50438a4bffd1/tests/pox-pools-1-cycle_flow_test.ts#L346

Expected behavior Return error ERR_STACKING_INVALID_LOCK_PERIOD

friedger avatar May 24 '23 08:05 friedger