mirror of
https://github.com/ilyakooo0/urbit.git
synced 2024-11-10 10:05:09 +03:00
ames: don't drop events with old wires
Previously we were dropping events that used old wires that lacked a rift in them. This seems a bad behavior because we don't want to destroy a flow that has not been processed by both ends. Note: pending a fix to test-old-ames-wire
This commit is contained in:
parent
6cdebea1af
commit
91435a92ca
@ -1221,34 +1221,35 @@
|
||||
:: relay the vane ack to the foreign peer
|
||||
::
|
||||
?~ parsed=(parse-bone-wire wire)
|
||||
:: no-op?
|
||||
:: no-op
|
||||
::
|
||||
=/ =tape "; ames dropping malformed wire"
|
||||
(emit duct %pass /parse-wire %d %flog %text tape)
|
||||
=/ =tape "ames dropping malformed wire: {(spud wire)}"
|
||||
(emit duct %pass /malformed-wire %d %flog %text tape)
|
||||
?> ?=([@ her=ship *] u.parsed)
|
||||
=* her her.u.parsed
|
||||
=* her her.u.parsed
|
||||
=/ =peer-state (got-peer-state her)
|
||||
=/ =channel [[our her] now channel-state -.peer-state]
|
||||
|
||||
=/ peer-core (make-peer-core peer-state channel)
|
||||
|^
|
||||
?- u.parsed
|
||||
[%old *]
|
||||
:: ignore events from old wire
|
||||
?: ?& ?=([%new *] u.parsed)
|
||||
(lth rift.u.parsed rift.peer-state)
|
||||
==
|
||||
:: ignore events from an old rift
|
||||
::
|
||||
=/ =tape "; ames dropping old wire format"
|
||||
(emit duct %pass /parse-wire %d %flog %text tape)
|
||||
?. odd.veb event-core
|
||||
(log "ames dropping old rift wire: {(spud wire)}")
|
||||
=/ =bone
|
||||
?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed)
|
||||
=? event-core &(odd.veb ?=([%old *] u.parsed))
|
||||
(log "ames parsing old wire format: {(spud wire)}")
|
||||
?~ error
|
||||
(send-ack bone)
|
||||
(send-nack bone u.error)
|
||||
::
|
||||
[%new *]
|
||||
?: (lth rift.u.parsed rift.peer-state)
|
||||
:: ignore events from an old rift
|
||||
::
|
||||
=/ =tape "; ames dropping wire with old rift ({<rift.u.parsed>})"
|
||||
(emit duct %pass /parse-wire %d %flog %text tape)
|
||||
?~ error
|
||||
(send-ack bone.u.parsed)
|
||||
(send-nack bone.u.parsed u.error)
|
||||
==
|
||||
++ log
|
||||
|= =tape
|
||||
^+ event-core
|
||||
(emit duct %pass /on-take-done-parse-wire %d %flog %text tape)
|
||||
:: if processing succeded, send positive ack packet and exit
|
||||
::
|
||||
++ send-ack
|
||||
@ -1260,7 +1261,7 @@
|
||||
++ send-nack
|
||||
|= [=bone =^error]
|
||||
^+ event-core
|
||||
=. event-core abet:(run-message-sink:peer-core bone %done ok=%.n)
|
||||
=. event-core abet:(run-message-sink:peer-core bone %done ok=%.n)
|
||||
=/ =^peer-state (got-peer-state her)
|
||||
=/ =^channel [[our her] now channel-state -.peer-state]
|
||||
:: construct nack-trace message, referencing .failed $message-num
|
||||
@ -1527,29 +1528,33 @@
|
||||
++ on-take-boon
|
||||
|= [=wire payload=*]
|
||||
^+ event-core
|
||||
::
|
||||
|^
|
||||
?~ parsed=(parse-bone-wire wire)
|
||||
=/ =tape "; ames dropping malformed wire"
|
||||
(emit duct %pass /parse-wire %d %flog %text tape)
|
||||
(log "ames dropping malformed wire: {(spud wire)}")
|
||||
::
|
||||
?> ?=([@ her=ship *] u.parsed)
|
||||
=/ =peer-state (got-peer-state her.u.parsed)
|
||||
=/ =channel [[our her.u.parsed] now channel-state -.peer-state]
|
||||
=* her her.u.parsed
|
||||
=/ =peer-state (got-peer-state her)
|
||||
=/ =channel [[our her] now channel-state -.peer-state]
|
||||
::
|
||||
?- u.parsed
|
||||
[%old *]
|
||||
=/ =tape "; ames dropping old wire"
|
||||
(emit duct %pass /parse-wire %d %flog %text tape)
|
||||
?: ?& ?=([%new *] u.parsed)
|
||||
(lth rift.u.parsed rift.peer-state)
|
||||
==
|
||||
:: ignore events from an old rift
|
||||
::
|
||||
?. odd.veb event-core
|
||||
(log "ames dropping old rift wire: {(spud wire)}")
|
||||
=/ =bone
|
||||
?-(u.parsed [%new *] bone.u.parsed, [%old *] bone.u.parsed)
|
||||
=? event-core &(odd.veb ?=([%old *] u.parsed))
|
||||
(log "ames parsing old wire: {(spud wire)}")
|
||||
abet:(on-memo:(make-peer-core peer-state channel) bone payload %boon)
|
||||
::
|
||||
[%new *]
|
||||
=, u.parsed
|
||||
?: (lth rift rift.peer-state)
|
||||
:: ignore events from an old rift
|
||||
::
|
||||
=/ =tape "; ames dropping wire with old rift ({<rift>})"
|
||||
(emit duct %pass /parse-wire %d %flog %text tape)
|
||||
abet:(on-memo:(make-peer-core peer-state channel) bone payload %boon)
|
||||
==
|
||||
++ log
|
||||
|= =tape
|
||||
^+ event-core
|
||||
(emit duct %pass /on-take-boon-parse-wire %d %flog %text tape)
|
||||
--
|
||||
:: +on-plea: handle request to send message
|
||||
::
|
||||
++ on-plea
|
||||
|
@ -3,8 +3,8 @@
|
||||
/= jael /sys/vane/jael
|
||||
:: construct some test fixtures
|
||||
::
|
||||
=/ nec (ames ~nec)
|
||||
=/ bud (ames ~bud)
|
||||
=/ nec (ames ~nec)
|
||||
=/ bud (ames ~bud)
|
||||
=/ comet (ames ~bosrym-podwyl-magnes-dacrys--pander-hablep-masrym-marbud)
|
||||
::
|
||||
=. now.nec ~1111.1.1
|
||||
@ -287,7 +287,7 @@
|
||||
=^ moves4 nec (call nec ~[//unix] %hear (snag-packet 0 moves3))
|
||||
:: ~bud -> %boon -> ~nec
|
||||
::
|
||||
=^ moves5 bud (take bud /bone/~nec/0/1 ~[//unix] %g %boon [%post 'first1!!'])
|
||||
=^ moves5 bud (take bud /bone/~nec/0/1 ~[//unix] %g %boon [%post 'first1'])
|
||||
=^ moves6 nec (call nec ~[//unix] %hear (snag-packet 0 moves5))
|
||||
:: ~nec -> %done -> ~bud (just make sure ~bud doesn't crash on ack)
|
||||
::
|
||||
@ -296,7 +296,8 @@
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!> :~ [~[//unix] %pass /qos %d %flog %text "; ~nec is your neighbor"]
|
||||
[~[//unix] %pass /bone/~nec/0/1 %g %plea ~nec %g /talk [%get %post]]
|
||||
:^ ~[//unix] %pass /bone/~nec/0/1
|
||||
[%g %plea ~nec %g /talk [%get %post]]
|
||||
==
|
||||
!> moves2
|
||||
::
|
||||
@ -309,7 +310,7 @@
|
||||
!> (sy ,.moves4)
|
||||
::
|
||||
%+ expect-eq
|
||||
!> [~[/g/talk] %give %boon [%post 'first1!!']]
|
||||
!> [~[/g/talk] %give %boon [%post 'first1']]
|
||||
!> (snag 0 `(list move:ames)`moves6)
|
||||
==
|
||||
::
|
||||
@ -335,14 +336,19 @@
|
||||
!> (snag 1 `(list move:ames)`moves5)
|
||||
::
|
||||
++ test-old-ames-wire ^- tang
|
||||
=^ moves1 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~)
|
||||
=^ moves0 bud (call bud ~[/g/hood] %spew [%odd]~)
|
||||
=^ moves1 nec (call nec ~[/g/talk] %plea ~bud %g /talk [%get %post])
|
||||
=^ moves2 bud (call bud ~[//unix] %hear (snag-packet 0 moves1))
|
||||
=^ moves3 bud (take bud /bone/~nec/1 ~[//unix] %g %done ~)
|
||||
%+ expect-eq
|
||||
!> %- sy
|
||||
:_ ~
|
||||
[~[//unix] %pass /parse-wire %d %flog %text "; ames dropping old wire format"]
|
||||
!> (sy ,.moves1)
|
||||
:: ::
|
||||
:^ ~[//unix] %pass /on-take-done-parse-wire
|
||||
[%d %flog %text "ames dropping old wire format: /bone/~nec/1"]
|
||||
!> (snag 0 `(list move:ames)`moves3)
|
||||
::
|
||||
++ test-dangling-bone ^- tang
|
||||
=^ moves0 bud (call bud ~[/g/hood] %spew [%odd]~)
|
||||
:: ~nec -> %plea -> ~bud
|
||||
::
|
||||
=^ moves1 nec (call nec ~[/g/talk] %plea ~bud %g /talk [%get %post])
|
||||
@ -362,18 +368,12 @@
|
||||
%+ expect-eq
|
||||
!> %- sy
|
||||
:_ ~
|
||||
:* ~[//unix]
|
||||
%pass
|
||||
/parse-wire
|
||||
%d
|
||||
%flog
|
||||
%text
|
||||
"; ames dropping wire with old rift (0)"
|
||||
==
|
||||
:^ ~[//unix] %pass /on-take-done-parse-wire
|
||||
[%d %flog %text "ames dropping old rift wire: /bone/~nec/0/1"]
|
||||
!> (sy ,.moves3)
|
||||
::
|
||||
++ test-ames-flow-with-new-rift ^- tang
|
||||
:: ~bunecd receives a gift from %jael with ~bud's new rift
|
||||
:: ~nec receives a gift from %jael with ~bud's new rift
|
||||
::
|
||||
=^ moves1 nec
|
||||
%- take
|
||||
@ -400,7 +400,8 @@
|
||||
;: weld
|
||||
%+ expect-eq
|
||||
!> :~ [~[//unix] %pass /qos %d %flog %text "; ~nec is your neighbor"]
|
||||
[~[//unix] %pass /bone/~nec/0/1 %g %plea ~nec %g /talk [%get %post]]
|
||||
:^ ~[//unix] %pass /bone/~nec/0/1
|
||||
[%g %plea ~nec %g /talk [%get %post]]
|
||||
==
|
||||
!> moves3
|
||||
::
|
||||
|
Loading…
Reference in New Issue
Block a user