New state resulting from a
(receive-certificate-next msg systate) → new-systate
The certificate is added to the buffer of the destination validator. Recall that receive-certificate-possiblep requires the destination address to be of a correct validator.
The message is removed from the network.
Furthermore, if the validator has previously endorsed that certificate, the author-round pair is removed from the set of pairs, because the certificate is now in the buffer, and can be checked there in signers-do-not-have-author+round-p. The set deletion has no effect if the set does not have the pair.
Function:
(defun receive-certificate-next-val (cert vstate) (declare (xargs :guard (and (certificatep cert) (validator-statep vstate)))) (let ((__function__ 'receive-certificate-next-val)) (declare (ignorable __function__)) (b* (((certificate cert) cert) (buffer (validator-state->buffer vstate)) (new-buffer (insert cert buffer)) (endorsed (validator-state->endorsed vstate)) (new-endorsed (delete (make-address+pos :address cert.author :pos cert.round) endorsed))) (change-validator-state vstate :buffer new-buffer :endorsed new-endorsed))))
Theorem:
(defthm validator-statep-of-receive-certificate-next-val (b* ((new-vstate (receive-certificate-next-val cert vstate))) (validator-statep new-vstate)) :rule-classes :rewrite)
Function:
(defun receive-certificate-next (msg systate) (declare (xargs :guard (and (messagep msg) (system-statep systate)))) (declare (xargs :guard (receive-certificate-possiblep msg systate))) (let ((__function__ 'receive-certificate-next)) (declare (ignorable __function__)) (b* (((certificate cert) (message->certificate msg)) (dest (message->destination msg)) (vstate (get-validator-state dest systate)) (new-vstate (receive-certificate-next-val (message->certificate msg) vstate)) (systate (update-validator-state dest new-vstate systate)) (network (get-network-state systate)) (new-network (delete msg network))) (update-network-state new-network systate))))
Theorem:
(defthm system-statep-of-receive-certificate-next (b* ((new-systate (receive-certificate-next msg systate))) (system-statep new-systate)) :rule-classes :rewrite)
Theorem:
(defthm receive-certificate-next-of-system-state-fix-systate (equal (receive-certificate-next msg (system-state-fix systate)) (receive-certificate-next msg systate)))
Theorem:
(defthm receive-certificate-next-system-state-equiv-congruence-on-systate (implies (system-state-equiv systate systate-equiv) (equal (receive-certificate-next msg systate) (receive-certificate-next msg systate-equiv))) :rule-classes :congruence)
Theorem:
(defthm validator-state->round-of-receive-certificate-next (implies (and (in val (correct-addresses systate)) (receive-certificate-possiblep msg systate)) (equal (validator-state->round (get-validator-state val (receive-certificate-next msg systate))) (validator-state->round (get-validator-state val systate)))))
Theorem:
(defthm validator-state->dag-of-receive-certificate-next (implies (and (in val (correct-addresses systate)) (receive-certificate-possiblep msg systate)) (equal (validator-state->dag (get-validator-state val (receive-certificate-next msg systate))) (validator-state->dag (get-validator-state val systate)))))
Theorem:
(defthm validator-state->last-of-receive-certificate-next (implies (and (in val (correct-addresses systate)) (receive-certificate-possiblep msg systate)) (equal (validator-state->last (get-validator-state val (receive-certificate-next msg systate))) (validator-state->last (get-validator-state val systate)))))
Theorem:
(defthm validator-state->blockchain-of-receive-certificate-next (implies (and (in val (correct-addresses systate)) (receive-certificate-possiblep msg systate)) (equal (validator-state->blockchain (get-validator-state val (receive-certificate-next msg systate))) (validator-state->blockchain (get-validator-state val systate)))))
Theorem:
(defthm validator-state->committed-of-receive-certificate-next (implies (and (in val (correct-addresses systate)) (receive-certificate-possiblep msg systate)) (equal (validator-state->committed (get-validator-state val (receive-certificate-next msg systate))) (validator-state->committed (get-validator-state val systate)))))