Collect all the anchor certificates to commit.
(collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals) → anchors
The starting point is an anchor,
Since
In order to calculate the leader at
The role of the
The returned list of anchors is never empty,
and it always starts with (i.e. its car is)
the
The returned list of anchors has even, strictly increasing (right to left) round numbers, under suitable assumptions on some of the inputs.
The returned list of anchors consists of certificates that are all in the DAG and are connected by paths; see certificates-dag-paths-p.
We also show that the rounds of the returned anchors are all above the last committed round, provided that the round of the input anchor is. More precisely, we say that the lowest-numbered anchor round (i.e. the car of last, i.e. the rightmost one) is above the last committed round. This assumption is satisfied when this function is called. Note that, since we also proved that rounds are strictly increasing, proving that the rightmost anchor has round above the last committed one implies that all the other anchors do as well; but in any case we need the theorem in this form, with car of last, so it can be used to relieve the hypothesis in a theorem about extend-blockchain.
Function:
(defun collect-anchors (current-anchor previous-round last-committed-round dag blockchain all-vals) (declare (xargs :guard (and (certificatep current-anchor) (natp previous-round) (natp last-committed-round) (certificate-setp dag) (block-listp blockchain) (address-setp all-vals)))) (declare (xargs :guard (and (evenp previous-round) (> (certificate->round current-anchor) previous-round) (or (zp previous-round) (active-committee-at-round previous-round blockchain all-vals))))) (let ((__function__ 'collect-anchors)) (declare (ignorable __function__)) (b* (((unless (and (mbt (and (natp previous-round) (evenp previous-round) (natp last-committed-round) (or (zp previous-round) (active-committee-at-round previous-round blockchain all-vals)) t)) (> previous-round last-committed-round))) (list (certificate-fix current-anchor))) (commtt (active-committee-at-round previous-round blockchain all-vals)) (previous-leader (leader-at-round previous-round commtt)) (previous-anchor? (path-to-author+round current-anchor previous-leader previous-round dag))) (if previous-anchor? (cons (certificate-fix current-anchor) (collect-anchors previous-anchor? (- previous-round 2) last-committed-round dag blockchain all-vals)) (collect-anchors current-anchor (- previous-round 2) last-committed-round dag blockchain all-vals)))))
Theorem:
(defthm certificate-listp-of-collect-anchors (b* ((anchors (collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals))) (certificate-listp anchors)) :rule-classes :rewrite)
Theorem:
(defthm consp-of-collect-anchors (b* ((anchors (collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals))) (consp anchors)) :rule-classes :type-prescription)
Theorem:
(defthm car-of-collect-anchors (b* ((?anchors (collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals))) (equal (car anchors) (certificate-fix current-anchor))))
Theorem:
(defthm certificates-ordered-even-p-of-collect-anchors (implies (and (evenp (certificate->round current-anchor)) (evenp previous-round) (< previous-round (certificate->round current-anchor))) (b* ((?anchors (collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals))) (certificates-ordered-even-p anchors))))
Theorem:
(defthm certificates-dag-paths-p-of-collect-anchors (implies (and (certificate-setp dag) (in current-anchor dag) (< previous-round (certificate->round current-anchor))) (b* ((?anchors (collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals))) (certificates-dag-paths-p anchors dag))))
Theorem:
(defthm collect-anchors-above-last-committed-round (implies (> (certificate->round current-anchor) last-committed-round) (b* ((?anchors (collect-anchors current-anchor previous-round last-committed-round dag blockchain all-vals))) (> (certificate->round (car (last anchors))) last-committed-round))))