From 6e6650cc56ed59c1be116a479848ae7d9b53b0d4 Mon Sep 17 00:00:00 2001 From: Jessica Tallon Date: Sun, 26 Nov 2023 13:44:19 +0100 Subject: [PATCH 1/2] Remove op:bootstrap reflecting new CapTP behavior --- goblins/ocapn/captp.rkt | 58 +++++++++++------------------------------ 1 file changed, 15 insertions(+), 43 deletions(-) diff --git a/goblins/ocapn/captp.rkt b/goblins/ocapn/captp.rkt index 0c7c164..c39be9a 100644 --- a/goblins/ocapn/captp.rkt +++ b/goblins/ocapn/captp.rkt @@ -71,10 +71,6 @@ ;;; Messages -(define-recordable-struct op:bootstrap - (answer-pos resolve-me-desc) - marshall::op:bootstrap unmarshall::op:bootstrap) - ;; Queue a delivery of verb(args..) to recip, discarding the outcome. (define-recordable-struct op:deliver-only (;; Position in the table for the target @@ -197,8 +193,7 @@ marshall::op:start-session unmarshall::op:start-session) (define marshallers - (list marshall::op:bootstrap - marshall::op:deliver-only + (list marshall::op:deliver-only marshall::op:deliver marshall::op:abort marshall::op:listen @@ -219,8 +214,7 @@ marshall::ocapn-bearer-union)) (define unmarshallers - (list unmarshall::op:bootstrap - unmarshall::op:deliver-only + (list unmarshall::op:deliver-only unmarshall::op:deliver unmarshall::op:abort unmarshall::op:listen @@ -248,8 +242,6 @@ #t] [_ #f])) -;; TODO: - (define (signed-handoff-receive? obj) (match obj [(desc:sig-envelope (desc:handoff-receive (? bytes? session) @@ -342,7 +334,7 @@ [(get-remote-location) ($ coordinator 'get-remote-location)] [(get-remote-bootstrap) - remote-bootstrap-vow] + remote-bootstrap-obj] [(get-session-name) ($ coordinator 'get-session-name)] [(get-our-side-name) @@ -714,18 +706,16 @@ [(keyword? arg) (values args (cons arg kw-args) kw-vals #t)] [else (values (cons arg args) kw-args kw-vals #f)]))) + (define remote-bootstrap-obj + (maybe-install-import! (desc:import-object 0))) + (unless (eq? (maybe-install-export! bootstrap-obj) 0) + (error 'invalid-bootstrap-export "Bootstrap object MUST be exported at position 0")) + (define ((^captp-incoming-handler bcom) msg) (unless running? (error 'captp-breakage "Captp session is no longer running but got ~a" msg)) (match msg - [(op:bootstrap (? integer? answer-pos) resolve-me-desc) - (define-values (_answer-promise answer-resolver) - (install-answer! answer-pos resolve-me-desc)) - - ;; And since we're bootstrapping, we resolve it immediately - ($ answer-resolver 'fulfill bootstrap-obj) - (void)] ;; TODO: Handle case where the target doesn't exist? ;; Or maybe just generally handle unmarshalling errors :P [(op:deliver-only to-desc args-marshalled) @@ -877,25 +867,7 @@ (define internal-handler (spawn ^internal-handler)) - ;;; BEGIN REMOTE BOOTSTRAP OPERATION - ;;; ================================ - (define this-question-finder - (question-finder)) - ;; called for its effect of installing the question - (question-finder->question-pos! this-question-finder) - (define-values (remote-bootstrap-vow remote-bootstrap-resolver) - (_spawn-promise-values #:question-finder - this-question-finder - #:captp-connector - captp-connector)) - (define bootstrap-msg - (op:bootstrap (hash-ref questions this-question-finder) - (outgoing-pre-marshall! remote-bootstrap-resolver))) - (send-to-remote bootstrap-msg) - ;;; END REMOTE BOOTSTRAP OPERATION - ;;; ============================== - - (values captp-incoming-handler remote-bootstrap-vow)) + (values captp-incoming-handler remote-bootstrap-obj)) ;;; ================BEGIN CRYPTOGRAPHY ADMONISHMENT============== ;;; *TODO TODO TODO:* This cryptography stuff doesn't belong here, @@ -1390,7 +1362,7 @@ ;; We don't actually have a bootstrap vow until setup completion, so ;; we'll have to return a vow to a vow - (define-values (meta-bootstrap-vow meta-bootstrap-resolver) + (define-values (remote-bootstrap-vow remote-bootstrap-resolver) (spawn-promise-values)) ;; Complete the initialization step against the remote node. @@ -1468,13 +1440,13 @@ (when can-continue? (let*-values ([(session-name) ($ coordinator 'get-session-name)] [(local-bootstrap-obj) (make-local-bootstrap-obj)] - [(captp-incoming-handler remote-bootstrap-vow) + [(captp-incoming-handler remote-bootstrap-obj) (setup-captp-conn send-to-remote coordinator local-bootstrap-obj intra-node-warden intra-node-incanter)]) ;; Fulfill the meta-bootstrap-promise with the promise that ;; setup-captp-conn gave us - ($ meta-bootstrap-resolver 'fulfill remote-bootstrap-vow) + ($ remote-bootstrap-resolver 'fulfill remote-bootstrap-obj) ;; Set things up so that the incoming-forwarder now goes ;; to the captp-incoming-handler @@ -1487,7 +1459,7 @@ ($ open-session-names->sessionmeta 'set session-name (sessionmeta remote-location - local-bootstrap-obj remote-bootstrap-vow + local-bootstrap-obj remote-bootstrap-obj coordinator session-name)))) (void)] [(internal-shutdown type reason) @@ -1556,8 +1528,8 @@ our-location our-location-sig)) - ;; Return the meta-bootstrap-vow, which will be completed as above - meta-bootstrap-vow] + ;; Return the remote-bootstrap-vow, which will be completed as above + remote-bootstrap-vow] [self-location? self-location?] ;; ... is that it? From be9058efee996cb23c07ce42a51c666a54fe662f Mon Sep 17 00:00:00 2001 From: Jessica Tallon Date: Thu, 30 Nov 2023 15:33:46 +0100 Subject: [PATCH 2/2] Update CapTP version to 0.12 and fix op:abort --- goblins/ocapn/captp.rkt | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/goblins/ocapn/captp.rkt b/goblins/ocapn/captp.rkt index c39be9a..625f4c7 100644 --- a/goblins/ocapn/captp.rkt +++ b/goblins/ocapn/captp.rkt @@ -65,7 +65,7 @@ ;; For the handoff stuff: ;; https://dustycloud.org/tmp/captp-handoff-musings.org.txt ;; https://dustycloud.org/misc/3vat-handoff-scaled.jpg -(define captp-version "goblins-0.11") +(define captp-version "goblins-0.12") (struct captp-session-severed ()) @@ -1462,12 +1462,14 @@ local-bootstrap-obj remote-bootstrap-obj coordinator session-name)))) (void)] + [(op:abort _reason) + (bcom (lambda _ (void)))] [(internal-shutdown type reason) ;; We're shutting down before we've properly set the connection up, ;; we're no longer needed :( (when (eq? type 'abort) (send-to-remote (op:abort reason))) - (bcom (^setup-completer (lambda _ (void))))])) + (bcom (lambda _ (void)))])) (define-values (incoming-forwarder incoming-swap) (swappable (spawn ^setup-completer)))