Skip to content
This repository has been archived by the owner on Jan 10, 2025. It is now read-only.

Commit

Permalink
fix: compute quorum (vs hard code)
Browse files Browse the repository at this point in the history
  • Loading branch information
Ludo Galabru committed Dec 7, 2023
1 parent e61fcf7 commit 8d586d3
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions contracts/wormhole/wormhole-core-v1.clar
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,6 @@
(define-constant ERR_GSU_CHECK_CHAIN (err u1303))
;; Guardian Set Update new index invalid
(define-constant ERR_GSU_CHECK_INDEX (err u1304))
;; Quorum of addresses required
(define-constant QUORUM u13)

(define-constant hk-cursor-v2 'SP2J933XB2CP2JQ1A4FGN8JA968BBG3NK3EKZ7Q9F.hk-cursor-v2)

Expand Down Expand Up @@ -176,7 +174,7 @@
(asserts! (is-eq (get version (get vaa message)) u1)
ERR_VAA_CHECKS_VERSION_UNSUPPORTED)
;; Ensure that the count of valid signatures is >= 13
(asserts! (>= (len (get result signatures-from-active-guardians)) QUORUM)
(asserts! (>= (len (get result signatures-from-active-guardians)) (get-quorum (len active-guardians)))
ERR_VAA_CHECKS_THRESHOLD_SIGNATURE)
;; Good to go!
(ok (get vaa message)))))
Expand Down Expand Up @@ -357,6 +355,9 @@
}
})))

(define-private (get-quorum (guardian-set-size uint))
(+ (/ (* guardian-set-size u2) u3) u1))

(define-private (is-guardian-cue (byte (buff 1)) (acc { cursor: uint, result: (list 19 uint) }))
(if (is-eq u0 (mod (get cursor acc) u20))
{
Expand Down

0 comments on commit 8d586d3

Please sign in to comment.