From bc521fa8300ac628b447d5c39dfaf5fa0ca4704a Mon Sep 17 00:00:00 2001 From: pkova Date: Tue, 28 Feb 2023 11:25:06 -0600 Subject: [PATCH 1/5] Revert "Merge pull request #5973 from urbit/m/http-auth-tokens" This reverts commit 61d32b559865dea832de65bf7a6085f75ef95748, reversing changes made to b271d5e3c33e19271e4b31e96bda8c7765e22606. --- pkg/arvo/sys/lull.hoon | 3 - pkg/arvo/sys/vane/eyre.hoon | 25 ++---- tests/sys/vane/eyre.hoon | 171 +++++++++++++++++++++++------------- 3 files changed, 118 insertions(+), 81 deletions(-) diff --git a/pkg/arvo/sys/lull.hoon b/pkg/arvo/sys/lull.hoon index e99578baa..9856f9311 100644 --- a/pkg/arvo/sys/lull.hoon +++ b/pkg/arvo/sys/lull.hoon @@ -1315,9 +1315,6 @@ :: so we can apply configurations on a per-site basis :: [%set-config =http-config] - :: sessions: valid authentication cookie strings - :: - [%sessions ses=(set @t)] :: response: response to an event from earth :: [%response =http-event:http] diff --git a/pkg/arvo/sys/vane/eyre.hoon b/pkg/arvo/sys/vane/eyre.hoon index e587bea66..e1716c624 100644 --- a/pkg/arvo/sys/vane/eyre.hoon +++ b/pkg/arvo/sys/vane/eyre.hoon @@ -984,7 +984,6 @@ (session-cookie-string session &) :: =; out=[moves=(list move) server-state] - =. moves.out [give-session-tokens moves.out] :: if we didn't have any cookies previously, start the expiry timer :: ?. first-session out @@ -1059,7 +1058,7 @@ ?~ channels =^ moz state (handle-response response) - [[give-session-tokens (weld moves moz)] state] + [(weld moves moz) state] =^ moz state (discard-channel:by-channel i.channels |) $(moves (weld moves moz), channels t.channels) @@ -2143,13 +2142,6 @@ (cury cat 3) ?~ ext.request-line '' (cat 3 '.' u.ext.request-line) - :: +give-session-tokens: send valid session tokens to unix - :: - ++ give-session-tokens - ^- move - :- outgoing-duct.state - =* ses sessions.authentication-state.state - [%give %sessions (~(run in ~(key by ses)) (cury scot %uv))] -- :: ++ forwarded-params @@ -2329,15 +2321,12 @@ =. outgoing-duct.server-state.ax duct :: :_ http-server-gate - :* :: hand back default configuration for now - :: - [duct %give %set-config http-config.server-state.ax] - :: provide a list of valid auth tokens - :: - =< give-session-tokens - (per-server-event [eny duct now rof] server-state.ax) + ;: weld + :: hand back default configuration for now :: - closed-connections + [duct %give %set-config http-config.server-state.ax]~ + :: + closed-connections == :: ?: ?=(%code-changed -.task) @@ -2611,8 +2600,6 @@ :: ^- [(list move) _http-server-gate] :_ http-server-gate - :- =< give-session-tokens - (per-server-event [eny duct now rof] server-state.ax) ?: =(~ sessions) ~ =; next-expiry=@da [duct %pass /sessions/expire %b %wait next-expiry]~ diff --git a/tests/sys/vane/eyre.hoon b/tests/sys/vane/eyre.hoon index 10802f190..f8fd9ba0f 100644 --- a/tests/sys/vane/eyre.hoon +++ b/tests/sys/vane/eyre.hoon @@ -7,14 +7,27 @@ :: |% ++ test-init - -:perform-init -:: -++ test-born - -:(perform-born eyre-gate) + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == + :: + results1 :: ++ test-overwrite-bindings :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: =^ results2 eyre-gate @@ -44,7 +57,14 @@ :: ++ test-remove-binding :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: =^ results2 eyre-gate @@ -110,7 +130,14 @@ :: ++ test-builtin-four-oh-four :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: when there's no configuration and nothing matches, expect 404 :: =^ results2 eyre-gate @@ -146,7 +173,14 @@ :: ++ test-basic-app-request :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: =^ results2 eyre-gate @@ -232,7 +266,14 @@ :: ++ test-app-error :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: =^ results2 eyre-gate @@ -328,7 +369,14 @@ :: ++ test-multipart-app-request :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: =^ results2 eyre-gate @@ -436,11 +484,17 @@ :: ++ test-login-handler-full-path :: - =^ results1 eyre-gate perform-init - =^ results2 eyre-gate (perform-born eyre-gate) + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: - =^ results3 eyre-gate + =^ results2 eyre-gate %- eyre-call :* eyre-gate now=~1111.1.2 @@ -450,7 +504,7 @@ == :: outside requests a path that app1 has bound to :: - =^ results4 eyre-gate + =^ results3 eyre-gate %- eyre-call-with-comparator :* eyre-gate now=~1111.1.3 @@ -496,7 +550,7 @@ == :: app then gives a redirect to Eyre :: - =^ results5 eyre-gate + =^ results4 eyre-gate %- eyre-take :* eyre-gate now=~1111.1.4 @@ -515,7 +569,7 @@ == == == :: the browser then fetches the login page :: - =^ results6 eyre-gate + =^ results5 eyre-gate %- perform-authentication :* eyre-gate now=~1111.1.5 @@ -523,7 +577,7 @@ == :: going back to the original url will acknowledge the authentication cookie :: - =^ results7 eyre-gate + =^ results6 eyre-gate %- eyre-call-with-comparator :* eyre-gate now=~1111.1.5..1.0.0 @@ -590,12 +644,18 @@ results4 results5 results6 - results7 == :: ++ test-generator :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: gen1 binds successfully :: =^ results2 eyre-gate @@ -723,7 +783,14 @@ :: ++ test-channel-reject-unauthenticated :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: =^ results2 eyre-gate %- eyre-call :* @@ -1806,7 +1873,14 @@ :: ++ test-born-sends-pending-cancels :: - =^ results1 eyre-gate perform-init + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: app1 binds successfully :: =^ results2 eyre-gate @@ -1877,15 +1951,15 @@ |= moves=(list move:eyre-gate) ^- tang :: - ?. ?=([^ ^ ^ ~] moves) + ?. ?=([^ ^ ~] moves) [%leaf "wrong number of moves: {<(lent moves)>}"]~ :: - :: we don't care about the first two, which are just - :: configuration moves. + :: we don't care about the first one, which is just a static + :: configuration move. :: - =/ =move:eyre-gate i.t.t.moves - =/ =duct duct.move - =/ card card.move + =/ move=move:eyre-gate i.t.moves + =/ =duct duct.move + =/ card=(wind note:eyre-gate gift:eyre-gate) card.move :: %+ weld (expect-eq !>(~[/http-blah]) !>(duct)) @@ -2052,30 +2126,6 @@ :: todo: handle other deals :: [%leaf "unexpected %deal type"]~ -:: +perfom-init: %init a new eyre-gate -:: -++ perform-init - %- eyre-call :* - eyre-gate - now=~1111.1.1 - scry=scry-provides-code - call-args=[duct=~[/init] ~ [%init ~]] - expected-moves=~ - == -:: +perform-born: %born an eyre-gate -:: -++ perform-born - |= =_eyre-gate - %- eyre-call :* - eyre-gate - new=~1111.1.1 - scry=scry-provides-code - call-args=[duct=~[/unix] ~ [%born ~]] - ^= expected-moves - :~ [duct=~[/unix] %give %set-config *http-config:eyre] - [duct=~[/unix] %give %sessions ~] - == - == :: +perform-authentication: goes through the authentication flow :: ++ perform-authentication @@ -2135,9 +2185,6 @@ :~ ::NOTE this ~d7 is tied to the eyre-internal +session-timeout... :- duct=~[/http-blah] [%pass p=/sessions/expire q=[%b [%wait p=(add start-now ~d7.m1)]]] - :: - =+ token='0v3.q0p7t.mlkkq.cqtto.p0nvi.2ieea' - [duct=~[/unix] %give %sessions [token ~ ~]] :: :* duct=~[/http-blah] %give @@ -2162,11 +2209,17 @@ == ^- [tang _eyre-gate] :: - =^ results1 eyre-gate perform-init - =^ results2 eyre-gate (perform-born eyre-gate) + =^ results1 eyre-gate + %- eyre-call :* + eyre-gate + now=~1111.1.1 + scry=scry-provides-code + call-args=[duct=~[/init] ~ [%init ~]] + expected-moves=~ + == :: ensure there's an authenticated session :: - =^ results3 eyre-gate + =^ results2 eyre-gate %- perform-authentication :* eyre-gate now=~1111.1.2 @@ -2174,7 +2227,7 @@ == :: send the channel a poke and a subscription request :: - =^ results4 eyre-gate + =^ results3 eyre-gate %- eyre-call-with-comparator :* eyre-gate now=~1111.1.2 @@ -2240,7 +2293,7 @@ == == :: :_ eyre-gate - :(weld results1 results2 results3 results4) + :(weld results1 results2 results3) :: ++ scry-provides-code ^- roof |= [gang =view =beam] From f5eeffef587b06bc93540536cf88a10e49dc77fd Mon Sep 17 00:00:00 2001 From: J Lynn Date: Wed, 8 Mar 2023 09:23:37 +1100 Subject: [PATCH 2/5] %eth-watcher: ensure get-block-by-number RPC call doesn't pad block number. Resolves #6377 - stuck %eth-watcher due to get-block-by-number zero-padded number RPC failure --- pkg/base-dev/lib/ethereum.hoon | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/pkg/base-dev/lib/ethereum.hoon b/pkg/base-dev/lib/ethereum.hoon index 9f63062f9..fd30a7829 100644 --- a/pkg/base-dev/lib/ethereum.hoon +++ b/pkg/base-dev/lib/ethereum.hoon @@ -733,7 +733,7 @@ :: %eth-get-block-by-number :- 'eth_getBlockByNumber' - :~ (tape (num-to-hex bon.req)) + :~ (tape (num-to-hex-minimal bon.req)) b+txs.req == :: @@ -942,6 +942,15 @@ %- render-hex-bytes (as-octs:mimes:html n) :: +++ num-to-hex-minimal + |= n=@ + ^- tape + %- prefix-hex + ?: =(0 n) + "0" + %- render-hex-bytes-minimal + (as-octs:mimes:html n) +:: ++ address-to-hex |= a=address ^- tape @@ -980,6 +989,12 @@ ^- tape ((x-co:co (mul 2 p.a)) q.a) :: +++ render-hex-bytes-minimal + :: atom to string of hex bytes without 0x prefix and dots, minimal representation (no padding). + |= a=octs + ^- tape + ((x-co:co 1) q.a) +:: ++ pad-to-multiple |= [wat=tape mof=@ud wer=?(%left %right)] ^- tape From 0a1e39cb47d7366f8def156736e49898172e9ed5 Mon Sep 17 00:00:00 2001 From: J Lynn Date: Wed, 8 Mar 2023 09:59:47 +1100 Subject: [PATCH 3/5] %eth-watcher: clean up extraneous render-hex-bytes-minimal formatter Per suggestion at https://github.com/urbit/urbit/pull/6377/files/f5eeffef587b06bc93540536cf88a10e49dc77fd#r1128704330 Moves x-co:co into num-to-hex-minimal. --- pkg/base-dev/lib/ethereum.hoon | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/pkg/base-dev/lib/ethereum.hoon b/pkg/base-dev/lib/ethereum.hoon index fd30a7829..23b69e9a3 100644 --- a/pkg/base-dev/lib/ethereum.hoon +++ b/pkg/base-dev/lib/ethereum.hoon @@ -948,8 +948,7 @@ %- prefix-hex ?: =(0 n) "0" - %- render-hex-bytes-minimal - (as-octs:mimes:html n) + ((x-co:co 1) n) :: ++ address-to-hex |= a=address @@ -989,12 +988,6 @@ ^- tape ((x-co:co (mul 2 p.a)) q.a) :: -++ render-hex-bytes-minimal - :: atom to string of hex bytes without 0x prefix and dots, minimal representation (no padding). - |= a=octs - ^- tape - ((x-co:co 1) q.a) -:: ++ pad-to-multiple |= [wat=tape mof=@ud wer=?(%left %right)] ^- tape From 307dce7f56015b6c2a81d6ba0f965915ca076baf Mon Sep 17 00:00:00 2001 From: Pyry Kovanen Date: Tue, 7 Mar 2023 17:16:47 -0600 Subject: [PATCH 4/5] lib/ethereum: remove unnecessary conditional --- pkg/base-dev/lib/ethereum.hoon | 2 -- 1 file changed, 2 deletions(-) diff --git a/pkg/base-dev/lib/ethereum.hoon b/pkg/base-dev/lib/ethereum.hoon index 23b69e9a3..4f53df668 100644 --- a/pkg/base-dev/lib/ethereum.hoon +++ b/pkg/base-dev/lib/ethereum.hoon @@ -946,8 +946,6 @@ |= n=@ ^- tape %- prefix-hex - ?: =(0 n) - "0" ((x-co:co 1) n) :: ++ address-to-hex From 2c262e1fd0bd9c0597990b370e2fad0ca32667f2 Mon Sep 17 00:00:00 2001 From: Philip Monk Date: Thu, 23 Mar 2023 15:46:33 -0700 Subject: [PATCH 5/5] clay: stop failed kelvin upgrades from retrying immediately We were retrying failed kelvin upgrades as many times as we had apps that needed to be suspended, because suspending an app triggers an attempt to run the next kelvin upgrade. This suspends all those apps in one batch move, and then tries the next kelvin upgrade only once at the end. Fixes #6407 Partially addresses #6285 --- pkg/arvo/lib/hood/kiln.hoon | 8 +++----- pkg/arvo/sys/lull.hoon | 1 + pkg/arvo/sys/vane/clay.hoon | 17 +++++++++++++++-- 3 files changed, 19 insertions(+), 7 deletions(-) diff --git a/pkg/arvo/lib/hood/kiln.hoon b/pkg/arvo/lib/hood/kiln.hoon index b1be5cf62..8c76cea0c 100644 --- a/pkg/arvo/lib/hood/kiln.hoon +++ b/pkg/arvo/lib/hood/kiln.hoon @@ -583,15 +583,13 @@ ..abet =/ kel i.wic %- emil - =/ cards + =/ desks=(list [=desk =zest]) %+ murn ~(tap by rock) |= [=desk =zest wic=(set weft)] ?: |(=(%base desk) !?=(%live zest) (~(has in wic) kel)) ~ - `u=[%pass /kiln/bump/[desk] %arvo %c %zest desk %held] - ?~ cards - [%pass /kiln/bump/wick %arvo %c %wick ~]~ - cards + `u=[desk %held] + [%pass /kiln/bump/zeal %arvo %c %zeal desks]~ :: ++ poke-cancel |= a=@tas diff --git a/pkg/arvo/sys/lull.hoon b/pkg/arvo/sys/lull.hoon index 9856f9311..a82a5fdea 100644 --- a/pkg/arvo/sys/lull.hoon +++ b/pkg/arvo/sys/lull.hoon @@ -801,6 +801,7 @@ [%warp wer=ship rif=riff] :: internal file req [%werp who=ship wer=ship rif=riff-any] :: external file req [%wick ~] :: try upgrade + [%zeal lit=(list [=desk =zest])] :: batch zest [%zest des=desk liv=zest] :: live $>(%plea vane-task) :: ames request == :: diff --git a/pkg/arvo/sys/vane/clay.hoon b/pkg/arvo/sys/vane/clay.hoon index bb2c2bd57..32f9b96d8 100644 --- a/pkg/arvo/sys/vane/clay.hoon +++ b/pkg/arvo/sys/vane/clay.hoon @@ -5018,9 +5018,22 @@ :: %wick =^ mos ruf - =/ den ((de now rof hen ruf) our %base) - abet:wick:den :: [wick] + abet:wick:((de now rof hen ruf) our %base) :: [wick] [mos ..^$] + :: + %zeal + =^ m1 ruf + =| mos=(list move) + |- ^+ [mos ruf] + ?~ lit.req + [mos ruf] + =/ den ((de now rof hen ruf) our desk.i.lit.req) + =^ mos-new ruf abet:(set-zest:den zest.i.lit.req) + $(mos (weld mos mos-new), lit.req t.lit.req) + =^ m2 ruf + abet:wick:((de now rof hen ruf) our %base) + =^ m3 ruf abet:goad:(lu now rof hen ruf) + [:(weld m1 m2 m3) ..^$] :: %zest =^ m1 ruf