hirosystems / clarinet

Write, test and deploy high-quality smart contracts to the Stacks blockchain and Bitcoin.
https://hiro.so/clarinet
GNU General Public License v3.0
307 stars 141 forks source link

Reproduction of "conflict between parser versions" #339

Closed hstove closed 2 years ago

hstove commented 2 years ago

No idea what this means, but the warning asks me to open an issue.

Warning text: "conflict between parser versions, reverting to parser v1"

Clarinet v0.28.1

Repro this by taking https://github.com/MarvinJanssen/executor-dao/blob/main/contracts/proposals/edp001-dev-fund.clar and commenting a few lines:

;; Title: EDP001 Dev Fund
;; Author: Marvin Janssen
;; Synopsis:
;; This proposal creates a simple dev fund that pays developers on a monthly basis.
;; Description:
;; If this proposal passes, it mints new governance tokens equal to 30% of the total
;; supply and awards them to the EDE005 Dev Fund extension. It contains a number of
;; principals and set allowances. Any principal with an allowance is able to claim
;; an amount of tokens equal to the allowance on a (roughly) monthly basis.
;; Principals can be added and removed, and allowances can be changed via future
;; proposals.

(impl-trait .proposal-trait.proposal-trait)

(define-constant dev-fund-percentage u30)

(define-public (execute (sender principal))
    (let
        (
            (total-supply (unwrap-panic (contract-call? .ede000-governance-token get-total-supply)))
            (dev-fund-amount (/ (* total-supply dev-fund-percentage) u100))
        )
        (try! (contract-call? .executor-dao set-extension .ede005-dev-fund true))
        ;; (try! (contract-call? .ede005-dev-fund set-allowance-start-height block-height))
        ;; (try! (contract-call? .ede005-dev-fund set-developer-allowances (list
        ;;  {who: 'ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG, allowance: u100}
        ;;  {who: 'ST2JHG361ZXG51QTKY2NQCVBPPRRE2KZB1HR05NNC, allowance: u20}
        ;; )))
        ;; (contract-call? .ede000-governance-token edg-mint dev-fund-amount .ede005-dev-fund)
        (ok true)
    )
)
obycode commented 2 years ago

Thanks for reporting, @hstove! This means that the new parser that we use in the REPL (mostly for better error messages) didn't match what the "canonical" parser produced. This case is actually very weird, and a good discovery of a bug in the canonical parser. I simplified your example further to:

(define-public (execute)
    (begin
        ;;  {who: 'ST2CY5V39NHDPWSXMW9QDT3HC3GD6Q6XX4CFRK9AG, allowance: u100}
        (ok true)
    )
)

Strangely, the commented tuple shows up in the AST from the v1 parser. It does not show up in the v2 parser's AST, so that is what triggered this error.

obycode commented 2 years ago

I'm going to close this issue, since the bug is in the blockchain, not in clarinet or the REPL, but I have opened stacks-network/stacks-blockchain#3124 to discuss it.